Przeglądaj źródła

feat: 新增物联设备点位关联功能

yusheng 2 miesięcy temu
rodzic
commit
cf59465a05

+ 24 - 1
src/api/material/list.js

@@ -160,7 +160,7 @@ export async function getProduceTreeByPid(parentId) {
     return res.data;
   }
   return Promise.reject(new Error(res.data.message));
-}  
+}
 
 export async function changeOnOff(id) {
   const res = await request.post(`/main/category/changeOnOff/${id}`);
@@ -170,3 +170,26 @@ export async function changeOnOff(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+// 获取实体列表分页
+export async function queryBindSubstanceList(data) {
+  let par = new URLSearchParams(data);
+  const res = await request.get(
+    `/main/asset/queryBindSubstanceList?` + par,
+    {}
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 获取实体物联点位
+export async function getPhysicalModel(id) {
+  const res = await request.get(
+    `/main/asset/getPhysicalModel/` + id,
+    {}
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 238 - 50
src/views/rulesManagement/components/MaterialAdd.vue

@@ -78,6 +78,8 @@
   import ProductSearch from './product-search.vue';
   import { getAssetList } from '@/api/ruleManagement/plan';
   import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
+  import { getMaterialList } from '@/api/material/list';
+
   export default {
     components: {
       ProductSearch
@@ -87,6 +89,11 @@
       multiple: {
         type: Boolean,
         default: true
+      },
+      //是否主数据
+      isMain: {
+        type: Boolean,
+        default: false
       }
     },
     data() {
@@ -114,55 +121,235 @@
     computed: {
       // 表格列配置
       columns() {
-        let list = [
-          {
-            label: '设备名称',
-            prop: 'name'
-          },
-          {
-            label: '编号',
-            prop: 'codeNumber'
-          },
-          {
-            label: '固资编码',
-            prop: 'fixCode'
-          },
-          {
-            label: '使用人',
-            prop: 'usePerson'
-          },
-          {
-            label: '使用岗位',
-            prop: 'postName'
-          },
-          {
-            label: '负责人',
-            prop: 'chargePerson'
-          },
-          {
-            label: '有效开始时间',
-            prop: 'startTime'
-          },
-          {
-            label: '有效结束时间',
-            prop: 'endTime'
-          },
-          {
-            label: '型号',
-            prop: 'modelType',
-            slot: 'modelType'
-          },
-          {
-            label: '规格',
-            prop: 'specification',
-            slot: 'specification'
-          },
-          {
-            label: '设备位置',
-            prop: 'pathName',
-            slot: 'pathName'
-          }
-        ];
+        let list = this.isMain
+          ? [
+              {
+                columnKey: 'index',
+                type: 'index',
+                width: 50,
+                align: 'center',
+                showOverflowTooltip: true,
+                label: '序号'
+              },
+              {
+                prop: 'code',
+                label: '编码',
+                align: 'center',
+                showOverflowTooltip: true,
+                sortable: true,
+                minWidth: 110
+              },
+              {
+                prop: 'name',
+                label: '名称',
+                align: 'center',
+                showOverflowTooltip: true,
+                minWidth: 110
+              },
+              {
+                prop: 'categoryLevelPath',
+                label: '分类',
+                align: 'center',
+                showOverflowTooltip: true
+              },
+
+              {
+                prop: 'brandNum',
+                align: 'center',
+                label: '牌号',
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'modelType',
+                label: '型号',
+                align: 'center',
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'specification',
+                label: '规格',
+                align: 'center',
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'level',
+                label: '级别',
+                align: 'center',
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'bomStatus',
+                label: 'MBOM状态',
+                align: 'center',
+                minWidth: 120,
+                formatter: (row, column) => {
+                  return row.bomStatus == 1 ? '有' : '无';
+                },
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'pBomStatus',
+                label: 'PBOM状态',
+                align: 'center',
+                minWidth: 120,
+                formatter: (row, column) => {
+                  return row.pbomStatus == 1 ? '有' : '无';
+                },
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'aBomStatus',
+                label: 'ABOM状态',
+                align: 'center',
+                minWidth: 120,
+                formatter: (row, column) => {
+                  return row.abomStatus == 1 ? '有' : '无';
+                },
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'isUnpack',
+                label: '是否允许拆包',
+                align: 'center',
+                minWidth: 120,
+                formatter: (row, column) => {
+                  return row.isUnpack == 1 ? '是' : '否';
+                },
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'isComeCheck',
+                label: '是否采购来料检验',
+                align: 'center',
+                minWidth: 120,
+                formatter: (row, column) => {
+                  return row.isComeCheck == 1 ? '是' : '否';
+                },
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'isOutsourcingCheck',
+                label: '是否委外来料检验',
+                align: 'center',
+                minWidth: 120,
+                formatter: (row, column) => {
+                  return row.isOutsourcingCheck == 1 ? '是' : '否';
+                },
+                showOverflowTooltip: true
+              },
+
+              {
+                prop: 'measuringUnit',
+                label: '计量单位',
+                showOverflowTooltip: true,
+                minWidth: 90
+              },
+
+              {
+                prop: 'weightUnit',
+                label: '重量单位',
+                showOverflowTooltip: true,
+                minWidth: 90
+              },
+
+              {
+                prop: 'roughWeight',
+                label: '毛重',
+                showOverflowTooltip: true,
+                minWidth: 90
+              },
+
+              {
+                prop: 'netWeight',
+                label: '净重',
+                showOverflowTooltip: true,
+                minWidth: 90
+              },
+
+              {
+                prop: 'packingUnit',
+                align: 'center',
+                label: '包装单位',
+                showOverflowTooltip: true
+              },
+
+              {
+                prop: 'createTime',
+                label: '创建时间',
+                align: 'center',
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'createUserName',
+                label: '创建人',
+                align: 'center',
+                showOverflowTooltip: true
+              },
+              {
+                prop: 'isEnabled',
+                align: 'center',
+                label: '状态',
+                slot: 'isEnabled',
+                showOverflowTooltip: true,
+                fixed: 'right',
+                formatter: (row, column) => {
+                  return row.isEnabled === 0
+                    ? '停用'
+                    : row.isEnabled === 1
+                    ? '启用'
+                    : '';
+                }
+              }
+            ]
+          : [
+              {
+                label: '设备名称',
+                prop: 'name'
+              },
+              {
+                label: '编号',
+                prop: 'codeNumber'
+              },
+              {
+                label: '固资编码',
+                prop: 'fixCode'
+              },
+              {
+                label: '使用人',
+                prop: 'usePerson'
+              },
+              {
+                label: '使用岗位',
+                prop: 'postName'
+              },
+              {
+                label: '负责人',
+                prop: 'chargePerson'
+              },
+              {
+                label: '有效开始时间',
+                prop: 'startTime'
+              },
+              {
+                label: '有效结束时间',
+                prop: 'endTime'
+              },
+              {
+                label: '型号',
+                prop: 'modelType',
+                slot: 'modelType'
+              },
+              {
+                label: '规格',
+                prop: 'specification',
+                slot: 'specification'
+              },
+              {
+                label: '设备位置',
+                prop: 'pathName',
+                slot: 'pathName'
+              }
+            ];
 
         if (this.multiple) {
           list.unshift({
@@ -191,7 +378,8 @@
     methods: {
       /* 表格数据源 */
       async datasource({ page, limit, where }) {
-        const res = await getAssetList({
+        let api = this.isMain ? getMaterialList : getAssetList;
+        const res = await api({
           ...where,
           pageNum: page,
           size: limit,

+ 374 - 0
src/views/rulesManagement/releaseRules/components/bindSubstanceList.vue

@@ -0,0 +1,374 @@
+<template>
+  <ele-modal
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="70%"
+    :maxable="true"
+  >
+    <el-card shadow="never">
+      <seekPage :seekList="seekList" @search="reload" />
+      <header-title title="设备台账"> </header-title>
+
+      <ele-pro-table
+        height="300px"
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        row-key="id"
+        :initLoad="false"
+        @cell-click="cellClick"
+      >
+        <template #radio="{ row }">
+          <el-radio v-model="currentId" :label="row.id" class="radio">
+            <i></i>
+          </el-radio>
+        </template>
+      </ele-pro-table>
+      <header-title title="物联点位"> </header-title>
+      <ele-pro-table
+        height="300px"
+        ref="table1"
+        :columns="columns1"
+        :datasource="physicalList"
+        :selection.sync="selection"
+        row-key="id"
+        :initLoad="false"
+        :needPage="false"
+      >
+      </ele-pro-table>
+    </el-card>
+
+    <div class="rx-sc">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import {
+    queryBindSubstanceList,
+    getPhysicalModel
+  } from '@/api/material/list';
+  export default {
+    components: {},
+    props: {
+      // 是否多选
+      multiple: {
+        type: Boolean,
+        default: false
+      }
+    },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '名称',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          }
+        ];
+      },
+      // 表格列配置
+      columns() {
+        const list = [
+          {
+            prop: 'radio',
+            slot: 'radio',
+            width: 50,
+            align: 'center',
+            fixed: 'left'
+          },
+          {
+            columnKey: 'index',
+            type: 'index',
+            label: '序号',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            columnKey: 'code',
+            prop: 'code',
+            slot: 'code',
+            label: '编码',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          // {
+          //   columnKey: 'code',
+          //   prop: 'code',
+          //   label: '设备编码',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110,
+          //   slot: 'code'
+          // },
+          {
+            prop: 'name',
+            label: '名称',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'fixCode',
+            label: '固资编码',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+
+          {
+            prop: 'codeNumber',
+            label: '编号',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          // {
+          //   prop: 'codeNumber',
+          //   label: '编号',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110
+          // },
+
+          {
+            prop: 'category.modelType',
+            label: '型号',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'category.specification',
+            label: '规格',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'workstationInfo.name',
+            label: '工位名称',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'postName',
+            label: '使用单位',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'usePerson',
+            label: '使用人',
+            showOverflowTooltip: true,
+            minWidth: 80
+          },
+          {
+            prop: 'ownershipGroupName',
+            label: '权属部门',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'areaPersonInChargeUserName',
+            label: '片区负责人',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'repairUserName',
+            label: '维修人',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'endTime',
+            label: '有效期结束时间',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+
+          {
+            prop: 'pathName',
+            label: '位置',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              const positionDetail =
+                _row.position &&
+                _row.position.length != 0 &&
+                _row.position[0].detailPosition
+                  ? _row.position[0].detailPosition
+                  : '-';
+              return _row.deviceLocationName
+                ? _row.deviceLocationName + '-' + positionDetail
+                : '';
+            }
+          }
+        ];
+
+        return list;
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        title: '选择',
+
+        type: null,
+        columns1: [
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center',
+
+            reserveSelection: true,
+            fixed: 'left'
+          },
+          {
+            columnKey: 'index',
+            type: 'index',
+            label: '序号',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+
+          {
+            prop: 'name',
+            label: '名称',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'identifier',
+            label: '点位',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'dataType.specs.max',
+            label: '最大值',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'dataType.specs.min',
+            label: '最小值',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'dataType.specs.unitName',
+            label: '单位',
+            showOverflowTooltip: true,
+            minWidth: 180
+          }
+        ],
+        // 表格选中数据
+        selection: [],
+        physicalList: [],
+        id: '',
+        currentId: '',
+        current: null
+      };
+    },
+
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      async datasource({ page, limit, where }) {
+        if (this.id) {
+          where['id'] = this.id;
+        }
+        return await queryBindSubstanceList({
+          ...where,
+          pageNum: page,
+          size: limit
+        });
+      },
+      getPhysicalModel(id) {
+        getPhysicalModel(id).then((res) => {
+          this.physicalList = res.properties;
+        });
+      },
+
+      cellClick(data) {
+        this.current = data;
+        this.currentId = data.id;
+        this.getPhysicalModel(data.id);
+      },
+      open(id) {
+        this.visible = true;
+        this.id = id;
+        this.$nextTick(() => {
+          this.reload();
+        });
+      },
+
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+
+      handleClose() {
+        this.$refs.table.setSelectedRows([]);
+        this.selection = [];
+        this.physicalList=[]
+        this.current = null;
+        this.currentId = '';
+        this.visible = false;
+      },
+      selected() {
+        let list =[];
+        if (!this.current) {
+          this.$message.warning('请选择设备!');
+          return;
+        }
+        if (this.selection.length) {
+          list = this.selection;
+        }else{
+          list=[{}]
+        }
+
+        this.$emit(
+          'bindSubstanceSuccess',
+          list.map((item) => {
+            return {
+              substanceCode: this.current.code,
+              substanceId: this.current.id,
+              substanceName: this.current.name,
+              paramCode: item.identifier,
+              paramValue: item.name,
+              maxValue: item.dataType?.specs.max,
+              minValue: item.dataType?.specs.min,
+              unitName: item.dataType?.specs.unitName
+            };
+          })
+        );
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .rx-sc {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+  }
+
+  .ml60 {
+    margin-left: 60px;
+  }
+
+  :deep(.radio) {
+    .el-radio__label {
+      padding: 0;
+    }
+  }
+</style>

+ 163 - 17
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -194,7 +194,18 @@
             />
           </el-form-item>
         </el-col>
-        <el-col v-if="formData.recordTemplateStyle == '2'&&this.businessType != 3" :span="8">
+        <!-- <el-col :span="8">
+          <el-form-item label="物联设备" prop="stopDate">
+                  
+          </el-form-item>
+        </el-col> -->
+        <el-col
+          v-if="
+            (formData.recordTemplateStyle == '2' && this.businessType != 3) ||
+            formData.reportWorkType == 5
+          "
+          :span="8"
+        >
           <el-form-item label="关联设备" prop="deviceName" required>
             <el-input
               v-model="formData.deviceName"
@@ -207,7 +218,10 @@
             </el-input>
           </el-form-item>
         </el-col>
-        <el-col v-if="formData.reportWorkType == 2&&this.businessType != 3" :span="8">
+        <el-col
+          v-if="formData.reportWorkType == 2 && this.businessType != 3"
+          :span="8"
+        >
           <el-form-item label="关联工序">
             <el-input
               v-model="formData.produceTaskName"
@@ -227,7 +241,10 @@
             </el-input>
           </el-form-item>
         </el-col>
-        <el-col v-if="formData.reportWorkType == 2&&this.businessType != 3" :span="8">
+        <el-col
+          v-if="formData.reportWorkType == 2 && this.businessType != 3"
+          :span="8"
+        >
           <el-form-item label="是否有执行方式" label-width="130px">
             <el-radio-group
               v-model="formData.isExecuteMethod"
@@ -239,7 +256,11 @@
           </el-form-item>
         </el-col>
         <el-col
-          v-if="formData.isExecuteMethod == 1 && formData.reportWorkType == 2&&this.businessType != 3"
+          v-if="
+            formData.isExecuteMethod == 1 &&
+            formData.reportWorkType == 2 &&
+            this.businessType != 3
+          "
           :span="8"
         >
           <el-form-item label="执行方式" required prop="executeMethodId">
@@ -331,6 +352,7 @@
             placeholder="请选择参数类型"
             size="mini"
             @change="paramTypeChange(row)"
+            :disabled="!!row.paramCode"
           >
             <el-option label="数值" :value="1" />
             <el-option label="选择" :value="2" />
@@ -371,6 +393,7 @@
             type="textarea"
             rows="1"
             autosize
+            :readonly="!!row.paramCode"
           ></el-input>
         </template>
 
@@ -498,6 +521,9 @@
             placeholder="请输入参数上限"
             size="mini"
           ></el-input>
+          <span v-else-if="row.paramType == 7 && row.substanceId">{{
+            row.maxValue
+          }}</span>
         </template>
         <template v-slot:minValue="{ row }">
           <el-input
@@ -506,6 +532,9 @@
             placeholder="请输入参数下限"
             size="mini"
           ></el-input>
+          <span v-else-if="row.paramType == 7 && row.substanceId">{{
+            row.minValue
+          }}</span>
         </template>
         <template v-slot:unitName="{ row }">
           <!-- <el-input
@@ -522,9 +551,16 @@
             size="mini"
           >
           </DictSelection>
+          <span v-else-if="row.paramType == 7 && row.substanceId">{{
+            row.unitName
+          }}</span>
         </template>
-        <template v-slot:toolName="{ row }">
-          <el-link :underline="false" style="cursor: pointer">
+        <template v-slot:toolName="{ row, $index }">
+          <el-link
+            :underline="false"
+            style="cursor: pointer"
+            v-if="formData.reportWorkType != 5"
+          >
             <div class="ele-cell">
               <div @click="handleAdd(row)">
                 {{
@@ -541,15 +577,40 @@
               <i v-else class="el-icon-close" @click="clearTool(row)"></i>
             </div>
           </el-link>
+          <el-link :underline="false" style="cursor: pointer" v-else>
+            <div class="ele-cell">
+              <div @click="handleAdd(row, $index)">
+                {{ row.substanceName || '请选择' }}
+              </div>
+              <i
+                v-if="!row.substanceName"
+                class="el-icon-arrow-down"
+                @click="handleAdd(row, $index)"
+              ></i>
+              <i
+                v-else
+                class="el-icon-close"
+                @click="clearTool(row, $index)"
+              ></i>
+            </div>
+          </el-link>
         </template>
         <template v-slot:toolCodes="{ row }">
           <el-input
+            v-if="formData.reportWorkType != 5"
             :value="
               row.tools && row.tools.length > 0
                 ? row.tools.map((i) => i.toolCode).join(',')
                 : ''
             "
-            placeholder="工具自动带出"
+            placeholder="自动带出"
+            disabled
+            size="mini"
+          ></el-input>
+          <el-input
+            v-else
+            :value="row.substanceCode"
+            placeholder="自动带出"
             disabled
             size="mini"
           ></el-input>
@@ -621,7 +682,12 @@
       <el-button :loading="btnLoading" @click="handleClose">取消</el-button>
     </template>
 
-    <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
+    <toolModal
+      ref="toolModalRef"
+      @chooseModal="chooseModal"
+      :isMain="formData.reportWorkType != 5"
+      :multiple="formData.reportWorkType != 5"
+    />
 
     <toolModal
       ref="toolModalTowRef"
@@ -635,7 +701,10 @@
       @chooseEquipment="chooseEquipment"
       :multiple="false"
     />
-
+    <bindSubstanceList
+      ref="bindSubstanceRef"
+      @bindSubstanceSuccess="bindSubstanceSuccess"
+    ></bindSubstanceList>
     <ProductModal
       ref="ProductModalRef"
       @changeProduct="changeProduct"
@@ -649,6 +718,17 @@
 </template>
 
 <script>
+  //设备初始化字段
+  const substanceKey = [
+    'substanceCode',
+    'substanceId',
+    'substanceName',
+    'paramCode',
+    'paramValue',
+    'maxValue',
+    'minValue',
+    'unitName'
+  ];
   import { getByCode } from '@/api/system/dictionary-data';
   // import RuleCycle from '../../matterRules/components/rule-cycle.vue';
   import RuleCycle from './rule-cycle.vue';
@@ -656,7 +736,9 @@
   import Details from './details.vue';
   import dictMixins from '@/mixins/dictMixins';
   import toolModal from './toolModal.vue';
+  import bindSubstanceList from './bindSubstanceList.vue';
   import MaterialAdd from '../../components/MaterialAdd.vue';
+
   import {
     recordrulesSave,
     recordrulesDetailPage,
@@ -687,7 +769,8 @@
       toolModal,
       processModal,
       ProductModalCorrelation,
-      experimentationProcess
+      experimentationProcess,
+      bindSubstanceList
     },
     props: {
       typeInfo: {
@@ -764,14 +847,14 @@
           },
           {
             prop: 'toolName',
-            label: '工具名称',
+            label: this.formData.reportWorkType == 5 ? '设备名称' : '工具名称',
             align: 'center',
             slot: 'toolName',
             minWidth: 110
           },
           {
             prop: 'toolCodes',
-            label: '工具编码',
+            label: this.formData.reportWorkType == 5 ? '设备编码' : '工具编码',
             align: 'center',
             slot: 'toolCodes',
             minWidth: 110
@@ -1105,7 +1188,8 @@
           { label: '工序统计', value: '3' }
         ],
         opSelectOptions: ['+', '-', '*', '/', '%', '(', ')'],
-        typeList: []
+        typeList: [],
+        currentIndex: ''
       };
     },
     mounted() {
@@ -1703,6 +1787,11 @@
           unitName: null,
           productName: '',
           productCode: '',
+          paramCode: '',
+          substanceId: '',
+          substanceCode: '',
+
+          substanceName: '',
           // 1-成品统计,2-物料统计,3-工序统计"
           statisticsType:
             this.formData.recordTemplateStyle == '4'
@@ -1724,9 +1813,60 @@
           this.formData.details.splice(index, 1);
         }
       },
-      handleAdd(row) {
+      handleAdd(row, index) {
         this.currentRow = row;
-        this.$refs.toolModalRef.open(row.toolCodes);
+        this.currentIndex = index;
+        if (this.formData.reportWorkType == 5) {
+          this.$refs.bindSubstanceRef.open(this.formData.deviceId);
+        } else {
+          this.$refs.toolModalRef.open(row.toolCodes);
+        }
+      },
+      bindSubstanceSuccess(list) {
+        console.log(list, 'list');
+        const currentIndex = this.currentIndex;
+        list.forEach((item, index) => {
+          if (!index) {
+            substanceKey.forEach((key) => {
+              this.$set(this.formData.details[currentIndex], key, item[key]);
+            });
+            this.$set(this.formData.details[currentIndex], 'paramType', 7);
+          } else {
+            this.formData.details.push({
+              id: new Date().getTime(),
+              defaultValue: '',
+              maxValue: item.maxValue,
+              minValue: item.minValue,
+              paramType: 7,
+              paramValue: item.paramValue,
+              remark: '',
+              symbol: null,
+              tools: [],
+              unitName: item.unitName,
+              productName: '',
+              productCode: '',
+              paramCode: item.paramCode,
+              substanceId: item.substanceId,
+              substanceCode: item.paramCode,
+              substanceName: item.substanceName,
+              // 1-成品统计,2-物料统计,3-工序统计"
+              statisticsType:
+                this.formData.recordTemplateStyle == '4'
+                  ? this.statisticsType
+                  : null,
+              // 公式
+              formula: '',
+              _paramSelect: null,
+              _opSelect: null,
+              _replaceOrAppend: '',
+              formulaParts: [],
+              sortNum:
+                Math.max(
+                  ...this.formData.details.map((item) => item.sortNum || 0)
+                ) + 1
+            });
+          }
+        });
       },
       chooseModal(data) {
         console.log('data', data);
@@ -1749,8 +1889,14 @@
         this.formData.details = list;
       },
       // 清空工具
-      clearTool(row) {
-        row.tools = [];
+      clearTool(row, index) {
+        if (this.formData.reportWorkType == 5) {
+          substanceKey.forEach((key) => {
+            this.$set(this.formData.details[index], key, '');
+          });
+        } else {
+          row.tools = [];
+        }
       },
       // 查询 recordrulesCyclePage
       async recordrulesCyclePage(row) {