فهرست منبع

派单功能完善

jingshuyong 11 ماه پیش
والد
کامیت
aa092cc21c

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

@@ -179,3 +179,12 @@ export async function releaseWorkOrder(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 根据工厂查询班次
+export async function listByFactoryId(factoryId) {
+  const res = await request.get(`main/teamtime/listByFactoryId/${factoryId}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 131 - 158
src/views/produceOrder/components/releaseDialog/index.vue

@@ -178,29 +178,30 @@
               class="table"
             >
               <template v-slot:toolbar>
-                <el-button
-                  :loading="toolbarLoading"
-                  type="primary"
-                  @click="dispatch(item, 1)"
-                >
-                  派单
-                </el-button>
-                <el-button
-                  :loading="toolbarLoading"
-                  type="primary"
-                  @click="dispatch(item, 2)"
-                >
-                  撤回
-                </el-button>
-                <el-button
-                  :loading="toolbarLoading"
-                  type="primary"
-                  @click="dispatch(item, 3)"
-                >
-                  保存
-                </el-button>
-
-                <div style="margin-left: 50px; display: inline-block">
+                <div style="display: inline-block;" v-if="!item.isSpecialField">
+                  <el-button
+                    :loading="toolbarLoading"
+                    type="primary"
+                    @click="dispatch(item, 1)"
+                  >
+                    派单
+                  </el-button>
+                  <el-button
+                    :loading="toolbarLoading"
+                    type="primary"
+                    @click="dispatch(item, 2)"
+                  >
+                    撤回
+                  </el-button>
+                  <el-button
+                    :loading="toolbarLoading"
+                    type="primary"
+                    @click="dispatch(item, 3)"
+                  >
+                    保存
+                  </el-button>
+                </div>
+                <div style="margin-left: 50px; display: inline-block" v-if="!item.isSpecialField">
                   <span
                     class="text"
                     style="
@@ -232,11 +233,14 @@
                     </el-radio-button>
                   </el-radio-group>
                 </div>
+                <div v-if="item.isSpecialField" class="describe" style="color: #67c23a;">
+                  该工序已完成派单!
+                </div>
               </template>
               <template v-slot:quantity="{ row }">
                 <el-input
                   v-model="row.quantity"
-                  :disabled="permissions(row)"
+                  :disabled="permissions(row,item)"
                   placeholder="请输入数量"
                   type="number"
                   @input="(e) => handleQuantityInput(e, row, item)"
@@ -245,16 +249,32 @@
               <template v-slot:weight="{ row }">
                 <el-input
                   v-model="row.weight"
-                  :disabled="permissions(row)"
+                  :disabled="permissions(row,item)"
                   placeholder="请输入重量"
                   type="number"
                   @input="(e) => handleWeightInput(e, row, item)"
                 ></el-input>
               </template>
+              <template v-slot:teamTimeDetailId="{ row }">
+                <el-select
+                  v-model="row.teamTimeDetailId"
+                  placeholder="班次"
+                  :disabled="permissions(row,item)"
+                  @change="(e) => shiftSelection(e, row)"
+                >
+                  <el-option
+                    v-for="item in shiftList"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  >
+                  </el-option>
+                </el-select>
+              </template>
               <template v-slot:startTime="{ row }">
                 <el-date-picker
                   v-model="row.startTime"
-                  :disabled="permissions(row)"
+                  :disabled="permissions(row,item)"
                   :picker-options="{
                     disabledDate: (time) => {
                       return (
@@ -271,7 +291,7 @@
               <template v-slot:endTime="{ row }">
                 <el-date-picker
                   v-model="row.endTime"
-                  :disabled="permissions(row)"
+                  :disabled="permissions(row,item)"
                   :picker-options="{
                     disabledDate: (time) => {
                       return (
@@ -327,7 +347,8 @@
     resetAssignee,
     taskAssignment,
     taskRevoked,
-    taskSave
+    taskSave,
+    listByFactoryId
   } from '@/api/mainData/index.js';
 
   export default {
@@ -381,7 +402,9 @@
           { label: '要求生产重量:', prop: 'initialWeight' },
           { label: '计划开始时间:', prop: 'planStartTime' },
           { label: '计划结束时间:', prop: 'planCompleteTime' }
-        ]
+        ],
+        shiftList: [],
+        dateValue: ''
       };
     },
     computed: {
@@ -415,7 +438,8 @@
       },
       // 列表输入框操作 已派单的不能操作
       permissions() {
-        return (row) => {
+        return (row,item) => {
+          if(item.isSpecialField) return true
           if (!row.status) return false;
           if (row.status.code == 1) return true;
         };
@@ -463,40 +487,11 @@
               return row.status.desc || '';
             }
           },
-          // {
-          //   prop: 'name',
-          //   label: '名称',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
-          // {
-          //   prop: 'model',
-          //   label: '型号',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
-          // {
-          //   prop: 'specifications',
-          //   label: '规格',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
-          // {
-          //   prop: 'brandNumber',
-          //   label: '牌号',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
           {
             slot: 'quantity',
             prop: 'quantity',
             label: '数量',
             align: 'center',
-            showOverflowTooltip: true,
             width: 140
           },
           {
@@ -504,15 +499,20 @@
             prop: 'weight',
             label: `重量(${this.current.weightUnit})`,
             align: 'center',
-            showOverflowTooltip: true,
             width: 140
           },
+          {
+            slot: 'teamTimeDetailId',
+            prop: 'teamTimeDetailId',
+            label: '班次',
+            align: 'center',
+            minWidth: 140
+          },
           {
             slot: 'startTime',
             prop: 'startTime',
             label: '计划开始时间',
             align: 'center',
-            showOverflowTooltip: true,
             minWidth: 240
           },
           {
@@ -520,7 +520,6 @@
             prop: 'endTime',
             label: '计划完成时间',
             align: 'center',
-            showOverflowTooltip: true,
             minWidth: 240
           },
           {
@@ -538,10 +537,36 @@
     watch: {},
     created() {
       this.workCenterData();
-      this.FirstTaskIdFn();
+      this.getClassesData();
       this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
+      this.dateValue = this.getFormattedDate();
     },
     methods: {
+      // 查询班次
+      getClassesData() {
+        if (!this.current.factoriesId) return;
+        listByFactoryId(this.current.factoriesId).then((res) => {
+          if (!res) return;
+          this.shiftList = res;
+        });
+      },
+      // 选中班次
+      shiftSelection(e, row) {
+        let data = this.shiftList.find((item) => item.id == e);
+        let startTime = `${this.dateValue} ${data.startTime}`;
+        let endTime = `${this.dateValue} ${data.endTime}`;
+        this.$set(row, 'startTime', startTime);
+        this.$set(row, 'endTime', endTime);
+      },
+      // 获取当前年月日
+      getFormattedDate() {
+        const now = new Date();
+        const year = now.getFullYear();
+        const month = String(now.getMonth() + 1).padStart(2, '0');
+        const date = String(now.getDate()).padStart(2, '0');
+        return `${year}-${month}-${date}`;
+      },
+      // 查询工作中心
       async workCenterData() {
         const res = await listWorkCenter(this.current.taskInstanceId);
         this.workCenterList = res;
@@ -551,6 +576,7 @@
           // 查首工序
           this.changeWork(res[0].id); // 选择工作中心
           this.getProductionData(res[0].id); // 查询产线
+          this.FirstTaskIdFn(); // 查询工位数据
         }
       },
       // 查询工序列表数据
@@ -571,9 +597,17 @@
             res = allRes;
           } else {
             // 先将 存在的工序数据 数组的 id 存入 Set
-            const existIds = new Set(existRes.map((item) => item.taskId));
+            const existIds = new Map(
+              existRes.map((item) => [item.taskId, true])
+            );
             // 过滤 全部工序数据 数组
-            res = allRes.filter((aItem) => !existIds.has(aItem.sourceTaskId));
+            // res = allRes.map((aItem) => !existIds.has(aItem.sourceTaskId));
+            res = allRes.map((aItem) => {
+              return {
+                ...aItem,
+                isSpecialField: existIds.has(aItem.sourceTaskId)
+              };
+            });
           }
           // 如果没有首工序的数据 就不能选择工序任务派单
           if (!res || res.length === 0) {
@@ -586,6 +620,7 @@
           // this.procTaskDis = false;
           let list = [];
           res.forEach((item, index) => {
+            console.log(item, 'item 全部 ll');
             let obj = {
               id: item.sourceTaskId, //工序 id
               name: item.name, //工序 名称
@@ -595,6 +630,7 @@
               selection: [], // 当前工序下面的指派 选中的数据
               code: item.code, // 工序 编码
               index: index, // 当前工序数据的下标
+              isSpecialField: item.isSpecialField,
               radioBun: {
                 // 指派按钮的操作状态 绑定 默认false(可操作)
                 stationDis: false,
@@ -633,14 +669,18 @@
           const res = await listUserByIds([e]);
           this.crewList = res || [];
           // 查看当前的工序数据是不是 选择的人员 是的话同步更改
-          if (this.form.taskAss == 1) {
+          // if (this.form.taskAss == 1) {
+          //   return;
+          // }
+          if (!this.processId || this.processId == 0) {
             return;
           }
           let data = this.processList.find(
             (item) => item.id === this.processId
           );
           if (data.assignType == 2) {
-            this.$set(data, 'list', res);
+            this.handleClick({ name: this.processId });
+            // this.$set(data, 'list', res);
           }
         } catch {
           this.crewList = [];
@@ -723,7 +763,7 @@
             flag = false;
             return;
           }
-          assignees.push({
+          let Aobj = {
             assigneeId: item.id,
             quantity: item.quantity,
             weight: item.weight,
@@ -731,7 +771,11 @@
             endTime: item.endTime,
             assigneeType: row.assignType,
             assigneeName: item.name
-          });
+          };
+          if (item.teamTimeDetailId) {
+            Aobj.teamTimeDetailId = item.teamTimeDetailId;
+          }
+          assignees.push(Aobj);
           changeIds.push(item.changeId);
         });
         if (!flag) {
@@ -789,100 +833,14 @@
         }
         this.getAssignData(row.index, arr);
       },
-      // 最后提交
-      // async confirm() {
-      //   if (!this.form.singleReport) {
-      //     this.$message.warning('请先选择报工类型');
-      //     return;
-      //   }
-      //   if (!this.form.teamId) {
-      //     this.$message.warning('请先选择班组');
-      //     return;
-      //   }
-      //   if (this.form.taskAss == 1) {
-      //     this.issue();
-      //     // 按原来的逻辑
-      //     return;
-      //   }
-      //   let params = {
-      //     teamId: this.form.teamId,
-      //     workCenterId: this.form.workCenterId,
-      //     workOrderId: this.current.id
-      //   };
-      //   this.toolbarLoading = true;
-      //   try {
-      //     const res = await checkAssignConfirm(params);
-      //     if (!res) {
-      //       this.toolbarLoading = false;
-      //       return;
-      //     }
-      //     let paramsD = {
-      //       assignType: data.assignType,
-      //       singleReport: this.form.singleReport,
-      //       teamId: this.form.teamId,
-      //       crewIds: data.assignType == 2 ? dispatchArr : [], // 人员 2
-      //       workstationIds: data.assignType == 1 ? dispatchArr : [], // 工位 1
-      //       id: this.current.id
-      //     };
-      //     const response = await releaseWorkOrder(paramsD);
-      //     this.toolbarLoading = false;
-      //     if (response) {
-      //       this.$message.success('操作成功');
-      //       this.cancel();
-      //       this.$emit('createSuccess');
-      //     }
-      //   } catch (err) {
-      //     this.toolbarLoading = false;
-      //     this.$message.warning(err.message);
-      //   }
-      // },
-      // 下达
-      // issue() {
-      //   if (this.form.assignType == 1) {
-      //     if (
-      //       !this.form.workstationIds ||
-      //       this.form.workstationIds.length == 0
-      //     ) {
-      //       this.$message.warning('请选择工位');
-      //       return;
-      //     }
-      //   }
-      //   let data = {
-      //     assignType: this.form.assignType,
-      //     singleReport: this.form.singleReport,
-      //     teamId: this.form.teamId,
-      //     crewIds: [],
-      //     workstationIds: [],
-      //     id: this.current.id
-      //   };
-      //   if (this.form.assignType == 1) {
-      //     data.workstationIds = this.form.workstationIds || [];
-      //   } else {
-      //     data.crewIds = this.form.crewIds || [];
-      //   }
-      //   this.toolbarLoading = true;
-      //   releaseWorkOrder(data)
-      //     .then((res) => {
-      //       this.toolbarLoading = false;
-      //       if (res) {
-      //         this.$message.success('操作成功');
-      //         this.cancel();
-      //         this.$emit('createSuccess');
-      //       }
-      //     })
-      //     .catch((err) => {
-      //       this.toolbarLoading = false;
-      //       this.$message.warning(err.message);
-      //     });
-      // },
       // 工序选择
       handleClick(tab) {
         let id = tab.name;
         this.processId = id;
         let data = this.processList.find((item) => item.id == this.processId);
-        if (data.list.length == 0) {
-          this.changeRadio(1, data.index);
-        }
+        // if (data.list.length == 0) {
+        this.changeRadio(data.assignType, data.index);
+        // }
       },
       // 指派选择
       changeRadio(e, index) {
@@ -996,6 +954,7 @@
             listArr[idx].quantity = item.quantity;
             listArr[idx].weight = item.weight;
             listArr[idx].changeId = item.id;
+            listArr[idx].teamTimeDetailId = item.teamTimeDetailId;
           }
         });
         this.$set(dataRow, 'list', listArr);
@@ -1013,6 +972,20 @@
         // 更新绑定值
         row.quantity = value;
         this.calculateQuantity(row, item);
+        this.bringWeight(row.quantity, row);
+      },
+      // 自动算重量
+      bringWeight(value, row) {
+        if (!this.current.formingWeight) {
+          this.$set(row, 'weight', 0);
+          return;
+        }
+        let weight =
+          (this.current.formingWeight / this.current.formingNum) * value;
+        if (weight > 0) {
+          weight = weight.toFixed(4) - 0;
+        }
+        this.$set(row, 'weight', weight);
       },
       calculateQuantity(row, item) {
         // 如果没有该字段 就不做判断

+ 9 - 5
src/views/produceOrder/index.vue

@@ -474,21 +474,24 @@ export default {
           label: '计划开始时间',
           align: 'center',
           showOverflowTooltip: true,
-          minWidth: 110
+          minWidth: 150,
+           sortable: 'custom'
         },
         {
           prop: 'planCompleteTime',
           label: '计划结束时间',
           align: 'center',
           showOverflowTooltip: true,
-          minWidth: 110
+          minWidth: 150,
+           sortable: 'custom'
         },
         {
           prop: 'startTime',
           label: '实际开始时间',
           align: 'center',
           showOverflowTooltip: true,
-          minWidth: 110
+          minWidth: 150,
+           sortable: 'custom'
         },
         ...opt[this.activeName],
         {
@@ -496,7 +499,8 @@ export default {
           label: '创建时间',
           align: 'center',
           showOverflowTooltip: true,
-          minWidth: 110
+          minWidth: 150,
+           sortable: 'custom'
         },
         // {
         //   prop: 'status',
@@ -568,7 +572,7 @@ export default {
       getTaskIdByInstanceId(row.taskId).then((res)=>{
         if (res){
           this.dispatchRow = {...row};
-          this.dispatchRow.initialWeight = row.formingWeight + row.weightUnit;
+          this.dispatchRow.initialWeight = row.formingWeight ? row.formingWeight + row.weightUnit : '';
           this.dispatchRow.taskInstanceId = res
           this.dispatchVisible = true;
         }

+ 67 - 40
src/views/taskList/components/Ddtails.vue

@@ -18,7 +18,7 @@
     >
       <el-row>
         <headerTitle style="margin-top: 15px" title="报工信息"></headerTitle>
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+        <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
           <el-form-item
             :rules="{
               required: true,
@@ -39,7 +39,7 @@
             ></el-date-picker>
           </el-form-item>
         </el-col>
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+        <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
           <el-form-item
             :rules="{
               required: true,
@@ -60,7 +60,7 @@
             ></el-date-picker>
           </el-form-item>
         </el-col>
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+        <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
           <el-form-item label="合格数量" prop="qualifiedQuantity">
             <el-input
               v-model.number="form.qualifiedQuantity"
@@ -71,7 +71,7 @@
             ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+        <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
           <el-form-item label="不合格数量" prop="unqualifiedQuantity">
             <el-input
               v-model.number="form.unqualifiedQuantity"
@@ -82,7 +82,7 @@
             ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+        <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
           <el-form-item label="合格重量" prop="qualifiedWeight">
             <el-input
               v-model.number="form.qualifiedWeight"
@@ -93,7 +93,7 @@
             ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+        <el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="12">
           <el-form-item label="不合格重量" prop="unqualifiedWeight">
             <el-input
               v-model.number="form.unqualifiedWeight"
@@ -116,6 +116,15 @@
           </el-form-item>
         </el-col>
       </el-row>
+      <el-row class="tool_btn">
+        <el-button
+          type="primary"
+          size="medium"
+          @click="submitAdd"
+          :loading="loadingBtn"
+          >报工</el-button
+        >
+      </el-row>
       <headerTitle style="margin-top: 15px" title="工单信息"></headerTitle>
       <el-row :gutter="10" class="basic">
         <el-col
@@ -152,16 +161,19 @@
         <headerTitle style="margin-top: 15px" title="修改记录"></headerTitle>
         <ModifyRecord ref="ModifyRecordRef" :list="list" />
       </el-row>
+      <div slot="footer" class="tool_btn">
+        <el-button @click="cancel">关闭</el-button>
+      </div>
     </el-form>
-    <div slot="footer" class="footer">
-      <el-button @click="cancel">返回</el-button>
-      <el-button type="primary" @click="submitAdd" :loading="loadingBtn">报工</el-button>
-    </div>
   </ele-modal>
 </template>
 
 <script>
-  import { listWorkCenter,batchUpdateRealTime,listUpdateRealTimeRecord } from '@/api/workOrderList';
+  import {
+    listWorkCenter,
+    batchUpdateRealTime,
+    listUpdateRealTimeRecord
+  } from '@/api/workOrderList';
   import ModifyRecord from '@/views/taskList/components/ModifyRecord.vue';
   export default {
     components: {
@@ -242,7 +254,7 @@
           ]
         },
         loadingBtn: false,
-        list:[]
+        list: []
       };
     },
     computed: {
@@ -251,22 +263,24 @@
       }
     },
     methods: {
-      open(type, row,form) {
+      open(type, row, form) {
         this.title = type === 'report' ? '报工' : '详情';
         this.detailsVisible = true;
         this.current = { ...row };
-        if (form.realEndTime){
-          this.$nextTick(()=>{
-            this.form = {...form};
-          })
-          if (type !== 'report'){
-            listUpdateRealTimeRecord(row.apsAssigneeId).then(res => {
-              if (res){
-                this.list = res;
-              }
-            }).catch((err)=> {
-              this.$message.error(err.message);
-            })
+        if (form.realEndTime) {
+          this.$nextTick(() => {
+            this.form = { ...form };
+          });
+          if (type !== 'report') {
+            listUpdateRealTimeRecord(row.apsAssigneeId)
+              .then((res) => {
+                if (res) {
+                  this.list = res;
+                }
+              })
+              .catch((err) => {
+                this.$message.error(err.message);
+              });
           }
         }
         this.getData();
@@ -360,7 +374,9 @@
               (this.form.unqualifiedQuantity - 0) !==
             this.current.quantity
           ) {
-            return this.$message.warning('合格数量加不合格数量要等于任务数量');
+            return this.$message.warning(
+              `合格数量加不合格数量要等于任务数量${this.current.quantity}`
+            );
           }
           if (
             this.form.qualifiedWeight -
@@ -368,24 +384,26 @@
               (this.form.unqualifiedWeight - 0) !==
             this.current.weight
           ) {
-            return this.$message.warning('合格重量加不合格重量要等于任务重量');
+            return this.$message.warning(`合格重量加不合格重量要等于任务重量${this.current.weight}`);
           }
           let data = {
             ...this.form,
-            apsAssigneeId:this.current.apsAssigneeId
-          }
+            apsAssigneeId: this.current.apsAssigneeId
+          };
           this.loadingBtn = true;
-          batchUpdateRealTime([data]).then((res)=>{
-            this.loadingBtn = false;
-            if (res){
-              this.$message.success('操作成功');
-              this.cancel();
-              this.$emit('success');
-            }
-          }).catch((err)=>{
-            this.loadingBtn = false;
-            this.$message.error(err.message);
-          })
+          batchUpdateRealTime([data])
+            .then((res) => {
+              this.loadingBtn = false;
+              if (res) {
+                this.$message.success('操作成功');
+                this.cancel();
+                this.$emit('success');
+              }
+            })
+            .catch((err) => {
+              this.loadingBtn = false;
+              this.$message.error(err.message);
+            });
         });
       }
     }
@@ -396,4 +414,13 @@
   ::v-deep .time_select {
     width: 100%;
   }
+
+  ::v-deep .tool_btn {
+    text-align: right;
+
+    .el-button {
+      padding: 10px 18px !important;
+      font-size: 15px !important;
+    }
+  }
 </style>

+ 3 - 3
src/views/taskList/index.vue

@@ -267,14 +267,14 @@
             width: 180
           },
           {
-            slot: 'status',
+            prop:'statusText',
             label: '状态',
-            align: 'center'
+            align: 'center',
             // formatter: (row) => {
             //   const obj = this.statusOpt.find((i) => i.value == row.status);
             //   return obj && obj.label;
             // },
-            // width: 120
+            width: 120
           },
           {
             prop: 'customerName',