From a1f92cfeae089e51ca699a8e07b4aad1c2661afc Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Mon, 30 May 2022 21:28:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E3=80=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E3=80=91=E6=96=B0=E5=BB=BA=E8=AE=A1=E7=AE=97=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=97=B6=EF=BC=8C=E5=B0=86=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?ID=E6=98=BE=E7=A4=BA=E6=9B=BF=E6=8D=A2=E6=88=90=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/dataset/data/CalcFieldEdit.vue | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/dataset/data/CalcFieldEdit.vue b/frontend/src/views/dataset/data/CalcFieldEdit.vue index 5bf010c200..fee6b01f5a 100644 --- a/frontend/src/views/dataset/data/CalcFieldEdit.vue +++ b/frontend/src/views/dataset/data/CalcFieldEdit.vue @@ -86,7 +86,7 @@ :disabled="true" > - + @@ -106,7 +106,7 @@ :disabled="true" > - + @@ -248,6 +248,7 @@ export default { searchFunction: '', dimensionData: [], quotaData: [], + name2Auto: [], functionData: [] } }, @@ -292,9 +293,9 @@ export default { this.$refs.myCm.codemirror.showHint() }) this.initFunctions() - this.initField() this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0) this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0) + this.initField() }, methods: { onCmReady(cm) { @@ -318,6 +319,7 @@ export default { pos2.line = pos1.line pos2.ch = pos1.ch this.$refs.myCm.codemirror.replaceRange(param, pos2) + this.$refs.myCm.codemirror.markText(pos2, { line: pos2.line, ch: param.length + pos2.ch }, { atomic: true, selectRight: true }) }, initFunctions() { @@ -330,27 +332,57 @@ export default { initField() { if (this.field.id) { this.fieldForm = JSON.parse(JSON.stringify(this.field)) + this.name2Auto = [] + this.fieldForm.originName = this.setNameIdTrans('id', 'name', this.fieldForm.originName, this.name2Auto) + setTimeout(() => { + this.matchToAuto() + }, 500) } else { this.fieldForm = JSON.parse(JSON.stringify(this.fieldForm)) } }, - + matchToAuto() { + if (!this.name2Auto.length) return + this.name2Auto.forEach(ele => { + const search = this.$refs.myCm.codemirror.getSearchCursor(ele, { line: 0, ch: 0 }) + if (search.find()) { + const { from, to } = search.pos + this.$refs.myCm.codemirror.markText({ line: from.line, ch: from.ch - 1 }, { line: to.line, ch: to.ch + 1 }, { atomic: true, selectRight: true }) + } + }) + }, closeCalcField() { this.resetField() this.$emit('onEditClose', {}) }, + setNameIdTrans(from, to, originName, name2Auto) { + let name2Id = originName + const nameIdMap = [...this.dimensionData, ...this.quotaData].reduce((pre, next) => { + pre[next[from]] = next[to] + return pre + }, {}) + originName.match(/(?<=\[).+?(?=\])/g).forEach(ele => { + if (name2Auto) { + name2Auto.push(nameIdMap[ele]) + } + name2Id = name2Id.replace(ele, nameIdMap[ele]) + }) + return name2Id + }, saveCalcField() { - if (this.fieldForm.name && this.fieldForm.name.length > 50) { + const { id, name = [], deType, originName } = this.fieldForm + if (name.length > 50) { this.$message.error(this.$t('dataset.field_name_less_50')) return } - if (!this.fieldForm.id) { - this.fieldForm.type = this.fieldForm.deType - this.fieldForm.deExtractType = this.fieldForm.deType + if (!id) { + this.fieldForm.type = deType + this.fieldForm.deExtractType = deType this.fieldForm.tableId = this.param.id this.fieldForm.columnIndex = this.tableFields.dimensionList.length + this.tableFields.quotaList.length } + this.fieldForm.originName = this.setNameIdTrans('name', 'id', originName) post('/dataset/field/save', this.fieldForm).then(response => { this.closeCalcField() }) From c45f68bd23d8db19d395b2f05143e62c71dfd1e9 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Mon, 30 May 2022 21:28:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E3=80=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E3=80=91=E6=96=B0=E5=BB=BA=E8=AE=A1=E7=AE=97=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=97=B6=EF=BC=8C=E5=B0=86=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?ID=E6=98=BE=E7=A4=BA=E6=9B=BF=E6=8D=A2=E6=88=90=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/dataset/data/CalcFieldEdit.vue | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/dataset/data/CalcFieldEdit.vue b/frontend/src/views/dataset/data/CalcFieldEdit.vue index 5bf010c200..fee6b01f5a 100644 --- a/frontend/src/views/dataset/data/CalcFieldEdit.vue +++ b/frontend/src/views/dataset/data/CalcFieldEdit.vue @@ -86,7 +86,7 @@ :disabled="true" > - + @@ -106,7 +106,7 @@ :disabled="true" > - + @@ -248,6 +248,7 @@ export default { searchFunction: '', dimensionData: [], quotaData: [], + name2Auto: [], functionData: [] } }, @@ -292,9 +293,9 @@ export default { this.$refs.myCm.codemirror.showHint() }) this.initFunctions() - this.initField() this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0) this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0) + this.initField() }, methods: { onCmReady(cm) { @@ -318,6 +319,7 @@ export default { pos2.line = pos1.line pos2.ch = pos1.ch this.$refs.myCm.codemirror.replaceRange(param, pos2) + this.$refs.myCm.codemirror.markText(pos2, { line: pos2.line, ch: param.length + pos2.ch }, { atomic: true, selectRight: true }) }, initFunctions() { @@ -330,27 +332,57 @@ export default { initField() { if (this.field.id) { this.fieldForm = JSON.parse(JSON.stringify(this.field)) + this.name2Auto = [] + this.fieldForm.originName = this.setNameIdTrans('id', 'name', this.fieldForm.originName, this.name2Auto) + setTimeout(() => { + this.matchToAuto() + }, 500) } else { this.fieldForm = JSON.parse(JSON.stringify(this.fieldForm)) } }, - + matchToAuto() { + if (!this.name2Auto.length) return + this.name2Auto.forEach(ele => { + const search = this.$refs.myCm.codemirror.getSearchCursor(ele, { line: 0, ch: 0 }) + if (search.find()) { + const { from, to } = search.pos + this.$refs.myCm.codemirror.markText({ line: from.line, ch: from.ch - 1 }, { line: to.line, ch: to.ch + 1 }, { atomic: true, selectRight: true }) + } + }) + }, closeCalcField() { this.resetField() this.$emit('onEditClose', {}) }, + setNameIdTrans(from, to, originName, name2Auto) { + let name2Id = originName + const nameIdMap = [...this.dimensionData, ...this.quotaData].reduce((pre, next) => { + pre[next[from]] = next[to] + return pre + }, {}) + originName.match(/(?<=\[).+?(?=\])/g).forEach(ele => { + if (name2Auto) { + name2Auto.push(nameIdMap[ele]) + } + name2Id = name2Id.replace(ele, nameIdMap[ele]) + }) + return name2Id + }, saveCalcField() { - if (this.fieldForm.name && this.fieldForm.name.length > 50) { + const { id, name = [], deType, originName } = this.fieldForm + if (name.length > 50) { this.$message.error(this.$t('dataset.field_name_less_50')) return } - if (!this.fieldForm.id) { - this.fieldForm.type = this.fieldForm.deType - this.fieldForm.deExtractType = this.fieldForm.deType + if (!id) { + this.fieldForm.type = deType + this.fieldForm.deExtractType = deType this.fieldForm.tableId = this.param.id this.fieldForm.columnIndex = this.tableFields.dimensionList.length + this.tableFields.quotaList.length } + this.fieldForm.originName = this.setNameIdTrans('name', 'id', originName) post('/dataset/field/save', this.fieldForm).then(response => { this.closeCalcField() })