diff --git a/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue b/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue index 95989f44c..4d0766e79 100644 --- a/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue +++ b/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue @@ -43,22 +43,22 @@ - + -
  {{item.name}}
+
  {{item.name}}
{{$t('config.assetLabel.params')}} - +
-
+
{{$t('config.assetLabel.option')}} @@ -75,7 +75,7 @@ - {{$t('config.assetLabel.default')}} + {{$t('config.assetLabel.default')}} {{$t('config.assetLabel.default')}} @@ -90,7 +90,7 @@
-
+
{{$t('config.assetLabel.dateType')}}: @@ -108,7 +108,7 @@
-
+
{{$t('config.assetLabel.decimals')}}: @@ -119,11 +119,10 @@ - +
-
@@ -147,25 +146,12 @@ import assetTagEx from '../../page/asset/components/assetTagEx' export default { name: 'assetLabelBox', props: { - assetLabel: {} + obj: { type: Object } }, components: { assetTagEx }, data () { return { - editAssetMeta: { - id: '', - name: '', - metaKey: '', - groupId: { - id: '', - name: '' - }, - search: '0', - display: '0', - type: '', - param: {}, - remark: '' - }, + editAssetMeta: {}, rightBox: { // 面板弹出框相关 show: false }, @@ -176,66 +162,66 @@ export default { groupId: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }], type: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }] }, - value:'', + value: '', typeData: [ { icon: 'nz-icon nz-icon-text', - disabled:true, - value: 'text', + disabled: true, + value: 'TEXT', name: this.$t('config.assetLabel.text') }, { icon: 'nz-icon nz-icon-multitext', - disabled:true, - value: 'multitext', + disabled: true, + value: 'MULTITEXT', name: this.$t('config.assetLabel.multitext') }, { icon: 'nz-icon nz-icon-textarea', - disabled:true, - value: 'textarea', + disabled: true, + value: 'TEXTAREA', name: this.$t('config.assetLabel.textarea') }, { icon: 'nz-icon nz-icon-radio', - disabled:true, - value: 'radio', + disabled: true, + value: 'RADIO', name: this.$t('config.assetLabel.radio') }, { icon: 'nz-icon nz-icon-checkbox', - disabled:true, - value: 'checkbox', + disabled: true, + value: 'CHECKBOX', name: this.$t('config.assetLabel.checkbox') }, { icon: 'nz-icon nz-icon-xialaxuanze', - disabled:true, - value: 'select', + disabled: true, + value: 'SELECT', name: this.$t('config.assetLabel.select') }, { icon: 'nz-icon nz-icon-integer', - disabled:true, - value: 'integer', + disabled: true, + value: 'INTEGER', name: this.$t('config.assetLabel.integer') }, { icon: 'nz-icon nz-icon-double', - disabled:true, - value: 'double', + disabled: true, + value: 'DOUBLE', name: this.$t('config.assetLabel.double') }, { - icon: 'nz-icon nz-icon-double', - disabled:true, - value: 'datetime', + icon: 'el-icon-time', + disabled: true, + value: 'DATETIME', name: this.$t('config.assetLabel.datetime') }, { - icon: 'nz-icon nz-icon-double', - disabled:true, - value: 'email', + icon: 'el-icon-message', + disabled: true, + value: 'EMAIL', name: this.$t('config.assetLabel.email') } ], @@ -243,37 +229,56 @@ export default { } }, watch: { - assetLabel: { + obj: { + deep: true, immediate: true, handler (n) { - this.editAssetMeta = { ...n, search: `${n.search}`, display: `${n.display}` } - this.selectType(n.type, true) + this.editAssetMeta = { + ...n, + search: `${n.search}`, + display: `${n.display}`, + param: n.param && typeof n.param === 'string' ? JSON.parse(n.param) : {}, + type: n.type.toUpperCase() + } + console.info(this.editAssetMeta) + } + }, + 'editAssetMeta.search': { + deep: true, + immediate: true, + handler (n) { + this.switchSearch(n) } } }, mounted () { this.getGroupData() - this.switchSearch('0') }, methods: { - switchSearch(value){ - this.typeData.forEach(element => { - if( value == 0 ) { - element.disabled = false - console.log(value); - }else if(value == 1) { - console.log(value); - if(element.value == 'radio'){ - element.disabled = false - }else if(element.value == 'checkbox'){ - element.disabled = false - }else if(element.value == 'select'){ - element.disabled = false - } - }else { - return console.log('不为0,也不为1'); + switchSearch (value) { + if (value == 0) { + this.typeData.forEach(t => { + t.disabled = false + }) + } else if (value == 1) { + if (this.editAssetMeta.type !== 'RADIO' && + this.editAssetMeta.type !== 'CHECKBOX' && + this.editAssetMeta.type !== 'SELECT') { + this.editAssetMeta.type = 'RADIO' + } + this.typeData.forEach(t => { + if (t.value === 'RADIO' || t.value === 'CHECKBOX' || t.value === 'SELECT') { + t.disabled = false + } else { + t.disabled = true } - }) + }) + } else { + this.editAssetMeta.search = '0' + this.typeData.forEach(t => { + t.disabled = false + }) + } }, clickOutside () { this.esc(false) @@ -285,7 +290,7 @@ export default { save () { if (this.prevent_opt.save) { return - }; + } this.prevent_opt.save = true this.$refs.editAssetMetaForm.validate((valid) => { if (valid) { @@ -336,7 +341,6 @@ export default { if (this.prevent_opt.save) { return } - ; this.prevent_opt.save = true this.$confirm(this.$t('tip.confirmDelete'), { confirmButtonText: this.$t('tip.yes'), @@ -365,9 +369,9 @@ export default { }, selectType (val, init) { switch (val) { - case 'radio' : - case 'checkbox' : - case 'select' : + case 'RADIO' : + case 'CHECKBOX' : + case 'SELECT' : this.showParam = true if (init) return this.editAssetMeta.param = {} @@ -379,7 +383,7 @@ export default { check: false }] break - case 'datetime' : + case 'DATETIME' : this.showParam = true if (init) return this.editAssetMeta.param = { @@ -387,7 +391,7 @@ export default { interval: false } break - case 'double' : + case 'DOUBLE' : this.showParam = true if (init) return this.editAssetMeta.param = { @@ -408,7 +412,7 @@ export default { this.editAssetMeta.param.items.forEach((item, index) => { if (index === i) { item.check = !!item.check - } else if (this.editAssetMeta.type !== 'checkbox') { + } else if (this.editAssetMeta.type.toUpperCase() !== 'CHECKBOX') { item.check = false } }) @@ -437,7 +441,7 @@ export default { this.$forceUpdate() }, copyParam (index) { - if (this.editAssetMeta.type !== 'checkbox') { + if (this.editAssetMeta.type.toUpperCase() !== 'CHECKBOX') { this.editAssetMeta.param.items.push({ name: this.editAssetMeta.param.items[index].name, check: false diff --git a/nezha-fronted/src/components/common/rightBox/userBox.vue b/nezha-fronted/src/components/common/rightBox/userBox.vue index 289a5b5e3..70b69d544 100644 --- a/nezha-fronted/src/components/common/rightBox/userBox.vue +++ b/nezha-fronted/src/components/common/rightBox/userBox.vue @@ -93,7 +93,7 @@ export default { name: 'accountBox', props: { - user: Object + obj: Object }, computed: { isCurrentUser () { @@ -292,7 +292,7 @@ export default { }, watch: { // 将prop里的user转为组件内部对象 - user: { + obj: { immediate: true, deep: true, handler (n) { diff --git a/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue b/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue index 629f5ad19..1e33f57ac 100644 --- a/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue +++ b/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue @@ -45,14 +45,16 @@
Disabled
-
TEXT
-
MULTITEXT
-
TEXTAREA
-
RADI0
-
CHECKBOX
-
SELECT
-
INTEGER
-
DOUBLE
+
  TEXT
+
  MULTITEXT
+
  TEXTAREA
+
  RADI0
+
  CHECKBOX
+
  SELECT
+
  INTEGER
+
  DOUBLE
+
  DOUBLE
+
  DOUBLE
{{scope.row[item.prop] || '-'}} @@ -126,7 +128,7 @@ export default { } }, methods: { - + } } diff --git a/nezha-fronted/src/components/page/config/assetMeta.vue b/nezha-fronted/src/components/page/config/assetMeta.vue index 06e58dd3d..c57c52a59 100644 --- a/nezha-fronted/src/components/page/config/assetMeta.vue +++ b/nezha-fronted/src/components/page/config/assetMeta.vue @@ -56,7 +56,7 @@ - + { - this.object = { ...res.data, param: JSON.parse(res.data.param) } - this.rightBox.metaShow = true - }) */ this.object = JSON.parse(JSON.stringify(row)) this.rightBox.metaShow = true },