Browse Source

承担单位导出Excel

jiangyu 3 years ago
parent
commit
e1fee462df

+ 95 - 1
src/components/jc/routineMonitor.vue

@@ -48,7 +48,7 @@
 				<el-button type="primary" size="small" plain icon="el-icon-edit-outline" >发布</el-button>
 				<el-button type="primary" size="small" plain icon="el-icon-scissors" >废止</el-button>
 				<el-button type="primary" size="small" plain icon="el-icon-delete" >删除</el-button> -->
-					<el-button type="primary" size="small" plain icon="el-icon-download">导出</el-button>
+					<el-button type="primary" size="small" plain icon="el-icon-download" @click="exportData">导出Excel</el-button>
 				</div>
 			</el-row>
 			<!--  表格数据区域-->
@@ -102,6 +102,42 @@
 </template>
 
 <script>
+const qee = require('qf-export-excel')
+const HeadersList = [{
+						title: '任务名称',
+						key: 'task_name',
+					},
+					{
+						title: '年度',
+						key: 'year',
+					}, {
+						title: '文件号',
+						key: 'filenum',
+					},
+					{
+						title: '开始时间',
+						key: 'starttime',
+					},
+					{
+						title: '结束时间',
+						key: 'endtime',
+					},
+					{
+						title: '创建者',
+						key: 'releaser',
+					},
+					{
+						title: '创建时间',
+						key: 'createtime',
+					},{
+						title: '任务状态',
+						key: 'ispublic'
+					},{
+						title: '任务优先级',
+						key: 'level'
+					}
+
+				]
 	export default {
 		name: '',
 		data() {
@@ -273,6 +309,64 @@
 					}
 				})
 			},
+			// 导出Excel
+			async exportData() {
+			
+				// for (var key in this.exportInfo) {
+				// 	if (this.exportInfo[key] == '') {
+				// 		delete this.exportInfo[key]
+				// 	}
+				// }
+			console.log(this.tableData)
+				let exportList = []
+					exportList = this.tableData
+					
+					for (let i = 0; i < exportList.length; i++) {
+						if (exportList[i].level == '0') {
+							exportList[i].level = '一般'
+						} else if (exportList[i].level == '1')  {
+							exportList[i].level = '紧急'
+						}else{
+							exportList[i].level = '特急'
+						}
+						if (exportList[i].ispublic == '1') {
+							exportList[i].ispublic = '已发布'
+						} else if(exportList[i].ispublic == '2')  {
+							exportList[i].ispublic = '废止'
+						}else if(exportList[i].ispublic == '3') {
+							exportList[i].ispublic = '已结束,未完成'
+						}else if(exportList[i].ispublic == '4') {
+							exportList[i].ispublic = '已结束,已完成'
+						}else if(exportList[i].ispublic == '5') {
+							exportList[i].ispublic = '执行中'
+						}
+					}
+				// 导出表格的表头设置
+				// let allColumns = exportList
+				var columnNames = []
+				var columnValues = []
+				// var columns = []
+				require.ensure([], () => {
+					const {
+						export_json_to_excel
+					} = require('@/vendor/Export2Excel.js')
+			
+					for (var i = 0; i < HeadersList.length; i++) {
+						columnNames[i] = HeadersList[i].title
+						columnValues[i] = HeadersList[i].key
+					}
+					const tHeader = columnNames
+					const filterVal = columnValues
+					// console.log(columns)
+					const list = exportList
+					const data = this.formatJson(filterVal, list)
+					export_json_to_excel(tHeader, data, '例行监测任务')
+				
+				})
+			},
+			formatJson(filterVal, jsonData) {
+				return jsonData.map(v => filterVal.map(j => v[j]))
+			},
 
 		},
 	}

+ 4 - 3
src/components/jc/setTask.vue

@@ -160,7 +160,7 @@
 				<taskdetail :task_id="task_id"></taskdetail>
 				<div class="footer">
 					<el-button type="success" size="mini" @click="release()">发布</el-button>
-					<el-button type="success" size="mini" @click="exportOverview()">导出总览</el-button>
+					<el-button type="success" size="mini" @click="exportOverview(task_id)">导出总览</el-button>
 					<el-button type="success" size="mini" @click="next">返回</el-button>
 				</div>
 			</el-tab-pane>
@@ -169,7 +169,7 @@
 					<taskdetail :task_id="task_id"></taskdetail>
 					<div class="footer">
 					<el-button @click="dialogVisible2 = false">取 消</el-button>
-					<el-button type="success" size="mini" @click="exportOverviewpdf">导出总览pdf</el-button>
+					<el-button type="success" size="mini" @click="exportOverviewpdf()">导出总览pdf</el-button>
 				</div>
 				</el-dialog>
 
@@ -610,7 +610,8 @@
 				})
 			},
 			// 导出总览
-				exportOverview() {
+				exportOverview(id) {
+					console.log(this.id)
 				var that = this
 				that.dialogVisible2 = true
 			},

+ 2 - 0
src/components/jc/setTaskcd.vue

@@ -720,9 +720,11 @@
 					that.formjc = result.data.data
 				}
 			},
+			//下载检测报告
 			download() {
 				htmlToPdf.downloadPDF(document.querySelector('#pdf'), '检测报告')
 			},
+			//生成检测报告pdf
 			async creatpdf(sample_id) {
 				var that = this
 				that.dialogVisible2 = true

+ 94 - 1
src/components/jc/specialMonitorcd.vue

@@ -48,7 +48,7 @@
 				<el-button type="primary" size="small" plain icon="el-icon-edit-outline" >发布</el-button>
 				<el-button type="primary" size="small" plain icon="el-icon-scissors" >废止</el-button>
 				<el-button type="primary" size="small" plain icon="el-icon-delete" >删除</el-button> -->
-					<el-button type="primary" size="small" plain icon="el-icon-download">导出</el-button>
+					<el-button type="primary" size="small" plain icon="el-icon-download" @click="exportData">导出Excel</el-button>
 				</div>
 			</el-row>
 			<!--  表格数据区域-->
@@ -101,6 +101,41 @@
 </template>
 
 <script>
+const qee = require('qf-export-excel')
+const HeadersList = [{
+						title: '任务名称',
+						key: 'task_name',
+					},
+					{
+						title: '年度',
+						key: 'year',
+					}, {
+						title: '文件号',
+						key: 'filenum',
+					},
+					{
+						title: '开始时间',
+						key: 'starttime',
+					},
+					{
+						title: '结束时间',
+						key: 'endtime',
+					},
+					{
+						title: '创建者',
+						key: 'releaser',
+					},
+					{
+						title: '创建时间',
+						key: 'createtime',
+					},{
+						title: '任务状态',
+						key: 'ispublic'
+					},{
+						title: '任务优先级',
+						key: 'level'
+					}
+				]
 	export default {
 		name: '',
 		data() {
@@ -263,6 +298,64 @@
 					}
 				})
 			},
+			// 导出Excel
+			async exportData() {
+			
+				// for (var key in this.exportInfo) {
+				// 	if (this.exportInfo[key] == '') {
+				// 		delete this.exportInfo[key]
+				// 	}
+				// }
+			console.log(this.tableData)
+				let exportList = []
+					exportList = this.tableData
+					
+					for (let i = 0; i < exportList.length; i++) {
+						if (exportList[i].level == '0') {
+							exportList[i].level = '一般'
+						} else if (exportList[i].level == '1')  {
+							exportList[i].level = '紧急'
+						}else{
+							exportList[i].level = '特急'
+						}
+						if (exportList[i].ispublic == '1') {
+							exportList[i].ispublic = '已发布'
+						} else if(exportList[i].ispublic == '2')  {
+							exportList[i].ispublic = '废止'
+						}else if(exportList[i].ispublic == '3') {
+							exportList[i].ispublic = '已结束,未完成'
+						}else if(exportList[i].ispublic == '4') {
+							exportList[i].ispublic = '已结束,已完成'
+						}else if(exportList[i].ispublic == '5') {
+							exportList[i].ispublic = '执行中'
+						}
+					}
+				// 导出表格的表头设置
+				// let allColumns = exportList
+				var columnNames = []
+				var columnValues = []
+				// var columns = []
+				require.ensure([], () => {
+					const {
+						export_json_to_excel
+					} = require('@/vendor/Export2Excel.js')
+			
+					for (var i = 0; i < HeadersList.length; i++) {
+						columnNames[i] = HeadersList[i].title
+						columnValues[i] = HeadersList[i].key
+					}
+					const tHeader = columnNames
+					const filterVal = columnValues
+					// console.log(columns)
+					const list = exportList
+					const data = this.formatJson(filterVal, list)
+					export_json_to_excel(tHeader, data, '专项监测任务')
+				
+				})
+			},
+			formatJson(filterVal, jsonData) {
+				return jsonData.map(v => filterVal.map(j => v[j]))
+			},
 
 		},
 	}