ledgerList.vue
10.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
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
<!-- 分账类目 -->
<template>
<div>
<div class="d2-container-content" style="padding: 10px 20px;">
<d2-search ref="showSearch" class="show-search" :search-form="searchForm" :form-data="showFormData" />
<div class="up-btns">
<el-button :id="tableParams.btnId" size="small" type="primary">
查询
</el-button>
<el-button size="small" @click="handleReset">
重置
</el-button>
</div>
</div>
<div class="d2-container-content">
<d2-table-header>
<span slot="left">
<auth-button category="Button" :show-btn-ids="['9061601']" />
</span>
</d2-table-header>
<d2-table ref="ledgerListTable" :search-form="searchForm" :table-params="tableParams" :get-list-api="getListApi"
:before-search-fn="beforeSearchFn">
<template slot="formType" slot-scope="scope">
<el-popover placement="top" width="300" trigger="hover" v-if="scope.scope.formType == 2">
<div class="merchant-name-box">
{{ formTypeFilter(scope.scope) }}
</div>
<div slot="reference">
{{ formTypeFilter(scope.scope, 20) }}
</div>
</el-popover>
<div v-else>-</div>
</template>
<template slot="applicationSceneTypes" slot-scope="scope">
<el-popover placement="top" width="300" trigger="hover">
<div class="merchant-name-box">
{{ applicationSceneTypesFliter(scope.scope) }}
</div>
<div slot="reference">
{{ applicationSceneTypesFliter(scope.scope, 20) }}
</div>
</el-popover>
</template>
<div slot="auth-button" slot-scope="scope" v-if="filterEnableEdit(scope.scope.sourceType)">
<auth-button slot="auth-button" :show-btn-ids="['9061602']" :data="scope.scope" />
<auth-button slot="auth-button" :show-btn-ids="['9061603']" :data="scope.scope" />
</div>
</d2-table>
</div>
</div>
</template>
<script>
import { Util, deepClone } from '@/common/util'
import { mapActions } from 'vuex'
import { selectFeeCategoryList, deleteFeeCategory } from '@api/costCategory'
import { sceneCodeList, sceneList, targetType } from '@/common/constants.js'
export default {
name: 'LedgerList',
data() {
return {
searchForm: {
feeCategoryType: 1,
feeCategoryName: '',
applicationSceneType: '',
applicationObjectType: '',
formType: ''
},
showFormData: [{
label: '类目名称',
name: 'feeCategoryName',
type: 'input',
maxlength: '20',
isClear: true,
keyFn: this.keyDowmGetList
}, {
label: '应用场景',
name: 'applicationSceneType',
type: 'select',
isClear: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confValue',
optionsName: 'sceneTypeList'
}, {
label: '应用对象',
name: 'applicationObjectType',
type: 'select',
isClear: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'objList'
},
{
label: '费用类型',
name: 'formType',
type: 'select',
isClear: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'formTypeList'
}
],
// maxLength: 10,
getListApi: selectFeeCategoryList,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [{
label: '费用类目名称',
prop: 'feeCategoryName',
minWidth: '140'
}, {
label: '费用类型',
// prop: 'feeCategoryNameList',
width: '90',
formatter: (cellValue) => {
return cellValue.formType == 1 ? '普通' : '可拓展'
}
}, {
label: '子类目',
width: '300',
addHtml: 'formType',
formatter: (cellValue) => {
if (cellValue.formType == 2) {
let str = ''
cellValue.feeCategoryChildren.map((item, index) => {
const unit = cellValue.feeCategoryChildren.length - 1 == index ? '' : ','
str += item.feeCategoryName + unit
})
return str
} else {
return '-'
}
}
}, {
label: '应用场景',
prop: 'applicationSceneTypes',
addHtml: 'applicationSceneTypes',
width: '300',
formatter: (cellValue) => {
// applicationSceneTypes
const scenes = cellValue.applicationSceneTypes
if (scenes && scenes.length > 0) {
const list = scenes.map(item => {
return sceneList[item]
})
return list.join(",")
} else {
return ''
}
}
}, {
label: '应用对象',
prop: 'applicationObjectType',
width: '90',
formatter: (cellValue) => {
return targetType[cellValue.applicationObjectType]
}
}, {
label: '创建人',
prop: 'createdBy',
width: '100'
}, {
label: '创建时间',
prop: 'createdDate',
width: '160',
formatter: (cellValue) => {
return Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss')
}
}]
},
baseData: {
objList: [
{
confId: 1,
confLabel: '流量方'
}, {
confId: 2,
confLabel: '服务商'
}, {
confId: 3,
confLabel: '公共'
}
],
formTypeList: [
{
confId: 1,
confLabel: '普通'
}, {
confId: 2,
confLabel: '可拓展'
}
],
sceneTypeList: deepClone(sceneCodeList)
},
hideOptList: [1, 2, 3, 4, 5]
}
},
// // 定义组件过滤器
// filters: {
// filterEnableEdit(sourceType) {
// console.log('sourceType', sourceType)
// return sourceType != 1
// }
// },
filters: {
// formTypeFilter(ele, lenght) {
// console.log(ele)
// if (ele.formType == 2 && ele.feeCategoryChildren.length) {
// let str = ''
// ele.feeCategoryChildren.map((item, index) => {
// // console.log(item.)
// const unit = ele.feeCategoryChildren.length - 1 == index ? '' : ','
// str += item.feeCategoryName + unit
// })
// return str
// } else {
// return '-'
// }
// }
},
components: {
// relationCategoryDialog
},
mounted() {
this.getBaseData()
this.$nextTick(() => {
// console.log(this.$refs.ledgerListTable, 'this.$refs.ledgerListTable.page')
if (this.$refs.ledgerListTable && this.$refs.ledgerListTable.page) this.$refs.ledgerListTable.page.pageSize = 10
})
},
methods: {
...mapActions({ close: 'd2admin/page/close' }),
formTypeFilter(ele, lenght) {
// console.log(ele)
// console.log(lenght)
if (ele.formType == 2 && ele.feeCategoryChildren.length) {
let str = ''
ele.feeCategoryChildren.map((item, index) => {
// console.log(item.)
const unit = ele.feeCategoryChildren.length - 1 == index ? '' : ','
str += item.feeCategoryName + unit
})
return lenght ? (str?.length > lenght ? str.substring(0, lenght) + '\u2026' : str.substring(0, lenght)) : str
} else {
return '-'
}
},
applicationSceneTypesFliter(cellValue, lenght) {
// applicationSceneTypes
const scenes = cellValue.applicationSceneTypes
if (scenes && scenes.length > 0) {
const list = scenes.map(item => {
return sceneList[item]
})
return lenght ? (list.join(",")?.length > lenght ? list.join(",").substring(0, lenght) + '\u2026' : list.join(",").substring(0, lenght)) : list.join(",")
} else {
return '-'
}
},
async getBaseData() {
this.getOptionsList()
},
// 1是自建 2是系统内置 (不允许修改)
filterEnableEdit(sourceType) {
// console.log('sourceType', sourceType)
return sourceType != 2
},
beforeSearchFn() {
return new Promise(resolve => {
resolve()
})
},
keyDowmGetList() {
this.$refs.ledgerListTable.refreshTable()
},
handleReset() {
this.searchForm = {
feeCategoryType: 1,
feeCategoryName: '',
applicationSceneType: '',
applicationObjectType: '',
formType: ''
}
this.$refs.ledgerListTable.refreshTable()
},
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]
)
}
})
},
addLedgerCategory() {
this.close({ tagName: '/editLedger' })
this.$router.push({
name: 'editLedger',
params: {
addOrEdit: 'add',
activeName: 'ledger'
}
})
},
editLedgerCategory(row) {
this.close({ tagName: '/editLedger' })
this.$router.push({
name: 'editLedger',
params: {
addOrEdit: 'edit',
info: row,
activeName: 'ledger'
}
})
},
// 删除
delLedgerCategory(row) {
this.$confirm("删除后不可恢复,不影响原有已设置的财务规则。是否确定删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false
})
.then(() => {
deleteFeeCategory({ id: row.id }).then((res) => {
this.notice.okTips()
this.$refs.ledgerListTable.refreshTable()
})
})
.catch((err) => {
console.log(err)
})
}
}
}
</script>
<style scoped></style>