|
@@ -8,12 +8,15 @@
|
|
|
:height="900"
|
|
|
@ok="handleSubmit"
|
|
|
:bodyStyle="{ padding: 0 }"
|
|
|
+ @cancel="handleCloseFunc"
|
|
|
>
|
|
|
<DeviceBaseInfoList
|
|
|
ref="deviceBaseInfoListRef"
|
|
|
:noOperate="true"
|
|
|
@selection-change="handleRowSelectionChange"
|
|
|
- :superQueryParams="superQueryParams"
|
|
|
+ :deviceId="deviceBaseInfoId"
|
|
|
+ :queryUrl="queryUrl"
|
|
|
+ v-if="showTable"
|
|
|
/>
|
|
|
<a-divider orientation="left">已选{{ addType === 1 ? '父' : '子' }}设备:({{ selectedRows.length }})</a-divider>
|
|
|
<div class="selected-divider-rap">
|
|
@@ -26,7 +29,7 @@
|
|
|
import { ref, computed, unref } from 'vue';
|
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
import DeviceBaseInfoList from '../DeviceBaseInfoList.vue';
|
|
|
- import { saveParentDevice, saveSubDevice, queryDeviceBaseInfoByParentId } from '../DeviceBaseInfo.api';
|
|
|
+ import { saveParentDevice, saveSubDevice, queryDeviceBaseInfoByParentId, findParentDeviceList, findSubDeviceList } from '../DeviceBaseInfo.api';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
|
|
|
const { createMessage } = useMessage();
|
|
@@ -38,9 +41,19 @@
|
|
|
const selectedRows = ref<any[]>([]);
|
|
|
const selectedKeys = ref<string[]>([]);
|
|
|
const deviceBaseInfoId = ref('');
|
|
|
- const superQueryParams = ref<any[]>([]);
|
|
|
const orgPdata = ref<any[]>([]);
|
|
|
+ const deviceInfo = ref<any>({});
|
|
|
const addType = ref(1);
|
|
|
+ // 重新渲染table
|
|
|
+ const showTable = ref(false);
|
|
|
+ // 查询url
|
|
|
+ const queryUrl = computed(() => {
|
|
|
+ if (addType.value === 1) {
|
|
|
+ return findParentDeviceList;
|
|
|
+ } else {
|
|
|
+ return findSubDeviceList;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
//表单赋值
|
|
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
|
@@ -52,25 +65,29 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ deviceInfo.value = data?.device;
|
|
|
addType.value = data?.addType;
|
|
|
deviceBaseInfoId.value = data?.device?.id;
|
|
|
- if (data?.addType === 2) {
|
|
|
- superQueryParams.value = [
|
|
|
- { field: 'id', rule: 'ne', val: data?.device?.id, type: 'text', dbType: 'string' },
|
|
|
- // { field: 'subDeviceIds', rule: 'empty', val: '', type: 'text', dbType: 'string' },
|
|
|
- { field: 'subDeviceIds', rule: 'ne', val: data?.device?.id, type: 'text', dbType: 'string' },
|
|
|
- ];
|
|
|
- } else {
|
|
|
- superQueryParams.value = [
|
|
|
- { field: 'parentDeviceIds', rule: 'empty', val: '', type: 'text', dbType: 'string' },
|
|
|
- { field: 'id', rule: 'ne', val: data?.device?.id, type: 'text', dbType: 'string' },
|
|
|
- ];
|
|
|
- }
|
|
|
+ showTable.value = true;
|
|
|
|
|
|
await queryParentDevice(data?.device?.id);
|
|
|
});
|
|
|
//设置标题
|
|
|
- const title = computed(() => (!unref(isUpdate) ? `添加${addType.value === 1 ? '父' : '子'}设备` : !unref(isDetail) ? '详情' : '编辑'));
|
|
|
+ const title = computed(() =>
|
|
|
+ !unref(isUpdate)
|
|
|
+ ? `添加${addType.value === 1 ? '父' : '子'}设备 -【${deviceInfo.value.deviceName} / ${deviceInfo.value.deviceNumber}】`
|
|
|
+ : !unref(isDetail)
|
|
|
+ ? '详情'
|
|
|
+ : '编辑'
|
|
|
+ );
|
|
|
+
|
|
|
+ const handleCloseFunc = () => {
|
|
|
+ showTable.value = false;
|
|
|
+ selectedRows.value = [];
|
|
|
+ selectedKeys.value = [];
|
|
|
+ deviceBaseInfoListRef.value.setSelectedRowKeys([]);
|
|
|
+ };
|
|
|
+
|
|
|
//表单提交事件
|
|
|
async function handleSubmit() {
|
|
|
try {
|