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
/**
* @Description: 会计期段树
* @author wx
* @date 2022/12/23
*/
<template>
<div class="dxStAccountingConfigTree-com">
<el-tree
:data="treeData"
node-key="id"
default-expand-all
:expand-on-click-node="false"
:highlight-current="true"
@node-click="nodeClick"
>
<span slot-scope="{ node, data }" class="custom-tree-node">
<div>
<span>{{ data.label }} </span>
</div>
<span v-if="data.isDefault" class="tree-btn-box">
<span class="btn-item" title="设置" @click="() => setConfig(data, node)">
<img src="/icons/c-setting.png" alt="">
</span>
</span>
</span>
</el-tree>
<dee-dialog
:dialog-visible="dialogVisible"
title="设置会计期段"
width="580px"
@handleClose="handleClose"
>
<dee-form
ref="AddForm"
:form="form"
:form-data="AddData"
form-btn-position="center"
:inline="true"
:rules="rules1"
/>
<dee-up-table
table-height="auto"
:columns="tableColums"
:data="tableData"
>
<span v-if="curNodeData && curNodeData.label" slot="header">{{ curNodeData.label }}年 {{ getFirstDayOfMonth(curNodeData.label,1) }}~{{ getLastDayOfMonth(curNodeData.label,12) }}</span>
</dee-up-table>
<span style="display:flex;justify-content: center;margin-top: 20px;">
<el-button
type="primary"
class="searchBtn"
@click="handleSubmit"
>确定</el-button>
<el-button
class="searchBtn"
@click="handleClose"
>取消</el-button>
</span>
</dee-dialog>
</div>
</template>
<script>
import { getDxStAccountingConfigTree } from '@/api/storage'
import countSection from './countSection'
export default {
componentName: '会计期段树',
name: 'DxStAccountingConfigTree',
// import引入的组件需要注入到对象中才能使用
components: {},
mixins: [countSection],
props: {
basicData: {
type: Object,
default: null
}
},
data() {
// 这里存放数据
return {
evenList: [
{
even: 'nodeClick',
name: '节点被点击时的回调'
}
],
dialogVisible: false,
curNodeData: null,
treeData: [{
id: -1,
label: '年度',
children: []
}],
form: {
sectionType: ''
},
rules1: {
sectionType: [
{ required: true, message: '请输入', trigger: 'change' }
] },
AddData: [
{
split: 2,
data: [{
key: 'sectionType',
title: '期段',
component: {
name: 'el-select',
options: [{
label: '月度',
value: 12
}, {
label: '季度',
value: 4
}, {
label: '半年度',
value: 2
}, {
label: '年度',
value: 1
}]
}
}]
}],
tableData: [],
tableColums: [
{
title: '期段', key: 'section', align: 'center'
},
{
title: '开始时间', key: 'startDay', align: 'center'
},
{
title: '结束时间', key: 'endDay', align: 'center'
}
]
}
},
// 监听属性 类似于data概念
computed: {
},
// 监控data中的数据变化
watch: {
'form.sectionType': {
handler: function(val) {
this.getTableData(val)
}
}
},
// 生命周期 - 创建完成(可以访问当前this实例)
created() {
},
// 生命周期 - 挂载完成(可以访问DOM元素)
mounted() {
this.getDxStAccountingConfigTree()
},
activated() {
},
// 方法集合
methods: {
getDxStAccountingConfigTree() {
const params = {
'maxPageSize': 10000,
'indices': [],
'globalSearch': false,
'aggregationSearchParam': {
'groupBys': [
{
'fieldName': 'years',
'typeName': '.TermsAggregationGroupBy',
'ascOrder': true
}
],
'metrics': [
{
'name': 'idCount',
'fieldName': 'id',
'metricsType': 'CARDINALITY'
}
]
},
'openProps': [],
'searchItems': {
'items': [],
'operator': 'AND'
},
'sortItem': []
}
const curYear = new Date().getFullYear()
getDxStAccountingConfigTree(params).then(res => {
this.treeData[0].children = res.items.data.map((r, index) => {
return {
id: index + 1,
label: r.years
}
})
const findCurYear = this.treeData[0].children.find(r => r.label === curYear)
if (!findCurYear) {
this.treeData[0].children.push({
id: this.treeData[0].children.length + 1,
label: curYear,
isDefault: true
})
}
})
},
nodeClick(val) {
val.id !== -1 && this.$emit('nodeClick', val)
},
setConfig(data, node) {
this.curNodeData = data
this.dialogVisible = true
},
handleClose() {
this.dialogVisible = false
},
handleSubmit() {
const params = JSON.parse(JSON.stringify(this.tableData)).map(r => {
r.startDay = r.startDay + ' 00:00:00'
r.endDay = r.endDay + ' 23:59:59'
return r
})
this.$api.recursion('DxStAccountingConfig', params, true).then(res => {
this.$utils.showMessageSuccess('设置成功')
this.getDxStAccountingConfigTree()
this.handleClose()
})
}
}
}
</script>
<style lang='scss'>
.dxStAccountingConfigTree-com{
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
.tree-btn-box {
width: 66px;
display: flex;
justify-content: space-between;
align-items: center;
height: 100%;
.btn-item img {
padding: 4px;
width: 14px;
height: 14px;
}
}
}
</style>