695593266@qq.com hai 7 meses
pai
achega
19af679db4

+ 2 - 2
src/views/produce/components/outsourcing/addPlease.vue

@@ -243,7 +243,6 @@
     methods: {
       open(workOrderId, workData, taskObj) {
         this.taskObj = taskObj;
-        console.log(taskObj, 'taskObj');
         const newList = workData.list.map((item) => {
           const copy = this.deepCopy(item);
 
@@ -277,7 +276,8 @@
           return copy;
         });
 
-        this.form = Object.assign(this.form, newList[0]);
+        const data = Object.assign(this.form, newList[0]);
+        this.form = this.deepCopy(data);
         this.form.pleaseEntrustDeptName = this.$store.state.user.info.groupName;
         this.form.pleaseEntrustDeptId = this.$store.state.user.info.groupId;
         this.form.pleaseEntrustUserName = this.$store.state.user.info.name;

+ 278 - 116
src/views/produce/components/outsourcing/index.vue

@@ -185,17 +185,17 @@
       </el-form>
     </div>
 
-    <div v-if="activeName == '5'">
+    <div v-if="activeName == '2'">
       <el-form
         label-width="100px"
-        :rules="rules"
+        :rules="rulesPlease"
         ref="form"
-        :model="attributeData"
+        :model="form"
       >
         <el-form-item label="请托名称:" prop="name">
           <el-input
             placeholder=""
-            v-model="attributeData.name"
+            v-model="form.name"
             style="width: 260px"
           ></el-input>
         </el-form-item>
@@ -203,7 +203,7 @@
         <el-form-item label="请托类型:" prop="type">
           <DictSelection
             dictName="请托类型"
-            v-model="attributeData.type"
+            v-model="form.type"
             style="width: 260px"
           ></DictSelection>
         </el-form-item>
@@ -211,7 +211,7 @@
         <el-form-item label="紧急程度:" prop="priority">
           <el-select
             style="width: 260px"
-            v-model="attributeData.priority"
+            v-model="form.priority"
             placeholder="请选择"
             clearable
           >
@@ -224,24 +224,19 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="请托数量:" prop="formedNumLast">
-          <el-input
-            placeholder="请输入请托数量"
-            type="number"
-            v-model="attributeData.formedNumLast"
-            style="width: 260px"
-          ></el-input>
+        <el-form-item label="请托数量:" prop="totalCount">
+          <el-input v-model="form.totalCount" style="width: 260px">
+            <template slot="append">{{ form.measuringUnit }}</template>
+          </el-input>
         </el-form-item>
-        <el-form-item label="请托到:" prop="taskIdes">
+        <el-form-item label="请托工序:" prop="taskId">
           <el-select
-            v-model="attributeData.taskIdes"
+            v-model="form.taskId"
             placeholder="请选择"
             style="width: 260px"
-            @change="changeTaskId"
-            multiple
           >
             <el-option
-              v-for="item in newStepsList"
+              v-for="item in pleaseNewStepsList"
               :key="item.taskId"
               :label="item.taskTypeName"
               :value="item.taskId"
@@ -249,106 +244,82 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="请托场景:" prop="sceneText">
+        <!--
+        <el-form-item label="请托人:" prop="pleaseEntrustUserId">
           <el-input
-            placeholder=""
-            v-model="attributeData.sceneText"
+            v-model="form.pleaseEntrustUserName"
+            clearable
             disabled
             style="width: 260px"
-          ></el-input>
-        </el-form-item>
-        <!-- v-if="attributeData.isFirstTask != 1" -->
-        <el-form-item label="直接入库:" borderBottom prop="warehouseId">
-          <div style="display: flex">
-            <div
-              style="font-size: 15px"
-              v-if="attributeData.clientEnvironmentId == 2"
-              >是</div
-            >
-            <!-- <el-checkbox-group v-model="isInWarehouse" size="15px" v-if="attributeData.clientEnvironmentId != 2 ">
-                            <el-checkbox labelSize="15px" iconSize="10px" activeColor="#157A2C" name="true"
-                                label="是"></el-checkbox>
-                        </el-checkbox-group> -->
-            <!-- <el-checkbox labelSize="15px" iconSize="10px" v-model="isInWarehouse" activeColor="#157A2C" name="true"
-                                label="是" v-if="attributeData.clientEnvironmentId != 2 "></el-checkbox> -->
-            <el-select
-              v-if="attributeData.clientEnvironmentId == 2 || isInWarehouse"
-              v-model="attributeData.warehouseId"
-              placeholder="请选择"
-              style="width: 260px"
-            >
-              <el-option
-                v-for="item in warehouseList"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id"
-              >
-              </el-option>
-            </el-select>
-          </div>
+          />
         </el-form-item>
 
-        <el-form-item label="请托单位:">
-          <el-select
-            v-model="attributeData.factoriesId"
-            placeholder="请选择"
+        <el-form-item label="请托部门:" prop="pleaseEntrustDeptName">
+          <el-input
+            v-model="form.pleaseEntrustDeptName"
+            clearable
+            disabled
             style="width: 260px"
-            @change="changeTaskId"
           >
-            <el-option
-              v-for="item in factoryList"
-              :key="item.factoryId"
-              :label="item.factoryName"
-              :value="item.factoryId"
-            >
-            </el-option>
-          </el-select>
+          </el-input>
         </el-form-item>
 
-        <el-form-item
-          label="工艺路线:"
-          borderBottom
-          style="font-size: 15px"
-          prop="produceRoutingId"
-          v-if="
-            attributeData.clientEnvironmentId != 2 &&
-            attributeData.isFirstTask != 1 &&
-            isInWarehouse &&
-            isInWarehouse.length == 0
-          "
-        >
+        <el-form-item label="所属工厂:" prop="factoriesName">
+          <el-input v-model="form.factoriesName" disabled style="width: 260px">
+          </el-input>
+        </el-form-item> -->
+
+        <el-form-item label="受托工厂:" prop="beEntrustedFactoriesId">
           <el-select
-            v-model="attributeData.produceRoutingId"
-            placeholder="请选择"
             style="width: 260px"
+            v-model="form.beEntrustedFactoriesId"
+            placeholder="请选择"
+            clearable
           >
             <el-option
-              v-for="item in produceList"
+              v-for="item in factoryList"
               :key="item.id"
               :label="item.name"
               :value="item.id"
+              @click.native="factoryListChange(item)"
             >
             </el-option>
           </el-select>
         </el-form-item>
 
-        <el-form-item label="交付交期:" prop="requireDeliveryTime">
+        <el-form-item label="受托部门:" prop="beEntrustedDeptId">
+          <deptSelect
+            style="width: 260px"
+            v-model="form.beEntrustedDeptId"
+            @changeGroup="beEntrustedDeptIdChange"
+          />
+        </el-form-item>
+
+        <el-form-item label="完成日期:" prop="planDeliveryTime">
           <el-date-picker
-            v-model="attributeData.requireDeliveryTime"
-            value-format="yyyy-MM-dd"
+            v-model="form.planDeliveryTime"
+            type="datetime"
             style="width: 260px"
-            type="date"
-            placeholder="选择日期"
+            placeholder="选择日期时间"
+            format="yyyy-MM-dd HH:mm:ss"
+            value-format="yyyy-MM-dd HH:mm:ss"
           >
           </el-date-picker>
         </el-form-item>
 
-        <el-form-item label="生产备注:">
+        <el-form-item label="是否尾工序:" prop="isLast">
+          <el-radio-group v-model="form.isLast">
+            <el-radio :label="1">是</el-radio>
+            <el-radio :label="0">否</el-radio>
+          </el-radio-group>
+        </el-form-item>
+
+        <el-form-item label="需求描述:">
           <el-input
             type="textarea"
             :autosize="{ minRows: 2, maxRows: 4 }"
             placeholder="请输入内容"
-            v-model="textarea2"
+            v-model="form.describes"
             style="width: 260px"
           >
           </el-input>
@@ -356,8 +327,9 @@
       </el-form>
 
       <div class="btn-box">
-        <el-button type="primary" @click="confirm">确认</el-button>
         <el-button type="primary" @click="cancel">取消</el-button>
+        <el-button type="primary" @click="save(1)"> 保存 </el-button>
+        <el-button type="primary" @click="save(2)"> 提交 </el-button>
       </div>
     </div>
 
@@ -370,9 +342,13 @@
   import { contactList } from '@/api/produce/bom.js';
   import { getFactoryarea } from '@/api/aps';
   import timeDialog from './timeDialog.vue';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import { getTaskInstanceById } from '@/api/produce/index';
+  import { save, addSubmit, update } from '@/api/entrust/index';
   export default {
     components: {
-      timeDialog
+      timeDialog,
+      deptSelect
     },
     data() {
       return {
@@ -457,13 +433,60 @@
           ]
         },
 
+        rulesPlease: {
+          type: [{ required: true, message: '请选择', trigger: 'change' }],
+          name: [{ required: true, message: '请输入', trigger: 'change' }],
+
+          workOrderCode: [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          beEntrustedDeptId: [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          finishTime: [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          beEntrustedFactoriesId: [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          isLast: [{ required: true, message: '请选择', trigger: 'change' }],
+          planDeliveryTime: [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          totalCount: [
+            { required: true, message: '请输入', trigger: 'change' }
+          ],
+          taskId: [{ required: true, message: '请选择', trigger: 'change' }]
+        },
+
+        form: {
+          type: '',
+          priority: '',
+          name: '',
+          pleaseEntrustDeptName: '',
+          pleaseEntrustUserName: '',
+          factoriesName: '',
+          beEntrustedFactoriesId: '',
+          beEntrustedDeptId: '',
+          isLast: 0,
+          describes: '',
+          taskId: '',
+          planDeliveryTime: '',
+          beEntrustedDeptName: '',
+          beEntrustedFactoriesName: '',
+          pleaseEntrustDeptId: '',
+          pleaseEntrustUserId: '',
+          factoriesId: '',
+          factoriesName: ''
+        },
+
         loading: false,
         operationType: null,
-        workListIds: [],
         activeName: this.chooseType,
         textarea2: '',
         gysList: [],
         factoryList: [],
+        pleaseNewStepsList: [],
         clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId
       };
     },
@@ -472,13 +495,21 @@
         type: Object,
         default: () => ({})
       },
-      taskName: {
-        type: String,
+      taskObj: {
+        type: Object,
         default: ''
       },
       chooseType: {
         type: String,
         default: '1'
+      },
+      workListIds: {
+        type: String,
+        default: ''
+      },
+      workData: {
+        type: Object,
+        default: () => ({})
       }
     },
 
@@ -514,23 +545,71 @@
         immediate: true
       }
     },
-    computed: {
-      taskObj() {
-        return this.$store.state.user.taskObj;
-      }
-    },
+    // computed: {
+    //   taskObj() {
+    //     return this.$store.state.user.taskObj;
+    //   }
+    // },
 
     mounted() {
       this.getContactList();
       this.getFactoryList();
-      console.log(this.taskName, '委托');
       if (this.chooseType == '1') {
-        this.attributeData.name = this.taskName + '委外';
+        this.attributeData.name = this.taskObj.taskName + '委外';
         // this.$set(this.outsourceFormVal, 'name', this.taskName + '委托');
       } else if (this.chooseType == '2') {
-        this.attributeData.name = this.taskName + '请托';
+        this.attributeData.name = this.taskObj.taskName + '请托';
         // this.$set(this.outsourceFormVal, 'name', this.taskName + '请托');
       }
+
+      if (this.chooseType == '2') {
+        const newList = this.workData.list.map((item) => {
+          const copy = this.deepCopy(item);
+
+          Object.assign(copy, {
+            describes: '',
+            totalCount: copy.formingNum,
+            taskList: [],
+            taskId: '',
+            taskName: '',
+            beEntrustedFactoriesId: '',
+            beEntrustedFactoriesName: '',
+            status: '',
+            beEntrustedDeptName: '',
+            beEntrustedDeptId: '',
+            measuringUnit: copy.unit,
+            categoryName: copy.productName,
+            categoryCode: copy.productCode,
+            workOrderId: copy.id,
+            workOrderCode: copy.code,
+            brandNum: copy.brandNo,
+            modelType: copy.model,
+            name: '',
+            type: '',
+            planDeliveryTime: copy.startTime,
+            applyDeptId: this.form.pleaseEntrustDeptId,
+            applyDeptName: this.form.pleaseEntrustDeptName,
+            applyFactoriesId: this.form.factoriesId,
+            applyFactoriesName: this.form.factoriesName
+          });
+
+          return copy;
+        });
+
+        const data = Object.assign(this.form, newList[0]);
+        this.form = this.deepCopy(data);
+        this.form.pleaseEntrustDeptName = this.$store.state.user.info.groupName;
+        this.form.pleaseEntrustDeptId = this.$store.state.user.info.groupId;
+        this.form.pleaseEntrustUserName = this.$store.state.user.info.name;
+        this.form.pleaseEntrustUserId = this.$store.state.user.info.userId;
+        this.form.name = this.taskObj.name
+          ? this.taskObj.name + '请托'
+          : this.taskObj.taskTypeName + '请托';
+        const taskId = this.taskObj.name
+          ? this.taskObj.id
+          : this.taskObj.taskId;
+        this.getTaskInstanceByIdFn(this.workListIds, taskId);
+      }
     },
 
     methods: {
@@ -546,6 +625,22 @@
         });
       },
 
+      async getTaskInstanceByIdFn(workOrderId, taskId) {
+        await getTaskInstanceById(workOrderId).then((res) => {
+          let { data } = res;
+          if (data.length) {
+            data = data.filter((item) => item.taskId != -2);
+            let arr = data.findIndex((item) => item.sourceTaskId == taskId);
+
+            if (arr != -1) {
+              data.splice(0, arr);
+            }
+
+            this.pleaseNewStepsList = data;
+          }
+        });
+      },
+
       async getFactoryList() {
         let par = {
           type: 1,
@@ -563,10 +658,41 @@
             //   };
             // });
           }
+          const data = this.factoryList.filter(
+            (it) => it.factoryId == this.$store.state.user.info.factoryId
+          );
+
+          if (data.length != 0) {
+            this.form.factoriesId = data[0].factoryId;
+            this.form.factoriesName = data[0].factoryName;
+          }
         });
         console.log(this.factoryList, '工厂数据111');
       },
 
+      beEntrustedDeptIdChange(val, row) {
+        this.form.beEntrustedDeptName = row.name;
+      },
+      factoryListChange(row) {
+        this.form.beEntrustedFactoriesName = row.name;
+      },
+
+      deepCopy(obj, hash = new WeakMap()) {
+        if (obj === null) return null;
+        if (obj instanceof Date) return new Date(obj);
+        if (obj instanceof RegExp) return new RegExp(obj);
+        if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
+        if (hash.has(obj)) return hash.get(obj);
+
+        const result = Array.isArray(obj) ? [] : {};
+        hash.set(obj, result);
+
+        return Object.keys(obj).reduce((acc, key) => {
+          acc[key] = this.deepCopy(obj[key], hash);
+          return acc;
+        }, result);
+      },
+
       async getContactList() {
         let param = {
           pageNum: 1,
@@ -684,21 +810,6 @@
                 this.attributeData.supplierName = obj ? obj.name : '';
               }
 
-              this.attributeData.taskIdes.forEach((it) => {
-                this.newStepsList.filter((i) => {
-                  if (i.taskId == it) {
-                    this.attributeData.taskDataList.push(i);
-                  }
-                });
-              });
-              this.attributeData.taskIds =
-                this.attributeData.taskIdes.join(',');
-              this.$emit('changePlugIn', this.attributeData, this.activeName);
-            } else if (this.activeName == '2') {
-              const obj = this.factoryList.find(
-                (item) => item.id === this.attributeData.factoriesId
-              );
-              this.attributeData.factoriesName = obj ? obj.name : '';
               this.attributeData.taskIdes.forEach((it) => {
                 this.newStepsList.filter((i) => {
                   if (i.taskId == it) {
@@ -716,13 +827,60 @@
           }
         });
       },
+
+      save(type) {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+
+          let URL;
+
+          const clearOrderIds = () => {
+            this.orderList.forEach((it) => (it.id = ''));
+          };
+
+          if (type === 1 && this.form.id) {
+            // 编辑
+            URL = update;
+          } else if (type === 1) {
+            // 新增
+            URL = save;
+            clearOrderIds();
+          } else {
+            // 其他类型提交
+            URL = addSubmit;
+            clearOrderIds();
+          }
+
+          this.loading = this.$loading({
+            lock: true,
+            text: '加载中',
+            background: 'rgba(0, 0, 0, 0.7)'
+          });
+
+          console.log(this.form, 'this.form');
+
+          const list = [];
+          list.push(this.form);
+
+          URL(list)
+            .then((res) => {
+              this.loading.close();
+              this.$message.success('成功');
+              this.cancel();
+            })
+            .catch((e) => {
+              this.loading.close();
+            });
+        });
+      },
       cancel() {
         this.$emit('changeCancel', this.activeName);
       }
     },
     created() {
       this.operationType = null;
-      this.workListIds = [];
     }
   };
 </script>
@@ -773,4 +931,8 @@
   ::v-deep .el-form-item {
     margin-bottom: 13px !important;
   }
+
+  ::v-deep .ele-basic-select {
+    width: 260px !important;
+  }
 </style>

+ 12 - 10
src/views/produce/index.vue

@@ -255,7 +255,9 @@
                 ></outsourcingDetails>
                 <outsourcing
                   :outsourceFormVal="outsourceForm"
-                  :taskName="taskObj.name"
+                  :taskObj="taskObj"
+                  :workListIds="workListIds[0]"
+                  :workData="workData"
                   @changePlugIn="changePlugIn"
                   @changeCancel="changeCancel"
                   :chooseType="chooseType"
@@ -1100,15 +1102,15 @@
       outsourcingAdd(type, activeName) {
         this.getTaskInstanceByIdFn(this.workListIds[0]);
         this.chooseType = activeName;
-        if (this.chooseType == 1) {
-          this.isStep = true;
-        } else {
-          this.$refs.addPleaseRef.open(
-            this.workListIds[0],
-            this.workData,
-            this.taskObj
-          );
-        }
+        // if (this.chooseType == 1) {
+        this.isStep = true;
+        // } else {
+        //   this.$refs.addPleaseRef.open(
+        //     this.workListIds[0],
+        //     this.workData,
+        //     this.taskObj
+        //   );
+        // }
       },
 
       refreshPlease() {

+ 10 - 21
src/views/produceOrder/workReport.vue

@@ -206,9 +206,12 @@
                         v-if="!isStep && !isOutsource && !isPleaseEntrust"
                         :chooseType="chooseType"
                       ></outsourcingDetails>
+
                       <outsourcing
                         :outsourceFormVal="outsourceForm"
-                        :taskName="taskObj.taskTypeName"
+                        :taskObj="taskObj"
+                        :workListIds="workListIds[0]"
+                        :workData="workInfoList"
                         @changePlugIn="changePlugIn"
                         @changeCancel="changeCancel"
                         :chooseType="chooseType"
@@ -429,7 +432,8 @@
         curTaskObj: null,
         produceList: [],
         workPlanType: '',
-        isPleaseEntrust: false
+        isPleaseEntrust: false,
+        workInfoList: {}
       };
     },
 
@@ -905,29 +909,14 @@
         }
       },
 
-      // outsourcingAdd() {
-      //   this.getTaskInstanceByIdFn(this.workListIds[0]);
-      //   this.isStep = true;
-      // },
-
       outsourcingAdd(type, activeName) {
-        // this.getTaskInstanceByIdFn(this.workListIds[0]);
-        // this.chooseType = activeName;
-        // this.isStep = true;
         this.getTaskInstanceByIdFn(this.workListIds[0]);
         this.chooseType = activeName;
-        if (this.chooseType == 1) {
-          this.isStep = true;
-        } else {
-          const dataList = { list: [] };
-          dataList.list.push(this.workData);
 
-          this.$refs.addPleaseRef.open(
-            this.workListIds[0],
-            dataList,
-            this.taskObj
-          );
-        }
+        this.isStep = true;
+
+        this.workInfoList = { list: [] };
+        this.workInfoList.list.push(this.workData);
       },
 
       async handOutsource(workOrderId) {