Просмотр исходного кода

feat: 新增物联参数绑定功能

yusheng 2 месяцев назад
Родитель
Сommit
5aa6f25142

+ 195 - 0
src/api/material/list.js

@@ -0,0 +1,195 @@
+import request from '@/utils/request';
+import { download } from '@/utils/file';
+
+// 获取列表
+export async function getGroupPage(data) {
+  const res = await request.get('/main/categorylevelgroup/page', {
+    params: data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+//  ==========  物料管理   =============/
+
+// 根据分类组编码查询分类树信息
+export async function getTreeByPid(pid) {
+  const res = await request.get(`/main/categoryLevel/getTreeByPid/${pid}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 新增物料
+export async function addMaterial(data) {
+  const res = await request.post(`/main/category/add`, data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 编辑物料
+export async function editMaterial(data) {
+  const res = await request.post(`/main/category/edit`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取列表
+export async function getMaterialList(data) {
+  const res = await request.get(`/main/category/getList`, {
+    params: data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取详情
+export async function getDetailInfo(id) {
+  const res = await request.get(`/main/category/info/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+//删除
+export async function removeMaterial(id) {
+  const res = await request.get(`/main/category/remove/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+//根据产品ID bom获取工艺路线列表【产品管理】
+export async function getBomRoutingList(categoryId) {
+  const res = await request.get(
+    `/main/bomCategory/bomRoutingListByCategoryId/${categoryId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 根据产品ID获取bom列表
+export async function getBomAssociationList(params) {
+  const res = await request.get(`/main/bomCategory/getList`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 产品工序与模具关联
+export async function categoryTaskPallet(data) {
+  const res = await request.post(`/main/category/categoryTaskPallet`, data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取产品工序与模具关联
+export async function getCategoryTaskPallet(categoryId) {
+  const res = await request.get(
+    `/main/category/getCategoryTaskPallet/${categoryId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 导入备品备件
+export async function importCategorySparePart(data) {
+  const res = await request.post(
+    `/main/excelUpload/importCategorySparePart`,
+    data
+  );
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 删除包装规格
+export async function deletePackageDisposition(data) {
+  const res = await request.delete(`/main/categoryPackageDisposition/delete`, {
+    data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 查询质检方案列表
+export async function getQualityTemplate(data) {
+  const res = await request.get(`/qms/qualitytemplate/page`, {
+    params: data
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 导出
+export async function exportFile(data) {
+  const res = await request.post('/main/category/export', data, {
+    responseType: 'blob'
+  });
+  download(res.data, '产品/物品数据.xlsx');
+}
+
+export async function getProduceTreeByPid(parentId) {
+  console.log(parentId, '55555');
+  const res = await request.get(
+    `/main/categoryLevel/getProduceTreeByPid?type=${parentId}`
+  );
+  if (res.data.code == 0) {
+    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}`);
+  console.log('changeOnOff', res);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  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));
+}

+ 263 - 0
src/views/recordComponents/bindSubstanceList.vue

@@ -0,0 +1,263 @@
+<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">
+      <ele-split-layout
+        width="266px"
+        allow-collapse
+        :right-style="{ overflow: 'hidden' }"
+      >
+        <div>
+          <div class="ele-border-lighter sys-organization-list">
+            <el-tree
+              :data="treeList"
+              :props="{
+                children: 'children',
+                value: 'id',
+                label: 'name'
+              }"
+              node-key="id"
+              ref="tree"
+              :highlight-current="true"
+              :expand-on-click-node="false"
+              @node-click="handleNodeClick"
+              v-bind="$attrs"
+              :default-expand-all="true"
+            >
+            </el-tree>
+          </div>
+        </div>
+        <template v-slot:content>
+          <ele-pro-table
+            max-height="500px"
+            ref="table"
+            :columns="columns"
+            :datasource="physicalList"
+            @selection-change="handleSelectionChange"
+            row-key="id"
+            :initLoad="false"
+            :needPage="false"
+          >
+          </ele-pro-table>
+        </template>
+      </ele-split-layout>
+    </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 = [
+          {
+            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
+          }
+        ];
+
+        return list;
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        title: '选择',
+
+        type: null,
+        // 表格选中数据
+        selection: [],
+        physicalList: [],
+        cachingData: {},
+        treeList: [],
+        current: null
+      };
+    },
+
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      async queryBindSubstanceList(id) {
+        let data = await queryBindSubstanceList({
+          id,
+          pageNum: 1,
+          size: 1000
+        });
+        this.treeList[0].children = data.list;
+      },
+      getPhysicalModel(id) {
+        getPhysicalModel(id).then((res) => {
+          this.physicalList = res.properties;
+          if (this.cachingData[id]) {
+            this.$refs.table.setSelectedRows(this.cachingData[id].list);
+          }
+        });
+      },
+
+      handleNodeClick(data) {
+        // if (data.id == this.treeList[0].id) {
+        //   this.physicalList = [];
+        //   return;
+        // }
+        this.current = data;
+        this.$refs.table.clearSelection();
+        this.getPhysicalModel(data.id);
+      },
+      open(id, name, code) {
+        this.visible = true;
+        if (id) {
+          this.treeList.push({
+            id,
+            name,
+            code,
+            children: []
+          });
+          this.$nextTick(() => {
+            this.queryBindSubstanceList(id);
+          });
+        }
+      },
+
+      handleSelectionChange(data) {
+        this.cachingData[this.current.id] = {
+          substanceCode: this.current.code,
+          substanceId: this.current.id,
+          substanceName: this.current.name,
+          list: data
+        };
+      },
+      handleClose() {
+        this.physicalList = [];
+        this.cachingData = [];
+        this.treeList = [];
+        this.visible = false;
+      },
+      selected() {
+        let cachingData = [];
+        let list = [];
+        for (let key in this.cachingData) {
+          cachingData.push(this.cachingData[key]);
+        }
+
+        if (!cachingData.length) {
+          this.$message.warning('请选择设备点位!');
+          return;
+        }
+        cachingData.forEach((item) => {
+          item.list.forEach((listItem) => {
+            list.push({
+              substanceCode: item.substanceCode,
+              substanceId: item.substanceId,
+              substanceName: item.substanceName,
+              paramCode: listItem.identifier,
+              paramValue: listItem.name,
+              maxValue: listItem.dataType?.specs.max,
+              minValue: listItem.dataType?.specs.min,
+              unitName: listItem.dataType?.specs.unitName
+            });
+          });
+        });
+        this.$emit('bindSubstanceSuccess', list);
+        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>

+ 1 - 1
src/views/recordComponents/plan.vue

@@ -368,7 +368,7 @@
         this.$refs.programRulesDialogRef.open(
           type,
           row,
-          this.getDictCode('记录规则类型', '蒸汽质量检查记录')
+          this.getDictCode('记录规则类型', '质量检查检测记录')
         );
       },
       async deleteRow(id) {

+ 164 - 33
src/views/recordComponents/programRulesDialog.vue

@@ -78,6 +78,7 @@
               size="small"
               @change="typeChange"
               style="width: 100%"
+              :disabled="addForm.autoOrder == 1 && type === 'dispatch'"
             >
               <el-option :value="1" label="班组"></el-option>
               <el-option :value="0" label="个人"></el-option>
@@ -202,6 +203,7 @@
               v-model="addForm.associatedObject"
               size="small"
               style="width: 100%"
+              @change="associatedObjectChange"
             >
               <el-option :value="1" label="车间"></el-option>
               <el-option :value="2" label="设备"></el-option>
@@ -294,6 +296,14 @@
             >
               新建
             </el-button>
+            <el-button
+              type="primary"
+              icon="el-icon-plus"
+              class="ele-btn-icon"
+              @click="bindSubstanceListOpen"
+            >
+              添加物联参数
+            </el-button>
           </div>
         </template>
 
@@ -315,6 +325,7 @@
             placeholder="请选择参数类型"
             size="mini"
             @change="paramTypeChange(row)"
+            :disabled="!!row.paramCode"
           >
             <el-option label="数值" :value="1" />
             <el-option label="选择" :value="2" />
@@ -353,6 +364,7 @@
             placeholder="请输入参数内容"
             size="mini"
             type="textarea"
+            :readonly="!!row.paramCode"
             rows="1"
             autosize
           ></el-input>
@@ -485,6 +497,9 @@
             placeholder="请输入参数上限"
             size="mini"
           ></el-input>
+          <span v-else-if="row.paramType == 7 && row.paramCode">{{
+            row.maxValue
+          }}</span>
         </template>
         <template v-slot:minValue="{ row }">
           <el-input
@@ -493,6 +508,9 @@
             placeholder="请输入参数下限"
             size="mini"
           ></el-input>
+          <span v-else-if="row.paramType == 7 && row.paramCode">{{
+            row.minValue
+          }}</span>
         </template>
         <template v-slot:unitName="{ row }">
           <!-- <el-input
@@ -509,34 +527,33 @@
             size="mini"
           >
           </DictSelection>
+          <span v-else-if="row.paramType == 7 && row.paramCode">{{
+            row.unitName
+          }}</span>
         </template>
-        <template v-slot:toolName="{ row }">
+        <template v-slot:toolName="{ row, $index }">
           <el-link :underline="false" style="cursor: pointer">
             <div class="ele-cell">
-              <div @click="handleAdd(row)">
-                {{
-                  row.tools && row.tools.length > 0
-                    ? row.tools.map((i) => i.toolName).join(',')
-                    : '请选择'
-                }}
+              <div @click="handleAdd(row, $index)">
+                {{ row.substanceName || '请选择' }}
               </div>
               <i
-                v-if="row.tools.length == 0"
+                v-if="!row.substanceName"
                 class="el-icon-arrow-down"
-                @click="handleAdd(row)"
+                @click="handleAdd(row, $index)"
+              ></i>
+              <i
+                v-else
+                class="el-icon-close"
+                @click="clearTool(row, $index)"
               ></i>
-              <i v-else class="el-icon-close" @click="clearTool(row)"></i>
             </div>
           </el-link>
         </template>
         <template v-slot:toolCodes="{ row }">
           <el-input
-            :value="
-              row.tools && row.tools.length > 0
-                ? row.tools.map((i) => i.toolCode).join(',')
-                : ''
-            "
-            placeholder="工具自动带出"
+            :value="row.substanceCode"
+            placeholder="自动带出"
             disabled
             size="mini"
           ></el-input>
@@ -588,6 +605,10 @@
     <toolModal ref="toolModalTowRef" @chooseModal="chooseModalProduct" />
     <MaterialAdd ref="MaterialAddRef" @chooseEquipment="confirmWorkshops" />
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
+    <bindSubstanceList
+      ref="bindSubstanceRef"
+      @bindSubstanceSuccess="bindSubstanceSuccess"
+    ></bindSubstanceList>
   </ele-modal>
 </template>
 
@@ -609,7 +630,18 @@
   import toolModal from '@/BIZComponents/toolModal.vue';
   import MaterialAdd from '@/components/common/MaterialAdd.vue';
   import { getteampage } from '@/api/main/index.js';
-
+  import bindSubstanceList from './bindSubstanceList.vue';
+  //设备初始化字段
+  const substanceKey = [
+    'substanceCode',
+    'substanceId',
+    'substanceName',
+    'paramCode',
+    'paramValue',
+    'maxValue',
+    'minValue',
+    'unitName'
+  ];
   const formBaseData = {
     address: '',
     areaId: 0,
@@ -644,7 +676,7 @@
     recordTemplateStyle: null,
     reportWorkType: null,
     executeIdList: [],
-    associatedObject: 1,
+    associatedObject: 2,
     deviceName: '',
     deviceId: '',
     deviceCode: '',
@@ -656,10 +688,12 @@
     productLineName: ''
   };
   export default {
+
     mixins: [dictMixins, tableColumnsMixin],
     components: {
       deptSelect,
       selectReleaseRules,
+      bindSubstanceList,
       selectWorkshop,
       toolModal,
       MaterialAdd
@@ -667,10 +701,9 @@
     data() {
       return {
         visible: false,
-        classify: '',
-
         title: '新增记录计划配置',
         activeIndex: 0,
+        classify: '',
         addForm: JSON.parse(JSON.stringify(formBaseData)),
         rules: {
           name: [
@@ -854,14 +887,14 @@
           },
           {
             prop: 'toolName',
-            label: '工具名称',
+            label: '设备名称',
             align: 'center',
             slot: 'toolName',
             minWidth: 110
           },
           {
             prop: 'toolCodes',
-            label: '工具编码',
+            label: '设备编码',
             align: 'center',
             slot: 'toolCodes',
             minWidth: 110
@@ -907,9 +940,9 @@
     },
     methods: {
       // 外部调用,打开弹窗
-      async open(type, data,classify) {
-        this.classify=classify;
+      async open(type, data, classify) {
         console.log('type data', type, data);
+        this.classify = classify;
         this.type = type;
         await this.getAllTeamList();
         if (type == 'add') {
@@ -959,6 +992,21 @@
 
         console.log('this.addForm', this.addForm);
       },
+      associatedObjectChange() {
+        this.addForm.detailList = [];
+        this.addForm.deviceCode = '';
+        this.addForm.deviceId = '';
+        this.addForm.deviceName = '';
+        this.addForm.workshopId = '';
+        this.addForm.workshopName = '';
+        this.addForm.workshopPlanId = '';
+        this.addForm.workshopPlanName = '';
+        this.addForm.address = '';
+        this.addForm.areaId = '';
+        this.addForm.areaName = '';
+        this.addForm.factoryId = '';
+        this.addForm.factoryName = '';
+      },
       // 关闭时清理表单
       handleClose() {
         this.addForm = JSON.parse(JSON.stringify(formBaseData));
@@ -979,6 +1027,9 @@
         console.log('this.addForm', this.addForm);
         this.$refs.formRef.validate(async (valid) => {
           if (valid) {
+            if (!this.addForm.detailList?.length) {
+              return this.$message.error('规则明细不能为空');
+            }
             this.butLoading = true;
 
             try {
@@ -990,7 +1041,7 @@
               }
 
               const body = this.formMateBody();
-              body.planType = 5;
+              body.planType =5
 
               if (this.type == 'dispatch') {
                 await recordrulesplanManualDispatchOrder(body);
@@ -1097,6 +1148,12 @@
         });
 
         console.log('规则明细数据', data.details);
+        if (data.deviceId) {
+          this.addForm.deviceId = data.deviceId;
+          this.addForm.deviceName = data.deviceName;
+          this.addForm.deviceCode = data.deviceCode;
+          this.addForm.associatedObject = 2;
+        }
 
         this.addForm.ruleId = rules.id;
         this.addForm.ruleName = rules.name;
@@ -1178,6 +1235,76 @@
           row.formula = '';
         }
       },
+
+      handleAdd(row, index) {
+        this.currentRow = row;
+        this.currentIndex = index;
+        this.$refs.bindSubstanceRef.open(
+          this.addForm.deviceId,
+          this.addForm.deviceCode,
+          this.addForm.deviceName
+        );
+      },
+      bindSubstanceListOpen() {
+        this.currentIndex = 9999;
+        this.$refs.bindSubstanceRef.open(
+          this.addForm.deviceId,
+          this.addForm.deviceName,
+          this.addForm.deviceCode
+        );
+      },
+      bindSubstanceSuccess(list) {
+        console.log(list, 'list');
+        const currentIndex = this.currentIndex;
+        list.forEach((item, index) => {
+          if (!index && currentIndex != 9999) {
+            substanceKey.forEach((key) => {
+              this.$set(this.addForm.detailList[currentIndex], key, item[key]);
+            });
+            this.$set(this.addForm.detailList[currentIndex], 'paramType', 7);
+          } else {
+            this.addForm.detailList.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.substanceCode,
+              substanceName: item.substanceName,
+              // 1-成品统计,2-物料统计,3-工序统计"
+              statisticsType:
+                this.addForm.recordTemplateStyle == '4'
+                  ? this.statisticsType
+                  : null,
+              // 公式
+              formula: '',
+              _paramSelect: null,
+              _opSelect: null,
+              _replaceOrAppend: '',
+              formulaParts: [],
+              sortNum:
+                Math.max(
+                  ...this.addForm.detailList.map((item) => item.sortNum || 0)
+                ) + 1
+            });
+          }
+        });
+      },
+      // 清空工具
+      clearTool(row, index) {
+        substanceKey.forEach((key) => {
+          this.$set(this.addForm.detailList[index], key, '');
+        });
+      },
       // 选择物品 产品、物料等
       selectChooseModalProduct(row) {
         this.currentRow = row;
@@ -1290,9 +1417,11 @@
         row.tools = [];
       },
       deleteRow(time, row) {
-        const index = this.addForm.findIndex((item) => item.id === row.id);
+        const index = this.addForm.detailList.findIndex(
+          (item) => item.id === row.id
+        );
         if (index !== -1) {
-          this.addForm.splice(index, 1);
+          this.addForm.detailList.splice(index, 1);
         }
       },
       // 负责人变更 同步执行人列表
@@ -1328,15 +1457,17 @@
           this.addForm.productLineName = '';
           this.addForm.productLineId = '';
         }
-
-        this.productLineList = currentTeam.factoryWorkstationVOList.map(
-          (item) => {
-            return {
+        this.productLineList = [];
+        currentTeam.factoryWorkstationVOList.forEach((item) => {
+          if (
+            !this.productLineList.find((p) => p.id === item.productionLineId)
+          ) {
+            this.productLineList.push({
               name: item.productionLineName,
               id: item.productionLineId
-            };
+            });
           }
-        );
+        });
 
         // if (currentTeam) {
         //   // 同步执行人

+ 20 - 2
src/views/recordComponents/redeployOther.vue

@@ -292,15 +292,33 @@
         }
 
         this.btnLoading = true;
-
         let params = {
           executeUsers,
           teamName: this.teamName,
           teamId: this.teamId,
           id: this.row.id,
-          // 0个人 1班组
           type: this.tabValue
         };
+        // 0个人 1班组
+
+        if (this.tabValue == 1) {
+          params = {
+            executeUsers: [],
+            teamName: this.teamName,
+            teamId: this.teamId,
+            id: this.row.id,
+            type: this.tabValue
+          };
+        } else {
+          params = {
+            executeUsers,
+            teamName: '',
+            teamId: '',
+            id: this.row.id,
+            type: this.tabValue
+          };
+        }
+
         recordrulesplanReManualDispatchOrder(params)
           .then(() => {
             this.$message.success(`该工单成功转派`);