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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<template>
<div>
<el-dialog
:title="brandName"
:visible.sync="dialogVisible"
width="1080px"
:before-close="handleClose()">
<el-tabs v-model="activeName">
<el-tab-pane :label="$t('未授权客户')" name="first">
<div class="brand">
<el-radio-group v-model="productBrank.unauthChargingModel" @change="changeModel">
<el-radio label="0">{{$t('统一收费标准')}}</el-radio>
<el-radio label="1">{{$t('针对客户收费标准')}}</el-radio>
</el-radio-group>
</div>
<div v-if="productBrank.unauthChargingModel==0" class="brand">
<span>{{$t('针对所有未授权客户的收费模式')}}:</span>
<el-select v-model="productBrank.unauthDefaultFeeType" :placeholder="$t('请选择')" size="small" style="margin-right: 10px;">
<el-option
v-for="(item,index) in feeType"
:key="index"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button type="primary" @click="updateBrank">{{$t('确定修改')}}</el-button>
</div>
<el-form :inline="true" class="demo-form-inline">
<el-form-item :label="$t('关键字')">
<el-input v-model="list1QueryParams.customerKey" :placeholder="$t('请填入关键字')"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="filterCustomer">{{$t('查询')}}</el-button>
</el-form-item>
</el-form>
<el-table
:data="list1"
style="width: 100%">
<el-table-column
prop="customerName"
:label="$t('客户名称')">
</el-table-column>
<el-table-column
prop="phone"
:formatter="(row, column, cellValue) => '+' + cellValue"
:label="$t('客户号码')">
</el-table-column>
<el-table-column
prop="feeScale"
:label="$t('收费类型')">
<template slot-scope="scope">
<dict-tag v-if="productBrank.unauthChargingModel==1&&scope.row.feeScale" :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL" :value="scope.row.feeScale" />
<span v-else-if="productBrank.unauthDefaultFeeType">{{productBrank.unauthDefaultFeeType==1?$t('有牌价'):$t('中性价')}}</span>
</template>
</el-table-column>
<el-table-column
width="200px"
:label="$t('操作')">
<template v-slot="{row}">
<el-button type="primary" size="mini" @click="handleAdd(row)">{{$t('添加授权')}}</el-button>
<el-button v-if="productBrank.unauthChargingModel=='1'" type="primary" size="mini" @click="editAdd(row)">{{$t('修改收费')}}</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total1 > 0" :total="total1" :page.sync="list1QueryParams.pageNo" :limit.sync="list1QueryParams.pageSize"
@pagination="getList1" style="height: 40px"/>
</el-tab-pane>
<el-tab-pane :label="$t('已授权客户')" name="second">
<el-table
:data="list2"
style="width: 100%">
<el-table-column
prop="customerName"
:label="$t('客户名称')">
</el-table-column>
<el-table-column
prop="phone"
:formatter="(row, column, cellValue) => '+' + cellValue"
:label="$t('客户号码')">
</el-table-column>
<el-table-column
prop="fileUrl"
:label="$t('授权证明')">
<template v-slot="{row}">
<div v-if="!!row.fileUrl && row.fileUrl.length > 0">
<span v-for="(item, index) in row.fileUrl.split(',')">
<a :href="item" target="_blank">{{$t('附件')}}{{ index + 1 }}</a>,
</span>
</div>
</template>
</el-table-column>
<el-table-column
prop="startTime"
width="200px"
:label="$t('授权时间')">
<template v-slot="{row}">
<span >{{row.startTime?(parseTime(row.startTime, '{y}-{m}-{d}') + ' - ' + parseTime(row.endTime, '{y}-{m}-{d}')):'永久'}}</span>
</template>
</el-table-column>
<el-table-column
prop="feeScale"
:formatter="(row) => getDictDataLabel(DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL, row.feeScale)"
:label="$t('收费标准')">
</el-table-column>
<el-table-column
prop="createUsername"
:label="$t('添加人')">
</el-table-column>
<el-table-column
width="100px"
:label="$t('操作')">
<template v-slot="{row}">
<el-button type="danger" size="mini" @click="handleDelete(row.id)">{{$t('删除')}}</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total2 > 0" :total="total2" :page.sync="list2QueryParams.pageNo" :limit.sync="list2QueryParams.pageSize"
@pagination="getList2" style="height: 40px"/>
</el-tab-pane>
</el-tabs>
</el-dialog>
<!-- 添加弹窗 -->
<el-dialog
:title="$t('添加')"
:visible.sync="addDialog.dialogVisible"
width="600px">
<el-form ref="form" :model="addDialog.form" label-width="80px">
<el-form-item :label="$t('客户名称')">{{ addDialog.form.customerName }}</el-form-item>
<el-form-item :label="$t('授权类型')">
<dict-selector v-model="addDialog.form.authType" :type="DICT_TYPE.ECW_AUTH_TYPE"></dict-selector>
</el-form-item>
<el-form-item :label="$t('授权时间')" v-if="addDialog.form.authType==1">
<!-- <el-date-picker
v-model="addDialog.dateRange"
@chang="handleDatePick"
type="daterange"
range-separator="至"
value-format="timestamp"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker> -->
<el-date-picker clearable v-model="addDialog.form.startTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss" type="datetime" :placeholder="$t('请选择开始日期')" />
<span style="margin: 0 8px;">{{$t('到')}}</span>
<el-date-picker clearable v-model="addDialog.form.endTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss" type="datetime" :placeholder="$t('请选择结束日期')" />
</el-form-item>
<el-form-item :label="$t('收费模式')">
<dict-selector v-model="addDialog.form.feeScale" :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL"></dict-selector>
</el-form-item>
<el-form-item :label="$t('授权证明')">
<file-upload v-model="addDialog.form.fileUrl"></file-upload>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="addDialog.dialogVisible = false">{{$t('取消')}}</el-button>
<el-button type="primary" @click="handleAddSubmit">{{$t('确定')}}</el-button>
</span>
</el-dialog>
<!-- 添加弹窗 -->
<el-dialog
:title="$t('修改单个客户收费模式')"
:visible.sync="editDialog.dialogVisible"
width="500px">
<el-form ref="form" :model="editDialog.form" label-width="80px">
<el-form-item :label="$t('客户名称')">{{ editDialog.customerName }}</el-form-item>
<el-form-item :label="$t('收费模式')">
<el-select v-model="editDialog.form.feeScale" :placeholder="$t('请选择')" size="small" style="margin-right: 10px;">
<el-option
v-for="item in feeType"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<!-- <dict-selector v-model="editDialog.form.feeScale" :type="DICT_TYPE.BRAND_CUSTOMER_CHARGING_MODEL"></dict-selector> -->
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleEditSubmit">{{$t('确定修改')}}</el-button>
<el-button @click="editDialog.dialogVisible = false">{{$t('关闭窗口')}}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {
createProductBrandEmpower,
deleteProductBrandEmpower,
getProductBrandEmpowerPageAuth,
getProductBrandEmpowerPageUnauth
} from "@/api/ecw/productBrandEmpower"
import {getProductBrank,changeFeeModel,setUnauthCustomerFeeType} from "@/api/ecw/productBrank";
import DictSelector from "@/components/DictSelector"
import { DICT_TYPE, getDictDataLabel } from '@/utils/dict'
import FileUpload from '@/components/FileUpload'
import { parseTime } from '@/utils/ruoyi'
export default {
name: "Empower",
components: {
DictSelector,
FileUpload
},
props: {
id: {
type: Number,
default: 0
},
brandName: String,
visible: {
type: Boolean,
default: false
}
},
data() {
return {
DICT_TYPE,
getDictDataLabel,
parseTime,
dialogVisible: false,
activeName: 'first',
total1: 0,
total2: 0,
list1: [],
list2: [],
feeType:[{
label:this.$t('有牌价'),
value:1
},{
label:this.$t('中性价'),
value:2
}],
unauthChargingModel:0,
list1QueryParams: {
pageNo: 1,
pageSize: 10,
customerKey: undefined
},
list2QueryParams: {
pageNo: 1,
pageSize: 10,
},
productBrank:{},
addDialog: {
dialogVisible: false,
customerName: '',
form: {
"customerContactsId": 0,
"customerId": 0,
"endTime": "",
"feeScale": '0',
"fileUrl": "",
"productBrandId": null,
"startTime": "",
"status": 0,
"authType":'0'
},
dateRange: []
},
editDialog: {
dialogVisible: false,
customerName: '',
form: {
"customerContactsId": 0,
"customerId": 0,
"feeScale":1,
"productBrandId": null,
}
}
}
},
mounted() {
},
methods: {
getBrank(){
getProductBrank(this.id).then(r => {
this.productBrank = r.data
if(this.productBrank.unauthDefaultFeeType){
this.productBrank.unauthDefaultFeeType = parseInt(this.productBrank.unauthDefaultFeeType)
}
this.unauthChargingModel = this.productBrank.unauthChargingModel
})
},
handleAddSubmit(){
this.addDialog.form.productBrandId = this.id
createProductBrandEmpower(this.addDialog.form).then(() => {
this.addDialog.dialogVisible = false
this.getList1()
this.getList2()
this.resetForm("form");
})
},
handleEditSubmit(){
var data = {}
data = this.editDialog.form
data.productBrandId = this.id
setUnauthCustomerFeeType(data).then(() => {
this.getList1()
this.editDialog = {
dialogVisible: false,
customerName: '',
form: {
"customerContactsId": 0,
"customerId": 0,
"feeScale":1,
"productBrandId": null,
}
}
})
},
handleDatePick(e){
console.log(e)
},
handleClose() {},
filterCustomer() {
this.list1QueryParams.pageNo = 1
this.getList1()
},
updateBrank(){
let params = {}
if(this.productBrank.unauthChargingModel==1){
params = {
id:this.productBrank.id,
unauthChargingModel:this.productBrank.unauthChargingModel,
}
}else{
params = {
id:this.productBrank.id,
unauthChargingModel:this.productBrank.unauthChargingModel,
unauthDefaultFeeType:this.productBrank.unauthDefaultFeeType
}
}
console.log(params)
changeFeeModel(params).then(r=>{
this.getList1()
this.getList2()
this.getBrank()
this.$modal.msgSuccess(this.$t("修改成功"));
})
},
changeModel(){
if(this.productBrank.unauthChargingModel==1&&this.unauthChargingModel != this.productBrank.unauthChargingModel){
this.updateBrank()
}
},
handleAdd(row) {
this.addDialog.form.customerId = row.customerId
this.addDialog.form.customerName = row.customerName
this.addDialog.dialogVisible = true
},
editAdd(row){
this.editDialog.form.customerId = row.customerId
if(row.customerContactsId){
this.editDialog.form.customerContactsId = row.customerContactsId
}
this.editDialog.customerName = row.customerName
this.editDialog.dialogVisible = true
},
handleDelete(id) {
this.$confirm(this.$t('确认删除该用户的授权')+'?', this.$t('提示'), {
confirmButtonText: this.$t('确定'),
cancelButtonText: this.$t('取消'),
type: 'warning'
}).then(() => {
deleteProductBrandEmpower(id).then(r => {
this.getList1()
this.getList2()
this.$message({
type: 'success',
message: this.$t('撤销授权成功')
});
})
}).catch(() => {
this.$message({
type: 'info',
message: this.$t('已取消删除')
});
});
},
getList1(){
getProductBrandEmpowerPageUnauth({...this.list1QueryParams, productBrandId: this.id}).then(r => {
this.list1 = r.data.list
this.total1 = r.data.total
})
},
getList2() {
getProductBrandEmpowerPageAuth({...this.list2QueryParams, productBrandId: this.id}).then(r => {
this.list2 = r.data.list
})
}
},
watch: {
visible(v){
if (v){
this.list1QueryParams.pageNo = 1
this.list2QueryParams.pageNo = 1
this.unauthDefaultFeeType = "1"
this.list1QueryParams.customerKey = ''
this.getList1()
this.getList2()
this.getBrank()
}
this.dialogVisible = v
},
dialogVisible(v) {
this.$emit('update:visible', v)
},
'addDialog.dateRange'(v) {
this.addDialog.form.startTime = v[0]
this.addDialog.form.endTime = v[1]
}
}
}
</script>
<style scoped>
.brand{
padding-bottom: 20px;
}
</style>