Quellcode durchsuchen

Merge branch 'test' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-aps into dengfei

695593266@qq.com vor 11 Monaten
Ursprung
Commit
c59059ccd3

+ 9 - 0
src/api/mainData/index.js

@@ -157,3 +157,12 @@ export async function listByRoutingIds(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 根据任务实例id查询工序id
+export async function getTaskIdByInstanceId(taskInstanceId) {
+  const res = await request.get(`/main/producetask/getTaskIdByInstanceId/${taskInstanceId}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 90 - 38
src/views/workOrder/components/releaseDialog.vue

@@ -29,7 +29,7 @@
           >
             <el-form-item :label="item.label">
               <!-- <div class="item_label">{{ current[item.prop] }}</div> -->
-              <el-input v-model="current[item.prop]" disabled />
+              <el-input :value="fieldValue(item.prop)" disabled />
             </el-form-item>
           </el-col>
         </el-row>
@@ -233,13 +233,13 @@
                   </el-radio-group>
                 </div>
               </template>
-              <template v-slot:quantity="{ row}">
+              <template v-slot:quantity="{ row }">
                 <el-input
                   :disabled="permissions(row)"
                   type="number"
                   v-model="row.quantity"
                   placeholder="请输入数量"
-                  @input="(e) => handleQuantityInput(e, row,item)"
+                  @input="(e) => handleQuantityInput(e, row, item)"
                 ></el-input>
               </template>
               <template v-slot:weight="{ row }">
@@ -248,9 +248,20 @@
                   type="number"
                   v-model="row.weight"
                   placeholder="请输入重量"
-                  @input="(e) => handleWeightInput(e, row,item)"
+                  @input="(e) => handleWeightInput(e, row, item)"
                 ></el-input>
               </template>
+              <template v-slot:classes>
+                <el-select v-model="row.classes" clearable placeholder="请选择">
+                  <el-option
+                    v-for="item in options"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  >
+                  </el-option>
+                </el-select>
+              </template>
               <template v-slot:startTime="{ row }">
                 <el-date-picker
                   :disabled="permissions(row)"
@@ -381,10 +392,37 @@
           { label: '要求生产重量:', prop: 'initialWeight' },
           { label: '计划开始时间:', prop: 'planStartTime' },
           { label: '计划结束时间:', prop: 'planCompleteTime' }
+        ],
+        options: [
+          {
+            value: '选项1',
+            label: '黄金糕'
+          },
+          {
+            value: '选项2',
+            label: '双皮奶'
+          },
+          {
+            value: '选项3',
+            label: '蚵仔煎'
+          },
+          {
+            value: '选项4',
+            label: '龙须面'
+          },
+          {
+            value: '选项5',
+            label: '北京烤鸭'
+          }
         ]
       };
     },
     computed: {
+      fieldValue() {
+        return (field) => {
+          return this.current[field];
+        };
+      },
       clientEnvironmentId() {
         return this.$store.state.user.info.clientEnvironmentId;
       },
@@ -507,6 +545,14 @@
             showOverflowTooltip: true,
             width: 140
           },
+          {
+            slot: 'classes',
+            prop: 'classes',
+            label: '班次',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 140
+          },
           {
             slot: 'startTime',
             prop: 'startTime',
@@ -538,12 +584,12 @@
     watch: {},
     created() {
       this.workCenterData();
-      this.FirstTaskIdFn();
       this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
     },
     methods: {
       async workCenterData() {
-        const res = await listWorkCenter(this.current.firstTaskId);
+        // const res = await listWorkCenter(this.current.firstTaskId);
+        const res = await listWorkCenter(this.current.taskInstanceId);
         this.workCenterList = res;
         if (res.length > 0) {
           this.form.factoryName = res[0].factoryName;
@@ -551,10 +597,12 @@
           // 查首工序
           this.changeWork(res[0].id); // 选择工作中心
           this.getProductionData(res[0].id); // 查询产线
+          this.FirstTaskIdFn(); // 查询工位数据
         }
       },
       // 查询工序列表数据
       changeDispatch(e) {
+        console.log('请求了这里 11');
         // if (e == 1) {
         //   return;
         // }
@@ -566,7 +614,6 @@
         // listByWorkCenter(this.form.workCenterId)
         listByRoutingIds([this.current.produceRoutingId])
           .then((res) => {
-
             this.tabsLoading = false;
             // 如果没有首工序的数据 就不能选择工序任务派单
             if (!res || res.length == 0) {
@@ -580,7 +627,9 @@
             let isExist = false;
             let firstTaskindex = '';
             res.forEach((item, index) => {
-              isExist = isExist ? isExist : item.sourceTaskId === this.current.firstTaskId;
+              isExist = isExist
+                ? isExist
+                : item.sourceTaskId === this.current.firstTaskId;
               // 如果有首工序id 存储它的下标
               if (isExist) {
                 if (!firstTaskindex && firstTaskindex !== 0) {
@@ -614,13 +663,13 @@
               this.processList = [];
               this.form.taskAss = 1;
               this.procTaskDis = true;
-              this.$message.warning('当前任务没有首工序报工')
+              this.$message.warning('当前任务没有首工序报工');
             }
           })
           .catch((err) => {
             this.processList = [];
             this.tabsLoading = false;
-            this.$message.warning(err.message);
+            this.$message.error(err.message);
           });
       },
       // 选择工作中心
@@ -661,13 +710,16 @@
       },
       // 查询工位数据
       FirstTaskIdFn() {
-        listByFirstTaskId(this.current.firstTaskId).then((res) => {
-          this.stationList = res;
-          this.changeDispatch();
-        }).catch((err) => {
-          this.stationList = [];
-          this.$message.error(err.message);
-        });
+        // listByFirstTaskId(this.current.firstTaskId)
+        listByFirstTaskId(this.current.taskInstanceId)
+          .then((res) => {
+            this.stationList = res;
+            this.changeDispatch();
+          })
+          .catch((err) => {
+            this.stationList = [];
+            this.$message.error(err.message);
+          });
       },
       // 重置(单个)
       resetData(row, item) {
@@ -686,7 +738,7 @@
           })
           .catch((err) => {
             this.toolbarLoading = false;
-            this.$message.warning(err.message);
+            this.$message.error(err.message);
           });
       },
       // 撤回的逻辑
@@ -777,7 +829,7 @@
           })
           .catch((err) => {
             this.toolbarLoading = false;
-            this.$message.warning(err.message);
+            this.$message.error(err.message);
           });
       },
       cancel() {
@@ -897,7 +949,7 @@
           })
           .catch((err) => {
             this.toolbarLoading = false;
-            this.$message.warning(err.message);
+            this.$message.error(err.message);
           });
       },
       // 工序选择
@@ -1028,7 +1080,7 @@
       },
       assignRadio(e) {},
       // 数量正则 quantity
-      handleQuantityInput(e, row,item) {
+      handleQuantityInput(e, row, item) {
         // 过滤非数字字符(包括负号)
         let value = e.replace(/[^\d]/g, '');
         // 限制不能以 0 开头(除非是 0 本身)
@@ -1037,45 +1089,45 @@
         }
         // 更新绑定值
         row.quantity = value;
-        this.calculateQuantity(row,item)
+        this.calculateQuantity(row, item);
       },
-      calculateQuantity(row,item){
+      calculateQuantity(row, item) {
         // 如果没有该字段 就不做判断
-        if (!this.current.formingNum){
+        if (!this.current.formingNum) {
           return;
         }
         let total = 0;
-        item.list.forEach(el => {
-          if (el.quantity){
+        item.list.forEach((el) => {
+          if (el.quantity) {
             total = total + (el.quantity - 0);
           }
-        })
-        if (total > (this.current.formingNum - 0)){
+        });
+        if (total > this.current.formingNum - 0) {
           this.$message.warning('列表数量相加不能大于目标要求生产数量');
           row.quantity = 0;
         }
       },
       // 计算重量
-      calculateWeight(row,item){
+      calculateWeight(row, item) {
         // 如果没有该字段 就不做判断
-        if (!this.current.formingWeight){
+        if (!this.current.formingWeight) {
           return;
         }
         let total = 0;
-        item.list.forEach(el => {
-          if (el.weight){
+        item.list.forEach((el) => {
+          if (el.weight) {
             total = total + (el.weight - 0);
           }
-        })
-        console.log(total,'total')
-        console.log(this.current,'this.current')
-        if (total > (this.current.formingWeight - 0)){
+        });
+        console.log(total, 'total');
+        console.log(this.current, 'this.current');
+        if (total > this.current.formingWeight - 0) {
           this.$message.warning('列表数量相加不能大于目标要求生产数量');
           row.weight = 0;
         }
       },
       // 重量正则 weight
-      handleWeightInput(e, row,item) {
+      handleWeightInput(e, row, item) {
         // 过滤非数字和非小数点字符(包括负号)
         let value = e.replace(/[^\d.]/g, '');
         // 限制只能有一个小数点
@@ -1090,7 +1142,7 @@
         }
         // 更新绑定值
         row.weight = value;
-        this.calculateWeight(row,item)
+        this.calculateWeight(row, item);
       }
     }
   };

+ 16 - 5
src/views/workOrder/index.vue

@@ -261,7 +261,8 @@
     teamPage,
     listByFirstTaskId,
     listByWorkCenterId,
-    listUserByIds
+    listUserByIds,
+    getTaskIdByInstanceId
   } from '@/api/mainData/index.js';
   import OrderSearch from './components/order-search.vue';
   import unpackDialog from './components/unpackDialog.vue';
@@ -689,10 +690,20 @@
       },
       //派单
       toReleaseOpen(row) {
-        this.dispatchRow = {...row};
-        this.dispatchRow.initialWeight = row.formingWeight + row.newWeightUnit;
-        this.dispatchVisible = true;
-        // this.$refs.releaseRef.open(row);
+        getTaskIdByInstanceId(row.firstTaskId)
+          .then((res) => {
+            if (res) {
+              this.dispatchRow = { ...row };
+              this.dispatchRow.initialWeight = row.formingWeight
+                ? row.formingWeight + row.newWeightUnit
+                : '';
+              this.dispatchRow.taskInstanceId = res;
+              this.dispatchVisible = true;
+            }
+          })
+          .catch((err) => {
+            this.$message.error(err.message);
+          });
       },
 
       createSuccess() {