调令导出

master
xy 1 year ago
parent f6b36bd48e
commit 8e9e483ab3

@ -12,7 +12,7 @@
<header-content :auths="auths_auth_mixin"> <header-content :auths="auths_auth_mixin">
<template #search> <template #search>
<div style="display: flex"> <div style="display: flex">
<el-date-picker type="daterange" v-model="selectDate" size="small" :clearable="false" style="width: 220px;" @change="getTransfer"></el-date-picker> <el-date-picker type="daterange" v-model="selectDate" size="small" :clearable="false" style="width: 220px;" @change="search"></el-date-picker>
<!-- <Button--> <!-- <Button-->
<!-- style="margin-left: 10px"--> <!-- style="margin-left: 10px"-->
<!-- type="primary"--> <!-- type="primary"-->
@ -28,41 +28,39 @@
</div> </div>
</div> </div>
<el-card id="docx-content"> <el-card id="docx-content" v-loading="loading"
<div class="title">{{ selectDate[0] ? $moment(selectDate[0]).format('YYYY-MM-DD') : "-" }} ~ {{ selectDate[1] ? $moment(selectDate[1]).format('YYYY-MM-DD') : "-" }}调度指令执行情况</div> element-loading-spinner="el-icon-loading"
element-loading-text="拼命加载中"
element-loading-background="rgba(0, 0, 0, 0.8)">
<div v-for="(value, date) in showData" :key="date" v-if="Object.keys(value).length > 0">
<div class="title">{{ date }}调度指令执行情况</div>
<p class="weather">{{ weather[date] ? weather[date].weather : '' }}</p>
<p style="text-indent: 30px;line-height: 1.2;padding: 20px 0;">{{ weather.weather }}</p> <div v-for="(area, areaId) in value" :key="areaId">
<div class="area">{{ area.area ? area.area.key : '暂无区域' }}</div>
<div v-for="(item, index) in showData.filter(i => i._data.size > 0)" :key="item.value"> <div v-for="(transfer, index) in area._data" :key="transfer.id" class="transfer">
<div class="item" v-if="item._data.size > 0"> <div class="transfer__name">{{ numberToChinese(++index) }}. {{ transfer.xuhao }} {{ transfer.equipment_id_equipments_id_relation ? transfer.equipment_id_equipments_id_relation.name: '' }}</div>
<div class="sub-title">{{ numberToChinese(index+1) }}. {{ item.key }}</div> <div class="transfer__type">
{{ diaolingleixing.get(transfer.diaolingleixing) }}{{ type(transfer.leibie) }}
<div v-for="(item1, index1) in Array.from(item._data)" :key="item1[0]">
<div class="name">
{{index1+1}}.{{ item1[1][0].equipment_id_equipments_id_relation ? item1[1][0].equipment_id_equipments_id_relation.name : '' }}
</div> </div>
<div v-for="(item2, index2) in item1[1].sort((a,b) => new Date(a.act_start_time).valueOf() - new Date(b.act_start_time).valueOf())" :key="item2.id" style="display: flex;"> <div class="transfer__plantime">
<div style="text-indent: 60px;">{{index1+1}}.{{index2+1}}</div> <span>计划时间</span>
<div> <span>{{ $moment(transfer.start_time).format('YYYY-MM-DD HH:mm') }} ~ {{ $moment(transfer.end_time).format('YYYY-MM-DD HH:mm') }}</span>
<div> </div>
{{ diaolingleixing.get(item2.diaolingleixing) }}{{ type(item2.leibie) }} <div class="transfer__acttime">
</div> <span>实际时间</span>
<div class="time"> <span>{{ $moment(transfer.act_start_time).format('YYYY-MM-DD HH:mm') }} ~ {{ $moment(transfer.act_end_time).format('YYYY-MM-DD HH:mm') }}</span>
<span>时间</span> </div>
<span>{{ item2.act_start_time ? $moment(item2.act_start_time).format('YYYY-MM-DD HH:mm') : "-" }} ~ {{ item2.act_end_time ? $moment(item2.act_end_time).format('HH:mm') : "-" }}</span> <div class="transfer__content">
</div> <span>调令内容</span>
<div class="content"> <span>{{ transfer.to_transfer_id ? "[调整]" : "" }}{{ transfer.content }}</span>
<span>内容</span>
<span>{{ item2.to_transfer_id ? "[调整]" : "" }}{{ item2.content }}</span>
</div>
<div class="content" v-if="item2.diaolingleixing === 4">
<p v-for="log in item2.id_logs_transfer_id_relation">{{ $moment(log.created_at).format('HH:mm') }} {{ log.content }}</p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<el-empty v-if="transfers.length === 0" description="暂无完成调令"></el-empty>
</el-card> </el-card>
</div> </div>
</template> </template>
@ -92,11 +90,12 @@ export default {
mixins: [authMixin], mixins: [authMixin],
data() { data() {
return { return {
loading: false,
types: [], types: [],
areas: [], areas: [],
weather: {}, weather: {},
transfers: [], transfers: [],
showData: [], showData: {},
selectDate: [new Date(),new Date()], selectDate: [new Date(),new Date()],
diaolingleixing: new Map([ diaolingleixing: new Map([
[1,"水环境调令"], [1,"水环境调令"],
@ -107,6 +106,12 @@ export default {
} }
}, },
methods: { methods: {
search () {
if (this.loading) return;
this.loading = true;
Promise.all([this.getTransfer(),this.getWeather()]).then(_ => this.loading = false).catch(_ => this.loading = false)
},
async getWeatherInfo () { async getWeatherInfo () {
try { try {
let infoObj = { let infoObj = {
@ -142,17 +147,24 @@ export default {
filter: [ filter: [
{ {
key: 'date', key: 'date',
op: 'eq', op: 'range',
value: this.$moment().format('YYYY-MM-DD') value: `${this.$moment(this.selectDate[0]||new Date()).startOf('days').format('YYYY-MM-DD HH:mm:ss')},${this.$moment(this.selectDate[1]||new Date()).endOf('days').format('YYYY-MM-DD HH:mm:ss')}`
} }
] ]
},false)).data[0] },false)).data
if (!res) { let pickDateArr = [];
await this.getWeatherInfo() let startDay = this.$moment(this.selectDate[0]||new Date()).startOf('days')
} else { while (startDay.isBefore(this.$moment(this.selectDate[1]||new Date()).endOf('days')) || (startDay.valueOf() === this.$moment(this.selectDate[1]||new Date()).endOf('days').valueOf())) {
this.weather = res pickDateArr.push(startDay.format('YYYY-MM-DD'))
startDay = startDay.add(1,'day')
} }
this.weather = {};
pickDateArr.forEach(date => {
this.weather[date] = res.find(i => i.date === date)
})
console.log(this.weather)
}, },
numberToChinese (num) { numberToChinese (num) {
@ -224,7 +236,7 @@ export default {
table_name: "transfers", table_name: "transfers",
page: 1, page: 1,
page_size: 999, page_size: 999,
sort_name: "equipment_id", sort_name: "start_time",
filter: [ filter: [
{ {
key: 'start_time', key: 'start_time',
@ -239,138 +251,267 @@ export default {
] ]
})).data })).data
this.showData = this.areas.map(i => { let pickDateArr = [];
return { let startDay = this.$moment(this.selectDate[0]||new Date()).startOf('days')
...i, while (startDay.isBefore(this.$moment(this.selectDate[1]||new Date()).endOf('days')) || (startDay.valueOf() === this.$moment(this.selectDate[1]||new Date()).endOf('days').valueOf())) {
_data: new Map() pickDateArr.push(startDay.format('YYYY-MM-DD'))
} startDay = startDay.add(1,'day')
}
this.showData = {}
pickDateArr.forEach(date => {
this.showData[date] = {}
}) })
this.transfers.forEach(item => { this.transfers.forEach(item => {
let filterData = this.showData.find(i => i.value === item.equipment_id_equipments_id_relation.area) if (item.start_time && item.equipment_id_equipments_id_relation.area) {
if (filterData) { let myDate = this.$moment(item.start_time).format('YYYY-MM-DD');
if (filterData._data.has(item.equipment_id)) { let dateObj = this.showData[myDate];
filterData._data.get(item.equipment_id).push(item) if (dateObj.hasOwnProperty(item.equipment_id_equipments_id_relation.area)) {
dateObj[item.equipment_id_equipments_id_relation.area]._data.push(item)
} else { } else {
filterData._data.set(item.equipment_id, [item]) dateObj[item.equipment_id_equipments_id_relation.area] = {
_data: [item],
area: this.areas.find(k => k.value === item.equipment_id_equipments_id_relation.area)
}
} }
} }
}) })
// this.showData = this.areas.map(i => {
// return {
// ...i,
// _data: new Map()
// }
// })
// this.transfers.forEach(item => {
// let filterData = this.showData.find(i => i.value === item.equipment_id_equipments_id_relation.area)
// if (filterData) {
// if (filterData._data.has(item.equipment_id)) {
// filterData._data.get(item.equipment_id).push(item)
// } else {
// filterData._data.set(item.equipment_id, [item])
// }
// }
// })
} catch (e) { } catch (e) {
} }
this.showData = Object.assign({}, this.showData)
console.log(this.showData) console.log(this.showData)
}, },
async exportDocx () { async exportDocx () {
// const innerHTML = document.querySelector("#docx-content").innerHTML; if (this.loading) return;
// const exportHTML = `<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head><meta charset='utf-8'><title></title></head><body>${innerHTML}</body></html>` if (this.transfers.length <=0 ) {
// let blob = new Blob(["\ufeff", exportHTML], { this.$message({
// type: "application/msword", type: "warning",
// }) message: "暂无完成调令"
})
}
const document = new Document({ const document = new Document({
sections: [ title: `${this.selectDate[0] ? this.$moment(this.selectDate[0]).format('YYYY年MM月DD日') : "-"} ~ ${this.selectDate[1] ? this.$moment(this.selectDate[1]).format('YYYY年MM月DD日') : "-"}调度指令执行情况`,
{ sections: (() => {
children: [ let sections = [];
new Paragraph({ for (let date in this.showData) {
text: `${this.selectDate[0] ? this.$moment(this.selectDate[0]).format('YYYY年MM月DD日') : "-"} ~ ${this.selectDate[1] ? this.$moment(this.selectDate[1]).format('YYYY年MM月DD日') : "-"}调度指令执行情况`, let value = this.showData[date];
heading: HeadingLevel.HEADING_1, if (Object.keys(value).length > 0) {
alignment: AlignmentType.CENTER, let sectionChildren = [
spacing: { new Paragraph({
after: 400 text: `${this.$moment(date).format('YYYY年MM月DD日')}调度指令执行情况`,
} heading: HeadingLevel.HEADING_2,
}), alignment: AlignmentType.CENTER,
new Paragraph({ spacing: {
indent: { after: 300
firstLine: convertInchesToTwip(0.5) }
}, }),
spacing: { new Paragraph({
before: 200, text: this.weather[date]?.weather,
line: 500 heading: HeadingLevel.HEADING_4,
}, alignment: AlignmentType.CENTER,
children: [ spacing: {
new TextRun({ after: 200
text: this.weather.weather, }
size: 18, }),
}) ]
] for (let areaId in value) {
}), let area = value[areaId];
...this.showData.filter(i => (i._data && i._data.size>0)).map((i, index) => ( sectionChildren.push(new Paragraph({
[ indent: {
new Paragraph({ firstLine: convertInchesToTwip(0.5)
},
spacing: {
after: 100,
before: 100
},
children: [
new TextRun({
text: area?.area.key || "暂无区域",
size: 24,
bold: true
})
]
}))
for (let index in area._data) {
let transfer = area._data[index];
sectionChildren.push(new Paragraph({
text: `${ this.numberToChinese(++index) }. ${ transfer?.xuhao || ' ' } ${ transfer?.equipment_id_equipments_id_relation?.name }`,
indent: {
firstLine: convertInchesToTwip(0.8)
},
spacing: { spacing: {
before: 200, after: 50
line: 400
}, },
children: [ }))
new TextRun({ sectionChildren.push(new Paragraph({
text: `${this.numberToChinese(index+1)}${i.key}`, text: `${ this.diaolingleixing.get(transfer.diaolingleixing) }${this.type(transfer.leibie)}`,
size: 28, indent: {
bold: true, firstLine: convertInchesToTwip(1)
}), },
] spacing: {
}), after: 50
...Array.from(i._data).map((i1, index1) => ( },
[ }))
new Paragraph({ sectionChildren.push(new Paragraph({
spacing: { text: `计划时间:${ this.$moment(transfer.start_time).format('YYYY-MM-DD HH:mm') } ~ ${ this.$moment(transfer.end_time).format('YYYY-MM-DD HH:mm') }`,
before: 200, indent: {
line: 300 firstLine: convertInchesToTwip(1)
}, },
indent: { spacing: {
left: 200 after: 50
}, },
children: [ }))
new TextRun({ sectionChildren.push(new Paragraph({
text: `${index1+1}. ${i1[1][0].equipment_id_equipments_id_relation ? i1[1][0].equipment_id_equipments_id_relation.name : ''}`, text: `实际时间:${ this.$moment(transfer.act_start_time).format('YYYY-MM-DD HH:mm') } ~ ${ this.$moment(transfer.act_end_time).format('YYYY-MM-DD HH:mm') }`,
size: 24, indent: {
}), firstLine: convertInchesToTwip(1)
] },
}), spacing: {
...i1[1].sort((a,b) => new Date(a.act_start_time).valueOf() - new Date(b.act_start_time).valueOf()).map((i2, index2) => { after: 50
return new Paragraph({ },
indent: { }))
left: 400 sectionChildren.push(new Paragraph({
}, text: `${ transfer.to_transfer_id ? '[调整]' : '' }内容:${ transfer.content || ' ' }`,
alignment: AlignmentType.LEFT, indent: {
children: [ firstLine: convertInchesToTwip(1)
new TextRun({ },
text: `${index1+1}.${index2+1}${ this.diaolingleixing.get(i2.diaolingleixing) }${ this.type(i2.leibie) }`, spacing: {
size: 20, after: 50
},
break: 1, }))
}), }
new TextRun({ }
text: `时间: ${i2.act_start_time ? this.$moment(i2.act_start_time).format('YYYY-MM-DD HH:mm') : "-" } ~ ${ i2.act_end_time ? this.$moment(i2.act_end_time).format('HH:mm') : "-" }`, sections.push({
size: 18, children: sectionChildren
break: 1, })
}), }
new TextRun({ }
text: `${ i2.to_transfer_id ? "[调整]" : "" }内容:${i2.content || ''}`, return sections;
size: 18, })()
break: 1,
}),
...(() => {
if (i2.diaolingleixing === 4) {
return i2.id_logs_transfer_id_relation.map(log => new TextRun({
text: `${this.$moment(log.created_at).format('HH:mm')} ${log.content}`,
size: 18,
break: 1,
}))
} else {
return []
}
})()
]
})
})
]
)).flat()
]
)).flat()
]
},
]
}) })
// const document = new Document({
// sections: [
// {
// children: [
// new Paragraph({
// text: `${this.selectDate[0] ? this.$moment(this.selectDate[0]).format('YYYYMMDD') : "-"} ~ ${this.selectDate[1] ? this.$moment(this.selectDate[1]).format('YYYYMMDD') : "-"}`,
// heading: HeadingLevel.HEADING_1,
// alignment: AlignmentType.CENTER,
// spacing: {
// after: 400
// }
// }),
// new Paragraph({
// indent: {
// firstLine: convertInchesToTwip(0.5)
// },
// spacing: {
// before: 200,
// line: 500
// },
// children: [
// new TextRun({
// text: this.weather.weather,
// size: 18,
// })
// ]
// }),
// ...this.showData.filter(i => (i._data && i._data.size>0)).map((i, index) => (
// [
// new Paragraph({
// spacing: {
// before: 200,
// line: 400
// },
// children: [
// new TextRun({
// text: `${this.numberToChinese(index+1)}${i.key}`,
// size: 28,
// bold: true,
// }),
// ]
// }),
// ...Array.from(i._data).map((i1, index1) => (
// [
// new Paragraph({
// spacing: {
// before: 200,
// line: 300
// },
// indent: {
// left: 200
// },
// children: [
// new TextRun({
// text: `${index1+1}. ${i1[1][0].equipment_id_equipments_id_relation ? i1[1][0].equipment_id_equipments_id_relation.name : ''}`,
// size: 24,
// }),
// ]
// }),
// ...i1[1].sort((a,b) => new Date(a.act_start_time).valueOf() - new Date(b.act_start_time).valueOf()).map((i2, index2) => {
// return new Paragraph({
// indent: {
// left: 400
// },
// alignment: AlignmentType.LEFT,
// children: [
// new TextRun({
// text: `${index1+1}.${index2+1} ${ this.diaolingleixing.get(i2.diaolingleixing) }${ this.type(i2.leibie) }`,
// size: 20,
//
// break: 1,
// }),
// new TextRun({
// text: ` ${i2.act_start_time ? this.$moment(i2.act_start_time).format('YYYY-MM-DD HH:mm') : "-" } ~ ${ i2.act_end_time ? this.$moment(i2.act_end_time).format('HH:mm') : "-" }`,
// size: 18,
// break: 1,
// }),
// new TextRun({
// text: `${ i2.to_transfer_id ? "[]" : "" }${i2.content || ''}`,
// size: 18,
// break: 1,
// }),
// ...(() => {
// if (i2.diaolingleixing === 4) {
// return i2.id_logs_transfer_id_relation.map(log => new TextRun({
// text: `${this.$moment(log.created_at).format('HH:mm')} ${log.content}`,
// size: 18,
// break: 1,
// }))
// } else {
// return []
// }
// })()
// ]
// })
// })
// ]
// )).flat()
// ]
// )).flat()
// ]
// },
// ]
// })
const blob = await Packer.toBlob(document) const blob = await Packer.toBlob(document)
saveAs(blob, `${this.selectDate[0] ? this.$moment(this.selectDate[0]).format('YYYY年MM月DD日') : "-"} ~ ${this.selectDate[1] ? this.$moment(this.selectDate[1]).format('YYYY年MM月DD日') : "-"}调度指令执行情况.docx`) saveAs(blob, `${this.selectDate[0] ? this.$moment(this.selectDate[0]).format('YYYY年MM月DD日') : "-"} ~ ${this.selectDate[1] ? this.$moment(this.selectDate[1]).format('YYYY年MM月DD日') : "-"}调度指令执行情况.docx`)
@ -391,43 +532,42 @@ export default {
created() { created() {
this.getType() this.getType()
this.getArea() this.getArea()
this.getTransfer() this.search()
this.getWeather()
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
#docx-content {
min-height: 300px;
}
.title { .title {
font-weight: bolder; font-weight: bolder;
font-size: 19px; font-size: 19px;
text-align: center; text-align: center;
line-height: 3;
padding: 10px 0;
}
.sub-title {
font-weight: bold;
font-size: 16px;
padding: 8px 0;
} }
.name { .weather {
text-indent: 30px; font-size: 15px;
text-align: center;
line-height: 1.5; line-height: 1.5;
padding: 6px 0;
} }
.time { .area {
text-indent: 10px; font-weight: 600;
line-height: 1.5; font-size: 15px;
line-height: 3;
} }
.content { .transfer {
text-indent: 10px; line-height: 1.75;
line-height: 1.5; text-indent: 20px;
& > div:nth-child(n+2) {
text-indent: 40px;
}
&__type {
} }
.item + .item { &__name {
margin-top: 20px;
}
} }
</style> </style>

@ -110,6 +110,7 @@ export default {
op, op,
select: { select: {
table_name: "", table_name: "",
sort_name: 'equipment_id',
filter: [ filter: [
{ {
key: "content", key: "content",

Loading…
Cancel
Save