EquityUpgrade.vue
6.6 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<template>
<div>
<d2-container class="m-t-40">
<div class="header" slot="header" style="padding: 10px 20px">
<d2-search ref="showSearch" class="show-search" :search-form="searchForm" :label-width="'100px'"
:form-data="showFormData">
<template slot="brand">
<el-cascader ref="cascader" v-model="searchForm.brandId" filterable :options="options" :value-key="'id'"
:props="cascaderProps" clearable></el-cascader>
</template>
</d2-search>
<div class="up-btns">
<el-button @click="handleSearch" size="small" type="primary">
查询
</el-button>
<el-button size="small" @click="handleReset"> 重置 </el-button>
</div>
</div>
<div class="d2-container-content">
<d2-table-header>
<el-button size="small" type="primary" @click="handleDialog">
新增配置
</el-button>
</d2-table-header>
<d2-table ref="table" :get-list-api="getListApi" :search-form="searchFormSearch" :table-params="tableParams"
:before-search-fn="beforeSearchFn">
<div slot="brandName" slot-scope="scope">
<template v-if="scope.scope.brandName">
{{ scope.scope.brandName.split(",").length > 1 ? scope.scope.brandName.split(",")[0] + '...' :
scope.scope.brandName.split(",")[0]}}
<el-popover placement="top-start" width="200" trigger="hover">
<p v-for="(item, index) in scope.scope.brandName.split(',')" :key="index">
{{ item }}
</p>
<span class="trick-no" slot="reference" v-show="scope.scope.brandName.split(',').length > 1">({{
scope.scope.brandName.split(",").length - 1 }})</span>
<!-- <el-button slot="reference">hover 激活</el-button> -->
</el-popover>
</template>
<template v-else>-</template>
</div>
<div slot="merchantName" slot-scope="scope">
<template v-if="scope.scope.merchantName">
{{ scope.scope.merchantName.split(",").length > 1 ? scope.scope.merchantName.split(",")[0] + '...' :
scope.scope.merchantName.split(",")[0]}}
<el-popover placement="top-start" width="200" trigger="hover">
<p v-for="(item, index) in scope.scope.merchantName.split(',')" :key="index">
{{ item }}
</p>
<span class="trick-no" slot="reference" v-show="scope.scope.merchantName.split(',').length > 1">({{
scope.scope.merchantName.split(",").length - 1 }})</span>
<!-- <el-button slot="reference">hover 激活</el-button> -->
</el-popover>
</template>
<template v-else>-</template>
</div>
<div slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleEdit(scope.scope)">
编辑
</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">
删除
</el-button>
</div>
</d2-table>
</div>
</d2-container>
</div>
</template>
<script>
import { deepClone } from "@/common/util"
import { getConfigList, getCarbrandTree, deleteConfig, getMateralDetail } from "@api/contentManager"
export default {
data() {
return {
searchForm: {},
showFormData: [
{
label: "品牌",
name: "sceneLabelCode",
addHtml: 'brand'
},
// {
// label: "门店",
// name: "merchantName",
// type: "input",
// // isClear: true,
// // optionList: [],
// // optionId: "merchantId",
// // optionLabel: "merchantName",
// // optionsName: "shopList"
// },
],
searchFormSearch: {},
getListApi: getConfigList,
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
tableOption: true,
tableColumns: [
{
label: "品牌",
prop: "brandName",
addHtml: "brandName"
},
{
label: "关联门店",
prop: "merchantName",
addHtml: "merchantName"
},
{
label: "更新时间",
prop: "updatedDate",
},
]
},
baseData: {
shopList: [],
},
options: [],
cascaderProps: { checkStrictly: true, value: 'id' }
}
},
mounted() {
this.getCarbrandTree()
},
methods: {
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch = deepClone(this.searchForm)
const { brandId, merchantName } = this.searchFormSearch
if (brandId) {
this.searchFormSearch.brandId = brandId[brandId.length - 1]
}
// if (merchantName) {
// this.searchFormSearch.scene = 0
// }
resolve()
})
},
handleSearch() {
this.page = this.$options.data.call(this).page
this.$refs.table.refreshTable(true, true)
},
handleReset() {
this.searchForm = this.$options.data.call(this).searchForm
console.log("this.searchForm", this.searchForm)
this.handleSearch()
},
// 获取品牌树
async getCarbrandTree() {
const res = await getCarbrandTree()
this.options = res
},
handleDialog() {
this.$router.push({ name: "addEquity" })
},
async handleEdit(row) {
const res = await getMateralDetail({id: row.id})
console.log(res)
this.$router.push({ name: "addEquity", query: {
id: row.id,
isRelMerchant: res.isRelMerchant,
materialInfoList: res.materialInfoList,
brandData: res.relList,
storeData: res.relMerchantList
} })
},
handleDelete(row) {
this.$confirm("删除后相关品牌素材将从展业助手中移除", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false
})
.then(async() => {
const res = await deleteConfig({id: row.id})
if (res) {
this.$message.success('删除成功')
this.$refs.table.refreshTable(true, true)
}
else this.$message.error('删除失败')
})
.catch((err) => {
console.log(err)
})
}
}
}
</script>
<style scoped>
.m-t-40 {
margin-top: 40px;
}
.trick-no {
cursor: pointer;
font-size: 13px;
color: #2a58ad;
line-height: 20px;
}
</style>