|
|
@@ -301,12 +301,23 @@ export default {
|
|
|
onResponse(data) {
|
|
|
console.log(data, 'data')
|
|
|
this.alertTip = '统计数据:' + data.total_amount
|
|
|
- this.searchForm[2].options = []
|
|
|
- data.change_types.forEach((e) => {
|
|
|
- this.searchForm[2].options.push({
|
|
|
- label: e,
|
|
|
- value: e
|
|
|
- })
|
|
|
+ // 合并接口 change_types 与列表数据中实际出现的类型,避免下拉框缺项
|
|
|
+ // 需在 nextTick 读取,因为 YMTable 先 emit onResponse 再赋值 listData
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const changeTypes = Array.isArray(data.change_types) ? [...data.change_types] : []
|
|
|
+ const listData = this.$refs.table ? this.$refs.table.listData : []
|
|
|
+ if (Array.isArray(listData)) {
|
|
|
+ listData.forEach((r) => {
|
|
|
+ if (r.change_type && !changeTypes.includes(r.change_type)) {
|
|
|
+ changeTypes.push(r.change_type)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 按 prop 定位「类型」下拉框,填充 change_types 选项
|
|
|
+ const typeItem = this.searchForm.find(item => item.prop === 'change_type')
|
|
|
+ if (typeItem) {
|
|
|
+ typeItem.options = changeTypes.map((e) => ({ label: e, value: e }))
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
onValueChange(val) {
|