This commit is contained in:
熊成强 2020-11-13 18:12:53 +08:00
parent 16ee3ecdc1
commit 363d9a4b72

View File

@ -5,7 +5,7 @@
:props="props" :props="props"
:options="timeOptions" :options="timeOptions"
@change="handleChange" @change="handleChange"
v-model="defaultStartId" v-model="startId"
style="width:250px"> style="width:250px">
</el-cascader> </el-cascader>
<div class="report_content"> <div class="report_content">
@ -89,10 +89,8 @@ export default {
return { return {
// //
pickerTime: '', pickerTime: '',
//
defaultStartId: [],
// id // id
startId: '', startId: [0, 0],
// //
statisticals: [ statisticals: [
{num: '0', desc: '参与人数'}, {num: '0', desc: '参与人数'},
@ -109,30 +107,19 @@ export default {
// //
value: [], value: [],
timeOptions: [{ timeOptions: [{
value: 0, startId: 0,
label: '月底', time: '月底',
children: [] children: []
}, { }, {
value: 1, startId: 1,
label: '自定义', time: '自定义',
children: [] children: []
}], }],
// //
props: { props: {
lazy: true, value: 'startId',
lazyLoad: (node, resolve) => { label: 'time',
// level: true
let type = node.data.value
// 2
this.handleStartsReq(type, function (reslut) {
const childNode = Array.from(reslut.list).map(item => ({
value: item.startId,
label: item.time
}))
// console.log(childNode)
resolve(childNode)
})
}
}, },
// //
option: { option: {
@ -215,7 +202,8 @@ export default {
computed: { computed: {
}, },
beforeMount () { }, beforeMount () { },
mounted () { async mounted () {
await this.handleStartsReq()
this.handleChartDataReq() this.handleChartDataReq()
}, },
methods: { methods: {
@ -286,15 +274,6 @@ export default {
this.$loadingStart() this.$loadingStart()
const result = await getChartData(params) const result = await getChartData(params)
this.$loadingEnd() this.$loadingEnd()
// startIdstartId
if (typeof startId === 'undefined') {
this.defaultStartId[0] = result.data[0].type
this.defaultStartId[1] = result.data[0].defaultId
this.startId = result.data[0].defaultId
this.defaultStartName = result.data[0].defaultTime
//
// this.handleStartsReq(result.data[0].type)
}
result.data.forEach((val, index) => { result.data.forEach((val, index) => {
if (val.type === 0) { if (val.type === 0) {
// //
@ -325,21 +304,22 @@ export default {
pageSize: 999 pageSize: 999
} }
try { try {
let res = await getStartsData(params) for (let i in this.timeOptions) {
if (typeof handleNode === 'undefined') { let res = await getStartsData(Object.assign({}, params, { cycleType: this.timeOptions[i].startId }))
let children = Array.from(res.data.list).map(item => ({ if (res.code !== 200) return this.$message.error(res.msg)
value: item.startId, res = res.data
label: item.time, console.log('res: ', res)
leaf: true this.key += 10
})) this.timeOptions[i].children = res.list.map((m, mindex) => {
if (type === 0) { console.log('timeOptions: ', typeof i)
this.timeOptions[0].children = children
} else { if (i === '0' && mindex === 0) {
this.timeOptions[1].children = children this.startId = [0, m.startId]
} }
} else { return m
handleNode(res.data) })
} }
console.log('this.timeOptions: ', this.timeOptions)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }