Ver código fonte

修改模板编辑权限判断

noob 3 anos atrás
pai
commit
4a4656f87f
1 arquivos alterados com 54 adições e 26 exclusões
  1. 54 26
      src/pages/main/performance/components/sheet.vue

+ 54 - 26
src/pages/main/performance/components/sheet.vue

@@ -2,7 +2,7 @@
  * @Author       : yuanrunwei
  * @Date         : 2021-12-04 14:23:58
  * @LastEditors  : yuanrunwei
- * @LastEditTime : 2021-12-24 10:05:55
+ * @LastEditTime : 2021-12-24 16:00:44
  * @FilePath     : \spfm-market-front\src\pages\main\performance\components\sheet.vue
 -->
 
@@ -29,7 +29,7 @@
                     type="primary"
                     @click="handleSave"
                     :disabled="handleForbid()"
-                    >保存</el-button
+                    >{{ id ? "保存" : "新增" }}</el-button
                 >
             </template>
         </div>
@@ -39,7 +39,7 @@
             :visible="visible"
             :modal="false"
             width="700px"
-            @confirm="handlePower"
+            @confirm="handleAuth"
             @cancel="handleVisible"
         >
             <el-form ref="form" :model="form" label-width="100px">
@@ -194,7 +194,7 @@ export default {
         },
         async handleQuery() {
             const {
-                data: { templateContent, templateName },
+                data: { templateContent, templateName, list },
             } = await this.$http({
                 url: "/market/CMKFileTemplate/QueryCMKFileTemplateById",
                 method: "post",
@@ -205,6 +205,20 @@ export default {
                     templateId: this.id,
                 },
             });
+            if (list && list.length) {
+                const [{ type, allowEditingColumns }] = list;
+                this.form = {
+                    ...this.form,
+                    type: JSON.parse(type),
+                    array: allowEditingColumns.split(","),
+                    charge: list.map(
+                        ({ principalId, principalName, rowNum }) => ({
+                            value: `${principalId},${principalName}`,
+                            key: rowNum.split(","),
+                        })
+                    ),
+                };
+            }
             this.handleCreate({
                 json: JSON.parse(templateContent),
                 name: templateName,
@@ -296,23 +310,7 @@ export default {
                 window.luckysheet.getWorkbookName()
             );
         },
-        async handleSave() {
-            const sheet_name = window.luckysheet.getSheet().name;
-            const data = window.luckysheet.getSheet(sheet_name);
-            const workbook_name = window.luckysheet.getWorkbookName();
-            const {
-                data: { body },
-            } = await this.$http({
-                url: "/market/CMKFileTemplate/CMKFileTemplateAdd",
-                method: "post",
-                headers: {
-                    "Content-Type": "application/json",
-                },
-                data: {
-                    templateContent: JSON.stringify(data),
-                    templateName: workbook_name,
-                },
-            });
+        async handleAddAuth({ id }) {
             const object = {};
             const { array, charge, type } = this.form;
             charge.map(({ key, value }) => {
@@ -321,7 +319,9 @@ export default {
                 }
             });
             await this.$http({
-                url: "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityAdd",
+                url: this.id
+                    ? "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityUpdate"
+                    : "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityAdd",
                 method: "post",
                 headers: {
                     "Content-Type": "application/json",
@@ -329,13 +329,37 @@ export default {
                 data: {
                     allowEditingColumns: array.join(","),
                     auth: JSON.stringify(object),
-                    templateId: body,
+                    templateId: id,
                     type,
                 },
             });
-            this.$message.success("保存成功");
+            this.$message.success("操作成功");
+        },
+        async handleSave() {
+            const sheet_name = window.luckysheet.getSheet().name;
+            const data = window.luckysheet.getSheet(sheet_name);
+            const workbook_name = window.luckysheet.getWorkbookName();
+            const {
+                data: { body },
+            } = await this.$http({
+                url: this.id
+                    ? "/market/CMKIssued/CMKIssuedSubmit"
+                    : "/market/CMKFileTemplate/CMKFileTemplateAdd",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    id: this.id,
+                    templateContent: JSON.stringify(data),
+                    templateName: workbook_name,
+                },
+            });
+            if (!this.id) {
+                this.handleAddAuth({ id: body });
+            }
         },
-        handlePower() {
+        handleAuth() {
             this.$refs["form"].validate((valid) => {
                 if (valid) {
                     if (this.handleForbid()) {
@@ -343,7 +367,11 @@ export default {
                         return false;
                     }
                     this.handleVisible();
-                    this.$message.success("设置成功");
+                    if (this.id) {
+                        this.handleAddAuth({ id: this.id });
+                    } else {
+                        this.$message.success("设置成功");
+                    }
                 }
             });
         },