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

标签管理新增及修改回显

parent c6cc0d64
......@@ -175,7 +175,7 @@
</el-col>
<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-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-row>
</el-form-item>
......@@ -269,7 +269,6 @@ export default {
},
methods: {
getKeyRules(item) {
console.log(item)
return [
{ required: !!item.value && !item.key, message: '请输入key的值', trigger: 'blur' }
]
......@@ -359,12 +358,15 @@ export default {
const id = row.businessId
getIncomeWmsLabel(id).then(response => {
this.form = response.data
const obj = JSON.parse(this.form.params)
this.paramsItems = []
for (const key in obj) {
if (Object.hasOwnProperty.call(obj, key)) {
const value = obj[key]
this.paramsItems.push({ key: key, value: value })
console.log(this.form)
if (this.form.params !== null && this.form.params !== undefined) {
this.paramsItems = []
const obj = JSON.parse(this.form.params)
for (const key in obj) {
if (Object.hasOwnProperty.call(obj, key)) {
const value = obj[key]
this.paramsItems.push({ key: key, value: value })
}
}
}
this.open = true
......@@ -393,10 +395,14 @@ export default {
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
this.form.params = JSON.stringify(this.paramsItems.reduce((obj, item) => {
obj[item.key] = item.value
return obj
}, {}))
if (this.paramsItems.length === 1 && this.paramsItems[0].key === '') {
this.form.params = undefined
} else {
this.form.params = JSON.stringify(this.paramsItems.reduce((obj, item) => {
obj[item.key] = item.value
return obj
}, {}))
}
if (this.form.businessId !== undefined) {
updateIncomeWmsLabel(this.form).then(response => {
this.msgSuccess('修改成功')
......@@ -473,6 +479,9 @@ export default {
width: 115%;
.el-input{
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