Răsfoiți Sursa

修改所有的勾选导出逻辑,采用前端导出表格数据

lph 1 an în urmă
părinte
comite
e681125257

+ 165 - 0
zkqy-ui/src/components/ExcelDownLoad/index.vue

@@ -0,0 +1,165 @@
+<template>
+  <div id="app">
+    <download-excel
+      class="export-excel-wrapper"
+      :data="json_data"
+      :fields="headerList"
+      type="xlsx"
+      :title="excelTitle"
+      :name="fileName"
+    >
+      <el-button
+        type="warning"
+        plain
+        icon="el-icon-download"
+        size="mini"
+        v-hasPermi="['system:process:export']"
+      >
+        导出已选
+      </el-button>
+    </download-excel>
+  </div>
+</template>
+<script>
+import moment from "moment";
+export default {
+  name: "ExcelDownLoad",
+  props: ["headerList", "fieldList", "excelTitle"],
+  data() {
+    return {
+      fileName: "",
+      json_data: [], //导出的数据
+      json_fields: {}, // 转化导出的字段名
+    };
+  },
+  watch: {
+    dataList: {
+      handler(val) {
+        let temp = JSON.parse(JSON.stringify(val));
+        this.json_data = this.dataHandler(temp);
+      },
+      immediate: true,
+      deep: true,
+    },
+  },
+  computed: {
+    dataList() {
+      return this.fieldList || [];
+    },
+  },
+  methods: {
+    dataHandler(list) {
+      console.log("list", list);
+      this.fileName = this.excelTitle + "_" + new Date().getTime() + ".xlsx";
+      switch (this.excelTitle) {
+        case "process":
+          list.forEach((item) => {
+            item.processType == "0"
+              ? (item.processType = "OA类型")
+              : (item.processType = "mes类型");
+            if (item.processDeployTime) {
+              let date = new Date(item.processDeployTime);
+              item.processDeployTime = moment(date).format("YYYY-MM-DD") || "";
+            }
+            // 版本状态
+            item.processVersion == 0
+              ? (item.processVersion = "最新版本")
+              : (item.processVersion = "历史版本");
+          });
+          break;
+        case "form":
+          list.forEach((item) => {
+            item.dfHtmlTemplate = item.dfHtmlTemplate.replace(/\n/g, "");
+            console.log(item.dfHtmlTemplate);
+          });
+          break;
+        case "tenant":
+          list.forEach((item) => {
+            item.isDel = item.isDel == 0 ? "未删除" : "已删除";
+          });
+          break;
+        case "user":
+          list.forEach((item) => {
+            item.sex = item.sex == 0 ? "男" : item.sex == 1 ? "女" : "未知";
+            item.status = item.status == 0 ? "正常" : "禁用";
+            item.loginDate = moment(new Date(item.loginDate)).format(
+              "YYYY-MM-DD HH:mm:ss"
+            );
+            item.deptName = item.dept?.deptName;
+            item.leader = item.dept?.leader;
+          });
+          break;
+        case "role":
+          list.forEach((item) => {
+            switch (item.dataScope) {
+              case "1":
+                item.dataScope = "所有数据权限";
+                break;
+              case "2":
+                item.dataScope = "自定义数据权限";
+                break;
+              case "3":
+                item.dataScope = "本部门数据权限";
+                break;
+              case "4":
+                item.dataScope = "本部门及以下数据权限";
+                break;
+              case "5":
+                item.dataScope = "仅本人数据权限";
+                break;
+              default:
+                break;
+            }
+            item.status = item.status == 0 ? "正常" : "停用";
+          });
+          break;
+        case "post":
+          list.forEach((item) => {
+            item.status = item.status == 0 ? "正常" : "停用";
+          });
+          break;
+        case "type":
+          list.forEach((item) => {
+            item.status = item.status == 0 ? "正常" : "停用";
+          });
+          break;
+        case "config":
+          list.forEach((item) => {
+            item.configType = item.configType == "Y" ? "是" : "否";
+          });
+          break;
+        case "style":
+          list.forEach((item) => {
+            item.styleStatus = item.styleStatus == "0" ? "正常" : "停用";
+          });
+          break;
+        case "job":
+          list.forEach((item) => {
+            switch (item.misfirePolicy) {
+              case "0":
+                item.misfirePolicy = "默认";
+                break;
+              case "1":
+                item.misfirePolicy = "立即触发执行";
+                break;
+              case "2":
+                item.misfirePolicy = "触发一次执行";
+                break;
+              case "3":
+                item.misfirePolicy = "不触发立即执行";
+                break;
+              default:
+                item.misfirePolicy = "未知";
+            }
+            item.concurrent = item.concurrent == 0 ? "允许" : "禁止";
+            item.status = item.status == 0 ? "正常" : "暂停";
+          });
+          break;
+        default:
+          break;
+      }
+      return list;
+    },
+  },
+};
+</script>

+ 2 - 0
zkqy-ui/src/main.js

@@ -85,6 +85,7 @@ import JsonExcel from 'vue-json-excel'
 import Directives from '@/utils/directives'
 // import './mock.js'
 
+
 // 全局方法挂载
 Vue.prototype.getDicts = getDicts
 Vue.prototype.getConfigKey = getConfigKey
@@ -118,6 +119,7 @@ Object.keys(Directives).forEach(item => {
 })
 
 
+
 /**
  * If you don't want to use mock-server
  * you want to use MockJs for mock api

+ 27 - 2
zkqy-ui/src/views/bpmprocess/index.vue

@@ -111,12 +111,19 @@
         <el-button
           type="warning"
           plain
+          v-if="selection.length == 0"
           icon="el-icon-download"
           size="mini"
           @click="handleExport"
           v-hasPermi="['system:process:export']"
-          >导出
+          >导出所有
         </el-button>
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -353,13 +360,31 @@ import {
   enableProcess,
 } from "@/api/bpmprocess/process";
 import Preview from "./components/preview.vue";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Process",
   dicts: ["bpm_state", "bpm_type", "bpm_start_event_type", "bpm_version"],
-  components: { Preview },
+  components: { Preview, ExcelDownLoad },
   data() {
     return {
+      // 前端导出数据
+      headerList: {
+        流程名称: "processName",
+        流程别名: "processKey",
+        流程开启状态: "processOpenState",
+        流程类型: "processType",
+        流程部署时间: "processDeployTime",
+        启动事件类型: "startEventType",
+        版本注释: "note",
+        版本状态: "processVersion",
+        xml流文件: "processXml",
+        节点ison串: "processJson",
+        xml标签内容: "processXmlContent",
+        xml文件存放地址: "processXmlPath",
+      },
+      // fieldList: [],
+      excelTitle: "process",
       // 预览的数据
       previewData: {},
       // 预览弹窗

+ 24 - 2
zkqy-ui/src/views/dragform/index.vue

@@ -132,6 +132,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -139,6 +140,12 @@
           @click="handleExport"
           >导出
         </el-button>
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
@@ -361,12 +368,27 @@
 
 <script>
 import { delForm, addForm, updateForm, listForm } from "@/api/dragform/form";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 // import fromModel from '../system/fromModel/index.vue'
 export default {
   name: "Form",
-
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      headerList: {
+        sql编号: "sqlKey",
+        表单名称: "dfName",
+        表单别名: "dfNickName",
+        表单vue模板: "dfVueTemplate",
+        表单html模版: "dfHtmlTemplate",
+        表单sql: "dfFormSql",
+        节点ID: "dfNodeId",
+        数据源名称: "dfDatabase",
+      },
+      excelTitle: "form",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -475,7 +497,7 @@ export default {
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map((item) => item.fId);
-      this, (selection = selection);
+      this.selection = selection;
       this.single = selection.length !== 1;
       this.multiple = !selection.length;
     },

+ 32 - 6
zkqy-ui/src/views/dragform/tableList.vue

@@ -73,6 +73,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -80,6 +81,12 @@
           @click="handleExport"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
@@ -224,15 +231,32 @@
 </template>
 <script>
 import { listTable, removeTableList } from "@/api/dragform/tableList";
-import { delStatistic } from "@/api/tablelist/commonTable"
+import { delStatistic } from "@/api/tablelist/commonTable";
 import { delMenu } from "@/api/system/menu";
 import { mapGetters } from "vuex";
 import DictData from "@/components/DictData";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Table",
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      headerList: {
+        表格名称: "dtName",
+        表格类型: "dtType",
+        表格别名: "dtNickname",
+        table编号: "tableKey",
+        sql编号: "sqlKey",
+        绑定表名称: "dtTableName",
+        表格描述: "dtNotes",
+        列字段标题名称: "dtColumnName",
+        时间格式: "timeFormat",
+      },
+      excelTitle: "表格列表",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -351,7 +375,7 @@ export default {
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map((item) => item.tId);
-      this.tableKeys = selection.map((item) =>item.tableKey);
+      this.tableKeys = selection.map((item) => item.tableKey);
       this.Keys = selection.map((item) => item.sqlKey);
       this.menuIds = selection.map((item) => item.menuId);
       this.selection = selection;
@@ -432,11 +456,11 @@ export default {
         )
         .then(async function () {
           let res = await delMenu(menuIdList);
-          // await delStatistic(row.tableKey) 
+          // await delStatistic(row.tableKey)
 
           //  await removeTableList(data);
 
-          if (res.code == 200) { 
+          if (res.code == 200) {
             await removeTableList(data);
           } else {
             return Promise.reject();
@@ -462,11 +486,13 @@ export default {
         })
         .then(() => {
           this.getList();
-          this.tempSelection = []
+          this.tempSelection = [];
           this.reloadRouter();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch((e) => {console.log(e);});
+        .catch((e) => {
+          console.log(e);
+        });
     },
     // 更新路由
     reloadRouter() {

+ 23 - 1
zkqy-ui/src/views/monitor/job/index.vue

@@ -95,6 +95,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -103,6 +104,12 @@
           v-hasPermi="['monitor:job:export']"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -455,13 +462,27 @@ import {
   changeJobStatus,
 } from "@/api/monitor/job";
 import Crontab from "@/components/Crontab";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
-  components: { Crontab },
+  components: { Crontab, ExcelDownLoad },
   name: "Job",
   dicts: ["sys_job_group", "sys_job_status"],
   data() {
     return {
+      // 前端导出数据
+      selection: [],
+      headerList: {
+        任务序号: "jobId",
+        任务名称: "jobName",
+        任务组名: "jobGroup",
+        调用目标字符串: "invokeTarget",
+        执行表达式: "cronExpression",
+        计划策略: "misfirePolicy",
+        并发执行: "concurrent",
+        任务状态: "status",
+      },
+      excelTitle: "job",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -566,6 +587,7 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
+      this.selection = selection;
       this.ids = selection.map((item) => item.jobId);
       this.single = selection.length != 1;
       this.multiple = !selection.length;

+ 22 - 0
zkqy-ui/src/views/system/config/index.vue

@@ -102,6 +102,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -110,6 +111,12 @@
           v-hasPermi="['system:config:export']"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -284,12 +291,26 @@ import {
   updateConfig,
   refreshCache,
 } from "@/api/system/config";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Config",
   dicts: ["sys_yes_no"],
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      selection: [],
+      headerList: {
+        参数主键: "configId",
+        参数名称: "configName",
+        参数键名: "configKey",
+        参数键值: "configValue",
+        系统内置: "configType",
+      },
+      excelTitle: "config",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -388,6 +409,7 @@ export default {
       this.ids = selection.map((item) => item.configId);
       this.single = selection.length != 1;
       this.multiple = !selection.length;
+      this.selection = selection;
     },
     /** 修改按钮操作 */
     handleUpdate(row) {

+ 21 - 0
zkqy-ui/src/views/system/dict/index.vue

@@ -104,6 +104,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -112,6 +113,12 @@
           v-hasPermi="['system:dict:export']"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -285,12 +292,25 @@ import {
   updateType,
   refreshCache,
 } from "@/api/system/dict/type";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Dict",
   dicts: ["sys_normal_disable"],
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      selection: [],
+      headerList: {
+        字典主键: "dictId",
+        字典名称: "dictName",
+        字典类型: "dictType",
+        状态: "status",
+      },
+      excelTitle: "type",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -385,6 +405,7 @@ export default {
       this.ids = selection.map((item) => item.dictId);
       this.single = selection.length != 1;
       this.multiple = !selection.length;
+      this.selection = selection;
     },
     /** 修改按钮操作 */
     handleUpdate(row) {

+ 18 - 0
zkqy-ui/src/views/system/post/index.vue

@@ -90,6 +90,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -98,6 +99,12 @@
           v-hasPermi="['system:post:export']"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
@@ -248,12 +255,23 @@ import {
   addPost,
   updatePost,
 } from "@/api/system/post";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Post",
   dicts: ["sys_normal_disable"],
+  components: { ExcelDownLoad },
   data() {
     return {
+      // 前端导出数据
+      headerList: {
+        岗位序号: "postId",
+        岗位编码: "postCode",
+        岗位名称: "postName",
+        岗位排序: "postSort",
+        状态: "status",
+      },
+      excelTitle: "post",
       // 遮罩层
       loading: true,
       // 选中数组

+ 21 - 0
zkqy-ui/src/views/system/role/index.vue

@@ -112,6 +112,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -120,6 +121,12 @@
           v-hasPermi="['system:role:export']"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
@@ -423,12 +430,26 @@ import {
   treeselect as menuTreeselect,
   roleMenuTreeselect,
 } from "@/api/system/menu";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Role",
   dicts: ["sys_normal_disable"],
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      excelTitle: "role",
+      headerList: {
+        角色序号: "roleId",
+        角色名称: "roleName",
+        角色权限: "roleKey",
+        角色排序: "roleSort",
+        数据范围: "dataScope",
+        角色状态: "status",
+      },
       // 遮罩层
       loading: true,
       // 选中数组

+ 23 - 0
zkqy-ui/src/views/system/tenant/index.vue

@@ -99,6 +99,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -107,6 +108,12 @@
           v-hasPermi="['system:tenant:export']"
           >导出
         </el-button>
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
         <!-- <el-button
           type="warning"
           plain
@@ -374,6 +381,7 @@ import {
 import { getDataSourceInfo, insertDataSource } from "@/api/system/data";
 import { servicesLoading } from "@/utils/zkqy";
 import { getIsExistUser } from "@/api/system/user";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "Tenant",
@@ -384,8 +392,22 @@ export default {
     "dm_connection_information",
     "orcale_connection_information",
   ],
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      selection: [],
+      headerList: {
+        租户名称: "tenantName",
+        租户编号: "tenantCode",
+        负责人: "owner",
+        联系方式: "contactInfo",
+        地址: "address",
+        是否删除: "isDel",
+      },
+      excelTitle: "tenant",
       // 弹窗的加载提示
       dialogLoading: false,
       // 遮罩层
@@ -639,6 +661,7 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
+      this.selection = selection;
       this.ids = selection.map((item) => item.tenantId);
       this.single = selection.length !== 1;
       this.multiple = !selection.length;

+ 25 - 1
zkqy-ui/src/views/system/user/index.vue

@@ -153,6 +153,7 @@
           </el-col>
           <el-col :span="1.5">
             <el-button
+              v-if="selection.length == 0"
               type="warning"
               plain
               icon="el-icon-download"
@@ -161,6 +162,12 @@
               v-hasPermi="['system:user:export']"
               >导出</el-button
             >
+            <ExcelDownLoad
+              v-else
+              :headerList="headerList"
+              :fieldList="selection"
+              :excelTitle="excelTitle"
+            ></ExcelDownLoad>
           </el-col>
           <right-toolbar
             :showSearch.sync="showSearch"
@@ -568,13 +575,30 @@ import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import { mapGetters } from "vuex";
 import { getIsExistUser } from "@/api/system/user";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "User",
   dicts: ["sys_normal_disable", "sys_user_sex"],
-  components: { Treeselect },
+  components: { Treeselect, ExcelDownLoad },
   data() {
     return {
+      // 前端导出数据
+      headerList: {
+        用户序号: "userId",
+        部门编号: "deptId",
+        登录名称: "userName",
+        用户名称: "nickName",
+        用户邮箱: "email",
+        手机号码: "phonenumber",
+        用户性别: "sex",
+        帐号状态: "status",
+        最后登录IP: "loginIp",
+        最后登录时间: "loginDate",
+        部门名称: "deptName",
+        部门负责人: "leader",
+      },
+      excelTitle: "user",
       // 遮罩层
       loading: true,
       // 选中数组

+ 25 - 0
zkqy-ui/src/views/tableMange/styleMange/index.vue

@@ -100,6 +100,7 @@
       </el-col>
       <el-col :span="1.5">
         <el-button
+          v-if="selection.length == 0"
           type="warning"
           plain
           icon="el-icon-download"
@@ -108,6 +109,12 @@
           v-hasPermi="['system:style:export']"
           >导出</el-button
         >
+        <ExcelDownLoad
+          v-else
+          :headerList="headerList"
+          :fieldList="selection"
+          :excelTitle="excelTitle"
+        ></ExcelDownLoad>
       </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
@@ -247,12 +254,29 @@ import {
 } from "@/api/system/style";
 import { getDictLabel } from "@/utils/other";
 import * as monaco from "monaco-editor";
+import ExcelDownLoad from "@/components/ExcelDownLoad/index.vue";
 
 export default {
   name: "StyleMange",
   dicts: ["table_style_type"],
+  components: {
+    ExcelDownLoad,
+  },
   data() {
     return {
+      // 前端导出数据
+      selection: [],
+      headerList: {
+        样式key: "styleKey",
+        样式名称: "styleName",
+        样式类型: "styleType",
+        样式代码: "styleCode",
+        样式描述: "styleDescription",
+        样式状态: "styleStatus",
+        创建者ID: "createById",
+        更新者ID: "updateById",
+      },
+      excelTitle: "style",
       // 遮罩层
       loading: true,
       // 选中数组
@@ -356,6 +380,7 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
+      this.selection = selection;
       this.ids = selection.map((item) => item.id);
       this.single = selection.length !== 1;
       this.multiple = !selection.length;