|
@@ -1,16 +1,17 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="old">
|
|
|
- <el-tag v-for="(it, index) in oldLabels" :key="it.id" closable type="success" @close="removeOldLabel(index)">
|
|
|
- {{it.name}}
|
|
|
+ <el-tag class="tag" v-for="(oit, oindex) in oldLabels" :key="oit.id" closable type="success" @close="removeOldLabel(oindex)">
|
|
|
+ {{oit.name}}
|
|
|
</el-tag>
|
|
|
</div>
|
|
|
<div class="new">
|
|
|
- <el-tag v-for="(it, index) in newLabels" :key="it.id" type="success">
|
|
|
- {{it.name}}
|
|
|
- </el-tag>
|
|
|
+ <el-button type="danger" plain v-for="(nit, nindex) in newLabels" :key="nit.id" v-on:click="add(nindex)" size="mini">{{nit.name}}</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="option">
|
|
|
+ <el-button type="primary" @click="save">保存</el-button>
|
|
|
+ <el-button @click="goBack">取消</el-button>
|
|
|
</div>
|
|
|
- <div class="option"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
@@ -30,13 +31,47 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getNewGoodLabels: function(){
|
|
|
- this.$http.okLabels({}, this).then(res => {
|
|
|
- this.newLabels = res.obj
|
|
|
- });
|
|
|
+ getNewGoodLabels: function() {
|
|
|
+ this.$http.okLabels({}, this).then(res => {
|
|
|
+ this.newLabels = res.obj
|
|
|
+ })
|
|
|
+ },
|
|
|
+ removeOldLabel: function(index) {
|
|
|
+ this.oldLabels.splice(index, 1)
|
|
|
},
|
|
|
- removeOldLabel: function(index){
|
|
|
- this.oldLabels.splice(index, 1)
|
|
|
+ goBack: function() {
|
|
|
+ this.$router.back()
|
|
|
+ },
|
|
|
+ add: function(index) {
|
|
|
+ var item = this.newLabels[index]
|
|
|
+ var have = false
|
|
|
+ this.oldLabels.forEach(it => {
|
|
|
+ if (it.id === item.id) {
|
|
|
+ have = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!have) {
|
|
|
+ this.oldLabels.push({ id: item.id, name: item.name })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ save: function() {
|
|
|
+ var lids = []
|
|
|
+ this.oldLabels.forEach(it => {
|
|
|
+ lids.push(it.id)
|
|
|
+ })
|
|
|
+ var that = this
|
|
|
+ this.$http
|
|
|
+ .setGoodLabels({ gid: this.gid, lids: lids }, this)
|
|
|
+ .then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: '操作成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1000,
|
|
|
+ onClose: function() {
|
|
|
+ that.goBack()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
@@ -47,3 +82,23 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+.old {
|
|
|
+ height: 150px;
|
|
|
+}
|
|
|
+.new {
|
|
|
+ border-top: 1px solid #666;
|
|
|
+ padding-top: 20px;
|
|
|
+ height: 150px;
|
|
|
+}
|
|
|
+.tag {
|
|
|
+ margin-left: 10px;
|
|
|
+ margin-right: 10px;
|
|
|
+}
|
|
|
+.option {
|
|
|
+ border-top: 1px solid #666;
|
|
|
+ padding-top: 20px;
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|