{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-bpm\\src\\views\\meta\\DataDicManager.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\src\\views\\meta\\DataDicManager.vue","mtime":1675071993006},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-bpm\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\r\nimport form from \"@/api/form.js\";\r\nimport styles from \"@/assets/css/element-variables.scss\";\r\nconst EipSysTypeSelector = () =>\r\n  import(\"@/components/selector/EipSysTypeSelector.vue\");\r\nimport portalApi from \"@/api/portal.js\";\r\nimport req from \"@/request.js\"\r\nconst htSysTypeTree = () => import(\"@/components/common/HtSysTypeTree.vue\");\r\nexport default {\r\n  components: {\r\n    EipSysTypeSelector,\r\n    htSysTypeTree\r\n  },\r\n  props: {\r\n    width: {\r\n      type: String,\r\n      default: styles.aside_width\r\n    },\r\n    supportFilter: {\r\n      type: Boolean,\r\n      default: true\r\n    }\r\n  },\r\n  data() {\r\n    return {\r\n      dicData: {\r\n        key: \"\",\r\n        name: \"\",\r\n        parentId: \"\",\r\n        typeId: \"\"\r\n      },\r\n      dicParentId: \"\", //存储数据字典父类id用于刷新数据字典树\r\n      title: \"添加数据字典分类\",\r\n      dicTitle: \"添加数据字典\",\r\n      asideShow: true,\r\n      isExpand: true,\r\n      isExpandDic: true,\r\n      dialogVisible: false,\r\n      dicDialogVisible: false,\r\n      dialogImportVisible:false,\r\n      fullscreenLoading: false,\r\n      fileList: [],\r\n      sysType: {\r\n        children: [],\r\n        icon: \"{}\",\r\n        isLeaf: \"N\",\r\n        struType: 0,\r\n        typeKey: \"\",\r\n        name: \"\"\r\n      },\r\n      parentSysType: {\r\n        name: \"\"\r\n      },\r\n      treeData: [],\r\n      defaultProps: {\r\n        children: \"children\",\r\n        label: \"name\"\r\n      },\r\n      data: [],\r\n      pageResult: {\r\n        page: 1,\r\n        pageSize: 20,\r\n        total: 0\r\n      },\r\n      bpmForm: {\r\n        key: \"\",\r\n        bos: \"\",\r\n        desc: \"\"\r\n      },\r\n      dicDatas: []\r\n    };\r\n  },\r\n  computed: {\r\n    formDeleteUrl: function() {\r\n      return `${window.context.uc}/form/form/v1/remove`;\r\n    },\r\n    navbarCollapseStyle: function() {\r\n      if (this.asideShow) {\r\n        return { left: parseInt(this.width) + \"px\" };\r\n      }\r\n      return { left: \"0px\" };\r\n    },\r\n    saveSysTypeUrl: function() {\r\n      return `${window.context.portal}/sys/sysType/v1/save?parentId=${\r\n        this.parentSysType.id\r\n      }&isRoot=${this.parentSysType.parentId == 0 ? 1 : 0}&isPriNode=0`;\r\n    },\r\n    saveDicDataUrl: function() {\r\n      return `${window.context.portal}/sys/dataDict/v1/save`;\r\n    },\r\n    importUrl: function() {\r\n      return window.context.portal + \"/sys/dataDict/v1/import\";\r\n    }\r\n  },\r\n  mounted() {},\r\n  methods: {\r\n    formatTreeData(jsonData) {\r\n      var result = [],\r\n        temp = {},\r\n        i = 0,\r\n        j = 0,\r\n        len = jsonData.length;\r\n      for (; i < len; i++) {\r\n        temp[jsonData[i][\"id\"]] = jsonData[i]; // 以id作为索引存储元素，可以无需遍历直接定位元素\r\n      }\r\n      for (; j < len; j++) {\r\n        var currentElement = jsonData[j];\r\n        var tempCurrentElementParent = temp[currentElement[\"parentId\"]]; // 临时变量里面的当前元素的父元素\r\n        if (tempCurrentElementParent) {\r\n          // 如果存在父元素\r\n          if (!tempCurrentElementParent[\"children\"]) {\r\n            // 如果父元素没有chindren键\r\n            tempCurrentElementParent[\"children\"] = []; // 设上父元素的children键\r\n          }\r\n          tempCurrentElementParent[\"children\"].push(currentElement); // 给父元素加上当前元素作为子元素\r\n        } else {\r\n          // 不存在父元素，意味着当前元素是一级元素\r\n          result.push(currentElement);\r\n        }\r\n      }\r\n      return result;\r\n    },\r\n    handleNodeClick(node) {\r\n      this.dicLoadData(node.id);\r\n    },\r\n    dicLoadData(id) {\r\n      portalApi.getByTypeId(id).then(data => {\r\n        if (data) {\r\n          //数据转换成树 children格式\r\n          this.dicParentId = id;\r\n          this.dicDatas = this.formatTreeData(data);\r\n        }\r\n      });\r\n    },\r\n    syncTree() {\r\n      this.$refs.htDataDicTree.loadData();\r\n    },\r\n    syncDicTree() {\r\n      if (this.dicParentId) {\r\n        this.dicLoadData(this.dicParentId);\r\n      }\r\n    },\r\n    handleExpand() {\r\n      this.isExpand = !this.isExpand;\r\n      let elTree = this.$refs.htDataDicTree.$refs.htTree.$refs.elTree;\r\n      for (var i = 0; i < elTree.store._getAllNodes().length; i++) {\r\n        elTree.store._getAllNodes()[i].expanded = this.isExpand;\r\n      }\r\n    },\r\n    handleExpandDic() {\r\n      this.isExpandDic = !this.isExpandDic;\r\n      let elTree = this.$refs.dicDataTree.$refs.elTree;\r\n      for (var i = 0; i < elTree.store._getAllNodes().length; i++) {\r\n        elTree.store._getAllNodes()[i].expanded = this.isExpandDic;\r\n      }\r\n    },\r\n    handleCommand(command) {\r\n      let node = command.node;\r\n      let data = command.data;\r\n      let action = command.action;\r\n      switch (action) {\r\n        case \"add\":\r\n          this.dialogVisible = true;\r\n          this.dicTypeAdd = true;\r\n          if (data) {\r\n            this.sysType.id = \"\";\r\n            this.sysType.name = \"\";\r\n            this.sysType.typeKey = \"\";\r\n            this.parentSysType = data;\r\n            this.sysType.parentId = data.id;\r\n            this.sysType.typeGroupKey =\r\n              data.parentId == 0 ? data.typeKey : data.typeGroupKey;\r\n          }\r\n          break;\r\n        case \"edit\":\r\n          var newDicdata = {};\r\n          this.title = \"编辑数据字典分类\";\r\n          //克隆一个对象 以免数据与树动态绑定\r\n          Object.assign(newDicdata, data);\r\n          this.sysType = newDicdata;\r\n          this.dialogVisible = true;\r\n          break;\r\n        case \"import\":\r\n          var newDicdata = {};\r\n          Object.assign(newDicdata, data);\r\n          this.sysType = newDicdata;\r\n          this.dialogImportVisible = true;\r\n          break;\r\n        case \"delete\":\r\n          if (data.id) {\r\n            let this_ = this;\r\n            this.$confirm(`是否确定删除 [${data.name}]  及其子分类（包含分类下数据字典项数据）?`, \"提示\", {\r\n              confirmButtonText: \"确定\",\r\n              cancelButtonText: \"取消\",\r\n              type: \"warning\"\r\n            }).then(() => {\r\n              this_.$http.get(\"${portal}/sys/dataDict/v1/removeByTypeId?typeIds=\"+data.id)\r\n                .then(\r\n                  resp => {\r\n                    let data = resp.data;\r\n                    if (data.state) {\r\n                      this.$message({\r\n                        type: \"success\",\r\n                        message: data.message || \"删除成功\"\r\n                      });\r\n                      this.$refs.htDataDicTree.loadData();\r\n                      this.dicDatas = null;\r\n                      this.syncDicTree();\r\n                    } else {\r\n                      this.$message.error(data.message || \"删除失败\");\r\n                    }\r\n                  },\r\n                  error => {\r\n                    this.$message.error(error || \"删除失败\");\r\n                  }\r\n                )\r\n                .catch(() => {\r\n                  this.dialogVisible = false;\r\n                });\r\n            });\r\n          }\r\n          break;\r\n        case \"dicAdd\": //数据字典添加\r\n          this.dicTitle = \"添加数据字典\";\r\n          this.dicDialogVisible = true;\r\n          this.dicData.id = \"\";\r\n          this.dicData.name = \"\";\r\n          this.dicData.key = \"\";\r\n          this.dicData.parentId = data.id;\r\n          this.dicData.typeId = data.typeId;\r\n          break;\r\n        case \"dicDelete\":\r\n          if (data.id) {\r\n            this.$confirm(`是否确定删除 [${data.name}] ?`, \"提示\", {\r\n              confirmButtonText: \"确定\",\r\n              cancelButtonText: \"取消\",\r\n              type: \"warning\"\r\n            }).then(() => {\r\n              portalApi\r\n                .delDataDict(data.id)\r\n                .then(\r\n                  data => {\r\n                    if (data.state) {\r\n                      this.$message({\r\n                        type: \"success\",\r\n                        message: data.message || \"删除成功\"\r\n                      });\r\n                      this.syncDicTree();\r\n                    } else {\r\n                      this.$message.error(data.message || \"删除成功\");\r\n                    }\r\n                  },\r\n                  error => {\r\n                    this.$message.error(error || \"删除失败\");\r\n                  }\r\n                )\r\n                .catch(() => {\r\n                  this.dicDialogVisible = false;\r\n                });\r\n            });\r\n          }\r\n          break;\r\n        case \"dicEdit\":\r\n          this.editDic(node.data);\r\n          break;\r\n        case \"export\":\r\n          //导出成excel\r\n          this.exportExcel(node.data);\r\n          break;\r\n        default:\r\n          break;\r\n      }\r\n    },\r\n    editDic(data){\r\n      this.dicTitle = \"编辑数据字典\";\r\n      //克隆一个对象 以免数据与树动态绑定\r\n      this.dicData = {...data};\r\n      this.dicDialogVisible = true;\r\n    },\r\n    handleClose() {\r\n      this.dialogVisible = false;\r\n      this.dicDialogVisible = false;\r\n    },\r\n    afterSaveData() {\r\n      this.$refs.htDataDicTree.loadData();\r\n      if (this.sysType.id) {\r\n        this.dialogVisible = false;\r\n        return;\r\n      }\r\n      this.sysType.name = \"\";\r\n      this.sysType.typeKey = \"\";\r\n      this.$confirm(\"是否继续?\", \"提示\", {\r\n        confirmButtonText: \"确定\",\r\n        cancelButtonText: \"取消\",\r\n        type: \"success\"\r\n      })\r\n        .then(() => {})\r\n        .catch(() => {\r\n          this.dialogVisible = false;\r\n        });\r\n    },\r\n    afterSaveDicData() {\r\n      if (this.dicParentId) {\r\n        this.dicLoadData(this.dicParentId);\r\n      }\r\n      if (this.dicData.id) {\r\n        this.dicDialogVisible = false;\r\n        return;\r\n      }\r\n      this.dicData.name = \"\";\r\n      this.dicData.key = \"\";\r\n      this.$confirm(\"是否继续?\", \"提示\", {\r\n        confirmButtonText: \"确定\",\r\n        cancelButtonText: \"取消\",\r\n        type: \"success\"\r\n      })\r\n        .then(() => {})\r\n        .catch(() => {\r\n          this.dicDialogVisible = false;\r\n        });\r\n    },\r\n    //导入\r\n    importData(param) {\r\n      let formData = new FormData();\r\n      formData.append(\"file\", param.file);\r\n      portalApi.importDataDict(formData, this.sysType.id).then(data => {\r\n        this.fullscreenLoading = false;\r\n        if (data.state) {\r\n          this.$message({ type: \"success\", message: data.message });\r\n          param.onSuccess();\r\n          this.dialogImportVisible = false;\r\n          this.dicLoadData(this.sysType.id);\r\n          this.$refs.upload.clearFiles();\r\n          this.fileList = [];\r\n        } else {\r\n          this.$message.error(data.message);\r\n          param.onError();\r\n        }\r\n      }).catch(() => {\r\n        this.fullscreenLoading = false;\r\n      });\r\n    },\r\n    beforeUpload(file) {\r\n      this.fullscreenLoading = true;\r\n    },\r\n    submitImport() {\r\n      if (\r\n        !this.$refs.upload.uploadFiles ||\r\n        this.$refs.upload.uploadFiles.length == 0\r\n      ) {\r\n        this.$message.warning(\"请上传数据字典文件进行导入\");\r\n        return false;\r\n      }\r\n      if(this.sysType.id && this.sysType.id == \"\"){\r\n        this.$message.warning(\"请选择某一个分类进行导入!\");\r\n      }\r\n      this.$refs.upload.submit();\r\n    },\r\n    cancelConfirm(){\r\n      this.$refs.upload.clearFiles();\r\n      this.fileList = [];\r\n      this.dialogImportVisible = false;\r\n    },\r\n    //下载模板\r\n    downloadTemplate(){\r\n      window.location.href = window.context.manage + '/static/excel/数据字典模板.xls';\r\n    },\r\n    exportExcel(data){\r\n      let id = data.id;\r\n      let url = window.context.portal + \"/sys/dataDict/v1/export?typeId=\"+id;\r\n      req.download(url).then(resp=>{\r\n        if(resp.status == 200){\r\n          this.$message({type:\"success\",message:\"导出成功\"});\r\n        }else{\r\n          this.$message({type:\"error\",message:\"导出失败\"});\r\n        }\r\n      })\r\n\r\n    },\r\n    dicClick(data){\r\n      this.editDic(data);\r\n    }\r\n  }\r\n};\r\n",null]}