ruleChangeSet.vue
11 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
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
<!-- 发票查询 - 列表 -->
<template>
<div>
<d2-container>
<div class="header"
slot="header"
style="padding: 20px 20px;">
<d2-search ref="showSearch"
class="show-search"
:search-form="searchForm"
:label-width="labelWidth"
:form-data="showFormData">
<!-- 月开票总额 -->
<div slot="monthlyLimitHtml">
<input-range start-placeholder="最小金额"
end-placeholder="最大金额"
reg-rule-str="priceReg_negative_input"
:display-value="searchForm.monthlyLimit"></input-range>
</div>
</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>
<auth-button category="Button" />
</d2-table-header>
<d2-table ref="recordTable"
:get-list-api="getListApi"
:search-form="searchFormSearch"
:table-params="tableParams"
:before-search-fn="beforeSearchFn">
<div slot="warningEmailsHtml"
slot-scope="scope">
<template v-if="
scope.scope.warningEmails &&
scope.scope.warningEmails.split(',').length > 1
">
<span>{{
scope.scope.warningEmails.split(",").slice(0, 1).join("")
}}</span>
<el-popover placement="top"
width="fit-content"
trigger="hover">
<div :class="{
serverHeight: scope.scope.warningEmails.split(',').length >= 10
}">
<div v-for="(item, index) in scope.scope.warningEmails.split(',')"
:key="index">
{{ item }}
</div>
</div>
<span class="more-info"
slot="reference">...({{ scope.scope.warningEmails.split(",").length }})</span>
</el-popover>
</template>
<template v-else>
<span>{{
scope.scope.warningEmails ? scope.scope.warningEmails : "-"
}}</span>
</template>
</div>
<auth-button slot="auth-button"
slot-scope="scope"
:data="scope.scope" />
</d2-table>
</div>
</d2-container>
<!-- 新增/编辑规则 -->
<editRuleDialog :visible.sync="addVisible"
v-if="addVisible"
:params-obj="recordInfo"
@dialogClose="closeAddDialog" />
<!-- 详情 -->
<ruleDetailDialog :visible.sync="detailVisible"
v-if="detailVisible"
:params-obj="recordInfo"
@dialogClose="closeDetailDialog" />
</div>
</template>
<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { isActiveOpt } from "@/common/constants.js"
import {
getRulePage,
deleteRule
} from "@api/invoiceManage"
import inputRange from './components/inputRange'
import editRuleDialog from './components/editRuleDialog'
import ruleDetailDialog from './components/ruleDetailDialog'
export default {
name: 'InvoiceQueryList',
components: {
inputRange,
editRuleDialog,
ruleDetailDialog
},
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
labelWidth: '120px',
searchForm: {
createdBy: '',
createData: '',
isActive: '',
invoiceSubjectName: '',
switchSubjectName: '',
monthlyLimit: [],
warningEmails: ''
},
searchFormSearch: {},
showFormData: [{
label: '操作人',
name: 'updatedBy',
type: 'input',
maxlength: '50',
isClear: true
}, {
label: '操作时间',
name: 'createData',
type: 'datePicker',
isClear: true,
pickerOptions: 'rangePickerOptions'
}, {
label: "规则生效状态",
name: "isActive",
type: "select",
isClear: true,
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "isActiveOpt"
}, {
label: '开票主体',
name: 'invoiceSubjectName',
type: 'input',
maxlength: '50',
isClear: true
}, {
label: '切换主体',
name: 'switchSubjectName',
type: 'input',
maxlength: '50',
isClear: true
},
{
label: '月开票总额',
name: 'monthlyLimit',
addHtml: "monthlyLimitHtml"
}, {
label: '预警通知邮箱',
name: 'warningEmails',
type: 'input',
maxlength: '50',
isClear: true
}],
getListApi: getRulePage,
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [{
label: "规则状态",
prop: "isActive",
width: '120px',
formatter: (cellValue) => {
return this.baseData.isActiveOpt.find(item => item.confId === cellValue.isActive)?.confValue
},
className: (cellValue) => {
return {
N: 'redSpot',
Y: 'greenSpot'
}[cellValue.isActive]
}
}, {
label: '开票主体',
prop: 'invoiceSubjectName',
width: '250px'
}, {
label: '月开票总额(元)',
prop: 'monthlyLimit',
width: '200px'
}, {
label: '切换主体',
prop: 'switchSubjectName',
width: '200px'
}, {
label: '操作人',
prop: 'updatedBy',
width: '180px'
}, {
label: '操作时间',
prop: 'updatedDate',
width: '150px',
formatter: (cellValue) => {
return cellValue.updatedDate ? Util.dateFormate(cellValue.updatedDate, 'YYYY-MM-DD HH:mm:ss') : '-'
}
}, {
label: '预警通知邮箱',
prop: 'warningEmails',
addHtml: "warningEmailsHtml"
}
]
},
baseData: {
isActiveOpt: deepClone(isActiveOpt)
},
recordInfo: null,
addVisible: false,
detailVisible: false,
redVisible: false,
redInfo: {}
}
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList
})
},
mounted() {
this.getBaseData()
},
methods: {
...mapActions({
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
...mapActions('d2admin/user', ['actionSetDownloadList']),
async getBaseData() {
this.getOptionsList()
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchFormSearch = deepClone(this.searchForm)
if (this.searchFormSearch.createData) {
this.searchFormSearch.startDate = Util.dateFormate(this.searchFormSearch.createData[0], 'YYYY-MM-DD HH:mm:ss')
this.searchFormSearch.endDate = Util.dateFormate(this.searchFormSearch.createData[1], 'YYYY-MM-DD') + ' 23:59:59'
} else {
delete this.searchFormSearch.startDate
delete this.searchFormSearch.endDate
}
if (this.searchFormSearch.monthlyLimit && this.searchFormSearch.monthlyLimit.length > 0) {
this.searchFormSearch.monthlyLimitMin = this.searchFormSearch.monthlyLimit[0] || ''
this.searchFormSearch.monthlyLimitMax = this.searchFormSearch.monthlyLimit[1] || ''
} else {
delete this.searchFormSearch.monthlyLimitMin
delete this.searchFormSearch.monthlyLimitMax
}
resolve()
})
},
getOptionsList() {
this.showFormData.forEach((item, index) => {
if (item.type === 'select') {
if (
this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部'
) {
const temp = {}
temp[this.showFormData[index].optionId] = ''
temp[this.showFormData[index].optionLabel] = '全部'
this.baseData[item.optionsName].unshift(temp)
}
this.$set(
this.showFormData[index],
'optionList',
this.baseData[item.optionsName]
)
}
})
},
handleSearch() {
this.$refs.recordTable.refreshTable(false, true)
},
handleReset() {
this.searchForm = {
createdBy: '',
createData: '',
isActive: '',
invoiceSubjectName: '',
switchSubjectName: '',
monthlyLimit: [],
warningEmails: ''
}
this.$refs.recordTable.refreshTable(false, true)
},
// 开票主体切换规则配置excel导出(异步)
handleExport() {
var params = deepClone(this.searchFormSearch)
// 去除为null的值
for (const key in params) {
if (params[key] === null || params[key] === '' || params[key].length == 0) {
delete params[key]
}
}
params.method = 'dj.smartcarlife.api.vpt.invoice.rule.exportExcel.async'
const list = [
...this.dowloadList,
{
name: '开票主体切换规则配置导出',
exportParam: JSON.stringify(params),
status: 'waiting',
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: 'dowloadList' })
},
// 新增规则
handleAdd() {
this.recordInfo = null
this.addVisible = !this.addVisible
},
closeAddDialog(obj) {
console.log('obj', obj)
this.addVisible = !this.addVisible
if (obj.flag) {
this.$refs.recordTable.refreshTable(false, true)
}
},
// 编辑规则
handleEdit(row) {
this.recordInfo = row
this.addVisible = !this.addVisible
},
// 查看详情
handleDetail(row) {
this.recordInfo = row
this.detailVisible = !this.detailVisible
},
closeDetailDialog() {
this.detailVisible = !this.detailVisible
},
// 删除
handleDelete(row) {
this.$confirm('是否确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
closeOnClickModal: false
}).then(() => {
deleteRule({ id: row.id }).then(res => {
this.notice.okTips()
this.$refs.recordTable.refreshTable()
})
}).catch(err => {
console.log(err)
})
}
}
}
</script>
<style lang="scss" scoped>
.more-info {
white-space: nowrap;
color: #5850ff;
cursor: pointer;
}
</style>