Commit 66c243d5 authored by 旭艳's avatar 旭艳

生产准备检查页面的导出功能

parent 5d47ae28
/**
* element 导出excel
* @Author:fangk
*/
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
/**
*
* @param {Dom元素} element
* @param {导出名称} name
* @returns
* 已知bug1:单元格如有英文逗号则不显示
* 已知bug2:树表格的情况收缩数据不下载
*/
export function exportExcel(element, name) {
/* out-table关联导出的dom节点 */
var wb = XLSX.utils.table_to_book(element)
/* get binary string as output */
var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
try {
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), name + '.xlsx')
} catch (e) { if (typeof console !== 'undefined') console.error(e, wbout) }
return wbout
}
<!--
* @Author:fangk
* @Date: 2021-03-23
* @Description: 生产准备检查-生产准备检查
* @setAuthor:fangk 2021-03-22
-->
<template>
<div class="production-preparation-inspection-confirmation">
<el-table
......@@ -70,7 +63,7 @@
</template>
<script>
import { v4 as uuidv4 } from 'uuid'
// import { exportExcel } from '@/api/exportExcel-elementUI.js'
import { exportExcel } from '@/api/exportExcel-elementUI.js'
export default {
props: {
confirmaData: {
......@@ -134,16 +127,16 @@ export default {
return dictValue[0].dictValue
}
return ''
}
},
/**
* 导出数据
*/
// exportTable() {
// exportExcel(this.$refs[this.onlyUuid].$el, '总装制造执行系统')
// },
// exportTable2() {
// exportExcel(this.$parent.$refs[this.$parent.onlyUuid].$el, '准备情况')
// }
exportTable() {
exportExcel(this.$refs[this.onlyUuid].$el, '总装制造执行系统')
},
exportTable2() {
exportExcel(this.$parent.$refs[this.$parent.onlyUuid].$el, '准备情况')
}
}
}
</script>
......@@ -64,14 +64,6 @@
end-placeholder="结束日期"
/>
</div>
<!-- <div>
<span>表格显示计划状态:</span>
<el-select v-model="tableShow" placeholder="请选择" size="small">
<el-option value="1" label="合并显示" />
<el-option value="2" label="显示准备情况确认表" />
<el-option value="3" label="显示生产准备确认项表" />
</el-select>
</div> -->
</div>
</div>
<div>
......@@ -126,37 +118,9 @@
</el-tabs>
<div>
<dee-tools :tools="tools" mode="normal" app-name="tf-mom" :collapse="false" />
<!-- <el-button
v-if="conStatus === 'Not'"
class="dee-tools"
size="small"
@click="preparaConfirmation(true)"
>
<img
src="/icons/c-newpart.png"
class="icon"
alt=""
>生产准备确认</el-button>
<el-button
v-else
class="dee-tools"
size="small"
@click="preparaConfirmation(false)"
>
<img
src="/icons/c-newpart.png"
class="icon"
alt=""
>撤销</el-button> -->
<!-- <el-button class="dee-tools" size="small" @click="exportTable">
<img
src="/icons/c-Import.png"
class="icon"
alt=""
>导出</el-button> -->
</div>
</header>
<div v-loading="confirmaLoading" class="table">
<div class="table">
<el-table
v-if="!confirmaLoading"
ref="table"
......@@ -304,16 +268,7 @@
>{{ item.name }}</el-radio-button>
</el-radio-group>
<div>
<!-- <el-button
class="dee-tools"
size="small"
@click="exportTableSituation"
>
<img
src="/icons/c-Import.png"
class="icon"
alt=""
>导出</el-button> -->
<dee-tools :tools="toolsRight" :collapse="false" style="width:100px" />
<div v-if="conStatus === 'Yes'" class="legnd">
<div
v-for="item in joExecutePlanStateData"
......@@ -330,7 +285,7 @@
</div>
</div>
</header>
<div v-loading="preparaLoading" class="table">
<div class="table">
<el-table
v-if="!preparaLoading"
:ref="onlyUuid"
......@@ -582,6 +537,7 @@
import { post } from '@/utils/http'
import { v4 as uuidv4 } from 'uuid'
import exportExcelTable from './exportExcelTable.vue'
import { exportExcel } from '@/api/exportExcel-elementUI.js'
export default {
name: 'StationPlanDetails',
components: {
......@@ -627,6 +583,17 @@ export default {
icon: '/icons/c-newpart.png'
}
],
toolsRight: [
{
name: '导出',
icon: '/icons/c-Import.png',
handler: {
click: () => {
this.exportTableSituation()
}
}
}
],
editRow: {
id: null,
parenId: null,
......@@ -996,6 +963,12 @@ export default {
getCheckConfirmYes(status) {
var that = this
that.confirmaLoading = true
let state = null
if (status) {
state = status
} else {
state = this.conStatus === 'Not' ? this.conStatus : 'Y'
}
post(
'WrProduction/findProductionPrepare',
{
......@@ -1004,7 +977,7 @@ export default {
serialNumber: this.AOname,
scheduledStart: (this.date.length && this.date[0]) || '',
scheduledEnd: (this.date.length && this.date[1]) || '',
state: this.conStatus
state: state
}
)
.then((res) => {
......@@ -1430,26 +1403,26 @@ export default {
})
.catch((err) => console.error(err))
.finally(() => {})
}
},
/**
* 导出数据
*/
// exportTable() {
// this.$refs.exportExcelTable.exportTable()
// },
// exportTableSituation() {
// var title = ''
// this.confirmaData.forEach((p) => {
// p.children.forEach((q) => {
// if (q.highlight) title = q.materNo
// })
// })
// var label = ''
// this.tabsData.forEach((p) => {
// if (this.readyStatus === p.typeName) label = p.name
// })
// exportExcel(this.$refs[this.onlyUuid].$el, title + '-' + label)
// }
exportTable() {
this.$refs.exportExcelTable.exportTable()
},
exportTableSituation() {
var title = ''
this.confirmaData.forEach((p) => {
p.children.forEach((q) => {
if (q.highlight) title = q.materNo
})
})
var label = ''
this.tabsData.forEach((p) => {
if (this.readyStatus === p.typeName) label = p.name
})
exportExcel(this.$refs[this.onlyUuid].$el, title + '-' + label)
}
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment