| | |
| | | * @version: |
| | | * @Date: 2024-06-22 00:58:43 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-07-01 17:13:16 |
| | | * @LastEditTime: 2024-07-02 19:59:39 |
| | | */ |
| | | import { Ref, h } from 'vue'; |
| | | import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; |
| | | import { ActionItem, BasicColumn, useTable } from '/@/components/Table'; |
| | | import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table'; |
| | | import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; |
| | | import { buildUUID } from '/@/utils/uuid'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { formatToDateTime } from '/@/utils/dateUtil'; |
| | | import { Tag } from 'ant-design-vue'; |
| | | import { useDrawer } from '/@/components/Drawer'; |
| | | import { EditOperation, Search } from '../data'; |
| | | |
| | | function _default() { |
| | | const ActionColumn: BasicColumn = { |
| | |
| | | * @param {*} u |
| | | * @return {*} |
| | | */ |
| | | EditOperation: (data: Ref<any[]>, d, u) => { |
| | | if (u.isUpdate) { |
| | | //更新 |
| | | var _data = data.value.map((item) => { |
| | | if (item['ID'] == d.ID) |
| | | return { |
| | | ...item, |
| | | RSN_CODE: d.RSN_CODE, |
| | | RSN_NAME: d.RSN_NAME, |
| | | NEED_REPLACE: d.NEED_REPLACE, |
| | | REMARK: d.REMARK, |
| | | }; |
| | | return item; |
| | | }); |
| | | data.value = _data; |
| | | } else { |
| | | //新增 |
| | | d.ID = buildUUID(); |
| | | d.CREATE_USER = useUserStore().getUserInfo.userId as string; |
| | | d.UPDATE_TIME = formatToDateTime(new Date()); |
| | | d.UPDATE_USER = useUserStore().getUserInfo.userId as string; |
| | | var _data2: any[] = []; |
| | | if (!isNullOrEmpty(data.value)) { |
| | | _data2 = data.value.map((item) => { |
| | | return item; |
| | | }); |
| | | } |
| | | _data2.push(d); |
| | | data.value = _data2; |
| | | } |
| | | EditOperation: (data: Ref<any[]>, d, u, item) => { |
| | | //更新 |
| | | var _data = data.value[item].map((item) => { |
| | | if (item['ID'] == d.ID) |
| | | return { |
| | | ...item, |
| | | RSN_CODE: d.RSN_CODE, |
| | | RSN_NAME: d.RSN_NAME, |
| | | NEED_REPLACE: d.NEED_REPLACE, |
| | | REMARK: d.REMARK, |
| | | }; |
| | | return item; |
| | | }); |
| | | EditOperation(data,d, u, item, _data); |
| | | }, |
| | | /** |
| | | * @description: 高级表单和详情页面返回主页面的url |
| | |
| | | * @param {array} args |
| | | * @return {*} |
| | | */ |
| | | GetUseTables: (data: any[], ...args) => { |
| | | GetUseTables: (data: Ref<{}>, ...args) => { |
| | | return { |
| | | BAS_REASON: useTable({ |
| | | title: '列表信息', |
| | | dataSource: data, |
| | | dataSource: data.value['BAS_REASON'], |
| | | columns: baseColumns['BAS_REASON'], |
| | | formConfig: { |
| | | labelWidth: 140, |
| | | schemas: searchForms['BAS_REASON'], |
| | | submitFunc: () => Search('BAS_REASON', data, args[0]), //自定义查询提交按钮的方法,触发查询提交事件 |
| | | }, |
| | | useSearchForm: true, |
| | | showTableSetting: true, |
| | |
| | | }, //自定义操作列 |
| | | }), |
| | | }; |
| | | }, |
| | | /** |
| | | * @description: 表格查询回调,父组件中通过子组件触发的事件获取传入的值,做具体的查询逻辑实现 |
| | | * @param {*} d |
| | | * @return {*} |
| | | */ |
| | | FormSearch: (d) => { |
| | | let data = {} as any; |
| | | switch (d.type) { |
| | | case 'BAS_REASON': |
| | | data = d.data.value[d.type].filter( |
| | | (item) => |
| | | item.RSN_CODE.includes(d.values.RSN_CODE) || item.RSN_NAME == d.values.RSN_NAME, |
| | | ); |
| | | if (isNullOrEmpty(d.values.RSN_CODE) && isNullOrEmpty(d.values.RSN_NAME)) { |
| | | data = d.data.value[d.type]; |
| | | } |
| | | break; |
| | | } |
| | | return data; |
| | | }, |
| | | OthersValues: (val: string, id: string) => { |
| | | return { RSNG_CODE: val }; |
| | |
| | | title: '更新人', |
| | | dataIndex: 'UPDATE_USER', |
| | | }, |
| | | ], |
| | | ] as BasicColumn[], |
| | | }; |
| | | |
| | | const searchForms = { |
| | |
| | | span: 8, |
| | | }, |
| | | }, |
| | | ], |
| | | ] as FormSchema[], |
| | | }; |
| | | |
| | | const crudForms = { |
| | |
| | | }, |
| | | show: false, |
| | | }, |
| | | ], |
| | | ] as FormSchema[], |
| | | }; |
| | | |
| | | return [methods, ActionColumn]; |