|
|
@ -1,25 +1,36 @@ |
|
|
|
<template> |
|
|
|
<Dialog :title="dialogTitle" v-model="dialogVisible" :width="isBusiness?'60%':'40%'"> |
|
|
|
<Form |
|
|
|
ref="formRef" |
|
|
|
v-loading="formLoading" |
|
|
|
:rules="rules" |
|
|
|
:schema="formSchema" |
|
|
|
<Dialog :title="dialogTitle" v-model="dialogVisible" :width="isBusiness ? '60%' : '40%'"> |
|
|
|
<Form |
|
|
|
ref="formRef" |
|
|
|
v-loading="formLoading" |
|
|
|
:rules="rules" |
|
|
|
:schema="formSchema" |
|
|
|
:is-col="true" |
|
|
|
@opensearchTable="opensearchTable" |
|
|
|
> |
|
|
|
<template #crontab="formSchema"> |
|
|
|
<crontab v-model="formSchema.crontab" /> |
|
|
|
</template> |
|
|
|
<template #crontab="formSchema"> |
|
|
|
<crontab v-model="formSchema.crontab" /> |
|
|
|
</template> |
|
|
|
<template #type="formSchema"> |
|
|
|
<el-select v-model="formSchema.type" placeholder="选择盘点类型" @change="selectChange('type',$event)"> |
|
|
|
<el-option |
|
|
|
v-for="dict in getStrDictOptions(DICT_TYPE.COUNT_TYPE)" |
|
|
|
:key="dict.value" |
|
|
|
:label="dict.label" |
|
|
|
:value="dict.value" |
|
|
|
/> |
|
|
|
</el-select> |
|
|
|
</template> |
|
|
|
</Form> |
|
|
|
<div class="table" v-if="isBusiness && formType == 'create'"> |
|
|
|
<TableForm ref="tableFormRef" |
|
|
|
class="w-[100%]" |
|
|
|
<TableForm |
|
|
|
ref="tableFormRef" |
|
|
|
class="w-[100%]" |
|
|
|
:tableFields="tableAllSchemas.tableFormColumns" |
|
|
|
:tableData="tableData" |
|
|
|
:tableData="tableData" |
|
|
|
:tableFormRules="tableFormRules" |
|
|
|
:isShowButton="isShowButton" |
|
|
|
@handleAddTable="handleAddTable" |
|
|
|
@handleAddTable="handleAddTable" |
|
|
|
@handleDeleteTable="handleDeleteTable" |
|
|
|
@tableSelectionChange="tableSelectionChange" |
|
|
|
@extendedButtonsClick="extendedButtonsClick" |
|
|
@ -27,7 +38,8 @@ |
|
|
|
@tableSortChange="tableSortChange" |
|
|
|
@selectCallback="selectCallback" |
|
|
|
@handleTableSelect="handleTableSelect" |
|
|
|
@inpuFocus="inpuFocus"/> |
|
|
|
@inpuFocus="inpuFocus" |
|
|
|
/> |
|
|
|
</div> |
|
|
|
<template #footer> |
|
|
|
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" /> |
|
|
@ -36,18 +48,19 @@ |
|
|
|
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" /> |
|
|
|
</template> |
|
|
|
<script setup lang="ts"> |
|
|
|
import { SearchTable } from '@/components/SearchTable'; |
|
|
|
import { SearchTable } from '@/components/SearchTable' |
|
|
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|
|
|
import ButtonBase from '@/components/XButton/src/ButtonBase.vue' |
|
|
|
import TableForm from '@/components/TableForm/src/TableForm.vue' |
|
|
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
// 是否显示TableForm 新增/删除按钮 |
|
|
|
isShowButton: { |
|
|
|
type: Boolean, |
|
|
|
default: true, |
|
|
|
default: true |
|
|
|
}, |
|
|
|
// 校验rules |
|
|
|
// 校验rules |
|
|
|
rules: { |
|
|
|
type: Object, |
|
|
|
required: true, |
|
|
@ -66,7 +79,7 @@ const props = defineProps({ |
|
|
|
default: null |
|
|
|
}, |
|
|
|
// 列表数据 |
|
|
|
tableData:{ |
|
|
|
tableData: { |
|
|
|
type: Array, |
|
|
|
required: true, |
|
|
|
default: null |
|
|
@ -107,7 +120,7 @@ const props = defineProps({ |
|
|
|
default: true |
|
|
|
}, |
|
|
|
// 表单form |
|
|
|
form:{ |
|
|
|
form: { |
|
|
|
type: Object, |
|
|
|
required: true, |
|
|
|
default: null |
|
|
@ -139,20 +152,34 @@ const formSchema = ref(props.formAllSchemas?.formSchema) |
|
|
|
|
|
|
|
/** 弹层操作 */ |
|
|
|
// formField form表单中的字段 |
|
|
|
// searchField 查询列表中的字段 |
|
|
|
// type 发起事件位置 type=tableForm 是明细中发起的 否则 为主表发起的 |
|
|
|
// searchField 查询列表中的字段 |
|
|
|
// type 发起事件位置 type=tableForm 是明细中发起的 否则 为主表发起的 |
|
|
|
// searchCondition 查询条件 |
|
|
|
const searchTableRef = ref() |
|
|
|
const opensearchTable = (formField, searchField, searchTitle, searchAllSchemas, searchPage, searchCondition,multiple, type, row ) => { |
|
|
|
const opensearchTable = ( |
|
|
|
formField, |
|
|
|
searchField, |
|
|
|
searchTitle, |
|
|
|
searchAllSchemas, |
|
|
|
searchPage, |
|
|
|
searchCondition, |
|
|
|
multiple, |
|
|
|
type, |
|
|
|
row |
|
|
|
) => { |
|
|
|
const _searchCondition = {} |
|
|
|
// 判断查询条件中,是否存在指向主表的数据 |
|
|
|
if (searchCondition && searchCondition.length > 0) { |
|
|
|
searchCondition.forEach(item => { |
|
|
|
searchCondition.forEach((item) => { |
|
|
|
// 查询条件为主表某字段,需要赋值主表数据,数据来源是详情的,赋值需要从row中获取 |
|
|
|
if (item.isMainValue) { |
|
|
|
_searchCondition[item.key] = formRef.value.formModel[item.value]? |
|
|
|
formRef.value.formModel[item.value]:props.detailData? |
|
|
|
props.detailData[item.value]:row[item.value]?row[item.value]:'' |
|
|
|
_searchCondition[item.key] = formRef.value.formModel[item.value] |
|
|
|
? formRef.value.formModel[item.value] |
|
|
|
: props.detailData |
|
|
|
? props.detailData[item.value] |
|
|
|
: row[item.value] |
|
|
|
? row[item.value] |
|
|
|
: '' |
|
|
|
} else { |
|
|
|
_searchCondition[item.key] = item.value |
|
|
|
} |
|
|
@ -161,12 +188,22 @@ const opensearchTable = (formField, searchField, searchTitle, searchAllSchemas, |
|
|
|
const _searchTableTitle = searchTitle |
|
|
|
const _searchTableAllSchemas = searchAllSchemas |
|
|
|
const _searchTablePage = searchPage |
|
|
|
searchTableRef.value.open(_searchTableTitle, _searchTableAllSchemas, _searchTablePage, formField, searchField,multiple, type, row, _searchCondition) |
|
|
|
searchTableRef.value.open( |
|
|
|
_searchTableTitle, |
|
|
|
_searchTableAllSchemas, |
|
|
|
_searchTablePage, |
|
|
|
formField, |
|
|
|
searchField, |
|
|
|
multiple, |
|
|
|
type, |
|
|
|
row, |
|
|
|
_searchCondition |
|
|
|
) |
|
|
|
} |
|
|
|
// 弹层确定返回所选数据 |
|
|
|
// val : 弹层列表row 数据 |
|
|
|
const searchTableSuccess = (formField,searchField, val, type, row) => { |
|
|
|
emit('searchTableSuccess', formField, searchField, val, formRef.value, type, row ) |
|
|
|
const searchTableSuccess = (formField, searchField, val, type, row) => { |
|
|
|
emit('searchTableSuccess', formField, searchField, val, formRef.value, type, row) |
|
|
|
} |
|
|
|
|
|
|
|
/** 打开弹窗 */ |
|
|
@ -177,8 +214,8 @@ const open = async (type: string, row?: any, masterParmas?: any) => { |
|
|
|
resetForm() |
|
|
|
// 修改时,设置数据 |
|
|
|
// 如果是从主表的详情页面进图添加子表,需要添加masterId,number参数 |
|
|
|
if(masterParmas){ |
|
|
|
if(!row){ |
|
|
|
if (masterParmas) { |
|
|
|
if (!row) { |
|
|
|
row = { |
|
|
|
masterId: masterParmas.masterId, |
|
|
|
number: masterParmas.number |
|
|
@ -196,12 +233,12 @@ const open = async (type: string, row?: any, masterParmas?: any) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
defineExpose({ open , formRef, opensearchTable, dialogVisible, formLoading }) // 提供 open 方法,用于打开弹窗 |
|
|
|
defineExpose({ open, formRef, opensearchTable, dialogVisible, formLoading }) // 提供 open 方法,用于打开弹窗 |
|
|
|
|
|
|
|
/** 弹窗按钮 */ |
|
|
|
const Butttondata = [ |
|
|
|
defaultButtons.formSaveBtn(null), // 保存 |
|
|
|
defaultButtons.formCloseBtn(null), // 关闭 |
|
|
|
defaultButtons.formCloseBtn(null) // 关闭 |
|
|
|
] |
|
|
|
|
|
|
|
/** 按钮事件 */ |
|
|
@ -209,7 +246,6 @@ const buttonBaseClick = (val) => { |
|
|
|
// 保存 |
|
|
|
if (val == 'save') { |
|
|
|
submitForm() |
|
|
|
|
|
|
|
} |
|
|
|
// 关闭 |
|
|
|
else if (val == 'close') { |
|
|
@ -244,14 +280,14 @@ const submitForm = async () => { |
|
|
|
// 主子表——提交请求 |
|
|
|
try { |
|
|
|
const data = unref(formRef)?.formModel |
|
|
|
emit('submitForm', formType.value, data ) |
|
|
|
emit('submitForm', formType.value, data) |
|
|
|
} finally { |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 编辑 |
|
|
|
try { |
|
|
|
const data = unref(formRef)?.formModel |
|
|
|
emit('submitForm', formType.value, data ) |
|
|
|
emit('submitForm', formType.value, data) |
|
|
|
} finally { |
|
|
|
} |
|
|
|
} |
|
|
@ -260,7 +296,7 @@ const submitForm = async () => { |
|
|
|
formLoading.value = true |
|
|
|
try { |
|
|
|
const data = unref(formRef)?.formModel |
|
|
|
emit('success',formType.value,data) |
|
|
|
emit('success', formType.value, data) |
|
|
|
} finally { |
|
|
|
formLoading.value = false |
|
|
|
} |
|
|
@ -287,6 +323,7 @@ const emit = defineEmits([ |
|
|
|
'searchTableSuccess', |
|
|
|
'opensearchTable', |
|
|
|
'submitForm', |
|
|
|
'selectChange' |
|
|
|
]) |
|
|
|
//普通下拉改变事件 |
|
|
|
const formSelectChange = (field, val) => { |
|
|
@ -320,20 +357,24 @@ const handleAddTable = () => { |
|
|
|
} |
|
|
|
// 输入框聚焦 |
|
|
|
const inpuFocus = (headerItem, row, index) => { |
|
|
|
console.log(headerItem.tableForm.multiple); |
|
|
|
|
|
|
|
console.log(headerItem.tableForm.multiple) |
|
|
|
|
|
|
|
opensearchTable( |
|
|
|
headerItem.field, |
|
|
|
headerItem.tableForm.searchField, |
|
|
|
headerItem.tableForm.searchTitle, |
|
|
|
headerItem.tableForm.searchAllSchemas, |
|
|
|
headerItem.tableForm.searchPage, |
|
|
|
headerItem.field, |
|
|
|
headerItem.tableForm.searchField, |
|
|
|
headerItem.tableForm.searchTitle, |
|
|
|
headerItem.tableForm.searchAllSchemas, |
|
|
|
headerItem.tableForm.searchPage, |
|
|
|
headerItem.tableForm.searchCondition, |
|
|
|
headerItem.tableForm.multiple, |
|
|
|
'tableForm', |
|
|
|
row, |
|
|
|
row |
|
|
|
) |
|
|
|
} |
|
|
|
// 修改盘点类型 |
|
|
|
const selectChange=((field,val)=>{ |
|
|
|
emit('selectChange',field,val) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
<style lang="scss" scoped> |
|
|
|
.table { |
|
|
|