| | |
| | | <template> |
| | | <div> |
| | | <BasicTable @register="registerTable"> |
| | | <PageWrapper |
| | | :dense="dense" |
| | | contentFullHeight |
| | | fixedHeight |
| | | contentClass="flex" |
| | | :title="pageTitle" |
| | | :content="pageContent" |
| | | @back="goBack" |
| | | > |
| | | <GeneralTree |
| | | class="w-1/4 xl:w-1/5" |
| | | @select="handleSelect" |
| | | :title="title" |
| | | :treeData="treeData" |
| | | :create-icon="createIcon" |
| | | :fieldNames="fieldNames" |
| | | /><!-- |
| | | add |
| | | @handle-add="handleAdd" --> |
| | | <div class="w-3/4 xl:w-4/5 p-5"> |
| | | <RouteAction v-if="entityName == 'ProdRouteBinding'" /> |
| | | </div> |
| | | <!-- <BasicTable class="w-3/4 xl:w-4/5" @register="registerTable"> |
| | | <template #toolbar> |
| | | <a-button type="primary" @click="handleCreate"> 新增部门 </a-button> |
| | | <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 新增 </a-button> |
| | | </template> |
| | | <template #bodyCell="{ column, record }"> |
| | | <template v-if="column.key === 'action'"> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | icon: 'clarity:note-edit-line', |
| | | onClick: handleEdit.bind(null, record), |
| | | }, |
| | | { |
| | | icon: 'ant-design:delete-outlined', |
| | | color: 'error', |
| | | popConfirm: { |
| | | title: '是否确认删除', |
| | | placement: 'left', |
| | | confirm: handleDelete.bind(null, record), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | <TableAction :actions="createActions(record)" /> |
| | | </template> |
| | | </template> |
| | | </BasicTable> |
| | | <DeptModal @register="registerModal" @success="handleSuccess" /> |
| | | </div> |
| | | </BasicTable> --> |
| | | <!-- <normalDrawer @register="registerDrawer" @success="handleSuccess" /> --> |
| | | <CustModal |
| | | @register="registerCust" |
| | | @success="custSuccess" |
| | | :type="cType" |
| | | :detailSlots="dtlSlots" |
| | | > |
| | | <!-- 用插槽自定义多表单 --> |
| | | <template #[item.name] v-for="item in dtlSlots" :key="item.name"> |
| | | <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]"> |
| | | <!-- 用插槽自定义弹出选择框 --> |
| | | <template #[name]="{ field }" v-for="name in item.slots" :key="name"> |
| | | <a-button |
| | | class="mt-1 ml-1" |
| | | size="small" |
| | | @click="handleCustClick(field)" |
| | | :preIcon="item.preIcons[name]" |
| | | /> |
| | | <GeneralModal |
| | | @register="useModalData[name][0]" |
| | | @success="(d, u) => handleEntSuccess(d, u, item.name)" |
| | | /> |
| | | </template> |
| | | </BasicForm> |
| | | <!-- 自定义内容 --> |
| | | </template> |
| | | </CustModal> |
| | | </PageWrapper> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { BasicTable, useTable, TableAction } from '@/components/Table'; |
| | | import { getDeptList } from '@/api/demo/system'; |
| | | |
| | | import { PageWrapper } from '@/components/Page'; |
| | | import GeneralTree from '/@/views/components/GeneralTree.vue'; |
| | | import { useModal } from '@/components/Modal'; |
| | | import DeptModal from './DeptModal.vue'; |
| | | |
| | | import { columns, searchFormSchema } from './dept.data'; |
| | | import normalDrawer from '../normalDrawer.vue'; |
| | | import GeneralModal from '/@/views/components/GeneralModal.vue'; |
| | | import RouteAction from './RouteAction.vue'; |
| | | import CustModal from '/@/views/components/CustModal.vue'; |
| | | import { |
| | | GetActionsData, |
| | | GetSelectSuccess, |
| | | OpenCustModal, |
| | | fetchTreeData, |
| | | getFormSchema, |
| | | getHomeUrl, |
| | | getOthersValues, |
| | | } from '../data'; |
| | | import { onMounted, reactive, ref } from 'vue'; |
| | | import { useRoute } from 'vue-router'; |
| | | import { useDrawer } from '/@/components/Drawer'; |
| | | import { BasicForm, useForm } from '/@/components/Form/index'; |
| | | import { TreeItem } from '/@/components/TigerTree'; |
| | | import { createIconByType } from '../data'; |
| | | import { RouteToProd } from '/@/api/tigerapi/mes/router'; |
| | | import { useTabs } from '/@/hooks/web/useTabs'; |
| | | import { isNullOrUnDef } from '/@/utils/is'; |
| | | import { useGo } from '/@/hooks/web/usePage'; |
| | | |
| | | defineOptions({ name: 'DeptManagement' }); |
| | | |
| | | const [registerModal, { openModal }] = useModal(); |
| | | const [registerTable, { reload }] = useTable({ |
| | | title: '部门列表', |
| | | api: getDeptList, |
| | | columns, |
| | | formConfig: { |
| | | labelWidth: 120, |
| | | schemas: searchFormSchema, |
| | | }, |
| | | pagination: false, |
| | | striped: false, |
| | | useSearchForm: true, |
| | | showTableSetting: true, |
| | | bordered: true, |
| | | showIndexColumn: false, |
| | | canResize: false, |
| | | actionColumn: { |
| | | width: 80, |
| | | title: '操作', |
| | | dataIndex: 'action', |
| | | // slots: { customRender: 'action' }, |
| | | fixed: undefined, |
| | | }, |
| | | const go = useGo(); |
| | | const route = useRoute(); |
| | | const { setTitle } = useTabs(); |
| | | const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); //ref(JSON.parse(history.state.obj)) |
| | | const entityName = ref(objParams.value.Name); |
| | | const formSchemas = ref({}); //弹出框或高级页面多表单结构 |
| | | const useModalData = ref({}); //表单中插槽渲染按钮打开模态框useModal方法 |
| | | const useFormData = ref({}); |
| | | const colSlots = ref<any>(objParams.value.colSlots); //按钮插槽 |
| | | const crudColSlots = ref<any>(objParams.value.crudColSlots); |
| | | const cType = ref(''); |
| | | const dtlSlots = ref([] as any[]); |
| | | const selectVals = ref({}); |
| | | const baseCards = ref([] as any[]); |
| | | const otherCards = ref([] as any[]); |
| | | const searchInfo = reactive<Recordable>({}); |
| | | const treeData = ref<TreeItem[]>([]); |
| | | const title = ref(''); |
| | | const fieldNames = ref({}); |
| | | const dense = isNullOrUnDef(objParams.value.dense) ? ref(false) : ref(objParams.value.dense); |
| | | const pageTitle = ref(objParams.value.pageTitle); |
| | | const pageContent = ref(objParams.value.pageContent); |
| | | const others = ref(getOthersValues(entityName.value, objParams.value.CODE, objParams.value.ID)); |
| | | const [registerCust, { openModal: openCustomModal, closeModal }] = useModal(); |
| | | const [registerItemAdd, { openModal: openItemModal }] = useModal(); |
| | | const [registerDrawer, { openDrawer }] = useDrawer(); |
| | | setTitle(objParams.value.Title); //设置标签页标题 |
| | | // const [registerTable, { reload }] = useTable({ |
| | | // title: '列表信息', |
| | | // api: getRoleListByPage, |
| | | // columns, |
| | | // formConfig: { |
| | | // labelWidth: 120, |
| | | // schemas: searchFormSchema, |
| | | // }, |
| | | // pagination: false, |
| | | // striped: false, |
| | | // useSearchForm: true, |
| | | // showTableSetting: true, |
| | | // bordered: true, |
| | | // showIndexColumn: false, |
| | | // canResize: false, |
| | | // actionColumn: { |
| | | // width: 80, |
| | | // title: '操作', |
| | | // dataIndex: 'action', |
| | | // // slots: { customRender: 'action' }, |
| | | // fixed: undefined, |
| | | // }, |
| | | // }); |
| | | |
| | | /** |
| | | * @description: 获取树形数据 |
| | | * @param {*} type |
| | | * @return {*} |
| | | */ |
| | | async function fetch(type: string) { |
| | | //根据type获取树形数据 |
| | | const data = await fetchTreeData(type, objParams.value.CODE); |
| | | title.value = data.title; |
| | | treeData.value = data.treeData; |
| | | fieldNames.value = data.fieldNames; |
| | | } |
| | | |
| | | /** |
| | | * @description: 页面左侧点击返回链接时的操作 |
| | | * @return {*} |
| | | */ |
| | | function goBack() { |
| | | go(getHomeUrl(entityName.value)); |
| | | } |
| | | |
| | | // function handleAdd(){ |
| | | // console.log('handleAdd'); |
| | | // } |
| | | |
| | | /** |
| | | * @description: 树形节点图标 |
| | | * @param {*} params |
| | | * @param {*} type |
| | | * @return {*} |
| | | */ |
| | | function createIcon(params: Recordable<any>) { |
| | | return createIconByType(params, entityName.value); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetch(entityName.value); |
| | | }); |
| | | |
| | | /** |
| | | * @description: 生成列表中操作项的按钮 |
| | | * @param {*} record |
| | | * @return {*} |
| | | */ |
| | | function createActions(record) { |
| | | // return GetActionsData( |
| | | // { |
| | | // record, |
| | | // isUpdate: true, |
| | | // ifSave: true, |
| | | // entityName: entityName.value, |
| | | // formJson: getFormSchema(`${entityName.value}_Crud`), |
| | | // cType, |
| | | // dtlSlots, |
| | | // useModalData, |
| | | // useFormData, |
| | | // crudColSlots, |
| | | // }, |
| | | // openDrawer, |
| | | // reload, |
| | | // openCustomModal, |
| | | // useForm, |
| | | // useModal, |
| | | // ); |
| | | } |
| | | |
| | | /** |
| | | * @description: 验证表单 |
| | | * @return {*} |
| | | */ |
| | | async function validate() { |
| | | let validates = {}; |
| | | const Keys = Object.getOwnPropertyNames(useFormData.value); |
| | | let i; |
| | | for (i = 0; i < Keys.length; i++) { |
| | | validates[Keys[i]] = await useFormData.value[Keys[i]][1].validate(); |
| | | } |
| | | return validates; |
| | | } |
| | | |
| | | function handleCreate() { |
| | | openModal(true, { |
| | | isUpdate: false, |
| | | }); |
| | | // 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 |
| | | // ? res[Keys[i]]['ID'] |
| | | // : res[Keys[i]][objParams.value.pCode]; |
| | | // } |
| | | // openDrawer(true, { |
| | | // isUpdate: false, |
| | | // ifSave: true, |
| | | // entityName: entityName.value, |
| | | // formJson: getFormSchema(`${entityName.value}_Crud`), |
| | | // crudColSlots, |
| | | // others: others.value, |
| | | // }); |
| | | // }); |
| | | RouteToProd({ rotId: 'e4712192f75b465585107fdcd13d8003', prodCode: 'K5019AA013517' }).then( |
| | | () => {}, |
| | | ); |
| | | } |
| | | |
| | | function handleEdit(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: true, |
| | | }); |
| | | // function handleEdit(record: Recordable) { |
| | | // openModal(true, { |
| | | // record, |
| | | // isUpdate: true, |
| | | // }); |
| | | // } |
| | | |
| | | // function handleDelete(record: Recordable) { |
| | | // console.log(record); |
| | | // } |
| | | |
| | | function handleSelect(deptId = '', info) { |
| | | searchInfo.deptId = deptId; |
| | | // reload(); |
| | | } |
| | | |
| | | function handleDelete(record: Recordable) { |
| | | console.log(record); |
| | | // function handleSuccess() { |
| | | // reload(); |
| | | // } |
| | | |
| | | /** |
| | | * @description: 弹出框确定返回 |
| | | * @param {*} d |
| | | * @return {*} |
| | | */ |
| | | function custSuccess(d) { |
| | | // reload(); |
| | | } |
| | | |
| | | function handleSuccess() { |
| | | reload(); |
| | | /** |
| | | * @description: 各表单内弹出选择框选择成功后方法 |
| | | * @param {*} d |
| | | * @param {*} u |
| | | * @param {*} item |
| | | * @return {*} |
| | | */ |
| | | function handleEntSuccess(d, u, item) { |
| | | var values = GetSelectSuccess(d, u, cType.value); |
| | | selectVals.value = values; //保存弹出框选择的结果 |
| | | let _val = {}; |
| | | _val[d.returnFieldName] = values[d.returnFieldName]; |
| | | useFormData.value[item][1].setFieldsValue(_val); |
| | | } |
| | | |
| | | /** |
| | | * @description: 打开自定义模态框 |
| | | * @param {*} item |
| | | * @return {*} |
| | | */ |
| | | function handleCustClick(item) { |
| | | OpenCustModal( |
| | | useModalData.value[item][1].openModal, //带入openModal方法 |
| | | cType.value, |
| | | item, |
| | | [], |
| | | // selectVals.value['ROUTE_CODE'], |
| | | ); //[openRvModal], selectVals.value['ID']这是自定义参数,按实际需求 |
| | | } |
| | | </script> |