| | |
| | | Object.keys(d.work_plan).forEach((key) => { |
| | | var item = d.work_plan[key]; |
| | | var showTxt = ""; |
| | | var index = 0; |
| | | if (key.indexOf("mon_") > -1) { |
| | | showTxt = "周一"; |
| | | index = 1; |
| | | } |
| | | if (key.indexOf("tue_") > -1) { |
| | | showTxt = "周二"; |
| | | index = 2; |
| | | } |
| | | if (key.indexOf("wed_") > -1) { |
| | | showTxt = "周三"; |
| | | index = 3; |
| | | } |
| | | if (key.indexOf("thur_") > -1) { |
| | | showTxt = "周四"; |
| | | index = 4; |
| | | } |
| | | if (key.indexOf("fri_") > -1) { |
| | | showTxt = "周五"; |
| | | index = 5; |
| | | } |
| | | if (key.indexOf("sat_") > -1) { |
| | | showTxt = "周六"; |
| | | index = 6; |
| | | } |
| | | if (key.indexOf("sun_") > -1) { |
| | | showTxt = "周日"; |
| | | index = 7; |
| | | } |
| | | if (item.id) { |
| | | if (!planMap[item.id]) planMap[item.id] = { showTxt: [] }; |
| | | if (!planMap[item.id]) |
| | | planMap[item.id] = { showTxt: [], index: null }; |
| | | planMap[item.id].times = item.times; |
| | | planMap[item.id].showTxt.push(showTxt); |
| | | if (planMap[item.id].index) { |
| | | if (planMap[item.id].index > index) |
| | | planMap[item.id].index = index; |
| | | } else { |
| | | if (!planMap["null"]) planMap["null"] = { showTxt: [] }; |
| | | planMap[item.id].index = index; |
| | | } |
| | | } else { |
| | | if (!planMap["null"]) planMap["null"] = { showTxt: [], index: 999 }; |
| | | planMap.null.showTxt.push(showTxt); |
| | | } |
| | | }); |
| | | console.log(planMap, "planMap"); |
| | | // 根据班次分类显示时间 |
| | | var html_ = ""; |
| | | |
| | | // 根据班次分类显示时间,并且根据周一到周日排序,休息放在最后 |
| | | var infoList = []; |
| | | Object.keys(planMap).forEach((key) => { |
| | | infoList.push(planMap[key]) |
| | | }); |
| | | infoList.sort((a, b) => a.index - b.index); |
| | | console.log(infoList, "infoList"); |
| | | var html_ = ""; |
| | | for (let i = 0; i < infoList.length; i++) { |
| | | const infoItem = infoList[i]; |
| | | html_ += |
| | | "<p>" + |
| | | planMap[key].showTxt.join("、") + |
| | | infoItem.showTxt.join("、") + |
| | | ":" + |
| | | (planMap[key].times && planMap[key].times.length > 0 |
| | | ? planMap[key].times.map( |
| | | (infoItem.times && infoItem.times.length > 0 |
| | | ? infoItem.times.map( |
| | | (item) => item.begin_time + " - " + item.end_time |
| | | ) |
| | | : "休息") + |
| | | "</p>"; |
| | | }); |
| | | } |
| | | |
| | | console.log(html_); |
| | | |
| | | return html_; |