relationCategoryDialog.vue
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!-- 关联类目 -->
<template>
<d2-dialog title="关联类目"
:is-visible="categoryVisible"
class="categoryDailog"
width="40%"
btn-ok-label="提交"
@closeDialog="handleClose"
@confirmDialog="handleAddConfirm">
<el-form ref="categoryForm"
:model="infoForm"
:rules="formRules"
label-width="120px">
<el-form-item label="特色产品:">
{{ info.featuredGoodsName }}
</el-form-item>
<el-form-item label="关联类目:"
prop="category">
<el-select v-model="infoForm.category"
multiple
filterable
style="width:400px">
<el-option v-for="item in baseData.noRelatcategoryList"
:key="item.id"
:label="item.categoryName"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="已关联类目:">
{{ info.categoryName }}
</el-form-item>
</el-form>
</d2-dialog>
</template>
<script>
import { queryGoodsCategoryBySceneId, editFeaturedGoods } from '@api/sceneCategory'
import { deepClone } from '@/common/util'
export default {
name: 'RelationCategoryDialog',
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
infoForm: {
category: ''
},
formRules: {
category: [
{ required: true, message: '请选择关联类目', trigger: 'change' }
]
},
selectLoading: false,
// 基本数据
baseData: {
noRelatcategoryList: []
}
}
},
props: {
categoryVisible: {
type: Boolean,
default: false
},
info: {
type: Object,
default: () => { }
}
},
watch: {
},
created() {
},
components: {},
computed: {
},
mounted() {
this.queryCategory()
},
methods: {
queryCategory() {
var params = {}
params.sceneType = this.info.sceneType
params.categoryTypeList = this.info.categoryType
queryGoodsCategoryBySceneId(params).then(res => {
this.baseData.noRelatcategoryList = res
console.log(this.baseData.noRelatcategoryList)
})
},
handleAddConfirm() {
this.$refs.categoryForm.validate(valid => {
if (valid) {
var infoForm = deepClone(this.infoForm)
console.log(infoForm)
var params = {}
var obj
var categoryNameList = []
var categoryTypeList = []
infoForm.category.forEach(item => {
obj = {}
obj = this.baseData.noRelatcategoryList.find(
cat => cat.id === item
)
categoryNameList.push(obj.categoryName)
categoryTypeList.push(obj.categoryType)
})
params.id = this.info.id
params.categoryName = categoryNameList.join(",") + (this.info.categoryName ? (',' + this.info.categoryName) : '')
params.categoryType = categoryTypeList.join(",") + (this.info.categoryType ? (',' + this.info.categoryType) : '')
console.log(params)
editFeaturedGoods(params).then(res => {
this.notice.okTips()
this.handleClose(true)
})
}
})
},
handleClose(flag) {
this.$emit('dialogClose', flag)
}
}
}
</script>
<style >
::v-deep .categoryVisible {
/*下拉选择框-多选-内容过长-用...代替 begin */
.el-tag.el-tag--info {
background-color: #f4f4f5;
border-color: #e9e9eb;
color: #909399;
max-width: calc(100% - 50px);
/* white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;*/
}
.el-tag.el-tag--info {
width: calc(100% - 200px);
}
.el-tag.el-tag--info .el-select__tags-text {
width: calc(100% - 20px);
float: left;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
/*下拉选择框-多选-内容过长-用...代替 end */
::v-deep .categoryDailog .el-dialog {
min-width: 700px;
}
::v-deep .categoryDailog .el-select-dropdown__item {
width: 395px !important;
}
</style>