n20-common-lib 3.2.47 → 3.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -100,20 +100,10 @@ export default {
|
|
|
100
100
|
},
|
|
101
101
|
getOptionLabel(option) {
|
|
102
102
|
if (this.labelMode === 'code-value') {
|
|
103
|
-
if (this.type === TYPE_CASH_FLOW_DIRECTION) {
|
|
104
|
-
return `${option.label}(${option.code})`
|
|
105
|
-
}
|
|
106
103
|
return `${option.code} - ${option.label}`
|
|
107
104
|
}
|
|
108
105
|
return option.label
|
|
109
106
|
},
|
|
110
|
-
getPaymentCategoryOptions() {
|
|
111
|
-
return [
|
|
112
|
-
{ code: 1, label: $lc('收入'), raw: { label: $lc("收入"), value: 1 } },
|
|
113
|
-
{ code: 0, label: $lc('支出'), raw: { label: $lc("支出"), value: 0 } },
|
|
114
|
-
{ code: 2, label: $lc('净额'), raw: { label: $lc("净额"), value: 2 } }
|
|
115
|
-
]
|
|
116
|
-
},
|
|
117
107
|
normalizeResponse(response) {
|
|
118
108
|
if (Array.isArray(response)) return response
|
|
119
109
|
if (response && Array.isArray(response.data)) return response.data
|
|
@@ -132,16 +122,23 @@ export default {
|
|
|
132
122
|
raw: item
|
|
133
123
|
}))
|
|
134
124
|
},
|
|
125
|
+
flattenTreeOptions(list) {
|
|
126
|
+
const result = []
|
|
127
|
+
const flatten = items => {
|
|
128
|
+
items.forEach(item => {
|
|
129
|
+
result.push(item)
|
|
130
|
+
if (Array.isArray(item.children) && item.children.length) {
|
|
131
|
+
flatten(item.children)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
flatten(Array.isArray(list) ? list : [])
|
|
136
|
+
return result
|
|
137
|
+
},
|
|
135
138
|
async loadOptions() {
|
|
136
139
|
const requestSequence = ++this.requestSequence
|
|
137
140
|
this.options = []
|
|
138
141
|
|
|
139
|
-
if (this.type === TYPE_PAYMENT_CATEGORY) {
|
|
140
|
-
this.loading = false
|
|
141
|
-
this.options = this.getPaymentCategoryOptions()
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
142
|
this.loading = true
|
|
146
143
|
try {
|
|
147
144
|
let response
|
|
@@ -150,12 +147,20 @@ export default {
|
|
|
150
147
|
|
|
151
148
|
if (this.type === TYPE_CASH_FLOW_DIRECTION) {
|
|
152
149
|
response = await this.$axios.get(
|
|
153
|
-
'/bems/1.0/cashflow
|
|
154
|
-
{},
|
|
150
|
+
'/bems/1.0/cashflow',
|
|
151
|
+
{ resultType: 1, flowDir: '' },
|
|
152
|
+
{ loading: false, noMsg: true }
|
|
153
|
+
)
|
|
154
|
+
codeKey = 'flowNo'
|
|
155
|
+
labelKey = 'flowName'
|
|
156
|
+
} else if (this.type === TYPE_PAYMENT_CATEGORY) {
|
|
157
|
+
response = await this.$axios.get(
|
|
158
|
+
'/bems/1.0/paymentCategory',
|
|
159
|
+
{ resultType: 1 },
|
|
155
160
|
{ loading: false, noMsg: true }
|
|
156
161
|
)
|
|
157
|
-
codeKey = '
|
|
158
|
-
labelKey = '
|
|
162
|
+
codeKey = 'paymentCategoryNo'
|
|
163
|
+
labelKey = 'paymentCategoryName'
|
|
159
164
|
} else if (this.type === TYPE_PAY_BANK) {
|
|
160
165
|
response = await this.$axios.get('/bems/1.0/bank', { isEnable: 1 }, { loading: false, noMsg: true })
|
|
161
166
|
codeKey = 'bankNo'
|
|
@@ -163,7 +168,11 @@ export default {
|
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
if (requestSequence !== this.requestSequence) return
|
|
166
|
-
|
|
171
|
+
let list = this.normalizeResponse(response)
|
|
172
|
+
if (this.type === TYPE_CASH_FLOW_DIRECTION) {
|
|
173
|
+
list = this.flattenTreeOptions(list)
|
|
174
|
+
}
|
|
175
|
+
this.options = this.normalizeOptions(list, codeKey, labelKey)
|
|
167
176
|
} catch (error) {
|
|
168
177
|
if (requestSequence !== this.requestSequence) return
|
|
169
178
|
this.options = []
|