diff --git a/src/views/order/component/createDispatch.vue b/src/views/order/component/createDispatch.vue index 6a38757..a4d8078 100644 --- a/src/views/order/component/createDispatch.vue +++ b/src/views/order/component/createDispatch.vue @@ -1,6 +1,30 @@ @@ -88,6 +89,8 @@ export default { }, data() { return { + dispatches: [], + transferDispatches: [], createType: 1, pickerOptions: { firstDayOfWeek: 1, @@ -149,6 +152,68 @@ export default { render: (h, { row, index }) => { let text = row.equipment ? row.equipment.name : ""; return h("div", [ + h('el-popover',{ + props: { + title: "今日调令", + width: "400px" + }, + on: { + show: _ => { + this.transferDispatches = this.dispatches.filter(i => (i.equipment_id === row.equipment_id)) + } + } + },[ + h('span',{ + slot: 'reference', + // props: { + // type: "ios-list-box" + // }, + style: { + 'border-radius': '100%', + 'margin-right': '4px', + 'cursor': 'pointer', + 'width': '20px', + 'height': '20px', + 'display': 'inline-block', + 'background': '#367bc7', + 'color': '#fff' + } + },this.dispatches.reduce((pre,cur) => { + return cur.equipment_id === row.equipment_id ? ++pre : pre + },0)), + h('Table',{ + style: { + 'width': "480px" + }, + props: { + size: "small", + data: this.transferDispatches, + columns: [ + { + title: " ", + type: "index", + width: 46 + }, + { + title: '开始时间', + key: 'start_time', + align: 'center', + render:(h, { row }) => (h('span',this.$moment(row.start_time).format('YYYY-MM-DD HH:mm'))) + }, + { + title: '结束时间', + key: 'end_time', + align: 'center', + render:(h, { row }) => (h('span',this.$moment(row.end_time).format('YYYY-MM-DD HH:mm'))) + }, + { + title: '内容', + key: 'content' + } + ] + } + }) + ]), h('span',text), h('Button',{ props: { @@ -216,11 +281,58 @@ export default { format: "HH:mm" }, on: { - ["on-change"]: (e) => (this.data[index].start_time = e), + ["on-change"]: (e) => { + this.data[index].start_time = e + + if (this.data[index]._last) { + const [hour,min] = this.data[index].start_time.split(':').map(i => Number(i)) + let addTime = { + hour: Math.floor(this.data[index]._last), + min: (this.data[index]._last % 1) * 60 + } + let resTime = { + hour: hour + addTime.hour + ((min + addTime.min) >= 60 ? 1 : 0), + min: (min + addTime.min) % 60 + } + this.data[index].end_time = `${resTime.hour}:${resTime.min}` + } + }, }, }); }, }, + { + title: "持续时间(时)", + width: 140, + align: "center", + key: "last", + render: (h,{ row, index }) => { + return h('InputNumber',{ + props: { + value: 0, + min: 0, + step: 0.5, + size: "small", + precision: 1 + }, + on: { + ['on-change']:e => { + this.data[index]._last = e + const [hour,min] = this.data[index].start_time.split(':').map(i => Number(i)) + let addTime = { + hour: Math.floor(e), + min: (e % 1) * 60 + } + let resTime = { + hour: hour + addTime.hour + ((min + addTime.min) >= 60 ? 1 : 0), + min: (min + addTime.min) % 60 + } + this.data[index].end_time = `${resTime.hour}:${resTime.min}` + } + } + }) + } + }, { title: "结束时间", width: 140, @@ -339,6 +451,29 @@ export default { }; }, methods: { + clone () { + let verify = true; + const submitData = this.data.filter(i => (i.start_time || i.end_time || i.content)); + submitData.forEach(item => { + if (!item.start_time || !item.end_time || !item.level) { + verify = false; + } + }) + if (!verify) { + this.$message({ + type: 'warning', + message: '请填写完整信息' + }) + return + } + submitData.forEach(i => { + delete i['equipment_id-span'] + delete i['_index'] + delete i['_rowKey'] + }) + console.log(JSON.stringify(submitData)) + }, + clear () { this.select = { area: [], @@ -498,7 +633,7 @@ export default { }, equipmentList() { return this.equipments() || []; - }, + } }, watch: { equipmentList(val) { @@ -551,10 +686,14 @@ export default { }, mounted() {}, created() { + this.$bus.$on("getDispatches", dispatches => (this.dispatches = dispatches)) this.getArea(); this.getType(); this.getAbility(); }, + destroyed() { + this.$bus.$off("getDispatches") + } }; diff --git a/src/views/order/component/dispatchList.vue b/src/views/order/component/dispatchList.vue index 3c0b811..66264b0 100644 --- a/src/views/order/component/dispatchList.vue +++ b/src/views/order/component/dispatchList.vue @@ -214,6 +214,8 @@ export default { this.data = res.data; this.total = res.total; this.loading = false; + + this.$bus.$emit('getDispatches', this.data) } catch (e) { this.loading = false; }