diff --git a/src/components/goods/params.vue b/src/components/goods/params.vue index b0fd90b..fe0702b 100644 --- a/src/components/goods/params.vue +++ b/src/components/goods/params.vue @@ -40,6 +40,22 @@ + + { + this.$refs.saveTagInput.$refs.input.focus() + }) + }, + + async save (row) { + const { data: res } = await this.$http.put(`categories/${this.cateId}/attributes/${row.attr_id}`, { + attr_name: row.attr_name, + attr_sel: row.attr_sel, + attr_vals: row.attr_vals + }) + if (res.meta.status !== 200) { + return this.$message.error(res.meta.msg) + } + this.$message.success(res.meta.msg) + }, + + async handleInputConfirm (row) { + const inputValue = row.inputValue.trim() + if (inputValue.length > 0) { + row.attr_vals += (row.attr_vals.length > 0 ? ' ' : '') + inputValue + await this.save(row) + } + row.inputVisible = false + row.inputValue = '' + }, sub () { this.$refs.form.validate(valid => { if (valid) { @@ -197,6 +254,10 @@ export default { if (res.meta.status !== 200) { return this.$message.error(res.meta.msg) } + res.data.forEach((item, i) => { + res.data[i].inputVisible = false + res.data[i].inputValue = '' + }) this[this.tab] = res.data } }, @@ -232,4 +293,7 @@ export default { .el-alert{ margin-bottom: 15px; } + .el-tag { + margin-right: 10px; + }