zhangafei преди 1 месец
родител
ревизия
156aa8b56b

+ 1 - 0
src/assets/icons/el-device-metering.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1744773339112" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1181" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M768 1024H256C115.2 1024 0 908.8 0 768V256C0 115.2 115.2 0 256 0h512c140.8 0 256 115.2 256 256v512c0 140.8-115.2 256-256 256z" fill="#cd201f" p-id="1182"></path><path d="M678.4 445.866667v-121.6h42.666667c6.4 0 10.666667-4.266667 10.666666-10.666667v-25.6c0-6.4-4.266667-10.666667-10.666666-10.666667h-448c-6.4 0-10.666667 4.266667-10.666667 10.666667v25.6c0 6.4 4.266667 10.666667 10.666667 10.666667H320v121.6c0 4.266667 2.133333 8.533333 6.4 10.666666l134.4 59.733334-134.4 59.733333c-4.266667 0-6.4 4.266667-6.4 8.533333v115.2h-44.8c-6.4 0-10.666667 4.266667-10.666667 10.666667v25.6c0 6.4 4.266667 10.666667 10.666667 10.666667h448c6.4 0 10.666667-4.266667 10.666667-10.666667v-25.6c0-6.4-4.266667-10.666667-10.666667-10.666667h-42.666667v-115.2c0-4.266667-2.133333-8.533333-6.4-10.666666l-134.4-59.733334 134.4-59.733333c2.133333 0 4.266667-4.266667 4.266667-8.533333z m-46.933333-29.866667c0 4.266667-2.133333 8.533333-6.4 10.666667l-121.6 55.466666c-2.133333 2.133333-6.4 2.133333-8.533334 0L373.333333 426.666667c-4.266667-2.133333-6.4-6.4-6.4-10.666667v-89.6h266.666667l-2.133333 89.6z" fill="#FFFFFF" p-id="1183"></path></svg>

+ 1 - 0
src/assets/icons/el-device-verification.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1744773344117" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1343" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M768 1024H256C115.2 1024 0 908.8 0 768V256C0 115.2 115.2 0 256 0h512c140.8 0 256 115.2 256 256v512c0 140.8-115.2 256-256 256z" fill="#531dab" p-id="1344"></path><path d="M294.4 264.533333c-25.6 0-44.8 19.2-44.8 44.8v44.8c0 25.6 19.2 44.8 44.8 44.8h405.333333c25.6 0 44.8-19.2 44.8-44.8v-44.8c0-25.6-19.2-44.8-44.8-44.8h-405.333333z m-44.8 270.933334c0 25.6 21.333333 44.8 44.8 44.8h44.8c25.6 0 44.8-19.2 44.8-44.8V490.666667c0-25.6-21.333333-44.8-44.8-44.8h-44.8c-25.6 0-44.8 19.2-44.8 44.8v44.8z m179.2 0c0 25.6 19.2 44.8 44.8 44.8h44.8c25.6 0 44.8-19.2 44.8-44.8V490.666667c0-25.6-19.2-44.8-44.8-44.8h-44.8c-25.6 0-44.8 19.2-44.8 44.8v44.8z m181.333333 0c0 25.6 21.333333 44.8 44.8 44.8h44.8c25.6 0 44.8-19.2 44.8-44.8V490.666667c0-25.6-21.333333-44.8-44.8-44.8h-44.8c-25.6 0-44.8 19.2-44.8 44.8v44.8z m-360.533333 179.2c0 25.6 19.2 44.8 44.8 44.8h44.8c25.6 0 44.8-19.2 44.8-44.8v-44.8c0-25.6-19.2-44.8-44.8-44.8h-44.8c-25.6 0-44.8 19.2-44.8 44.8v44.8z m179.2 0c0 25.6 19.2 44.8 44.8 44.8h44.8c25.6 0 44.8-21.333333 44.8-44.8v-44.8c0-25.6-19.2-44.8-44.8-44.8h-44.8c-25.6 0-44.8 21.333333-44.8 44.8v44.8z m181.333333 0c0 25.6 19.2 44.8 44.8 44.8h44.8c25.6 0 44.8-19.2 44.8-44.8v-44.8c0-25.6-19.2-44.8-44.8-44.8h-44.8c-25.6 0-44.8 19.2-44.8 44.8v44.8z" fill="#FFFFFF" p-id="1345"></path></svg>

+ 9 - 0
src/views/equipmentLifecycle/device/list/DeviceBaseInfo.api.ts

@@ -11,6 +11,10 @@ enum Api {
   deleteBatch = '/deviceInfo/deviceBaseInfo/deleteBatch',
   importExcel = '/deviceInfo/deviceBaseInfo/importExcel',
   exportXls = '/deviceInfo/deviceBaseInfo/exportXls',
+  // 添加父设备基本信息-分页列表查询
+  findParentDeviceList = '/deviceInfo/deviceBaseInfo/findParentDeviceList',
+  // 添加子设备基本信息-分页列表查询
+  findSubDeviceList = '/deviceInfo/deviceBaseInfo/findSubDeviceList',
   // 设备编号是否是唯一的
   checkDeviceCode = '/deviceInfo/deviceBaseInfo/queryDeviceBaseInfoByDeviceNumber',
   // 保存父级设备
@@ -39,6 +43,11 @@ export const getImportUrl = Api.importExcel;
  */
 export const list = (params) => defHttp.get({ url: Api.list, params });
 
+// 添加父设备基本信息-分页列表查询
+export const findParentDeviceList = (params) => defHttp.get({ url: Api.findParentDeviceList, params });
+// 添加子设备基本信息-分页列表查询
+export const findSubDeviceList = (params) => defHttp.get({ url: Api.findSubDeviceList, params });
+
 /**
  * 删除单个
  */

+ 25 - 24
src/views/equipmentLifecycle/device/list/DeviceBaseInfoList.vue

@@ -73,6 +73,8 @@
   <DeviceBaseInfoModal @register="registerModal" @success="handleSuccess" />
   <!-- 添加父、子级设备 -->
   <AddDeviceModal @register="registerParentDeviceModal" @success="handleSuccess" />
+  <!-- 添加备件 -->
+  <AddMaterialModal @register="registerMaterialModal" @success="handleSuccess" />
   <!-- 详情 -->
   <DeviceBaseInfoDetailDrawer @register="registerDetailDrawer" @success="handleSuccess" />
 </template>
@@ -86,6 +88,7 @@
   import { columns, searchFormSchema, superQuerySchema } from './DeviceBaseInfo.data';
   import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './DeviceBaseInfo.api';
   import AddDeviceModal from './components/AddDeviceModal.vue';
+  import AddMaterialModal from './components/AddMaterialModal.vue';
   import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
   import DeviceBaseInfoDetailDrawer from './components/DeviceBaseInfoDetailDrawer.vue';
   import { useDrawer } from '/@/components/Drawer';
@@ -95,7 +98,8 @@
   const emits = defineEmits(['selection-change']);
   const props = defineProps<{
     noOperate?: boolean;
-    superQueryParams?: any[];
+    deviceId?: string;
+    queryUrl?: any;
   }>();
 
   //注册model
@@ -104,11 +108,13 @@
   const [registerParentDeviceModal, { openModal: openAddDeviceModal }] = useModal();
   // 注册详情抽屉
   const [registerDetailDrawer, detailDrawer] = useDrawer();
+  // 注册添加备件modal
+  const [registerMaterialModal, { openModal: openMaterialModal }] = useModal();
   //注册table数据
   const { tableContext, onExportXls, onImportXls } = useListPage({
     tableProps: {
       title: '设备基本信息',
-      api: list,
+      api: props.noOperate && props.queryUrl ? props.queryUrl : list,
       columns,
       canResize: false,
       formConfig: {
@@ -125,30 +131,13 @@
         fixed: 'right',
       },
       beforeFetch: (params) => {
+        let addParams = {};
         if (props.noOperate === true) {
-          let superQueryParamsArr: any[] = [];
-          if (queryParam['superQueryParams']) {
-            superQueryParamsArr = JSON.parse(decodeURIComponent(queryParam['superQueryParams']));
-          }
-
-          if (!queryParam['superQueryMatchType']) {
-            queryParam['superQueryMatchType'] = 'and';
-          }
-
-          (props.superQueryParams || []).forEach((ele) => {
-            const parentDeviceIdsIndex = superQueryParamsArr.findIndex((item) => {
-              return item.field === ele.field;
-            });
-            if (parentDeviceIdsIndex !== -1) {
-              superQueryParamsArr.splice(parentDeviceIdsIndex, 1, ele);
-            } else {
-              superQueryParamsArr.push(ele);
-            }
-          });
-
-          queryParam['superQueryParams'] = encodeURIComponent(JSON.stringify(superQueryParamsArr));
+          addParams = {
+            id: props.deviceId,
+          };
         }
-        return Object.assign(params, queryParam);
+        return Object.assign(params, queryParam, addParams);
       },
     },
     exportConfig: {
@@ -260,6 +249,18 @@
         },
         auth: 'deviceInfo:sub_device_info:add',
       },
+      {
+        label: '添加备件',
+        onClick: () => {
+          openMaterialModal(true, {
+            device: record,
+            isUpdate: false,
+            showFooter: true,
+            addType: 2, // 子设备
+          });
+        },
+        auth: 'deviceInfo:device_material_relation_info:add',
+      },
       {
         label: '详情',
         onClick: handleDetail.bind(null, record),

+ 33 - 16
src/views/equipmentLifecycle/device/list/components/AddDeviceModal.vue

@@ -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 {

+ 49 - 0
src/views/equipmentLifecycle/device/list/components/AddMaterialModal.vue

@@ -0,0 +1,49 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="registerModal"
+    destroyOnClose
+    :title="title"
+    :width="1400"
+    :height="900"
+    @ok="handleSubmit"
+    :bodyStyle="{ padding: 0 }"
+    @cancel="handleCloseFunc"
+  >
+    <!-- <a-divider orientation="left">已选{{ addType === 1 ? '父' : '子' }}设备:({{ selectedRows.length }})</a-divider>
+    <div class="selected-divider-rap">
+      <a-tag color="#3b5999" v-for="item in selectedRows" :key="item.id" closable @close="() => removeTag(item)">{{ item.deviceName }}</a-tag>
+    </div> -->
+  </BasicModal>
+</template>
+<script setup lang="ts">
+  import { ref, computed } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+
+  const deviceInfo = ref<any>({});
+
+  // 表单赋值
+  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
+    setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
+    if (!data?.device) {
+      closeModal();
+      return;
+    }
+
+    deviceInfo.value = data?.device;
+  });
+
+  //设置标题
+  const title = computed(() => `添加备件 -【${deviceInfo.value.deviceName} / ${deviceInfo.value.deviceNumber}】`);
+
+  // 关闭弹窗
+  const handleCloseFunc = () => {
+    // showTable.value = false;
+    // selectedRows.value = [];
+    // selectedKeys.value = [];
+    // deviceBaseInfoListRef.value.setSelectedRowKeys([]);
+  };
+
+  // 表单提交事件
+  async function handleSubmit() {}
+</script>

+ 2 - 0
src/views/equipmentLifecycle/device/list/components/DeviceBaseInfoDetailDrawer.vue

@@ -35,6 +35,8 @@
         { key: '7', tab: '设备处置', icon: 'el-device-equipment-disposal', disabled: true, component: 'BaseInfo', size: '32' },
         { key: '8', tab: '备件', icon: 'el-device-spare-parts', disabled: false, component: 'BaseInfo', size: '32' },
         { key: '9', tab: '事件', icon: 'el-device-events', disabled: false, component: 'BaseInfo', size: '32' },
+        { key: '10', tab: '计量', icon: 'el-device-metering', disabled: false, component: 'BaseInfo', size: '32' },
+        { key: '11', tab: '检定', icon: 'el-device-verification', disabled: false, component: 'BaseInfo', size: '32' },
       ];
 
       // 抽屉注册及关闭方法,用于openDrawer方法中

+ 15 - 4
src/views/equipmentLifecycle/device/list/components/deviceDetail.vue/baseInfo.vue

@@ -158,7 +158,7 @@
         },
       });
 
-      const [registerSubTable] = tableSubContext;
+      const [registerSubTable, { reload: reloadSubTable }] = tableSubContext;
 
       // 注册父设备table数据
       const { tableContext: tableParentContext } = useListPage({
@@ -175,7 +175,7 @@
           },
         },
       });
-      const [registerParentTable] = tableParentContext;
+      const [registerParentTable, { reload: reloadParentTable }] = tableParentContext;
 
       // 注册材料table数据
       const { tableContext: tableMaterialContext } = useListPage({
@@ -192,14 +192,20 @@
           },
         },
       });
-      const [registerMaterialTable] = tableMaterialContext;
+      const [registerMaterialTable, { reload: reloadMaterialTable }] = tableMaterialContext;
 
       // 渲染字典标签
       const renderDictTag = (value: string, dictCode: string) => {
         return render.renderDictTag(value, dictCode);
       };
 
-      return { renderDictTag, registerSubTable, registerParentTable, registerMaterialTable };
+      const reload = () => {
+        reloadSubTable();
+        reloadParentTable();
+        reloadMaterialTable();
+      };
+
+      return { renderDictTag, registerSubTable, registerParentTable, registerMaterialTable, reload };
     },
     computed: {
       // 处理图片
@@ -211,6 +217,11 @@
         });
       },
     },
+    watch: {
+      info() {
+        this.reload();
+      },
+    },
   });
 </script>
 <style scoped lang="less">