Browse Source

PDF类型选择

zhangjie 2 years ago
parent
commit
9fb32420e3

+ 0 - 10
src/components/base/lin.html

@@ -1,10 +0,0 @@
-<div class="el-select major-select el-select--small">
-  <div class="el-input el-input--small el-input--suffix is-focus">
-    <input type="text" autocomplete="off" placeholder="专业" class="el-input__inner">
-    <span class="el-input__suffix">
-      <span class="el-input__suffix-inner">
-        <i class="el-select__caret el-input__icon el-icon-arrow-up is-reverse"></i>
-      </span>
-    </span>
-  </div>
-</div>

+ 2 - 0
src/constants/enumerate.js

@@ -255,3 +255,5 @@ export const ANALYSIS_BATCH_STATUS = {
   CALCULATING: "计算中",
   FINISH_CALCULATE: "已完成"
 };
+
+export const PDF_LIST = ["A3", "A4", "A5", "B3", "B4", "B5", "8K"];

+ 2 - 2
src/modules/admin/api.js

@@ -37,8 +37,8 @@ export const schoolSelectedMenuTree = schoolId => {
     schoolId
   });
 };
-export const updateSchoolMenu = ({ schoolId, privilegeIds }) => {
-  return $post("/api/admin/menu/custom/save", { schoolId, privilegeIds });
+export const updateSchoolMenu = datas => {
+  return $post("/api/admin/menu/custom/save", datas);
 };
 // auth-set
 // school-menu-manage

+ 138 - 107
src/modules/admin/views/SchoolMenuManage.vue

@@ -1,107 +1,138 @@
-<template>
-  <div class="school-menu-manage">
-    <div class="part-box part-box-filter part-box-flex">
-      <el-form ref="FilterForm" label-position="left" inline>
-        <el-form-item label="学校:">
-          <school-select
-            v-model="schoolId"
-            placeholder="请选择学校"
-            :clearable="false"
-            style="width:100%;"
-            @change="search"
-          ></school-select>
-        </el-form-item>
-      </el-form>
-      <div class="part-box-action">
-        <el-button
-          type="primary"
-          :disabled="fetching"
-          :loading="loading"
-          @click="save"
-          >保存</el-button
-        >
-      </div>
-    </div>
-
-    <div class="part-box part-box-pad">
-      <privilege-set
-        v-if="menus && menus.length"
-        ref="PrivilegeSet"
-        :menus="menus"
-      ></privilege-set>
-    </div>
-  </div>
-</template>
-
-<script>
-import {
-  schoolMenuTree,
-  schoolSelectedMenuTree,
-  updateSchoolMenu
-} from "../api";
-import PrivilegeSet from "../../base/components/PrivilegeSet";
-
-export default {
-  name: "school-menu-manage",
-  components: { PrivilegeSet },
-  data() {
-    return {
-      schoolId: "",
-      menus: [],
-      loading: false,
-      fetching: false,
-      defaultProps: {
-        label: "name"
-      }
-    };
-  },
-  mounted() {
-    this.getPrivileges();
-  },
-  methods: {
-    async getPrivileges() {
-      const needHideModules = ["common", "customer"];
-      const data = await schoolMenuTree();
-      const menus = data || [];
-
-      this.menus = menus
-        .filter(item => !needHideModules.includes(item.url))
-        .map(item => {
-          item.parentId = null;
-          return item;
-        });
-
-      this.$nextTick(() => {
-        this.$refs.PrivilegeSet.buildTableData([]);
-      });
-    },
-    async search() {
-      if (!this.schoolId) return;
-      this.fetching = true;
-      const data = await schoolSelectedMenuTree(this.schoolId).catch(() => {});
-      this.fetching = false;
-
-      const privilegeIds = data || [];
-      this.$refs.PrivilegeSet.buildTableData(privilegeIds);
-    },
-    async save() {
-      if (!this.schoolId) {
-        this.$message.error("学校必须选择!");
-        return;
-      }
-      if (this.loading) return;
-
-      this.loading = true;
-      const privilegeIds = this.$refs.PrivilegeSet.getSelectedPrivilegeIds();
-      const res = await updateSchoolMenu({
-        schoolId: this.schoolId,
-        privilegeIds: privilegeIds
-      });
-      this.loading = false;
-      if (!res) return;
-
-      this.$message.success("修改成功!");
-    }
-  }
-};
-</script>
+<template>
+  <div class="school-menu-manage">
+    <div class="part-box part-box-filter part-box-flex">
+      <el-form ref="FilterForm" label-position="left" inline>
+        <el-form-item label="学校:">
+          <school-select
+            v-model="schoolId"
+            placeholder="请选择学校"
+            :clearable="false"
+            style="width:100%;"
+            @change="search"
+          ></school-select>
+        </el-form-item>
+      </el-form>
+      <div class="part-box-action">
+        <el-button
+          type="primary"
+          :disabled="fetching"
+          :loading="loading"
+          @click="save"
+          >保存</el-button
+        >
+      </div>
+    </div>
+
+    <div class="part-box part-box-pad">
+      <el-form class="mb-2" label-width="80px">
+        <el-form-item label="PDF格式">
+          <el-select
+            v-model="modalForm.pdfSize"
+            class="campus-select"
+            placeholder="请选择"
+            multiple
+            style="width:100%"
+          >
+            <el-option
+              v-for="item in sysPdfSize"
+              :key="item"
+              :value="item"
+              :label="item"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+
+      <privilege-set
+        v-if="menus && menus.length"
+        ref="PrivilegeSet"
+        :menus="menus"
+      ></privilege-set>
+    </div>
+  </div>
+</template>
+
+<script>
+import {
+  schoolMenuTree,
+  schoolSelectedMenuTree,
+  updateSchoolMenu
+} from "../api";
+import PrivilegeSet from "../../base/components/PrivilegeSet";
+
+export default {
+  name: "school-menu-manage",
+  components: { PrivilegeSet },
+  data() {
+    return {
+      schoolId: "",
+      menus: [],
+      loading: false,
+      fetching: false,
+      sysPdfSize: [],
+      modalForm: {
+        pdfSize: []
+      },
+      defaultProps: {
+        label: "name"
+      }
+    };
+  },
+  mounted() {
+    this.getPrivileges();
+  },
+  methods: {
+    async getPrivileges() {
+      const needHideModules = ["common", "customer"];
+      const data = await schoolMenuTree();
+      const menus = data.customPrivilegeList || [];
+      this.sysPdfSize = data.sysPdfSize || [];
+
+      this.menus = menus
+        .filter(item => !needHideModules.includes(item.url))
+        .map(item => {
+          item.parentId = null;
+          return item;
+        });
+
+      this.$nextTick(() => {
+        this.$refs.PrivilegeSet.buildTableData([]);
+      });
+    },
+    async search() {
+      if (!this.schoolId) return;
+      this.fetching = true;
+      const data = await schoolSelectedMenuTree(this.schoolId).catch(() => {});
+      this.fetching = false;
+
+      this.modalForm.pdfSize = data.pdfSize || [...this.sysPdfSize];
+      const privilegeIds = data.privilegeIdList || [];
+      this.$refs.PrivilegeSet.buildTableData(privilegeIds);
+    },
+    async save() {
+      if (!this.schoolId) {
+        this.$message.error("学校必须选择!");
+        return;
+      }
+      if (!this.modalForm.pdfSize.length) {
+        this.$message.error("PDF格式必须选择!");
+        return;
+      }
+      if (this.loading) return;
+
+      this.loading = true;
+      const privilegeIds = this.$refs.PrivilegeSet.getSelectedPrivilegeIds();
+      const res = await updateSchoolMenu({
+        schoolId: this.schoolId,
+        privilegeIds: privilegeIds,
+        ...this.modalForm
+      });
+      this.loading = false;
+      if (!res) return;
+
+      this.$message.success("修改成功!");
+    }
+  }
+};
+</script>

+ 228 - 222
src/modules/base/components/PrivilegeSet.vue

@@ -1,222 +1,228 @@
-<template>
-  <div class="privilege-set">
-    <table class="table">
-      <tr>
-        <th v-for="(item, index) in tableHead" :key="index">{{ item }}</th>
-      </tr>
-      <tr v-for="row in tableData" :key="row.id">
-        <td v-for="(col, cindex) in row.columns" :key="cindex">
-          <div v-if="col && col.type === 'page'">{{ col.name }}</div>
-          <div v-else-if="col && col.type === 'page-checkbox'">
-            <el-checkbox
-              v-model="row.enable"
-              @change="enable => pageSelectChange(row, enable)"
-            ></el-checkbox>
-          </div>
-          <div v-else-if="col && col.type">
-            <div
-              class="cell-check-list"
-              v-for="item in col.datas"
-              :key="item.field"
-            >
-              <el-checkbox
-                v-model="item.enable"
-                @change="enable => typeSelectChange(row, enable)"
-                >{{ item.name }}</el-checkbox
-              >
-            </div>
-          </div>
-          <div v-else></div>
-        </td>
-      </tr>
-    </table>
-  </div>
-</template>
-
-<script>
-export default {
-  name: "privilege-set",
-  props: {
-    menus: {
-      type: Array,
-      default() {
-        return [];
-      }
-    }
-  },
-  data() {
-    return {
-      maxDeep: 0,
-      tableData: [],
-      tableHead: []
-    };
-  },
-  created() {
-    this.initData();
-  },
-  methods: {
-    initData() {
-      this.maxDeep = this.getNavsDeep();
-      this.tableHead = this.buildTableHead();
-      // this.buildTableData();
-    },
-    getNavsDeep() {
-      let maxDeep = 0;
-      const getDeep = (navs, deep) => {
-        ++deep;
-        navs.forEach(nav => {
-          if (maxDeep < deep) maxDeep = deep;
-
-          if (nav.children && nav.children.length) getDeep(nav.children, deep);
-        });
-      };
-      getDeep(this.menus, maxDeep);
-
-      return maxDeep;
-    },
-    buildTableHead() {
-      let headers = [];
-      let codes = ["一", "二", "三", "四", "五", "六", "七", "八"];
-      for (let index = 0; index < this.maxDeep; index++) {
-        headers.push(`${codes[index]}级页面`);
-      }
-      headers = [
-        ...headers,
-        "页面",
-        "查询条件",
-        "功能按钮",
-        "列表展示",
-        "操作列"
-      ];
-      return headers;
-    },
-    buildTableData(privilegeIds = []) {
-      let tableData = [];
-      let tableColumnCount = this.maxDeep + 5;
-      const pageSetTypes = ["conditions", "buttons", "lists", "links"];
-      const buildData = (navs, deep) => {
-        ++deep;
-        navs.forEach(nav => {
-          let columns = new Array(tableColumnCount);
-          columns[deep - 1] = { type: "page", name: nav.name };
-          columns[this.maxDeep] = {
-            type: "page-checkbox"
-          };
-
-          const isPage = pageSetTypes.some(
-            type => nav[type] && nav[type].length
-          );
-          if (isPage) {
-            pageSetTypes.forEach((type, index) => {
-              const datas = !nav[type]
-                ? []
-                : nav[type].map(elem => {
-                    let data = { ...elem };
-                    data.enable = privilegeIds.includes(elem.id);
-                    return data;
-                  });
-              columns[this.maxDeep + index + 1] = { type, datas };
-            });
-          }
-
-          tableData.push({
-            id: nav.id,
-            name: nav.name,
-            enable: privilegeIds.includes(nav.id),
-            type: nav.type,
-            parentId: nav.parentId,
-            isPage,
-            columns
-          });
-
-          if (nav.children && nav.children.length)
-            buildData(nav.children, deep);
-        });
-      };
-      buildData(this.menus, 0);
-
-      this.tableData = tableData;
-    },
-    getSelectedPrivilegeIds() {
-      let privilegeIds = [];
-      this.tableData
-        .filter(row => row.enable)
-        .forEach(row => {
-          privilegeIds.push(row.id);
-          row.columns.forEach(column => {
-            if (column.type === "page" || column.type === "page-checkbox")
-              return;
-
-            column.datas.forEach(item => {
-              if (item.enable) privilegeIds.push(item.id);
-            });
-          });
-        });
-      return privilegeIds;
-    },
-    // set change
-    pageSelectChange(row, enable) {
-      this.changRowColumnEnable(row, enable);
-      this.changeParentNodeSelected(row.parentId, enable);
-      this.changeChildrenNodeSelected(row.id, enable);
-    },
-    typeSelectChange(row, enable) {
-      if (!row.enable && enable) {
-        row.enable = enable;
-        this.changeParentNodeSelected(row.parentId, enable);
-        this.changeChildrenNodeSelected(row.id, enable);
-      }
-    },
-    changRowColumnEnable(row, enable) {
-      if (!row.isPage) return;
-      row.columns.forEach(column => {
-        if (column.type === "page" || column.type === "page-checkbox") return;
-
-        column.datas.forEach(item => {
-          item.enable = enable;
-        });
-      });
-    },
-    changeParentNodeSelected(parentId, enable) {
-      if (!parentId) return;
-      let curParentId = parentId;
-      if (enable) {
-        while (curParentId) {
-          let curParentNode = this.tableData.find(
-            row => row.id === curParentId
-          );
-          curParentNode.enable = enable;
-          curParentId = curParentNode.parentId;
-          this.changRowColumnEnable(curParentNode, enable);
-        }
-      } else {
-        while (curParentId) {
-          let curParentNode = this.tableData.find(
-            row => row.id === curParentId
-          );
-          let childrenHasOneSelected = this.tableData
-            .filter(row => row.parentId === curParentId)
-            .some(row => row.enable);
-          curParentNode.enable = childrenHasOneSelected;
-          curParentId = curParentNode.parentId;
-          this.changRowColumnEnable(curParentNode, enable);
-        }
-      }
-    },
-    changeChildrenNodeSelected(id, enable) {
-      if (!id) return;
-      let curIds = [id];
-      while (curIds.length) {
-        const validNodes = this.tableData.filter(row =>
-          curIds.includes(row.parentId)
-        );
-        validNodes.forEach(row => {
-          row.enable = enable;
-          this.changRowColumnEnable(row, enable);
-        });
-        curIds = validNodes.map(row => row.id);
-      }
-    }
-  }
-};
-</script>
+<template>
+  <div class="privilege-set">
+    <table class="table">
+      <colgroup>
+        <col width="100" />
+        <col width="100" />
+      </colgroup>
+      <tbody>
+        <tr>
+          <th v-for="(item, index) in tableHead" :key="index">{{ item }}</th>
+        </tr>
+        <tr v-for="row in tableData" :key="row.id">
+          <td v-for="(col, cindex) in row.columns" :key="cindex">
+            <div v-if="col && col.type === 'page'">{{ col.name }}</div>
+            <div v-else-if="col && col.type === 'page-checkbox'">
+              <el-checkbox
+                v-model="row.enable"
+                @change="enable => pageSelectChange(row, enable)"
+              ></el-checkbox>
+            </div>
+            <div v-else-if="col && col.type">
+              <div
+                class="cell-check-list"
+                v-for="item in col.datas"
+                :key="item.field"
+              >
+                <el-checkbox
+                  v-model="item.enable"
+                  @change="enable => typeSelectChange(row, enable)"
+                  >{{ item.name }}</el-checkbox
+                >
+              </div>
+            </div>
+            <div v-else></div>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "privilege-set",
+  props: {
+    menus: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  data() {
+    return {
+      maxDeep: 0,
+      tableData: [],
+      tableHead: []
+    };
+  },
+  created() {
+    this.initData();
+  },
+  methods: {
+    initData() {
+      this.maxDeep = this.getNavsDeep();
+      this.tableHead = this.buildTableHead();
+      // this.buildTableData();
+    },
+    getNavsDeep() {
+      let maxDeep = 0;
+      const getDeep = (navs, deep) => {
+        ++deep;
+        navs.forEach(nav => {
+          if (maxDeep < deep) maxDeep = deep;
+
+          if (nav.children && nav.children.length) getDeep(nav.children, deep);
+        });
+      };
+      getDeep(this.menus, maxDeep);
+
+      return maxDeep;
+    },
+    buildTableHead() {
+      let headers = [];
+      let codes = ["一", "二", "三", "四", "五", "六", "七", "八"];
+      for (let index = 0; index < this.maxDeep; index++) {
+        headers.push(`${codes[index]}级页面`);
+      }
+      headers = [
+        ...headers,
+        "页面",
+        "查询条件",
+        "功能按钮",
+        "列表展示",
+        "操作列"
+      ];
+      return headers;
+    },
+    buildTableData(privilegeIds = []) {
+      let tableData = [];
+      let tableColumnCount = this.maxDeep + 5;
+      const pageSetTypes = ["conditions", "buttons", "lists", "links"];
+      const buildData = (navs, deep) => {
+        ++deep;
+        navs.forEach(nav => {
+          let columns = new Array(tableColumnCount);
+          columns[deep - 1] = { type: "page", name: nav.name };
+          columns[this.maxDeep] = {
+            type: "page-checkbox"
+          };
+
+          const isPage = pageSetTypes.some(
+            type => nav[type] && nav[type].length
+          );
+          if (isPage) {
+            pageSetTypes.forEach((type, index) => {
+              const datas = !nav[type]
+                ? []
+                : nav[type].map(elem => {
+                    let data = { ...elem };
+                    data.enable = privilegeIds.includes(elem.id);
+                    return data;
+                  });
+              columns[this.maxDeep + index + 1] = { type, datas };
+            });
+          }
+
+          tableData.push({
+            id: nav.id,
+            name: nav.name,
+            enable: privilegeIds.includes(nav.id),
+            type: nav.type,
+            parentId: nav.parentId,
+            isPage,
+            columns
+          });
+
+          if (nav.children && nav.children.length)
+            buildData(nav.children, deep);
+        });
+      };
+      buildData(this.menus, 0);
+
+      this.tableData = tableData;
+    },
+    getSelectedPrivilegeIds() {
+      let privilegeIds = [];
+      this.tableData
+        .filter(row => row.enable)
+        .forEach(row => {
+          privilegeIds.push(row.id);
+          row.columns.forEach(column => {
+            if (column.type === "page" || column.type === "page-checkbox")
+              return;
+
+            column.datas.forEach(item => {
+              if (item.enable) privilegeIds.push(item.id);
+            });
+          });
+        });
+      return privilegeIds;
+    },
+    // set change
+    pageSelectChange(row, enable) {
+      this.changRowColumnEnable(row, enable);
+      this.changeParentNodeSelected(row.parentId, enable);
+      this.changeChildrenNodeSelected(row.id, enable);
+    },
+    typeSelectChange(row, enable) {
+      if (!row.enable && enable) {
+        row.enable = enable;
+        this.changeParentNodeSelected(row.parentId, enable);
+        this.changeChildrenNodeSelected(row.id, enable);
+      }
+    },
+    changRowColumnEnable(row, enable) {
+      if (!row.isPage) return;
+      row.columns.forEach(column => {
+        if (column.type === "page" || column.type === "page-checkbox") return;
+
+        column.datas.forEach(item => {
+          item.enable = enable;
+        });
+      });
+    },
+    changeParentNodeSelected(parentId, enable) {
+      if (!parentId) return;
+      let curParentId = parentId;
+      if (enable) {
+        while (curParentId) {
+          let curParentNode = this.tableData.find(
+            row => row.id === curParentId
+          );
+          curParentNode.enable = enable;
+          curParentId = curParentNode.parentId;
+          this.changRowColumnEnable(curParentNode, enable);
+        }
+      } else {
+        while (curParentId) {
+          let curParentNode = this.tableData.find(
+            row => row.id === curParentId
+          );
+          let childrenHasOneSelected = this.tableData
+            .filter(row => row.parentId === curParentId)
+            .some(row => row.enable);
+          curParentNode.enable = childrenHasOneSelected;
+          curParentId = curParentNode.parentId;
+          this.changRowColumnEnable(curParentNode, enable);
+        }
+      }
+    },
+    changeChildrenNodeSelected(id, enable) {
+      if (!id) return;
+      let curIds = [id];
+      while (curIds.length) {
+        const validNodes = this.tableData.filter(row =>
+          curIds.includes(row.parentId)
+        );
+        validNodes.forEach(row => {
+          row.enable = enable;
+          this.changRowColumnEnable(row, enable);
+        });
+        curIds = validNodes.map(row => row.id);
+      }
+    }
+  }
+};
+</script>