Commit 204223cb authored by 孙浩's avatar 孙浩

标签管理新增及修改回显

parent c6cc0d64
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
</el-col> </el-col>
<el-col :span="5" class="btn-container"> <el-col :span="5" class="btn-container">
<el-button type="primary" class="el-icon-plus" @click="addFormItem(index)" circle></el-button> <el-button type="primary" class="el-icon-plus" @click="addFormItem(index)" circle></el-button>
<el-button type="primary" class="el-icon-minus" @click="removeFormItem(index)" circle></el-button> <el-button v-if="paramsItems.length > 1" type="primary" class="el-icon-minus" @click="removeFormItem(index)" circle></el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
...@@ -269,7 +269,6 @@ export default { ...@@ -269,7 +269,6 @@ export default {
}, },
methods: { methods: {
getKeyRules(item) { getKeyRules(item) {
console.log(item)
return [ return [
{ required: !!item.value && !item.key, message: '请输入key的值', trigger: 'blur' } { required: !!item.value && !item.key, message: '请输入key的值', trigger: 'blur' }
] ]
...@@ -359,12 +358,15 @@ export default { ...@@ -359,12 +358,15 @@ export default {
const id = row.businessId const id = row.businessId
getIncomeWmsLabel(id).then(response => { getIncomeWmsLabel(id).then(response => {
this.form = response.data this.form = response.data
const obj = JSON.parse(this.form.params) console.log(this.form)
this.paramsItems = [] if (this.form.params !== null && this.form.params !== undefined) {
for (const key in obj) { this.paramsItems = []
if (Object.hasOwnProperty.call(obj, key)) { const obj = JSON.parse(this.form.params)
const value = obj[key] for (const key in obj) {
this.paramsItems.push({ key: key, value: value }) if (Object.hasOwnProperty.call(obj, key)) {
const value = obj[key]
this.paramsItems.push({ key: key, value: value })
}
} }
} }
this.open = true this.open = true
...@@ -393,10 +395,14 @@ export default { ...@@ -393,10 +395,14 @@ export default {
submitForm: function() { submitForm: function() {
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
this.form.params = JSON.stringify(this.paramsItems.reduce((obj, item) => { if (this.paramsItems.length === 1 && this.paramsItems[0].key === '') {
obj[item.key] = item.value this.form.params = undefined
return obj } else {
}, {})) this.form.params = JSON.stringify(this.paramsItems.reduce((obj, item) => {
obj[item.key] = item.value
return obj
}, {}))
}
if (this.form.businessId !== undefined) { if (this.form.businessId !== undefined) {
updateIncomeWmsLabel(this.form).then(response => { updateIncomeWmsLabel(this.form).then(response => {
this.msgSuccess('修改成功') this.msgSuccess('修改成功')
...@@ -473,6 +479,9 @@ export default { ...@@ -473,6 +479,9 @@ export default {
width: 115%; width: 115%;
.el-input{ .el-input{
width: 60%; width: 60%;
.el-input__inner{
padding-right: 0%;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment