daiqisheng 3 лет назад
Родитель
Сommit
870c4cc800
2 измененных файлов с 324 добавлено и 160 удалено
  1. 46 28
      src/pages/main/performance/components/sheet.vue
  2. 278 132
      src/pages/main/performance/department.vue

+ 46 - 28
src/pages/main/performance/components/sheet.vue

@@ -2,7 +2,7 @@
  * @Author       : yuanrunwei
  * @Date         : 2021-12-04 14:23:58
  * @LastEditors: Please set LastEditors
- * @LastEditTime: 2022-01-07 18:43:09
+ * @LastEditTime: 2022-01-08 20:26:39
  * @FilePath     : \spfm-market-front\src\pages\main\performance\components\sheet.vue
 -->
 
@@ -47,8 +47,23 @@
       <el-form ref="form" :model="form" label-width="80px">
         <el-radio-group v-model="form.permission_type">
           <el-form-item>
-            <el-radio :label="0"><span>公共权限:</span></el-radio>
-            <div class="form-input">
+            <el-radio :label="0"><span>公共权限</span></el-radio>
+            <div>
+              <span class="form-content">负责人</span>
+              <el-select
+                v-model="form.person"
+                multiple
+                placeholder="请选择负责人"
+              >
+                <el-option
+                  v-for="({ label, value }, index) in charge_list"
+                  :key="index"
+                  :label="label"
+                  :value="value"
+                ></el-option>
+              </el-select>
+            </div>
+            <!-- <div class="form-input">
               <span class="form-content"> 可编辑行:从</span>
               <el-input v-model="form.col_start" />
               <span class="form-content">到</span
@@ -59,7 +74,7 @@
               <el-input v-model="form.row_start" />
               <span class="form-content">到</span>
               <el-input v-model="form.row_end" />
-            </div>
+            </div> -->
           </el-form-item>
           <el-form-item>
             <el-radio :label="1"><span>特殊权限:</span></el-radio>
@@ -103,7 +118,7 @@
               </div>
             </el-form-item>
             <div>
-              <el-button @click.prevent="handleCharge('add')">添加</el-button>
+              <el-button @click.prevent="handleCharge('add')" >添加</el-button>
               <el-button
                 v-if="form.charge.length - 1"
                 @click.prevent="handleCharge('delete')"
@@ -200,7 +215,7 @@
                     </div>
                 </el-form-item> -->
       </el-form>
-      <!-- <template v-if="!id" v-slot:footer><div></div></template> -->
+      <template v-if="id" v-slot:footer><div></div></template>
     </simple-dialog>
   </div>
 </template>
@@ -231,7 +246,7 @@ export default {
       form: {
         charge: [
           {
-            person: "",
+            person: [],
             col_start: "",
             col_end: "",
             row_start: "",
@@ -240,7 +255,7 @@ export default {
         ],
         array: [],
         type: null,
-        permission_type: 0,
+        permission_type: null,
         col_start: "",
         col_end: "",
         row_start: "",
@@ -278,7 +293,7 @@ export default {
     //     console.log(e,'e');
     // },
     handleAllow({ row, column }) {
-      return this.row_list.includes(row) && this.column_list.includes(column);
+      return (!this.form.permission_type&&this.type === "edit")  || (this.row_list.includes(row) && this.column_list.includes(column));
     },
     async handleQuery() {
       let url = "";
@@ -315,16 +330,12 @@ export default {
         const { type } = list[0];
         if (type === "1") {
           // 公共权限
-          const { allowEditingColumns, rowNum } = list[0];
+          // const { allowEditingColumns, rowNum } = list[0];
           this.form = {
             permission_type: Number(type) - 1,
-            col_start: allowEditingColumns.split(",")[0],
-            col_end:
-              allowEditingColumns.split(",")[
-                allowEditingColumns.split(",").length - 1
-              ],
-            row_start: rowNum.split(",")[0],
-            row_end: rowNum.split(",")[rowNum.split(",").length - 1],
+            person:list.map(el=>{
+              return `${el.principalId},${el.principalName}`
+            }),
             charge: [
               {
                 person: "",
@@ -366,12 +377,12 @@ export default {
         // };
         // this.form = {};
         this.row_list =
-          this.type === "edit"
-            ? rowNum.split(",").map((element) => JSON.parse(element) - 1)
+          this.type === "edit"&&list[0].rowNum
+            ? list[0].rowNum.split(",").map((element) => JSON.parse(element) - 1)
             : [];
         this.column_list =
-          this.type === "edit"
-            ? allowEditingColumns
+          this.type === "edit"&&list[0].allowEditingColumns
+            ? list[0].allowEditingColumns
                 .split(",")
                 .map((element) => JSON.parse(element) - 1)
             : [];
@@ -386,9 +397,9 @@ export default {
       // const object = {};
       const { permission_type } = this.form;
       if (permission_type === 0) {
-        // 公共权限
-        const { col_start, col_end, row_start, row_end } = this.form;
-        if (col_start && col_end && row_start && row_end) {
+        // 公共权限 暂时不用可编辑行和列
+        const { person } = this.form;
+        if (person.length) {
           return false;
         }
         return true;
@@ -408,6 +419,8 @@ export default {
           }
         });
         return !flag;
+      } else {
+        return true;
       }
       //  form: {
       //   charge: [
@@ -524,9 +537,15 @@ export default {
       };
       if (!permission_type) {
         //  公共权限
-        const { col_start, col_end, row_start, row_end } = this.form;
-        reqdata.allowEditingColumns = this.paramsArr(col_start, col_end);
-        reqdata.rowNum = this.paramsArr(row_start, row_end);
+        const { person } = this.form;
+        const principalId = []
+        const principalName = []
+        person.forEach(el =>{
+          principalId.push(el.split(",")[0])
+          principalName.push(el.split(",")[1])
+        })
+        reqdata.principalId = principalId.join(',');
+        reqdata.principalName = principalName.join(',');
       } else {
         const { charge } = this.form;
         //  特殊权限
@@ -593,7 +612,6 @@ export default {
       this.$emit("save");
     },
     handleAuth() {
-      this.handleForbid();
       this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.handleForbid()) {

+ 278 - 132
src/pages/main/performance/department.vue

@@ -116,7 +116,7 @@
           </div>
           <div v-else-if="type === '2'">
             <el-button @click="handleTurn('finish')">结束</el-button>
-            <el-button @click="handleTurn('back')">退回</el-button>
+            <el-button @click="handleTurn('return')">退回</el-button>
             <el-button @click="handleTurn('back')">打回</el-button>
             <el-button @click="handleTurn('transfer')" type="primary"
               >转总经理审批</el-button
@@ -124,6 +124,7 @@
           </div>
           <div v-else>
             <el-button @click="handleTurn('back')">打回</el-button>
+            <el-button @click="handleTurn('return')">退回</el-button>
             <el-button @click="handleTurn('agree')" type="primary"
               >同意</el-button
             >
@@ -135,7 +136,7 @@
       title="转派"
       :visible="transfer_visible"
       :reload="reload"
-      width="500px"
+      width="1000px"
       @confirm="transferConfirm"
       @cancel="handleCancel('transfer_visible')"
     >
@@ -145,68 +146,85 @@
         ref="transfer_form"
         label-width="80px"
       >
-        <el-form-item label="转派人员" prop="personnel">
-          <el-select
-            filterable
-            v-model="transfer_form.personnel"
-            placeholder="请选择转派人员"
-          >
-            <el-option
-              v-for="(item, index) in transfer_list"
-              :key="index"
-              :label="item.label"
-              :value="item.loginNoStr"
+        <el-form-item
+          label="转派人员"
+          v-for="(item, index) in transfer_form.charge"
+          :key="index"
+          :rules="{
+            required: true,
+            message: '负责人不能为空',
+            trigger: 'blur',
+          }"
+        >
+          <div class="flex">
+            <el-select
+              class="margin-bottom-20 margin-right-10"
+              placeholder="请选择负责人"
+              v-model="item.person"
+              @change="personChange"
+              filterable
             >
-            </el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="可编辑行" prop="col_start">
-          <div class="form-select">
-            <span class="form-content">从</span>
-            <el-input v-model="transfer_form.col_start" />
-            <span class="form-content">到</span
-            ><el-input v-model="transfer_form.col_end" />
+              <el-option
+                v-for="({ label, value }, index) in transfer_list_orgin"
+                :key="index"
+                :label="label"
+                :value="value"
+              ></el-option>
+            </el-select>
+            <div v-if="permission_type === 2">
+              <span class="form-content">可编辑行:</span>
+              <el-select
+                class="margin-bottom-20 margin-right-10"
+                placeholder="请选择可编辑行"
+                multiple
+                v-model="item.allowEditingColumns"
+                @change="colsChange"
+              >
+                <el-option
+                  v-for="(item, index) in transfer_cols_orgin"
+                  :key="index"
+                  :label="item"
+                  :value="item"
+                ></el-option>
+              </el-select>
+            </div>
+            <div v-if="permission_type === 2">
+              <span class="form-content">可编辑列:</span>
+              <el-select
+                class="margin-bottom-20 margin-right-10"
+                placeholder="请选择可编辑列"
+                multiple
+                v-model="item.rowNum"
+                @change="rowsChange"
+              >
+                <el-option
+                  v-for="(item, index) in transfer_rows_orgin"
+                  :key="index"
+                  :label="item"
+                  :value="item"
+                ></el-option>
+              </el-select>
+            </div>
           </div>
-          <!-- <el-select
-            v-model="transfer_form.rows"
-            placeholder="可编辑行"
-            multiple
-          >
-            <el-option
-              v-for="(item, index) in transfer_rows"
-              :key="index"
-              :label="item.label"
-              :value="item.value"
-            >
-            </el-option>
-          </el-select> -->
         </el-form-item>
-        <el-form-item label="可编辑列" prop="row_start">
-          <div class="form-select">
-            <span class="form-content">从</span>
-            <el-input v-model="transfer_form.row_start" />
-            <span class="form-content">到</span>
-            <el-input v-model="transfer_form.row_end" />
-          </div>
-          <!-- <el-select
-            v-model="transfer_form.rows"
-            placeholder="可编辑行"
-            multiple
+        <div>
+          <el-button
+            class="margin-right-10"
+            @click.prevent="handleCharge('add')"
+            type="primary"
+            >添加</el-button
           >
-            <el-option
-              v-for="(item, index) in transfer_rows"
-              :key="index"
-              :label="item.label"
-              :value="item.value"
-            >
-            </el-option>
-          </el-select> -->
-        </el-form-item>
+          <el-button
+            v-if="transfer_form.charge.length - 1"
+            @click.prevent="handleCharge('delete')"
+            >删除</el-button
+          >
+        </div>
       </el-form>
     </simple-dialog>
     <simple-dialog
       title="回复详情"
-      width="700px"
+      width="1000px"
       @cancel="handleCancel('principal_visible')"
       @confirm="handleCancel('principal_visible')"
       :visible="principal_visible"
@@ -269,6 +287,8 @@ export default {
       total: 0,
       reviewType: "",
       isCheck: false,
+      // 判断是否为2---特殊权限或者为1---公共权限
+      permission_type: 2,
       // 职位判断转派用
       duty: "",
       //   搜索参数
@@ -285,38 +305,38 @@ export default {
       principal_visible: false,
       edit_form: {},
       // 回复详情
-      receiver_table_list: [
-        {
-          receiver: "接收人",
-          department: "科室",
-          date: "回复时间",
-          value: "2021.11.4 XXX 同意\n2021.11.4 XXX 同意",
-        },
-      ],
+      receiver_table_list: [],
       receiver_table_config: [
         {
           label: "接收人",
-          props: "receiver",
+          props: "receiveName",
         },
         {
           label: "科室",
-          props: "department",
+          props: "dept",
         },
         {
           label: "回复时间",
-          props: "date",
+          props: "createTime",
         },
         {
           label: "审批记录",
-          props: "value",
+          props: "result",
+          type: "textarea",
+        },
+        {
+          label: "审批意见",
+          props: "opinion",
           type: "textarea",
         },
       ],
+      transfer_list_orgin: [],
+      transfer_cols_orgin: [],
+      transfer_rows_orgin: [],
       transfer_list: [],
-      transfer_rows: [],
       transfer_form: {
-        personnel: "", // 转派人员
-        rows: [],
+        // personnel: "", // 转派人员
+        charge: [{ person: "", allowEditingColumns: [], rowNum: [] }],
       },
       reload: 0,
       // 判断类型
@@ -539,8 +559,9 @@ export default {
           "Content-Type": "application/json",
         },
         data: { id: this.edit_form.id },
-      }).then(({ data: { reviewType } }) => {
+      }).then(({ data: { reviewType, list } }) => {
         // 判断审批按钮是否还存在
+        this.permission_type = Number(list[0].type);
         console.log(reviewType, "res");
         this.reviewType = reviewType;
         switch (reviewType) {
@@ -598,48 +619,116 @@ export default {
     handleTrack() {
       this.track_visible = true;
     },
+    // 转派的增加或删除
+    handleCharge(type) {
+      switch (type) {
+        case "add":
+          this.transfer_form.charge.push({
+            person: "",
+            allowEditingColumns: [],
+            rowNum: [],
+          });
+          break;
+        case "delete":
+          this.transfer_form.charge.pop();
+          break;
+      }
+    },
+    // 三个change事件控制行列人员变动
+    personChange(val) {
+      console.log(val, this.transfer_list);
+      this.transfer_list = this.transfer_list.filter((el) => el.value !== val);
+      console.log(this.transfer_list, "this.transfer_list");
+    },
+    rowsChange(val) {
+      console.log(val, "rowsChange");
+    },
+    colsChange(val) {
+      console.log(val, "colsChange");
+    },
+    handleForbid() {
+      const permission_type = this.permission_type;
+      const { charge } = this.transfer_form;
+      let flag = 1;
+      console.log(permission_type, "permission_type");
+      if (permission_type === 1) {
+        // 公共权限 暂时不用可编辑行和列
+        charge.forEach((el) => {
+          if (el.person) {
+            flag = flag * 1;
+          } else {
+            flag = flag * 0;
+          }
+        });
+      } else if (permission_type === 2) {
+        // 特殊权限
+        console.log(permission_type, "permission_type");
+        charge.forEach((el) => {
+          if (el.person && el.allowEditingColumns.length && el.rowNum.length) {
+            flag = flag * 1;
+          } else {
+            flag = flag * 0;
+          }
+        });
+      }
+      return flag;
+    },
     // 转派的同意事件
-    transferConfirm() {
+    async transferConfirm() {
       this.$refs["transfer_form"].validate((valid) => {
         if (valid) {
-          let obj = {};
-          this.transfer_form.rows.forEach((el) => {
-            obj = {
-              ...obj,
-              [el]: this.transfer_form.personnel,
+          if (this.handleForbid()) {
+            const { charge } = this.transfer_form;
+            let params = {
+              issuedId: this.edit_form.id,
             };
-          });
-          let reqdata = {
-            forward: JSON.stringify(obj),
-            issuedId: this.edit_form.id,
-          };
-          this.$http({
-            url: "/market/CMKIssued/CMKIssuedTransfer",
-            method: "post",
-            headers: {
-              "Content-Type": "application/json",
-            },
-            data: reqdata,
-          }).then(({ data: { desc } }) => {
-            if (desc === "转派成功") {
-              this.$message({
-                type: "success",
-                message: desc,
-              });
-              this.transfer_visible = false;
-              this.handleInit({
-                ...this.table_search,
-                page: this.page,
-                pageSize: this.rows,
-              });
-              this.handleCancel("visible");
+            if (this.permission_type === 1) {
+              params.transferCommonAuthority = charge
+                .map((el) => {
+                  el = el.person.split(",")[0];
+                  return el;
+                })
+                .join(",");
+            } else if (this.permission_type === 2) {
+              params.transferAuthority = charge.map((el) =>
+                JSON.stringify({
+                  allowEditingColumns: el.allowEditingColumns.join(","),
+                  rowNum: el.rowNum.join(","),
+                  principalId: el.person.split(",")[0],
+                  principalName: el.person.split(",")[1],
+                })
+              );
             }
-          });
+            this.$http({
+              url: "/market/CMKIssued/CMKIssuedTransfer",
+              method: "post",
+              headers: {
+                "Content-Type": "application/json",
+              },
+              data: params,
+            }).then(({ data: { desc } }) => {
+              if (desc === "转派成功") {
+                this.$message({
+                  type: "success",
+                  message: desc,
+                });
+                this.transfer_visible = false;
+                this.handleInit({
+                  ...this.table_search,
+                  page: this.page,
+                  pageSize: this.rows,
+                });
+                this.handleCancel("visible");
+              }
+            });
+            console.log(params, "this.transfer_form");
+          } else {
+            this.$message.error("请填写必要的信息");
+          }
         }
       });
     },
     async handleTransfer() {
-      console.log(this.edit_form, "prams");
       let loginNoStr = JSON.parse(sessionStorage.userInfo).loginNoStr;
       let groupId = JSON.parse(sessionStorage.userInfo).groupId;
       await this.$http({
@@ -652,32 +741,31 @@ export default {
           groupId,
         },
       }).then(({ data }) => {
-        this.transfer_list = data
+        this.transfer_list_orgin = data
           .filter((el) => {
             return el.loginNoStr !== loginNoStr;
           })
           .map((el) => ({
             ...el,
-            label: el.loginNameStr,
+            label: `${el.loginNameStr}`,
+            value: `${el.loginNoStr},${el.loginNameStr}`,
           }));
+        this.transfer_list = this.transfer_list_orgin;
         // 可编辑行
       });
-      // await this.$http({
-      //   url: "/market/CMKIssued/CMKIssuedRow",
-      //   method: "post",
-      //   headers: {
-      //     "Content-Type": "application/json",
-      //   },
-      //   data: {
-      //     id: this.edit_form.id,
-      //   },
-      // }).then(({ data }) => {
-      //   console.log(data);
-      //   // this.transfer_rows = data.map((el) => ({
-      //   //   label: el,
-      //   //   value: el,
-      //   // }));
-      // });
+      await this.$http({
+        url: "/market/CMKIssued/CMKIssuedRow",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json",
+        },
+        data: {
+          id: this.edit_form.id,
+        },
+      }).then(({ data: { column, row } }) => {
+        this.transfer_cols_orgin = column.split(",");
+        this.transfer_rows_orgin = row.split(",");
+      });
       this.transfer_visible = true;
     },
     handleTurn(type) {
@@ -691,36 +779,43 @@ export default {
         case "finish":
           // status 0.打回 3.结束
           reqdata.status = "3";
+          reqdata.operateName = "结束";
           request = 1;
           break;
         case "transfer":
           // reviewType 2.副总经理 3总经理
           if (this.duty === "7") {
             reqdata.reviewType = 2;
+            reqdata.operateName = "转副总审批";
             request = 1;
           } else if (this.duty === "2") {
             reqdata.reviewType = 3;
             request = 1;
+            reqdata.operateName = "转总经理审批";
           }
           break;
         case "back":
           reqdata.status = "0";
           reqdata.reviewType = 1;
           request = 1;
+          reqdata.operateName = "打回";
+          break;
+        case "return":
+          reqdata.status = "0";
+          reqdata.operateName = "退回";
+          if (this.duty === "2") {
+            reqdata.reviewType = 1;
+          } else if (this.duty === "3") {
+            reqdata.reviewType = 2;
+          }
+          request = 1;
           break;
         case "agree":
+          reqdata.operateName = "同意";
           reqdata.status = "3";
           request = 1;
           break;
       }
-      console.log(reqdata, "reqdata");
-      this.handleInit({
-        ...this.table_search,
-        page: this.page,
-        pageSize: this.rows,
-      });
-      // this.handleCancel("visible");
-      // this.handleCancel("approve_visible");
       if (request) {
         // 这里调接口
         this.$http({
@@ -744,6 +839,39 @@ export default {
               page: this.page,
               pageSize: this.rows,
             });
+          } else if (desc === "存在未提交,是否还要审核") {
+            this.$confirm(desc, {
+              confirmButtonText: "确定",
+              cancelButtonText: "取消",
+              type: "warning",
+            })
+              .then((res) => {
+                this.$http({
+                  url: "/market/CMKIssued/CMKIssuedCheck",
+                  method: "post",
+                  headers: {
+                    "Content-Type": "application/json",
+                  },
+                  data: { ...reqdata, submitFlag: 1 },
+                }).then(({ data: { desc } }) => {
+                  if (desc === "审批成功") {
+                    this.$message({
+                      type: "success",
+                      message: desc,
+                    });
+                    this.handleCancel("visible");
+                    this.handleCancel("approve_visible");
+                    this.handleInit({
+                      ...this.table_search,
+                      page: this.page,
+                      pageSize: this.rows,
+                    });
+                  }
+                });
+              })
+              .catch((error) => {
+                console.log(error);
+              });
           }
         });
       }
@@ -763,7 +891,15 @@ export default {
       // this.handleCancel("approve_visible");
       // });
     },
-
+    // 通用方法用于转化全局
+    paramsArr(start, end) {
+      const arr = [];
+      console.log(start, end);
+      for (let i = Number(start); i <= Number(end); i++) {
+        arr.push(i);
+      }
+      return arr.join(",");
+    },
     handleConfirm(visible) {
       console.log(visible);
       this.track_visible = visible;
@@ -780,6 +916,16 @@ export default {
       // 回复详情
       console.log(id);
       this.principal_visible = true;
+      this.$http({
+        url: "/market/CMKIssued/replyDetails",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json",
+        },
+        data: { issuedId: id },
+      }).then(({data}) => {
+        this.receiver_table_list = data
+      });
     },
     // 关闭方法
     handleCancel(data) {