Browse Source

印品模板合并

zhangjie 2 years ago
parent
commit
14697f86e5

+ 0 - 1
src/constants/enumerate.js

@@ -74,7 +74,6 @@ export const CARD_TYPE = {
 
 // 模板类型
 export const TEMPLATE_TYPE = {
-  GENERIC: "通卡模板",
   VARIABLE: "变量印品模板",
   ORDINARY: "普通印品模板"
 };

+ 33 - 36
src/modules/base/components/ModifyTemplate.vue → src/modules/base/components/ModifyPrintTemplate.vue

@@ -21,7 +21,6 @@
           placeholder="建议不超过30个字,规则名称不允许重复"
           style="width: 100%"
           clearable
-          :disabled="!editable"
         ></el-input>
       </el-form-item>
       <el-form-item prop="remark" label="备注:">
@@ -31,24 +30,27 @@
           resize="none"
           :rows="2"
           :maxlength="50"
-          :disabled="!editable"
           clearable
           show-word-limit
           placeholder="建议不超过50个字"
         ></el-input>
       </el-form-item>
-      <el-form-item
-        v-if="modalForm.type !== 'GENERIC'"
-        prop="classify"
-        label="分类:"
-      >
+      <el-form-item prop="type" label="模板类型:">
         <el-select
-          v-model="modalForm.classify"
-          style="width: 100%;"
-          placeholder="请选择"
-          :disabled="!editable"
-          clearable
+          v-model="modalForm.type"
+          placeholder="模板类型"
+          @change="templateTypeChange"
         >
+          <el-option
+            v-for="(val, key) in TEMPLATE_TYPE"
+            :key="key"
+            :value="key"
+            :label="val"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item prop="classify" label="分类:">
+        <el-select v-model="modalForm.classify" placeholder="请选择" clearable>
           <el-option
             v-for="(val, key) in categories"
             :key="key"
@@ -61,7 +63,6 @@
         <upload-file-view
           :upload-data="uploadData"
           :upload-url="uploadUrl"
-          :disabled="!editable"
           :format="format"
           @valid-error="validError"
           @upload-success="uploadSuccess"
@@ -71,11 +72,7 @@
     </el-form>
 
     <div slot="footer">
-      <el-button
-        v-if="editable"
-        type="primary"
-        :disabled="isSubmit"
-        @click="submit"
+      <el-button type="primary" :disabled="isSubmit" @click="submit"
         >确认</el-button
       >
       <el-button @click="cancel">取消</el-button>
@@ -87,11 +84,12 @@
 import { updateTemplate } from "../api";
 import { attachmentDetail } from "../../login/api";
 import UploadFileView from "@/components/UploadFileView";
+import { TEMPLATE_TYPE } from "@/constants/enumerate";
 
 const initModalForm = {
   id: null,
   name: "",
-  type: "GENERIC",
+  type: "",
   remark: "",
   classify: "",
   attachmentId: ""
@@ -103,7 +101,7 @@ const TEMPLATE_CLASSIFY = {
 };
 
 export default {
-  name: "modify-template",
+  name: "modify-print-template",
   components: { UploadFileView },
   props: {
     instance: {
@@ -111,31 +109,20 @@ export default {
       default() {
         return {};
       }
-    },
-    editType: {
-      type: String,
-      default: "ADD",
-      validator: val => ["ADD", "PREVIEW", "EDIT"].includes(val)
     }
   },
   computed: {
-    title() {
-      const names = {
-        ADD: "新增模板",
-        PREVIEW: "模板详情",
-        EDIT: "编辑模板"
-      };
-      return names[this.editType];
+    isEdit() {
+      return !!this.instance.id;
     },
-    editable() {
-      return this.editType !== "PREVIEW";
+    title() {
+      return (this.isEdit ? "编辑" : "新增") + "模板";
     },
     categories() {
       return TEMPLATE_CLASSIFY[this.modalForm.type] || {};
     },
     format() {
       const formats = {
-        GENERIC: ["html"],
         VARIABLE: ["ftl"],
         ORDINARY: ["ftl", "html", "pdf"]
       };
@@ -157,6 +144,13 @@ export default {
             trigger: "change"
           }
         ],
+        type: [
+          {
+            required: true,
+            message: "请选择模板类型",
+            trigger: "change"
+          }
+        ],
         classify: [
           {
             required: true,
@@ -172,6 +166,7 @@ export default {
           }
         ]
       },
+      TEMPLATE_TYPE,
       // upload
       uploadUrl: "/api/admin/common/file/upload",
       uploadData: {
@@ -211,6 +206,9 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    templateTypeChange() {
+      this.modalForm.classify = "";
+    },
     async submit() {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;
@@ -220,7 +218,6 @@ export default {
       let datas = {
         ...this.modalForm
       };
-      if (datas.type === "GENERIC") datas.classify = "CARD";
       const data = await updateTemplate(datas).catch(() => {});
       this.isSubmit = false;
       if (!data) return;

+ 136 - 138
src/modules/base/router.js

@@ -1,138 +1,136 @@
-// user
-import OrganizationManage from "./views/OrganizationManage.vue";
-import RoleManage from "./views/RoleManage.vue";
-import UserManage from "./views/UserManage.vue";
-// rule
-import CommonRule from "./views/CommonRule.vue";
-import CardRuleManage from "./views/CardRuleManage.vue";
-import CommonCardTemplate from "./views/CommonCardTemplate.vue";
-import ParamPrintTemplate from "./views/ParamPrintTemplate.vue";
-import CommonPrintTemplate from "./views/CommonPrintTemplate.vue";
-import PrintPlanPushManage from "./views/PrintPlanPushManage.vue";
-import FlowManage from "./views/FlowManage.vue";
-import ApproveRecordManage from "./views/ApproveRecordManage.vue";
-import SmsManage from "./views/SmsManage.vue";
-import CardManage from "./views/CardManage.vue";
-// dict
-import CampusManage from "./views/CampusManage.vue";
-import StudentManage from "./views/StudentManage.vue";
-import CourseManage from "./views/CourseManage.vue";
-import ClazzManage from "./views/ClazzManage.vue";
-import SemesterManage from "./views/SemesterManage.vue";
-import MajorManage from "./views/MajorManage.vue";
-import ExamManage from "./views/ExamManage.vue";
-import CourseSimpleManage from "./views/CourseSimpleManage.vue";
-import ClazzSimpleManage from "./views/ClazzSimpleManage.vue";
-
-export default [
-  {
-    path: "/base/organization-manage",
-    name: "OrganizationManage",
-    component: OrganizationManage
-  },
-  {
-    path: "/base/role-manage",
-    name: "RoleManage",
-    component: RoleManage
-  },
-  {
-    path: "/base/user-manage",
-    name: "UserManage",
-    component: UserManage
-  },
-  {
-    path: "/base/common-rule",
-    name: "CommonRule",
-    component: CommonRule
-  },
-  {
-    path: "/base/card-rule-manage",
-    name: "CardRuleManage",
-    component: CardRuleManage
-  },
-  {
-    path: "/base/common-card-template",
-    name: "CommonCardTemplate",
-    component: CommonCardTemplate
-  },
-  {
-    path: "/base/param-print-template",
-    name: "ParamPrintTemplate",
-    component: ParamPrintTemplate
-  },
-  {
-    path: "/base/common-print-template",
-    name: "CommonPrintTemplate",
-    component: CommonPrintTemplate
-  },
-  {
-    path: "/base/print-plan-push-manage",
-    name: "PrintPlanPushManage",
-    component: PrintPlanPushManage
-  },
-  {
-    path: "/base/flow-manage",
-    name: "FlowManage",
-    component: FlowManage
-  },
-  {
-    path: "/base/approve-record-manage",
-    name: "ApproveRecordManage",
-    component: ApproveRecordManage
-  },
-  {
-    path: "/base/course-manage",
-    name: "CourseManage",
-    component: CourseManage
-  },
-  {
-    path: "/base/campus-manage",
-    name: "CampusManage",
-    component: CampusManage
-  },
-  {
-    path: "/base/student-manage",
-    name: "StudentManage",
-    component: StudentManage
-  },
-  {
-    path: "/base/clazz-manage",
-    name: "ClazzManage",
-    component: ClazzManage
-  },
-  {
-    path: "/base/semester-manage",
-    name: "SemesterManage",
-    component: SemesterManage
-  },
-  {
-    path: "/base/major-manage",
-    name: "MajorManage",
-    component: MajorManage
-  },
-  {
-    path: "/base/sms-manage",
-    name: "SmsManage",
-    component: SmsManage
-  },
-  {
-    path: "/base/exam-manage",
-    name: "ExamManage",
-    component: ExamManage
-  },
-  {
-    path: "/base/course-simple-manage",
-    name: "CourseSimpleManage",
-    component: CourseSimpleManage
-  },
-  {
-    path: "/base/clazz-simple-manage/:teachCourseId?",
-    name: "ClazzSimpleManage",
-    component: ClazzSimpleManage
-  },
-  {
-    path: "/base/card-manage",
-    name: "CardManage",
-    component: CardManage
-  }
-];
+// user
+import OrganizationManage from "./views/OrganizationManage.vue";
+import RoleManage from "./views/RoleManage.vue";
+import UserManage from "./views/UserManage.vue";
+// rule
+import CommonRule from "./views/CommonRule.vue";
+import CardRuleManage from "./views/CardRuleManage.vue";
+import PrintTemplateManage from "./views/PrintTemplateManage.vue";
+import PrintPlanPushManage from "./views/PrintPlanPushManage.vue";
+import FlowManage from "./views/FlowManage.vue";
+import ApproveRecordManage from "./views/ApproveRecordManage.vue";
+import SmsManage from "./views/SmsManage.vue";
+import CardManage from "./views/CardManage.vue";
+// dict
+import CampusManage from "./views/CampusManage.vue";
+import StudentManage from "./views/StudentManage.vue";
+import CourseManage from "./views/CourseManage.vue";
+import ClazzManage from "./views/ClazzManage.vue";
+import SemesterManage from "./views/SemesterManage.vue";
+import MajorManage from "./views/MajorManage.vue";
+import ExamManage from "./views/ExamManage.vue";
+import CourseSimpleManage from "./views/CourseSimpleManage.vue";
+import ClazzSimpleManage from "./views/ClazzSimpleManage.vue";
+
+export default [
+  {
+    path: "/base/organization-manage",
+    name: "OrganizationManage",
+    component: OrganizationManage
+  },
+  {
+    path: "/base/role-manage",
+    name: "RoleManage",
+    component: RoleManage
+  },
+  {
+    path: "/base/user-manage",
+    name: "UserManage",
+    component: UserManage
+  },
+  {
+    path: "/base/common-rule",
+    name: "CommonRule",
+    component: CommonRule
+  },
+  {
+    path: "/base/card-rule-manage",
+    name: "CardRuleManage",
+    component: CardRuleManage
+  },
+  {
+    path: "/base/print-template-manage",
+    name: "PrintTemplateManage",
+    component: PrintTemplateManage
+  },
+  {
+    path: "/base/param-print-template",
+    name: "ParamPrintTemplate",
+    component: PrintTemplateManage
+  },
+  {
+    path: "/base/common-print-template",
+    name: "CommonPrintTemplate",
+    component: PrintTemplateManage
+  },
+  {
+    path: "/base/print-plan-push-manage",
+    name: "PrintPlanPushManage",
+    component: PrintPlanPushManage
+  },
+  {
+    path: "/base/flow-manage",
+    name: "FlowManage",
+    component: FlowManage
+  },
+  {
+    path: "/base/approve-record-manage",
+    name: "ApproveRecordManage",
+    component: ApproveRecordManage
+  },
+  {
+    path: "/base/course-manage",
+    name: "CourseManage",
+    component: CourseManage
+  },
+  {
+    path: "/base/campus-manage",
+    name: "CampusManage",
+    component: CampusManage
+  },
+  {
+    path: "/base/student-manage",
+    name: "StudentManage",
+    component: StudentManage
+  },
+  {
+    path: "/base/clazz-manage",
+    name: "ClazzManage",
+    component: ClazzManage
+  },
+  {
+    path: "/base/semester-manage",
+    name: "SemesterManage",
+    component: SemesterManage
+  },
+  {
+    path: "/base/major-manage",
+    name: "MajorManage",
+    component: MajorManage
+  },
+  {
+    path: "/base/sms-manage",
+    name: "SmsManage",
+    component: SmsManage
+  },
+  {
+    path: "/base/exam-manage",
+    name: "ExamManage",
+    component: ExamManage
+  },
+  {
+    path: "/base/course-simple-manage",
+    name: "CourseSimpleManage",
+    component: CourseSimpleManage
+  },
+  {
+    path: "/base/clazz-simple-manage/:teachCourseId?",
+    name: "ClazzSimpleManage",
+    component: ClazzSimpleManage
+  },
+  {
+    path: "/base/card-manage",
+    name: "CardManage",
+    component: CardManage
+  }
+];

+ 28 - 42
src/modules/base/views/TemplateManage.vue → src/modules/base/views/PrintTemplateManage.vue

@@ -10,6 +10,16 @@
               clearable
             ></el-input>
           </el-form-item>
+          <el-form-item label="模板类型:" label-width="90px">
+            <el-select v-model="filter.type" placeholder="模板类型" clearable>
+              <el-option
+                v-for="(val, key) in TEMPLATE_TYPE"
+                :key="key"
+                :value="key"
+                :label="val"
+              ></el-option>
+            </el-select>
+          </el-form-item>
           <el-form-item label="创建时间:">
             <el-date-picker
               v-model="createTime"
@@ -68,11 +78,12 @@
           :index="indexMethod"
         ></el-table-column>
         <el-table-column prop="name" label="模板名称"></el-table-column>
-        <el-table-column
-          prop="classify"
-          label="分类"
-          v-if="templateType !== 'GENERIC'"
-        >
+        <el-table-column prop="type" label="模板类型">
+          <template slot-scope="scope">
+            {{ scope.row.type | templateTypeFilter }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="classify" label="分类">
           <template slot-scope="scope">
             {{ scope.row.classify | templateClassifyFilter }}
           </template>
@@ -130,14 +141,12 @@
         </el-pagination>
       </div>
     </div>
-    <!-- ModifyTemplate -->
-    <modify-template
-      ref="ModifyTemplate"
+    <!-- ModifyPrintTemplate -->
+    <modify-print-template
+      ref="ModifyPrintTemplate"
       :instance="curTemplate"
-      :edit-type="editType"
-      :template-type="templateType"
       @modified="getList"
-    ></modify-template>
+    ></modify-print-template>
     <!-- template-detail -->
     <el-dialog
       :visible.sync="templateDetailDialogIsShow"
@@ -158,26 +167,18 @@
 import { ABLE_TYPE, TEMPLATE_TYPE } from "@/constants/enumerate";
 import pickerOptions from "@/constants/datePickerOptions";
 import { templateListPage, ableTemplate, templateContentView } from "../api";
-import ModifyTemplate from "../components/ModifyTemplate";
+import ModifyPrintTemplate from "../components/ModifyPrintTemplate";
 
 export default {
   name: "template-manage",
   components: {
-    ModifyTemplate
-  },
-  props: {
-    templateType: {
-      type: String,
-      default: "GENERIC",
-      validator(val) {
-        return Object.keys(TEMPLATE_TYPE).indexOf(val) !== -1;
-      }
-    }
+    ModifyPrintTemplate
   },
   data() {
     return {
       filter: {
         enable: null,
+        type: "",
         name: "",
         startTime: "",
         endTime: ""
@@ -187,8 +188,8 @@ export default {
       total: 0,
       templates: [],
       curTemplate: {},
-      editType: "ADD",
       ABLE_TYPE,
+      TEMPLATE_TYPE,
       templateDetailDialogIsShow: false,
       // date-picker
       createTime: [],
@@ -204,7 +205,6 @@ export default {
 
       const datas = {
         ...this.filter,
-        type: this.templateType,
         pageNumber: this.current,
         pageSize: this.size
       };
@@ -223,28 +223,14 @@ export default {
       this.getList();
     },
     toAdd() {
-      this.curTemplate = { type: this.templateType };
-      this.editType = "ADD";
-      this.$refs.ModifyTemplate.open();
+      this.curTemplate = {};
+      this.$refs.ModifyPrintTemplate.open();
     },
     toEdit(row) {
-      this.curTemplate = { ...row, type: this.templateType };
-      this.editType = "EDIT";
-      this.$refs.ModifyTemplate.open();
+      this.curTemplate = { ...row };
+      this.$refs.ModifyPrintTemplate.open();
     },
     async toDetail(row) {
-      if (this.templateType === "GENERIC") {
-        window.open(
-          this.getRouterPath({
-            name: "CardPreview",
-            params: {
-              cardId: row.cardId,
-              viewType: "view"
-            }
-          })
-        );
-        return;
-      }
       const content = await templateContentView(row.attachmentId);
       if (!content) return;
 

+ 4 - 0
src/plugins/filters.js

@@ -1,6 +1,7 @@
 import Vue from "vue";
 import {
   TEMPLATE_CLASSIFY,
+  TEMPLATE_TYPE,
   EXAM_TASK_STATUS,
   AUDITING_STATUS,
   AUDITING_RESULT,
@@ -35,6 +36,9 @@ Vue.filter("enableFilter", function(val) {
 Vue.filter("templateClassifyFilter", function(val) {
   return TEMPLATE_CLASSIFY[val] || DEFAULT_FIELD;
 });
+Vue.filter("templateTypeFilter", function(val) {
+  return TEMPLATE_TYPE[val] || DEFAULT_FIELD;
+});
 Vue.filter("orgsFilter", function(val) {
   return val.map(item => item.name).join(",");
 });