| | |
| | | <TableAction :actions="createActions(record, index, item.name)" /> |
| | | </template> |
| | | <template #[item]="{ field }" v-for="item in colSlots" :key="item"> |
| | | <!-- <template #form-BAS_REASON3aadd="{ field }"> --> |
| | | <a-button |
| | | v-if="field" |
| | | class="mt-1 ml-1" |
| | |
| | | </div> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue'; |
| | | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| | | import { BasicForm, useForm } from '/@/components/Form/index'; |
| | | import { Ref, inject, onMounted, ref, watch } from 'vue'; |
| | | import { BasicTable, TableAction } from '/@/components/Table'; |
| | | import { useForm } from '/@/components/Form/index'; |
| | | import GeneralModal from '/@/views/components/GeneralModal.vue'; |
| | | import normalDrawer from '../normalDrawer.vue'; |
| | | import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; |
| | |
| | | entityName: { type: String }, |
| | | crudColSlots: { type: Object as PropType<any> }, |
| | | }); |
| | | /* 主页面注入的变量 */ |
| | | const objParams = inject('objParams') as Ref<any>; |
| | | const data = inject('data') as Ref<any>; |
| | | const _useTables = inject('useTables') as Ref<any>; |
| | | const useFormData = inject('useFormData') as Ref<{}>; |
| | | const others = inject('others') as Ref<Recordable[]>; |
| | | const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>; |
| | | |
| | | const go = useGo(); |
| | | const [registerItemAdd, { openModal: openItemModal }] = useModal(); |
| | | const cType = ref(''); |
| | | const dtlSlots = ref([] as any[]); |
| | | const selectVals = ref({}); |
| | | const baseCards = ref([] as any[]); |
| | | const useModalData = ref({}); //表单中插槽渲染按钮打开模态框useModal方法 |
| | | const custImport = ref<any[]>([]); |
| | | const EntityCustFunction = ref([ |
| | | { |
| | | ActionItem(params, data, ...args) {}, |
| | | EditOperation(data, d, u, item) {}, |
| | | GetBaseColumns(type: string | undefined) {}, |
| | | GetSearchForm(type: string | undefined) {}, |
| | | GetCrudForm(type: string | undefined, ...args) {}, |
| | | OthersValues(val, id) {}, |
| | | KeyFieldValues(val, id) {}, |
| | | GetTitle(type: string | undefined) {}, |
| | | GetUseTables(data: Ref<Recordable[]>, ...args) {}, |
| | | GetUseDrawers() {}, |
| | |
| | | { |
| | | ActionItem: nActionItem, |
| | | EditOperation, |
| | | GetBaseColumns, |
| | | GetSearchForm, |
| | | GetCrudForm, |
| | | OthersValues, |
| | | KeyFieldValues, |
| | | GetTitle, |
| | | GetUseTables, |
| | | GetUseDrawers, |
| | |
| | | ] = isNullOrUnDef(custImport.value['default']) |
| | | ? EntityCustFunction.value |
| | | : custImport.value['default'](); |
| | | others.value = OthersValues(objParams.value['CODE'], objParams.value['ID']); |
| | | const drawers = ref<any[]>(objParams.value['drawers']); |
| | | const useTables = GetUseTables(data, emit); |
| | | const useDrawers = GetUseDrawers(); |
| | | _useTables.value = useTables; |
| | | keyFieldValues.value = KeyFieldValues(objParams.value['CODE'], objParams.value['ID']); //获取一些其他有需要提供的值,这里是主页面跳转过来时带的关键字段值 |
| | | const drawers = ref<any[]>(objParams.value['drawers']); //是右侧边框列表,里面的name表示是哪一个实体,也就是高级表单中表格的名字,很多方法需要以这个名字为key |
| | | const useTables = GetUseTables(data, emit); //高级表单中各个表格(Table)的useTable方法实现列表 |
| | | const useDrawers = GetUseDrawers(); //高级表单中各个表格(Table)的右侧边框(Drawer)的useDrawer方法实现列表 |
| | | _useTables.value = useTables; //把useTable的列表响应到从主页面注入的_useTables,这样主页面能拿到useTable的结果,从而可以使用各个表格的内置方法 |
| | | // watch( |
| | | // () => props.dataSource, |
| | | // (newVal, oldVal) => { |
| | |
| | | // { deep: true, immediate: true }, |
| | | // ); |
| | | |
| | | /** |
| | | * @description: 挂载组件完成时 |
| | | * @return {*} |
| | | */ |
| | | onMounted(async () => { |
| | | for (const i in drawers.value) { |
| | | let sqlcmd = ' 1 =1 '; |
| | | if (!isNullOrEmpty(others.value[drawers.value[i].code])) { |
| | | sqlcmd += ` And ${drawers.value[i].code} = '${others.value[drawers.value[i].code]}'`; |
| | | if (!isNullOrEmpty(keyFieldValues.value[drawers.value[i].code])) { |
| | | sqlcmd += ` And ${drawers.value[i].code} = '${keyFieldValues.value[drawers.value[i].code]}'`; |
| | | } |
| | | const list = await getEntity({ |
| | | sqlcmd: sqlcmd, |
| | |
| | | * @param {*} record |
| | | * @return {*} |
| | | */ |
| | | function createActions(record,index, item) { |
| | | function createActions(record, index, item) { |
| | | const params = { |
| | | record, |
| | | isUpdate: true, |
| | |
| | | useFormData, |
| | | crudColSlots: props.crudColSlots, |
| | | data, |
| | | name: item, //drawers列表里面的name,表示是哪一个实体,也就是高级表单中表格的名字 |
| | | }; |
| | | const actionItem = [ |
| | | { |
| | |
| | | return validates; |
| | | } |
| | | |
| | | /** |
| | | * @description: 新增按钮方法 |
| | | * @param {*} index |
| | | * @param {*} item |
| | | * @return {*} |
| | | */ |
| | | function handleCreate(index, item) { |
| | | validate().then((res) => { |
| | | const Keys = Object.getOwnPropertyNames(useFormData.value); |
| | | let i; |
| | | for (i = 0; i < Keys.length; i++) { |
| | | others.value[objParams.value['pCode']] = objParams.value['IsID'] |
| | | keyFieldValues.value[objParams.value['pCode']] = objParams.value['IsID'] |
| | | ? res[Keys[i]]['ID'] |
| | | : res[Keys[i]][objParams.value['pCode']] == '0' || |
| | | isNullOrUnDef(res[Keys[i]][objParams.value['pCode']]) |
| | |
| | | isUpdate: false, |
| | | ifSave: true, |
| | | entityName: props.entityName, |
| | | formJson: GetCrudForm(item, data), //getFormSchema(`${entityName.value}_Crud`), |
| | | formJson: GetCrudForm(item, data), //获取增删改表单字段 |
| | | crudColSlots: props.crudColSlots, |
| | | others: others.value, |
| | | keyFieldValues: keyFieldValues.value, |
| | | }); |
| | | }); |
| | | } |
| | |
| | | * @description: 新增编辑返回成功方法 |
| | | * @param {*} d |
| | | * @param {*} u |
| | | * @param {*} item 页面上循环抽屉列表传入的实体名字,作为各表格相关方法的key,从而调用各表格相关的方法,如:useTables[item][1].setProps |
| | | * @return {*} |
| | | */ |
| | | */ |
| | | function handleSuccess(d, u, item) { |
| | | if (!isNullOrUnDef(custImport.value)) { |
| | | /* 自定义编辑方法,根据实体名去调用 */ |
| | |
| | | * @description: 弹出选择框选择成功后事件 |
| | | * @param {*} d |
| | | * @param {*} u |
| | | * @param {*} item |
| | | * @param {*} item 页面上循环抽屉列表传入的实体名字,作为各表格相关方法的key,从而调用各表格相关的方法,如:useTables[item][1].getForm() |
| | | * @return {*} |
| | | */ |
| | | function handleItemSuccess(d, u, item) { |