ysy há 1 ano atrás
pai
commit
7e2b32fcc0

+ 22 - 0
src/api/produce/job.js

@@ -22,4 +22,26 @@ export async function listByIdsReport(data) {
     }
     return Promise.reject(new Error(res.data.message));
   }
+  
+
+// 根据工单工序取计算参数
+  export async function getComputeParam(workOrderId, taskId) {
+    const res = await request.get(`/mes/computeparam/getComputeParam/${workOrderId}/${taskId}`);
+    if (res.data.code == 0) {
+      return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+  }
+
+
+  //工序计算列表
+export async function saveParam(data) {
+  const res = await request.post(`/mes/computeparam/save`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+
   

+ 448 - 234
src/views/produce/components/jobBooking/components/semiProductJobBom.vue

@@ -6,16 +6,8 @@
       <div class="rx-bc"> </div>
     </div>
 
-    <el-table
-      ref="oneJobQualityBom"
-      class="table_content"
-      :max-height="600"
-      :data="list"
-      tooltip-effect="dark"
-      style="width: 100%"
-      stripe
-      border
-    >
+    <el-table ref="oneJobQualityBom" class="table_content" :max-height="600" :data="list" tooltip-effect="dark"
+      style="width: 100%" stripe border>
       <el-table-column label="序号" type="index" width="55">
         <template slot-scope="{ row, $index }">
           {{ $index + 1 }}
@@ -24,20 +16,17 @@
 
       <el-table-column label="次数" type="index" width="80">
         <template slot-scope="{ row, $index }">
-          <div
-            class="tag_box"
-            v-if="
-              Object.prototype.hasOwnProperty.call(row, 'extInfo') &&
-              Object.prototype.hasOwnProperty.call(
-                row.extInfo,
-                'productionTimes'
-              ) &&
-              Object.prototype.hasOwnProperty.call(
-                row.extInfo.productionTimes,
-                item.currentTaskDiagram.taskId
-              )
-            "
-          >
+          <div class="tag_box" v-if="
+            Object.prototype.hasOwnProperty.call(row, 'extInfo') &&
+            Object.prototype.hasOwnProperty.call(
+              row.extInfo,
+              'productionTimes'
+            ) &&
+            Object.prototype.hasOwnProperty.call(
+              row.extInfo.productionTimes,
+              item.currentTaskDiagram.taskId
+            )
+          ">
             {{ row.extInfo.productionTimes[item.currentTaskDiagram.taskId] }}
           </div>
 
@@ -59,12 +48,12 @@
             row.rootCategoryLevelId == 2
               ? '在制品'
               : row.rootCategoryLevelId == 23
-              ? '半成品'
-              : row.rootCategoryLevelId == 9
-              ? '产品'
-              : row.rootCategoryLevelId == 28
-              ? '废品'
-              : ''
+                ? '半成品'
+                : row.rootCategoryLevelId == 9
+                  ? '产品'
+                  : row.rootCategoryLevelId == 28
+                    ? '废品'
+                    : ''
           }})
         </template>
       </el-table-column>
@@ -93,135 +82,62 @@
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1"
-        :label="
-          item.currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'
-        "
-        type="weightUnit"
-      >
+      <el-table-column v-if="singleReport == 1" :label="item.currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'
+        " type="weightUnit">
         <template slot-scope="{ row, $index }">
           <div v-if="item.currentTaskDiagram.isFirstTask == 1">
-            {{ row.extInfo.weight || 0 }} {{ row.extInfo.weightUnit }}</div
-          >
+            {{ row.extInfo.weight || 0 }} {{ row.extInfo.weightUnit }}</div>
           <div v-if="item.currentTaskDiagram.isFirstTask == 0">
             {{ row.extInfo.newWeight || 0 }}
-            {{ row.extInfo.weightUnit }}</div
-          >
+            {{ row.extInfo.weightUnit }}</div>
         </template>
       </el-table-column>
 
       <el-table-column v-if="singleReport == 1" label="刻码" type="engrave">
         <template slot-scope="{ row, $index }">
           <span v-if="isDetails">{{ row.extInfo.engrave }}</span>
-          <el-input
-            v-else
-            size="mini"
-            class="content_num"
-            v-model="row.extInfo.engrave"
-            placeholder="刻码"
-          />
+          <el-input v-else size="mini" class="content_num" v-model="row.extInfo.engrave" placeholder="刻码" />
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1"
-        label="物料代号"
-        type="materielCode"
-      >
+      <el-table-column v-if="singleReport == 1" label="物料代号" type="materielCode">
         <template slot-scope="{ row, $index }">
           <span v-if="isDetails">{{ row.extInfo.materielCode }}</span>
-          <el-input
-            v-else
-            size="mini"
-            class="content_num"
-            v-model="row.extInfo.materielCode"
-            placeholder="数量"
-          />
+          <el-input v-else size="mini" class="content_num" v-model="row.extInfo.materielCode" placeholder="数量" />
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1 && deviceList.length > 0"
-        width="140"
-        label="设备"
-        type="deviceId"
-      >
+      <el-table-column v-if="singleReport == 1 && deviceList.length > 0" width="140" label="设备" type="deviceId">
         <template slot-scope="{ row, $index }">
-          <el-select
-            class="content_num"
-            v-model="row.deviceId"
-            placeholder="请选择"
-            @change="(e) => selectVal(e, row, $index)"
-            size="mini"
-          >
-            <el-option
-              v-for="item in deviceList"
-              :label="item.name + '-' + item.codeNumber"
-              :value="item.id"
-              :key="item.id"
-            >
+          <el-select class="content_num" v-model="row.deviceId" placeholder="请选择"
+            @change="(e) => selectVal(e, row, $index)" size="mini">
+            <el-option v-for="item in deviceList" :label="item.name + '-' + item.codeNumber" :value="item.id"
+              :key="item.id">
             </el-option>
           </el-select>
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1 && deviceList.length > 0"
-        label="炉次号"
-        width="90"
-        type="heatNumber"
-      >
+      <el-table-column v-if="singleReport == 1 && deviceList.length > 0" label="炉次号" width="90" type="heatNumber">
         <template slot-scope="{ row, $index }">
-          <el-input
-            size="mini"
-            class="content_num"
-            v-model="row.extInfo.heatNumber"
-            placeholder="请输入炉次号"
-          />
+          <el-input size="mini" class="content_num" v-model="row.extInfo.heatNumber" placeholder="请输入炉次号" />
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1"
-        label="数量"
-        width="90"
-        type="feedQuantity"
-      >
+      <el-table-column v-if="singleReport == 1" label="数量" width="90" type="feedQuantity">
         <template slot-scope="{ row, $index }">
-          <el-input
-            size="mini"
-            class="content_num"
-            v-model="row.feedQuantity"
-            placeholder="数量"
-          />
+          <el-input size="mini" class="content_num" v-model="row.feedQuantity" placeholder="数量" />
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1"
-        label="位置"
-        width="110"
-        type="position"
-      >
+      <el-table-column v-if="singleReport == 1" label="位置" width="110" type="position">
         <template slot-scope="{ row, $index }">
           <span v-if="isDetails">{{ row.extInfo.position }}</span>
-          <el-input
-            v-else
-            size="mini"
-            class="content_num"
-            v-model="row.extInfo.position"
-            placeholder="位置"
-          />
+          <el-input v-else size="mini" class="content_num" v-model="row.extInfo.position" placeholder="位置" />
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1"
-        label="物料重量"
-        width="110"
-        type="weight"
-      >
+      <el-table-column v-if="singleReport == 1" label="物料重量" width="110" type="weight">
         <template slot-scope="{ row, $index }">
           <div class="tag_box">{{ row.extInfo.newWeight ? '上' : '原' }}</div>
           <span>{{
@@ -230,22 +146,11 @@
         </template>
       </el-table-column>
 
-      <el-table-column
-        v-if="singleReport == 1"
-        label="报工重量"
-        width="110"
-        type="feedQuantity"
-      >
+      <el-table-column v-if="singleReport == 1" label="报工重量" width="110" type="feedQuantity">
         <template slot-scope="{ row, $index }">
           <span v-if="isDetails">{{ row.extInfo.reportWeight }}</span>
-          <el-input
-            v-else
-            size="mini"
-            class="content_num"
-            v-model="row.extInfo.reportWeight"
-            placeholder="报工重量"
-            type="digit"
-          />
+          <el-input v-else size="mini" class="content_num" v-model="row.extInfo.reportWeight" placeholder="报工重量"
+            type="digit" />
         </template>
       </el-table-column>
 
@@ -260,22 +165,10 @@
 
       <el-table-column label="处置" width="130" type="taskName">
         <template slot-scope="{ row, $index }">
-
           <span v-if="isDetails">{{ row.extInfo.taskName }}</span>
-          <el-select
-            v-else
-            size="mini"
-            class="content_num"
-            v-model="row.extInfo.taskId"
-            placeholder="请选择"
-            @change="(e) => selectName(e, $index)"
-          >
-            <el-option
-              v-for="item in stepsList"
-              :label="item.taskTypeName"
-              :value="item.taskId"
-              :key="item.taskId"
-            >
+          <el-select v-else size="mini" class="content_num" v-model="row.extInfo.taskId" placeholder="请选择"
+            @change="(e) => selectName(e, $index)">
+            <el-option v-for="item in stepsList" :label="item.taskTypeName" :value="item.taskId" :key="item.taskId">
             </el-option>
           </el-select>
         </template>
@@ -287,116 +180,437 @@
         </template>
       </el-table-column>
     </el-table>
+
+    <el-dialog title="工序计算列表" :visible.sync="show" :before-close="cancel" :close-on-click-modal="false"
+      :close-on-press-escape="false" append-to-body width="800px">
+      <div class="material">
+        <div class="btn_end">
+          <el-button type="primary" size="mini" @click="handAddParam">添加</el-button>
+        </div>
+        <div class="content_table2">
+          <div class="head row rx-sc">
+            <div class="item ww30">工序名称</div>
+            <div class="item ww20">坯体密度</div>
+            <div class="item ww20">密度系数</div>
+            <div class="item ww20">重量</div>
+            <div class="item ww20">操作</div>
+          </div>
+
+          <div class="table">
+            <div class="tr row rx-sc" v-for="(it, idx) in paramList" :key="idx">
+              <div class="item ww30">
+                <el-select size="mini" class="content_num" v-model="it.taskId" placeholder="请选择">
+                  <el-option v-for="item in stepsList" :label="item.taskTypeName" :value="item.taskId"
+                    :key="item.taskId">
+                  </el-option>
+                </el-select>
+              </div>
+
+              <div class="item ww20">
+                <el-input class="content_num" size="mini" v-model="it.billet" type="digit"
+                  @input="changeInp(it, idx)"></el-input>
+              </div>
+
+              <div class="item ww20">
+                <el-input class="content_num" size="mini" v-model="it.density" type="digit"
+                  @input="changeInp(it, idx)"></el-input>
+              </div>
+
+              <div class="item ww20" v-if="idx == 0 || idx != paramList.length - 1">
+                < {{ it.CVIWeight }} </div>
+
+                  <div class="item ww20" v-if="paramList.length > 1 && idx == paramList.length - 1">
+                    ≥ {{ it.CVIWeight }}
+                  </div>
+
+                  <div class="item ww20 rx-cc" @click="getDelete(idx)">
+                    <el-link type="danger">删除</el-link>
+                  </div>
+              </div>
+            </div>
+          </div>
+
+          <div class="formula_box">计算公式: 物料重量/坯体密度*密度系数 </div>
+
+          <div class="reportWeight rx-sc">
+            物料重量: {{ weight }} ; 报工重量: {{ reportWeight }}
+          </div>
+        </div>
+
+        <template slot="footer">
+          <el-button size="mini" type="primary" @click="paramSave">保存并计算</el-button>
+          <el-button size="mini" type="primary" @click="save">计算</el-button>
+          <el-button size="mini" @click="cancel">取消</el-button>
+        </template>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-  import { getTaskInstanceList } from '@/api/produce/job';
-
-  export default {
-    name: 'semiProductJobBom',
-
-    props: {
-      list: {
-        type: Array,
-        default: () => []
-      },
-      equipmentList: {
-        type: Array,
-        default: () => []
-      },
-
-      item: {
-        type: Object,
-        default: () => {}
-      },
-      isDetails: {
-        type: Boolean,
-        default: false
-      },
-      singleReport: {
-        default: null
+import {
+  getTaskInstanceList,
+  getComputeParam,
+  saveParam
+} from '@/api/produce/job';
+
+export default {
+  name: 'semiProductJobBom',
+
+  props: {
+    list: {
+      type: Array,
+      default: () => []
+    },
+    equipmentList: {
+      type: Array,
+      default: () => []
+    },
+
+    item: {
+      type: Object,
+      default: () => { }
+    },
+    isDetails: {
+      type: Boolean,
+      default: false
+    },
+    singleReport: {
+      default: null
+    }
+  },
+
+  watch: {
+    equipmentList: {
+      immediate: true,
+      deep: true,
+      handler(newVal) {
+        this.deviceList = newVal;
+        this.changeHeatNumber();
       }
+    }
+  },
+
+  data() {
+    return {
+      deviceList: [],
+
+      stepsList: [],
+
+      weight: 0,
+      reportWeight: 0,
+
+      paramList: [],
+
+      resultObj: {},
+      resultIdx: 0,
+
+      show: false
+    };
+  },
+
+  methods: {
+    getTaskFn() {
+      getTaskInstanceList(this.item.workOrderId).then((res) => {
+        this.stepsList = res;
+      });
     },
 
-    watch: {
-      equipmentList: {
-        immediate: true,
-        deep: true,
-        handler(newVal) {
-          this.deviceList = newVal;
-          this.changeHeatNumber();
-        }
+    changeHeatNumber() {
+      this.deviceList.forEach((f) => {
+        this.list.forEach((o) => {
+          if (
+            o.deviceId &&
+            f.instanceId == o.deviceId &&
+            this.deviceList.length > 1
+          ) {
+            o.extInfo.heatNumber = f.extInfo.heatNumber;
+            this.$forceUpdate();
+          } else if (this.deviceList.length == 1) {
+            o.extInfo.heatNumber = this.deviceList[0].extInfo.heatNumber;
+            this.$forceUpdate();
+          }
+        });
+      });
+    },
+
+    selectName(value, idx) {
+      const taskObj = this.stepsList.find((item) => item.taskId === value);
+      this.$set(this.list[idx].extInfo, 'taskName', taskObj.taskTypeName);
+      this.$forceUpdate();
+    },
+
+    openNumerate(row, idx) {
+      if (!row.extInfo.reportWeight) {
+        this.$message({ message: '请先输入报工重量', type: 'warning' });
+        return false;
       }
+      this.weight = row.extInfo.weight;
+      this.reportWeight = row.extInfo.reportWeight;
+      this.resultIdx = idx;
+
+      this.show = true;
+    },
+
+    getCompute() {
+      getComputeParam(
+        this.item.workOrderId,
+        this.item.currentTaskDiagram.taskId
+      ).then((res) => {
+        this.paramList = [];
+        this.paramList = (res && res.paramList) || [];
+        this.paramObj = res || {};
+      });
+    },
+
+    handAddParam() {
+      this.paramList.push({
+        taskId: null,
+        taskName: null
+      });
+    },
+    getDelete(idx) {
+      this.paramList.splice(idx, 1);
     },
 
-    data() {
-      return {
-        deviceList: [],
+    changeInp(item, index) {
+      if (Number(item.billet) && Number(item.density)) {
+        this.paramList[index].CVIWeight = (
+          (Number(this.weight) / item.billet) *
+          item.density
+        ).toFixed(2);
+      }
+    },
 
-        stepsList: []
-      };
+    cancel() {
+      this.show = false;
+      this.reportWeight = 0;
+      this.weight = 0;
     },
 
-    methods: {
-      getTaskFn() {
-        getTaskInstanceList(this.item.workOrderId).then((res) => {
-          this.stepsList = res;
+    paramSave() {
+      if (this.paramList.length > 0) {
+        let bol;
+        let _i;
+        bol = this.paramList.every((e, i) => {
+          _i = i + 1;
+          return e.taskId && e.billet && e.density;
         });
-      },
-
-      changeHeatNumber() {
-        this.deviceList.forEach((f) => {
-          this.list.forEach((o) => {
-            if (
-              o.deviceId &&
-              f.instanceId == o.deviceId &&
-              this.deviceList.length > 1
-            ) {
-              o.extInfo.heatNumber = f.extInfo.heatNumber;
-              this.$forceUpdate();
-            } else if (this.deviceList.length == 1) {
-              o.extInfo.heatNumber = this.deviceList[0].extInfo.heatNumber;
-              this.$forceUpdate();
-            }
+
+        if (!bol) {
+          this.$message({ message: `第${_i}行数据不全`, type: 'warning' });
+
+          return false;
+        }
+
+        if (this.paramList.length < 1) {
+          this.$message({
+            message: '请输入二个以上计算数据',
+            type: 'warning'
           });
-        });
-      },
 
-      
-    selectName(value, idx) {
-      const taskObj = this.stepsList.find(item => item.taskId === value);
-      this.$set(this.list[idx].extInfo, 'taskName', taskObj.taskTypeName)
-      this.$forceUpdate()
+          return false;
+        }
+      }
+      let param = {};
+
+      if (!Object.prototype.hasOwnProperty.call(this.paramObj, 'id')) {
+        param = {
+          paramList: this.paramList,
+          workOrderId: this.item.workOrderId,
+          taskId: this.item.currentTaskDiagram.taskId
+        };
+      } else {
+        this.paramObj.paramList = this.paramList;
+        param = this.paramObj;
+      }
 
+      saveParam(param).then((res) => {
+        this.$message({ message: '保存成功', type: 'success' });
+        this.getCompute();
+      });
     },
+
+    save() {
+      if (this.item.currentTaskDiagram.isFirstTask == 1) {
+        this.resultObj = {};
+
+        if (Number(this.reportWeight) < Number(this.paramList[0].CVIWeight)) {
+          this.resultObj = this.paramList[0];
+          this.setDataSave();
+          return false;
+        }
+
+        if (
+          Number(this.reportWeight) >=
+          this.paramList[this.paramList.length - 1].CVIWeight
+        ) {
+          this.resultObj = this.paramList[this.paramList.length - 1];
+          this.setDataSave();
+          return false;
+        }
+
+        for (let i = 1; i < this.paramList.length; i++) {
+          console.log(i);
+          console.log(
+            11,
+            Number(this.paramList[i - 1].CVIWeight),
+            Number(this.reportWeight)
+          );
+          if (
+            Number(this.paramList[i - 1].CVIWeight) <
+            Number(this.reportWeight) &&
+            Number(this.reportWeight) < Number(this.paramList[i].CVIWeight)
+          ) {
+            this.resultObj = this.paramList[i];
+            break;
+          }
+        }
+        this.setDataSave();
+      }
     },
 
+    setDataSave() {
 
-    created() {
-      this.getTaskFn();
-    }
-  };
+      this.$set(this.list[this.resultIdx].extInfo, 'taskId', this.resultObj.taskId)
+      this.$set(this.list[this.resultIdx].extInfo, 'density', this.resultObj.density)
+      this.$set(this.list[this.resultIdx].extInfo, 'billet', this.resultObj.billet)
+      this.$set(this.list[this.resultIdx].extInfo, 'taskName', this.resultObj.taskName)
+
+
+      this.cancel()
+    },
+
+  },
+
+  created() {
+    this.getTaskFn();
+    this.getCompute();
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .tag_box {
-    display: inline-block;
-    padding: 1px 6px;
-    margin-right: 6px;
-    background: #e6a23c;
-    font-size: 11px;
-    color: #fff;
-    border-radius: 2px;
+.tag_box {
+  display: inline-block;
+  padding: 1px 6px;
+  margin-right: 6px;
+  background: #e6a23c;
+  font-size: 11px;
+  color: #fff;
+  border-radius: 2px;
+}
+
+.content_num {
+  --input-background-color: #f0f8f2;
+}
+
+.numerate {
+  font-size: 22rpx;
+  color: #157a2c;
+  cursor: pointer;
+}
+
+.material {
+  width: 100%;
+}
+
+.btn_end {
+  text-align: right;
+  margin-bottom: 10px;
+}
+
+.content_table2 {
+  width: 100%;
+
+  .row {
+    width: 100%;
+
+    .item {
+      color: #404446;
+      font-size: 14px;
+      padding-left: 6px;
+    }
+
+    .color157 {
+      color: #157a2c;
+    }
+
+    .ww20 {
+      width: 20%;
+    }
+
+    .ww30 {
+      width: 30%;
+    }
+
+    .ww25 {
+      width: 25%;
+    }
+
+    .ww35 {
+      width: 35%;
+    }
+
+    .ww10 {
+      width: 10%;
+    }
   }
 
-  .content_num {
-    --input-background-color: #f0f8f2;
+  .head {
+    height: 32px;
+    background: #f7f9fa;
+    border-top: 1px solid #e3e5e5;
+    border-left: 1px solid #e3e5e5;
+
+    .item {
+      height: 32px;
+      line-height: 32px;
+      border-right: 1px solid #e3e5e5;
+      box-sizing: border-box;
+    }
   }
 
-  .numerate {
-    font-size: 22rpx;
-    color: #157a2c;
-    cursor: pointer;
+  .tr {
+    border-top: 1px solid #e3e5e5;
+    border-left: 1px solid #e3e5e5;
+
+    .item {
+      font-size: 12px;
+      min-height: 32px;
+      display: flex;
+      align-items: center;
+      border-right: 1px solid #e3e5e5;
+      box-sizing: border-box;
+      white-space: normal;
+      word-break: break-all;
+    }
+
+    &:last-child {
+      border-bottom: 1px solid #e3e5e5;
+    }
   }
+}
+
+.formula_box {
+  font-size: 12px;
+  font-style: normal;
+  font-weight: 400;
+  margin-top: 15px;
+  color: #157a2c;
+}
+
+.reportWeight {
+  font-size: 12px;
+  font-style: normal;
+  font-weight: 400;
+  margin-top: 15px;
+  color: #157a2c;
+}
+
+.content_num {
+  display: flex;
+  align-items: center;
+  padding: 2px;
+  --input-background-color: #f0f8f2;
+}
 </style>