Explorar el Código

商机流程销售主管审批

Z hace 2 años
padre
commit
373eb17fbb
Se han modificado 1 ficheros con 201 adiciones y 180 borrados
  1. 201 180
      src/views/bpm/handleTask/components/businessOpportunity/submit.vue

+ 201 - 180
src/views/bpm/handleTask/components/businessOpportunity/submit.vue

@@ -49,7 +49,7 @@
         type="success"
         size="mini"
         @click="handleAudit(1)"
-        >通过
+      >通过
       </el-button>
       <!-- <el-button
         icon="el-icon-edit-outline"
@@ -65,7 +65,7 @@
         size="mini"
         @click="handleAudit(0)"
         v-if="!['starter', 'salesmanApprove'].includes(taskDefinitionKey)"
-        >驳回
+      >驳回
       </el-button>
 
       <!-- <el-button
@@ -96,206 +96,227 @@
 </template>
 
 <script>
-  import {
-    updateProduct,
-    UpdateInformation
-  } from '@/api/bpm/components/saleManage/businessOpportunity';
-  import { approveTaskWithVariables } from '@/api/bpm/task';
-  import { listAllUserBind } from '@/api/system/organization';
-  // 流程实例的详情页,可用于审批
-  export default {
-    name: '',
-    components: {},
-    props: {
-      businessId: {
-        default: ''
-      },
-      taskId: {
-        default: ''
-      },
-      id: {
-        default: ''
-      },
-      id: {
-        default: ''
-      },
-      taskDefinitionKey: {
-        default: ''
-      }
+import {
+  updateProduct,
+  UpdateInformation
+} from '@/api/bpm/components/saleManage/businessOpportunity';
+import {approveTaskWithVariables} from '@/api/bpm/task';
+import {listAllUserBind} from '@/api/system/organization';
+// 流程实例的详情页,可用于审批
+export default {
+  name: '',
+  components: {},
+  props: {
+    businessId: {
+      default: ''
     },
-
-    data() {
-      return {
-        form: {
-          technicianId: '',
-          reason: '',
-          technicalAnswerName: ''
-        },
-        userOptions: []
-      };
+    taskId: {
+      default: ''
     },
-    created() {
-      this.userOptions = [];
-      listAllUserBind().then((data) => {
-        this.userOptions.push(...data);
-      });
+    id: {
+      default: ''
+    },
+    id: {
+      default: ''
     },
+    taskDefinitionKey: {
+      default: ''
+    }
+  },
 
-    methods: {
-      head() {
-        this.$refs.headRef.open();
+  data() {
+    return {
+      form: {
+        technicianId: '',
+        reason: '',
+        technicalAnswerName: ''
       },
+      userOptions: []
+    };
+  },
+  created() {
+    this.userOptions = [];
+    listAllUserBind().then((data) => {
+      this.userOptions.push(...data);
+    });
+  },
 
-      /** 处理转办审批人 */
-      handleUpdateAssignee() {
-        this.$emit('handleUpdateAssignee');
-      },
-      /** 退回 */
-      handleBackList() {
-        this.$emit('handleBackList');
-      },
+  methods: {
+    head() {
+      this.$refs.headRef.open();
+    },
 
-      async handleAudit(status) {
-        if (this.taskDefinitionKey === 'starter') {
-          let arr = await this.getTableValue();
-          if (!arr) {
-            return;
-          }
-          let data = await UpdateInformation(arr);
-          if (data.code != '0') {
-            return;
-          }
-        }
-        //生产主管审批选择技术员
-        if (
-          this.taskDefinitionKey === 'productionSupervisorApprove1' &&
-          status === 1
-        ) {
-          let data = await this.getTableValue();
-          let userIfon = this.userOptions.find(
-            (item) => item.id == this.form.technicianId
-          );
-          let isProduceDeliveryDeadline = true;
-          let arr = data.map((item) => {
-            if (!item.produceDeliveryDeadline) {
-              isProduceDeliveryDeadline = false;
-            }
-            return {
-              ...item,
-              id: item.id,
-              produceDeliveryDeadline: item.produceDeliveryDeadline,
-              technicalAnswerId: this.form.technicianId,
-              technicalAnswerName: userIfon.name
-            };
-          });
+    /** 处理转办审批人 */
+    handleUpdateAssignee() {
+      this.$emit('handleUpdateAssignee');
+    },
+    /** 退回 */
+    handleBackList() {
+      this.$emit('handleBackList');
+    },
 
-          if (!isProduceDeliveryDeadline) {
-            this.$message.warning(`请选择生产交付交期!`);
-            return;
-          }
-          if (!this.form.technicianId) {
-            this.$message.warning(`请选择技术人员!`);
-            return;
-          }
-          if (!arr) {
-            return;
+    async handleAudit(status) {
+      if (this.taskDefinitionKey === 'starter') {
+        let arr = await this.getTableValue();
+        if (!arr) {
+          return;
+        }
+        let data = await UpdateInformation(arr);
+        if (data.code != '0') {
+          return;
+        }
+      }
+      //生产主管审批选择技术员
+      if (
+        this.taskDefinitionKey === 'productionSupervisorApprove1' &&
+        status === 1
+      ) {
+        let data = await this.getTableValue();
+        let userIfon = this.userOptions.find(
+          (item) => item.id == this.form.technicianId
+        );
+        let isProduceDeliveryDeadline = true;
+        let arr = data.map((item) => {
+          if (!item.produceDeliveryDeadline) {
+            isProduceDeliveryDeadline = false;
           }
+          return {
+            ...item,
+            id: item.id,
+            produceDeliveryDeadline: item.produceDeliveryDeadline,
+            technicalAnswerId: this.form.technicianId,
+            technicalAnswerName: userIfon.name
+          };
+        });
 
-          await updateProduct(arr);
+        if (!isProduceDeliveryDeadline) {
+          this.$message.warning(`请选择生产交付交期!`);
+          return;
         }
-        //技术员修改
-        if ((this.taskDefinitionKey === 'technicianApprove'||this.taskDefinitionKey === 'techLeaderApprove') && status === 1) {
-          let data = await this.getTableValue();
-          let arr = data.map((item) => {
-            return {
-              ...item,
-              id: item.id,
-              technicalDrawings: item.technicalDrawings || [],
-              industryArtFiles: item.industryArtFiles || [],
-              otherFiles: item.otherFiles || [],
-              remark: item.remark,
-              singleWeight: item.singleWeight,
-              technicalParams: item.technicalParams,
-              technicalAnswerId: item.technicalAnswerId,
-              technicalAnswerName: item.technicalAnswerName
-            };
-          });
-          // console.log(arr,'dasdasd')
-          // return
-          if (!arr) {
-            return;
-          }
-          await updateProduct(arr);
+        if (!this.form.technicianId) {
+          this.$message.warning(`请选择技术人员!`);
+          return;
+        }
+        if (!arr) {
+          return;
         }
-        //销售员补充和销售主管审批
-        if ((this.taskDefinitionKey === 'salesmanApprove'||this.taskDefinitionKey === 'salesManagerApprove') && status === 1) {
-          let arr = await this.getTableValue();
-          let singlePrice = true;
-          let totalCount = true;
-          let arrList = arr?.productList.map((item) => {
-            if (!item.singlePrice) {
-              singlePrice = false;
-            }
-            if (!item.totalCount) {
-              totalCount = false;
-            }
-            return {
-              ...item,
-              id: item.id,
-              singlePrice:item.singlePrice,
-              totalCount:item.totalCount,
-              totalPrice:item.totalPrice
-            };
-          })||[];
-         if(this.taskDefinitionKey === 'salesmanApprove'){
-         if (!singlePrice) {
-            this.$message.warning(`请输入单价`);
-            return;
+
+        await updateProduct(arr);
+      }
+      //技术员修改
+      if ((this.taskDefinitionKey === 'technicianApprove' || this.taskDefinitionKey === 'techLeaderApprove') && status === 1) {
+        let data = await this.getTableValue();
+        let arr = data.map((item) => {
+          return {
+            ...item,
+            id: item.id,
+            technicalDrawings: item.technicalDrawings || [],
+            industryArtFiles: item.industryArtFiles || [],
+            otherFiles: item.otherFiles || [],
+            remark: item.remark,
+            singleWeight: item.singleWeight,
+            technicalParams: item.technicalParams,
+            technicalAnswerId: item.technicalAnswerId,
+            technicalAnswerName: item.technicalAnswerName
+          };
+        });
+        // console.log(arr,'dasdasd')
+        // return
+        if (!arr) {
+          return;
+        }
+        await updateProduct(arr);
+      }
+      //和销售主管审批
+      if ((this.taskDefinitionKey === 'salesManagerApprove') && status === 1) {
+        let arr = await this.getTableValue();
+
+        let arrList = arr?.productList.map((item) => {
+          if (!item.singlePrice) {
+            singlePrice = false;
           }
-          if (!totalCount) {
-            this.$message.warning(`请输入数量`);
-            return;
+          if (!item.totalCount) {
+            totalCount = false;
           }
+          return {
+            ...item,
+            id: item.id,
+            singlePrice: item.singlePrice,
+            totalCount: item.totalCount,
+            totalPrice: item.totalPrice
+          };
+        }) || [];
+        if (!arrList.length) {
+          return;
         }
-          if (!arrList.length) {
-            return;
+        await updateProduct(arrList);
+      }
+      //销售员补充
+      if ((this.taskDefinitionKey === 'salesmanApprove') && status === 1) {
+        let arr = await this.getTableValue();
+        let singlePrice = true;
+        let totalCount = true;
+        let arrList = arr.map((item) => {
+          if (!item.singlePrice) {
+            singlePrice = false;
+          }
+          if (!item.totalCount) {
+            totalCount = false;
           }
-         
-          await updateProduct(arrList);
+          return {
+            ...item,
+            id: item.id,
+            singlePrice: item.singlePrice,
+            totalCount: item.totalCount,
+            totalPrice: item.totalPrice
+          };
+        }) || [];
+        if (!singlePrice) {
+          this.$message.warning(`请输入单价`);
+          return;
         }
-        this._approveTaskWithVariables(status);
-      },
-      async _approveTaskWithVariables(status) {
-        let variables = {
-          pass: !!status
-        };
-        if (this.form.technicianId) {
-          variables['technicianId'] = this.form.technicianId;
+        if (!totalCount) {
+          this.$message.warning(`请输入数量`);
+          return;
         }
+        if (!arrList.length) {
+          return;
+        }
+        await updateProduct(arrList);
+      }
+      this._approveTaskWithVariables(status);
+    },
+    async _approveTaskWithVariables(status) {
+      let variables = {
+        pass: !!status
+      };
+      if (this.form.technicianId) {
+        variables['technicianId'] = this.form.technicianId;
+      }
 
-        approveTaskWithVariables({
-          id: this.taskId,
-          reason: this.form.reason,
-          variables
-        }).then((res) => {
-          if (res.data.code != '-1') {
-            this.$emit('handleAudit', {
-              status,
-              title: status === 0 ? '驳回' : ''
-            });
-          }
-        });
-      },
-
-      getTableValue() {
-        return new Promise((resolve, reject) => {
-          this.$emit('getTableValue', async (data) => {
-            resolve(await data);
+      approveTaskWithVariables({
+        id: this.taskId,
+        reason: this.form.reason,
+        variables
+      }).then((res) => {
+        if (res.data.code != '-1') {
+          this.$emit('handleAudit', {
+            status,
+            title: status === 0 ? '驳回' : ''
           });
+        }
+      });
+    },
+
+    getTableValue() {
+      return new Promise((resolve, reject) => {
+        this.$emit('getTableValue', async (data) => {
+          resolve(await data);
         });
-      }
+      });
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss"></style>