From 535004719c750e6f3fd588a77a75e6e262060047 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Tue, 16 Aug 2022 14:07:33 +0800 Subject: [PATCH] add CKEditor & update dialog --- package-lock.json | 13 ++ package.json | 1 + .../base-dialog/addOrUpdate/index.vue | 47 ++++-- src/views/modules/monitoring/equipment.vue | 146 ++++++++++++++++-- src/views/modules/monitoring/equipmentAdd.vue | 32 ++++ 5 files changed, 211 insertions(+), 28 deletions(-) create mode 100644 src/views/modules/monitoring/equipmentAdd.vue diff --git a/package-lock.json b/package-lock.json index c145225..5f4e71e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5283,6 +5283,19 @@ "safe-buffer": "^5.0.1" } }, + "ckeditor4-integrations-common": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ckeditor4-integrations-common/-/ckeditor4-integrations-common-1.0.0.tgz", + "integrity": "sha512-OAoQT/gYrHkg0qgzf6MS/rndYhq3SScLVQ3rtXQeuCE8ju7nFHg3qZ7WGA2XpFxcZzsMP6hhugXqdel5vbcC3g==" + }, + "ckeditor4-vue": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ckeditor4-vue/-/ckeditor4-vue-2.1.1.tgz", + "integrity": "sha512-BBmpT1BYxOmaA+qy9+hvhG0tDYCGqFve1eDSol0ZNwWCm1hZvmPAke809AhkHFUjb834dbNRlTwH3c2qedjtkQ==", + "requires": { + "ckeditor4-integrations-common": "^1.0.0" + } + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npm.taobao.org/class-utils/download/class-utils-0.3.6.tgz", diff --git a/package.json b/package.json index 304f2fe..763e35c 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "axios": "^0.19.2", "babel-eslint": "^8.0.1", "babel-plugin-component": "^1.1.1", + "ckeditor4-vue": "^2.1.1", "core-js": "^3.6.5", "element-theme": "^2.0.1", "element-ui": "^2.15.7", diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index 7b4b44e..dac1127 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -4,7 +4,8 @@ - + + @@ -244,26 +246,39 @@ export default { /** 计算默认值 */ function calDefault(type) { switch (type) { - case 'array': + case 'array': return [] // more case... - default: + default: return '' } } /** 检查是否需要额外的组件 */ this.configs.extraComponents && this.configs.extraComponents.forEach(item => { - this.$set(this.dataForm, [item.name], calDefault(item.fieldType)) + if (Object.hasOwn(this.dataForm, [item.name])) { + console.log('有了!') + return + } else { + console.log('新建!') + this.$set(this.dataForm, [item.name], calDefault(item.fieldType)) + } + + console.log('component: ', item.component) }) /** 单独设置 id */ this.$set(this.dataForm, 'id', null) + console.log('mounted: this.dataForm', JSON.stringify(this.dataForm)) }) - console.log("mounted: this.dataForm", JSON.stringify(this.dataForm)) }, methods: { + getSpan(n, c) { + const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)] + return opt && opt.span ? opt.span : 24 / COLUMN_PER_ROW + }, + getLabel(n, c) { const opt = this.configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)] if (opt) { @@ -327,18 +342,22 @@ export default { if (this.shouldWait) this.shouldWait.then(() => { if (this.tempForm.length) { - console.log("create new, tempform", JSON.stringify(this.tempForm.length)) + console.log('create new, tempform', JSON.stringify(this.tempForm.length)) this.tempForm.forEach(item => { console.log('item data', item.data) this.dataForm[item.name] = item.data }) - console.log("create new, dataform", JSON.stringify(this.dataForm)) + console.log('create new, dataform', JSON.stringify(this.dataForm)) } }) } }) }, + handleEditorReady(val) { + console.log('editor rready..', val) + }, + handleClick(btn) { /** 提取url */ const urls = {} @@ -354,6 +373,8 @@ export default { /** 需要验证表单的操作 */ this.$refs['dataForm'].validate(valid => { if (valid) { + console.log('before send: ', this.dataForm) + this.$http({ url: this.$http.adornUrl(urls[btn.name].url), method: btn.name === 'save' ? 'POST' : 'PUT', @@ -403,7 +424,11 @@ export default { handleUploadListUpdate(filelist) { // 此处需要参照‘设备类型’新增的接口,灵活地设置 dataForm - this.$set(this.dataForm, 'fileIds', filelist.map(item => item.id)) + this.$set( + this.dataForm, + 'fileIds', + filelist.map(item => item.id) + ) console.log('handleUploadListUpdate(): ', this.dataForm) }, diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index 17eef26..fba3e64 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -6,12 +6,12 @@ 查询 + test 新增 - - + - + + +