| | |
| | | <template> |
| | | <PageWrapper dense contentFullHeight fixedHeight contentClass="flex"> |
| | | <CustTree |
| | | <PageWrapper |
| | | :dense="dense" |
| | | contentFullHeight |
| | | fixedHeight |
| | | contentClass="flex" |
| | | :title="pageTitle" |
| | | :content="pageContent" |
| | | @back="goBack" |
| | | > |
| | | <GeneralTree |
| | | class="w-1/4 xl:w-1/5" |
| | | v-if="isMounted" |
| | | @select="handleSelect" |
| | | @UnSelect="UnSelect" |
| | | :title="title" |
| | | :treeData="treeData" |
| | | :create-icon="createIcon" |
| | |
| | | /><!-- |
| | | add |
| | | @handle-add="handleAdd" --> |
| | | <BasicTable class="w-3/4 xl:w-4/5" @register="registerTable"> |
| | | <div class="w-3/4 xl:w-4/5 p-5"> |
| | | <AddRoute v-if="entityName == 'ProdRouteBinding' && rotType == 'Product'" /> |
| | | <ActionConfig v-if="entityName == 'ProdRouteBinding' && rotType == 'Action'" /> |
| | | </div> |
| | | <!-- <BasicTable class="w-3/4 xl:w-4/5" @register="registerTable"> |
| | | <template #toolbar> |
| | | <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 新增 </a-button> |
| | | </template> |
| | |
| | | <TableAction :actions="createActions(record)" /> |
| | | </template> |
| | | </template> |
| | | </BasicTable> |
| | | <normalDrawer @register="registerDrawer" @success="handleSuccess" /> |
| | | </BasicTable> --> |
| | | <!-- <normalDrawer @register="registerDrawer" @success="handleSuccess" /> --> |
| | | <CustModal |
| | | @register="registerCust" |
| | | @success="custSuccess" |
| | |
| | | @click="handleCustClick(field)" |
| | | :preIcon="item.preIcons[name]" |
| | | /> |
| | | <NormalModal |
| | | <GeneralModal |
| | | @register="useModalData[name][0]" |
| | | @success="(d, u) => handleEntSuccess(d, u, item.name)" |
| | | /> |
| | |
| | | </PageWrapper> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { BasicTable, useTable, TableAction } from '@/components/Table'; |
| | | import { getEntity, getRoleListByPage, convertToTree } from '@/api/tigerapi/system'; |
| | | import { PageWrapper } from '@/components/Page'; |
| | | import CustTree from './CustTree.vue'; |
| | | import GeneralTree from '/@/views/components/GeneralTree.vue'; |
| | | import { useModal } from '@/components/Modal'; |
| | | import normalDrawer from '../normalDrawer.vue'; |
| | | import NormalModal from '/@/views/components/NormalModal.vue'; |
| | | import GeneralModal from '/@/views/components/GeneralModal.vue'; |
| | | import AddRoute from './AddRoute.vue'; |
| | | import ActionConfig from './ActionConfig.vue'; |
| | | import CustModal from '/@/views/components/CustModal.vue'; |
| | | import { columns, searchFormSchema } from './dept.data'; |
| | | import { |
| | | GetActionsData, |
| | | GetSelectSuccess, |
| | | OpenCustModal, |
| | | fetchTreeData, |
| | | getFormSchema, |
| | | getOthersValues, |
| | | } from '../data'; |
| | | import { onMounted, reactive, ref } from 'vue'; |
| | | import { OpenCustModal } from '../data'; |
| | | import { Ref, onMounted, provide, 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 go = useGo(); |
| | | const route = useRoute(); |
| | | const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); |
| | | 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 treeData = ref<TreeItem[]>([]); |
| | | const title = ref(''); |
| | | const fieldNames = ref({}); |
| | | const others = ref(getOthersValues(entityName.value, objParams.value.CODE, objParams.value.ID)); |
| | | 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 prodCode = ref(''); |
| | | const actionCode = ref(''); |
| | | const rotType = ref(''); |
| | | const isMounted = ref(false); |
| | | const custImport = ref<any>(null); |
| | | const [registerCust, { openModal: openCustomModal, closeModal }] = useModal(); |
| | | const [registerItemAdd, { openModal: openItemModal }] = useModal(); |
| | | const [registerDrawer, { openDrawer }] = useDrawer(); |
| | | 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, |
| | | }, |
| | | }); |
| | | provide<Ref<string>>('prodCode', prodCode); |
| | | provide<Ref<string>>('actionCode', actionCode); |
| | | setTitle(objParams.value.Title); //设置标签页标题 |
| | | |
| | | /** |
| | | * @description: 获取树形数据 |
| | | * @param {*} type |
| | | * @return {*} |
| | | */ |
| | | */ |
| | | async function fetch(type: string) { |
| | | //根据type获取树形数据 |
| | | const data = await fetchTreeData(type); |
| | | title.value = data.title; |
| | | treeData.value = data.treeData; |
| | | fieldNames.value = data.fieldNames; |
| | | if (!isNullOrUnDef(custImport.value)) { |
| | | const [{ fetchTreeData }] = custImport.value['default'](); |
| | | //根据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() { |
| | | if (!isNullOrUnDef(custImport.value)) { |
| | | const [{ GetHomeUrl }] = custImport.value['default'](); |
| | | // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页 |
| | | go(GetHomeUrl(entityName.value)); |
| | | } |
| | | } |
| | | |
| | | // function handleAdd(){ |
| | |
| | | * @param {*} params |
| | | * @param {*} type |
| | | * @return {*} |
| | | */ |
| | | */ |
| | | function createIcon(params: Recordable<any>) { |
| | | return createIconByType(params, entityName.value); |
| | | if (isNullOrUnDef(custImport.value)) { |
| | | return ''; |
| | | } else { |
| | | const [{ CreateIcon }] = custImport.value['default'](); |
| | | return CreateIcon(params); |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetch(entityName.value); |
| | | onMounted(async () => { |
| | | isMounted.value = false; |
| | | /* 动态import实体名.ts的自定义方法 */ |
| | | try { |
| | | custImport.value = await import(/* @vite-ignore */ `../entityts/${entityName.value}`); |
| | | await fetch(entityName.value); |
| | | isMounted.value = true; |
| | | } catch (e) {} |
| | | }); |
| | | |
| | | /** |
| | | * @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() { |
| | | // 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 handleDelete(record: Recordable) { |
| | | // console.log(record); |
| | | // } |
| | | |
| | | function handleSelect(deptId = '') { |
| | | function handleSelect(deptId = '', info) { |
| | | searchInfo.deptId = deptId; |
| | | reload(); |
| | | rotType.value = info.selectedNodes[0].type; |
| | | prodCode.value =rotType.value=='Product'? info.selectedNodes[0].code: prodCode.value; |
| | | actionCode.value =rotType.value=='Action'? info.selectedNodes[0].code: actionCode.value; |
| | | // reload(); |
| | | } |
| | | |
| | | function handleSuccess() { |
| | | reload(); |
| | | /** |
| | | * @description: 取消选择时事件返回方法 |
| | | * @param {*} node |
| | | * @return {*} |
| | | */ |
| | | function UnSelect(node) { |
| | | prodCode.value = ''; |
| | | rotType.value = ''; |
| | | // reload(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return {*} |
| | | */ |
| | | function custSuccess(d) { |
| | | reload(); |
| | | // reload(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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); |
| | | /* 动态import实体名.ts的自定义方法 */ |
| | | try { |
| | | import(/* @vite-ignore */ `../entityts/${cType.value}`).then((m) => { |
| | | const [{ GetSelectSuccess }] = m.default(); |
| | | var values = GetSelectSuccess(d, u); |
| | | selectVals.value = values; //保存弹出框选择的结果 |
| | | let _val = {}; |
| | | _val[d.returnFieldName] = values[d.returnFieldName]; |
| | | useFormData.value[item][1].setFieldsValue(_val); |
| | | }); |
| | | } catch (e) {} |
| | | } |
| | | |
| | | /** |