From 5b821d0d462b1b3509c8f91d15004f58ac180d2e Mon Sep 17 00:00:00 2001 From: "wu.jian2" Date: Wed, 21 Jun 2023 11:18:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89JS=E6=95=B0=E6=8D=AE=E9=9B=86=EF=BC=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E3=80=81=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsDataSet/index.vue | 8 +-- .../packages/DataSetManagement/src/index.vue | 1 + data-room-ui/packages/PlotRender/index.vue | 60 ++++++++++++------- .../assets/images/alignIcon/export.js | 1 - .../packages/js/mixins/commonMixins.js | 31 +++++++++- 5 files changed, 72 insertions(+), 29 deletions(-) diff --git a/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue b/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue index 0320a2ab..c85e971e 100644 --- a/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue +++ b/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue @@ -353,7 +353,7 @@ import ParamsSettingDialog from './ParamsSettingDialog.vue' import OutputFieldDialog from './OutputFieldDialog.vue' import FieldFillDialog from './FieldFillDialog.vue' -import { nameCheckRepeat, datasetAddorUpdate, getDataset, getDatasetTypeList } from 'packages/js/utils/datasetConfigService' +import { nameCheckRepeat, datasetAdd, datasetUpdate, getDataset, getCategoryTree } from 'packages/js/utils/datasetConfigService' import { codemirror } from 'vue-codemirror' import 'codemirror/mode/javascript/javascript' import 'codemirror/lib/codemirror.css' @@ -457,7 +457,7 @@ export default { }, methods: { async init () { - this.categoryData = await getDatasetTypeList({ tableName: 'r_dataset', moduleCode: this.appCode }) + this.categoryData = await getCategoryTree({ tableName: 'dataset', moduleCode: this.appCode }) if (this.typeId) { this.dataForm.typeId = this.typeId this.$nextTick(() => { @@ -520,8 +520,8 @@ export default { fieldList: outputFieldList } } - // const datasetSave = this.dataForm.id === '' ? datasetAdd : datasetUpdate - datasetAddorUpdate(form).then(() => { + const datasetSave = this.dataForm.id === '' ? datasetAdd : datasetUpdate + datasetSave(form).then(() => { this.$message.success('操作成功') this.$parent.init(false) this.$parent.setType = null diff --git a/data-room-ui/packages/DataSetManagement/src/index.vue b/data-room-ui/packages/DataSetManagement/src/index.vue index 849599a7..68c79302 100644 --- a/data-room-ui/packages/DataSetManagement/src/index.vue +++ b/data-room-ui/packages/DataSetManagement/src/index.vue @@ -200,6 +200,7 @@ /> { if (data.success) { @@ -123,23 +122,23 @@ export default { /** * 更新组件 */ - updateChart () { - if (this.isPreview) { - this.getCurrentOption().then(({ data, config }) => { - if (data.success) { - // 成功后更新数据 - config = this.buildOption(config, data) - this.changeChartConfig(config) - this.chart.update(config.option) - } else { - config.option.data = this.plotList.find(plot => plot.name === config.name)?.option.data - this.chart.update(config.option) - } - }) - } else { - this.updateChartData(this.config) - } - }, + // updateChart () { + // if (this.isPreview) { + // this.getCurrentOption().then(({ data, config }) => { + // if (data.success) { + // // 成功后更新数据 + // config = this.buildOption(config, data) + // this.changeChartConfig(config) + // this.chart.update(config.option) + // } else { + // config.option.data = this.plotList.find(plot => plot.name === config.name)?.option.data + // this.chart.update(config.option) + // } + // }) + // } else { + // this.updateChartData(this.config) + // } + // }, /** * 注册事件 */ @@ -182,7 +181,7 @@ export default { // eslint-disable-next-line no-unused-vars const option = config.option // eslint-disable-next-line no-unused-vars - const setting = config.setting + // const setting = config.setting if (this.config.optionHandler) { try { // 此处函数处理config @@ -225,3 +224,20 @@ export default { } +function generateRandomData() { + const data = []; + function generateRandomValue() { + // 生成随机的字符串作为值 + return Math.random().toString(36).substr(2, 7); + } + + for (let i = 0; i < 10; i++) { + const obj = { + key1: generateRandomValue(), + key2: generateRandomValue(), + key3: generateRandomValue() + }; + data.push(obj); + } + return data; +} \ No newline at end of file diff --git a/data-room-ui/packages/assets/images/alignIcon/export.js b/data-room-ui/packages/assets/images/alignIcon/export.js index d49f9b84..360552a7 100644 --- a/data-room-ui/packages/assets/images/alignIcon/export.js +++ b/data-room-ui/packages/assets/images/alignIcon/export.js @@ -3,7 +3,6 @@ const svgFiles = require.context('./svg', true, /\.svg$/) const iconList = svgFiles.keys()?.map(item => svgFiles(item)) export default { getNameList () { - console.log(iconList) return iconList?.map(item => { return item?.default?.id?.split('-')[1] }) || [] diff --git a/data-room-ui/packages/js/mixins/commonMixins.js b/data-room-ui/packages/js/mixins/commonMixins.js index 6abe7845..9d9c47e6 100644 --- a/data-room-ui/packages/js/mixins/commonMixins.js +++ b/data-room-ui/packages/js/mixins/commonMixins.js @@ -63,9 +63,36 @@ export default { } }, // 组件仅更新数据 - changeData () {}, + changeData () { }, // 组件仅更新样式 - changeStyle () {}, + changeStyle () { + this.config = _.cloneDeep(this.config) + // 遍历config.setting,将config.setting中的值赋值给config.option中对应的optionField + this.config.setting.forEach(set => { + if (set.optionField) { + const optionField = set.optionField.split('.') + let option = this.config.option + optionField.forEach((field, index) => { + if (index === optionField.length - 1) { + // 数据配置时,必须有值才更新 + if ((set.tabName === 'data' && set.value) || set.tabName === 'custom') { + option[field] = set.value + } + } else { + option = option[field] + } + }) + } + }) + if (this.config.optionHandler) { + try { + // 此处函数处理config + eval(this.config.optionHandler) + } catch (e) { + console.error(e) + } + } + }, /** * 初始化组件时获取后端返回的数据, 返回数据和当前组件的配置 * @param settingConfig 设置时的配置。不传则为当前组件的配置