Compare commits

..

No commits in common. "34b3d8e1d401c98d547ffe5d46c6b8ebdfd23e3a" and "9c7c7b688aec8c0f7f3719a1f2687a0f8d4eaa51" have entirely different histories.

View File

@ -40,22 +40,6 @@
<el-table-column <el-table-column
type="expand" type="expand"
> >
<template slot-scope="scope">
<span v-if="scope.row.attr_vals" >
<el-tag closable :key="i" v-for="(tag,i) in scope.row.attr_vals.split(' ')" @close="delTag(tag,scope.row)">{{tag}}</el-tag>
</span>
<el-input
class="input-new-tag"
v-if="scope.row.inputVisible"
v-model="scope.row.inputValue"
ref="saveTagInput"
size="small"
@keyup.enter.native="handleInputConfirm(scope.row)"
@blur="handleInputConfirm(scope.row)"
>
</el-input>
<el-button v-else class="button-new-tag" size="small" @click="showInput(scope.row)">+ New Tag</el-button>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="#" label="#"
@ -85,11 +69,6 @@
<el-table-column <el-table-column
type="expand" type="expand"
> >
<template slot-scope="scope">
<div v-if="scope.row.attr_vals" >
<el-tag closable :key="i" v-for="(tag,i) in scope.row.attr_vals.split(' ')">{{tag}}</el-tag>
</div>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="#" label="#"
@ -163,42 +142,6 @@ export default {
} }
}, },
methods: { methods: {
delTag (tag, row) {
const tmp = row.attr_vals.split(' ')
tmp.splice(tmp.indexOf(tag), 1)
row.attr_vals = tmp.join(' ')
this.save(row)
},
showInput (row) {
row.inputVisible = true
//
this.$nextTick(_ => {
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 () { sub () {
this.$refs.form.validate(valid => { this.$refs.form.validate(valid => {
if (valid) { if (valid) {
@ -246,12 +189,6 @@ export default {
this.params() this.params()
}, },
handleChange () { handleChange () {
if (this.selectKey.length < 3) {
// this.data = []
this.only = []
this.many = []
return
}
this.params() this.params()
}, },
async params () { async params () {
@ -260,10 +197,6 @@ export default {
if (res.meta.status !== 200) { if (res.meta.status !== 200) {
return this.$message.error(res.meta.msg) 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 this[this.tab] = res.data
} }
}, },
@ -299,7 +232,4 @@ export default {
.el-alert{ .el-alert{
margin-bottom: 15px; margin-bottom: 15px;
} }
.el-tag {
margin-right: 10px;
}
</style> </style>