| | |
| | | <script setup lang="ts"> |
| | | import { computed, ref } from 'vue'; |
| | | |
| | | import { useVbenDrawer } from '@vben/common-ui'; |
| | | import { useVbenDrawer, useVbenModal } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | | import { addFullName, cloneDeep, getPopupContainer, listToTree } from '@vben/utils'; |
| | | |
| | | import { InputSearch } from 'ant-design-vue'; |
| | | |
| | | import { useVbenForm } from '#/adapter/form'; |
| | | import { addEqu, getEqu, updateEqu } from '#/api/eims/equ'; |
| | | import { getEquType, listEquType } from '#/api/eims/equ-type'; |
| | | import { getDeptTree, userList } from '#/api/system/user'; |
| | | import userModal from '#/views/eims/components/user-modal.vue'; |
| | | |
| | | import { drawerSchema } from './data'; |
| | | |
| | |
| | | if (isUpdate.value && id) { |
| | | const record = await getEqu(id); |
| | | await formApi.setValues(record); |
| | | if(isUpdate.value && record.deptUsed){ |
| | | await setupUserOptions(record.deptUsed) |
| | | if (isUpdate.value && record.deptUsed) { |
| | | await setupUserOptions(record.deptUsed); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 加载设备类型树选择 |
| | |
| | | } |
| | | }); |
| | | |
| | | // user modal |
| | | const [UserModal, userModalApi] = useVbenModal({ |
| | | connectedComponent: userModal, |
| | | draggable: true, |
| | | title: '选择成员' |
| | | }); |
| | | |
| | | function handleOpenModal() { |
| | | userModalApi.setData({}); |
| | | userModalApi.open(); |
| | | } |
| | | |
| | | /** |
| | | * 打开选择成员 |
| | | */ |
| | | const column = ref<string>(); |
| | | function onOpenSelectUser(type: any) { |
| | | column.value = type; |
| | | handleOpenModal(); |
| | | } |
| | | |
| | | /** |
| | | * 更新选择的成员 |
| | | * @param user |
| | | */ |
| | | async function selectUser(user: any) { |
| | | if (column.value === 'purchaseUser') { |
| | | await formApi.setValues({ 'purchaseUser': user.userId, 'purchaseUserName': user.nickName }); |
| | | } else if (column.value === 'handleUserName') { |
| | | await formApi.setValues({ 'handleUser': user.userId, 'handleUserName': user.nickName }); |
| | | } |
| | | } |
| | | |
| | | async function setupEquTypeSelect() { |
| | | // status-0 只查询未停用设备 |
| | |
| | | { |
| | | equTypeId: 0, |
| | | typeName: $t('menu.root'), |
| | | children: equTree, |
| | | }, |
| | | children: equTree |
| | | } |
| | | ]; |
| | | addFullName(fullEquTree, 'typeName', ' / '); |
| | | formApi.updateSchema([ |
| | |
| | | componentProps: { |
| | | fieldNames: { |
| | | label: 'typeName', |
| | | value: 'equTypeId', |
| | | value: 'equTypeId' |
| | | }, |
| | | getPopupContainer, |
| | | // 设置弹窗滚动高度 默认256 |
| | |
| | | treeLine: { showLeafIcon: false }, |
| | | // 筛选的字段 |
| | | treeNodeFilterProp: 'typeName', |
| | | treeNodeLabelProp: 'fullName', |
| | | treeNodeLabelProp: 'fullName' |
| | | }, |
| | | fieldName: 'equTypeId', |
| | | }, |
| | | fieldName: 'equTypeId' |
| | | } |
| | | ]); |
| | | } |
| | | |
| | |
| | | const placeholder = options.length > 0 ? '请选择' : '该部门下暂无用户'; |
| | | formApi.updateSchema([ |
| | | { |
| | | componentProps: { options, placeholder ,filterOption }, |
| | | componentProps: { options, placeholder, filterOption }, |
| | | fieldName: 'respPerson' |
| | | } |
| | | ]); |
| | |
| | | |
| | | <template> |
| | | <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[600px]"> |
| | | <BasicForm /> |
| | | <BasicForm> |
| | | <template #purchaseUserName="slotProps"> |
| | | <InputSearch :enter-button="true" placeholder="请选择" @search="onOpenSelectUser('purchaseUser')" v-bind="slotProps" /> |
| | | </template> |
| | | <template #handleUserName="slotProps"> |
| | | <InputSearch :enter-button="true" placeholder="请选择" @search="onOpenSelectUser('handleUserName')" v-bind="slotProps" /> |
| | | </template> |
| | | </BasicForm> |
| | | <UserModal class="w-[1200px]" @select-user="selectUser" /> |
| | | </BasicDrawer> |
| | | </template> |