@@ -666,6 +669,7 @@ export default {
label.value.splice(index, 1)
},
blankLabelValue (label) {
+ const defaultValue = JSON.parse(label.param).default || ''
if (label.type.toUpperCase() === this.assetConstants.labelTypeData.CHECKBOX) {
const arr = []
if (label.param && JSON.parse(label.param).items) {
@@ -677,7 +681,7 @@ export default {
}
return arr
} else if (label.type.toUpperCase() === this.assetConstants.labelTypeData.MULTITEXT || label.type.toUpperCase() === assetConstants.labelTypeData.TEXT || label.type.toUpperCase() === assetConstants.labelTypeData.TEXTAREA) {
- return ['']
+ return [defaultValue]
} else if (label.type.toUpperCase() === this.assetConstants.labelTypeData.RADIO || label.type.toUpperCase() === assetConstants.labelTypeData.SELECT) {
const arr = ['']
if (label.param && JSON.parse(label.param).items) {
@@ -689,7 +693,7 @@ export default {
}
return arr
} else {
- return ['']
+ return [defaultValue]
}
},
getParentAsset () {
diff --git a/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue b/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue
index 3f70b41dd..559a5736c 100644
--- a/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue
@@ -41,7 +41,7 @@
@@ -279,15 +279,19 @@ export default {
immediate: true,
handler (n) {
this.isEdit = true
+ const param = n.param && ((typeof n.param) === 'string') ? JSON.parse(n.param) : {}
+ if (!param.required) {
+ param.required = '0'
+ }
this.editAssetMeta = {
...n,
groupId: n.groupId ? Number(n.groupId) : '',
search: `${n.search}`,
display: `${n.display}`,
- required: n.required ? `${n.required}` : '0',
- param: n.param && ((typeof n.param) === 'string') ? JSON.parse(n.param) : {},
+ param: param,
type: n.type.toUpperCase()
}
+
this.selectType(this.editAssetMeta.type, true)
}
},
@@ -359,11 +363,7 @@ export default {
}
}
}
- if (param.type !== 'RADIO' && param.type !== 'CHECKBOX' && param.type !== 'SELECT' && param.type !== 'DATETIME' && param.type !== 'DOUBLE') {
- delete param.param
- } else {
- param.param = JSON.stringify(param.param)
- }
+ param.param = JSON.stringify(param.param)
if (this.editAssetMeta.id) {
this.$put('asset/field/meta', param).then(response => {
this.prevent_opt.save = false
@@ -432,7 +432,7 @@ export default {
case 'TEXT' :
case 'TEXTAREA' :
case 'INTEGER' :
- case 'PASSWORD' :
+ // case 'PASSWORD' :
this.showParam = true
break
default:
@@ -441,13 +441,15 @@ export default {
}
} else {
if (this.ready) {
+ const required = this.editAssetMeta.param.required
switch (val) {
case 'RADIO' :
case 'CHECKBOX' :
case 'SELECT' :
this.showParam = true
this.editAssetMeta.param = {
- items: []
+ items: [],
+ required: required
}
this.editAssetMeta.param.items = [{
name: 'Option 1',
@@ -460,6 +462,7 @@ export default {
case 'DATETIME' :
this.showParam = true
this.editAssetMeta.param = {
+ required: required,
subType: 'date',
interval: false
}
@@ -468,31 +471,41 @@ export default {
this.showParam = true
this.editAssetMeta.param = {
decimals: 2,
- default: undefined
+ default: undefined,
+ required: required
}
break
case 'TEXT' :
this.showParam = true
this.editAssetMeta.param = {
- default: ''
+ default: '',
+ required: required
}
break
case 'TEXTAREA' :
this.showParam = true
this.editAssetMeta.param = {
- default: ''
+ default: '',
+ required: required
}
break
case 'INTEGER' :
this.showParam = true
this.editAssetMeta.param = {
- default: undefined
+ default: undefined,
+ required: required
}
break
case 'PASSWORD' :
- this.showParam = true
+ this.showParam = false
this.editAssetMeta.param = {
- default: ''
+ required: required
+ }
+ break
+ case 'EMAIL' :
+ this.showParam = false
+ this.editAssetMeta.param = {
+ required: required
}
break
default:
diff --git a/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue b/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue
index 5567c8c0b..1dc0e3407 100644
--- a/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue
+++ b/nezha-fronted/src/components/common/table/asset/assetMetaTable.vue
@@ -75,6 +75,7 @@
DOUBLE
DATETIME
EMAIL
+ PASSWORD