{"remainingRequest":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\cssc-fvue\\src\\components\\ImportExportData\\FormatJson.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\cssc-fvue\\src\\components\\ImportExportData\\FormatJson.vue","mtime":1667804638462},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\cssc-fvue\\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\r\nimport utils from '@/hotent-ui-util'\r\nimport SelectDict from '@/components/ImportExportData/SelectDict'\r\nimport SelectRelative from '@/components/ImportExportData/SelectRelative'\r\nimport CustomQuery from '@/components/ImportExportData/CustomQuery.js'\r\nexport default {\r\n name: 'FormatJson',\r\n components: {SelectDict, SelectRelative},\r\n data() {\r\n return {\r\n dialogShow: false,\r\n tableHeight: 300,\r\n currentScope: {},\r\n data: [\r\n {\r\n key: 0,\r\n value: '',\r\n label: '',\r\n },\r\n ],\r\n }\r\n },\r\n mounted() {\r\n this.calcTableHeight()\r\n this.$root.$on('resize', () => {\r\n this.calcTableHeight(500)\r\n })\r\n },\r\n methods: {\r\n getDictData(dictCode) {\r\n if (sessionStorage.getItem('dict_data')) {\r\n let dict_data = JSON.parse(sessionStorage.getItem('dict_data'))\r\n if (dict_data[dictCode]) {\r\n let dictItem = dict_data[dictCode]\r\n // 格式key 是值 value 是显示值\r\n dictItem.forEach((item, index) => {\r\n item.key = dictCode + index\r\n item.value = item.value\r\n item.label = item.name\r\n })\r\n return dictItem\r\n }\r\n }\r\n },\r\n changeDict(dictCode) {\r\n let newDictItems = this.getDictData(dictCode)\r\n if (this.data.length == 1) {\r\n if (!this.data[0].value && !this.data[0].label) {\r\n this.data = newDictItems\r\n }\r\n } else {\r\n this.data = this.data.concat(newDictItems)\r\n }\r\n },\r\n handleOpenDict() {\r\n this.$refs.selectDict.openDialog()\r\n },\r\n changeRelative(row, fields) {\r\n CustomQuery.load(row.alias).then((relativeData) => {\r\n console.log(relativeData, 'relativeData')\r\n this.formatRelativeData(relativeData, fields)\r\n })\r\n },\r\n //加载关联查询数据\r\n formatRelativeData(relativeData, fields) {\r\n let tempData = []\r\n relativeData.forEach((item) => {\r\n tempData.push({\r\n key: item.id,\r\n value: item[fields.value],\r\n label: item[fields.label],\r\n })\r\n })\r\n if (this.data.length == 1) {\r\n if (!this.data[0].value && !this.data[0].label) {\r\n this.data = tempData\r\n }\r\n } else {\r\n this.data = this.data.concat(tempData)\r\n }\r\n },\r\n handleOpenRelative() {\r\n this.$refs.selectRelative.openDialog()\r\n },\r\n handleAdd() {\r\n this.data.push({\r\n key: this.data.length + 1,\r\n value: '',\r\n label: '',\r\n })\r\n },\r\n handleDel(key) {\r\n let dataTemp = utils.deepClone(this.data)\r\n const filterData = dataTemp.filter((item) => item.key !== key)\r\n this.data = filterData\r\n },\r\n openDialog(scope) {\r\n this.dialogShow = true\r\n this.currentScope = scope\r\n this.currentScope.row.fieldDataJson\r\n ? (this.data = JSON.parse(this.currentScope.row.fieldDataJson))\r\n : null\r\n },\r\n formatJson() {\r\n let result\r\n let objValue = {}\r\n let objLabel = {}\r\n this.data.forEach((item, index) => {\r\n if (!item.value) {\r\n item.valueFailed = true\r\n item.valueTips = '请完善数据'\r\n this.$nextTick(() => {\r\n this.$message.warning(`请完善数据!`)\r\n })\r\n } else if (objValue[item.value]) {\r\n item.valueFailed = true\r\n item.valueTips = '字段实际值重复'\r\n this.$nextTick(() => {\r\n this.$message.warning(`字段实际值重复!`)\r\n })\r\n } else if (item.value && !objValue[item.value]) {\r\n objValue[item.value] = true\r\n item.valueFailed = false\r\n item.valueTips = ''\r\n }\r\n\r\n if (!item.label) {\r\n item.labelFailed = true\r\n item.labelTips = '请完善数据'\r\n this.$nextTick(() => {\r\n this.$message.warning(`请完善数据!`)\r\n })\r\n } else if (objLabel[item.label]) {\r\n item.labelFailed = true\r\n item.labelTips = '字段显示值重复'\r\n this.$nextTick(() => {\r\n this.$message.warning(`字段显示值重复!`)\r\n })\r\n } else if (item.label && !objLabel[item.label]) {\r\n objValue[item.label] = true\r\n item.labelFailed = false\r\n item.labelTips = ''\r\n }\r\n\r\n if (!item.labelFailed && !item.valueFailed) {\r\n item.pass = true\r\n } else {\r\n item.pass = false\r\n item.key = new Date().getTime() + index\r\n }\r\n })\r\n let isResultFalse = this.data.some((item) => {\r\n if (!item.pass) {\r\n return true\r\n }\r\n })\r\n console.log(this.data, 'this.data')\r\n if (!isResultFalse) {\r\n result = []\r\n this.data.forEach((item) => {\r\n let tempObj = {\r\n value: item.value,\r\n label: item.label,\r\n }\r\n result.push(tempObj)\r\n })\r\n } else {\r\n this.$forceUpdate()\r\n result = false\r\n }\r\n return result\r\n },\r\n handleOk() {\r\n if (this.data.length) {\r\n let json = this.formatJson()\r\n if (!json) {\r\n return\r\n } else {\r\n this.$emit(\r\n 'getJson',\r\n JSON.stringify(json),\r\n this.currentScope\r\n )\r\n }\r\n } else {\r\n this.$emit('getJson', '', this.currentScope)\r\n }\r\n this.closeDialog()\r\n },\r\n closeDialog() {\r\n this.data = [\r\n {\r\n key: 0,\r\n value: '',\r\n label: '',\r\n },\r\n ]\r\n this.dialogShow = false\r\n },\r\n // 动态计算表格的高度,自适应当前容器\r\n calcTableHeight(delay) {\r\n setTimeout(() => {\r\n this.tableHeight =\r\n document.documentElement.clientHeight * 0.9 - 200\r\n }, delay || 0)\r\n },\r\n },\r\n}\r\n",null]}