jiangyu 3 năm trước cách đây
mục cha
commit
a651988ac5

+ 6 - 0
src/assets/js/htmlToPdf.js

@@ -44,6 +44,7 @@ function downloadPDF(ele, pdfName){
     } ).then( (canvas)=>{
         var contentWidth = canvas.width;
         var contentHeight = canvas.height;
+        console.log(contentHeight)
         //一页pdf显示html页面生成的canvas高度;
         var pageHeight = contentWidth / 592.28 * 841.89;
         //未生成pdf的html页面高度
@@ -54,12 +55,15 @@ function downloadPDF(ele, pdfName){
         var imgWidth = 595.28;
         var imgHeight = 595.28/contentWidth * contentHeight;
         var pageData = canvas.toDataURL('image/jpeg', 1.0);
+        console.log(pageData)
         var pdf = new JsPDF('', 'pt', 'a4');
+        console.log(111)
         //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
         //当内容未超过pdf一页显示的范围,无需分页
         if (leftHeight < pageHeight) {
             //在pdf.addImage(pageData, 'JPEG', 左,上,宽度,高度)设置在pdf中显示;
             pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
+            console.log(pageData)
             // pdf.addImage(pageData, 'JPEG', 20, 40, imgWidth, imgHeight);
         } else {    // 分页
             while(leftHeight > 0) {
@@ -72,8 +76,10 @@ function downloadPDF(ele, pdfName){
                 }
             }
         }
+        console.log(222)
         //可动态生成
         pdf.save(pdfName);
+        console.log(331)
     })
 }
 export default {

+ 0 - 4
src/components/jc/routineMonitorqt.vue

@@ -43,10 +43,6 @@
 			<!--  头部钮区域-->
 			<el-row :gutter="90" style="margin-right: 0px;">
 				<div style="display: flex;flex-direction: row;float: right;">
-				<!-- 	<el-button type="primary" size="small" plain icon="el-icon-plus" @click="add()">新增</el-button>
-					<el-button type="primary" size="small" plain icon="el-icon-edit-outline" @click="ispublic()">发布</el-button>
-					<el-button type="primary" size="small" plain icon="el-icon-scissors" @click="repeal()">废止</el-button>
-					<el-button type="primary" size="small" plain icon="el-icon-delete" @click="delArray()">删除</el-button> -->
 					<el-button type="primary" size="small" plain icon="el-icon-download" @click="exportData">导出Excel</el-button>
 				</div>
 			</el-row>

+ 29 - 8
src/components/jc/setTask.vue

@@ -122,6 +122,12 @@
 				
 
 				<!--  表格数据区域-->
+
+				<el-row :gutter="90" style="margin-right: 0px;">
+				<div style="display: flex;flex-direction: row;float: right;">
+					<el-button type="primary" size="small" plain @click="sampleDetail()">删除</el-button>
+				</div>
+				</el-row>
 				<el-table ref="multipleTable" :data="underTask" border stripe highlight-current-row
 					@selection-change="handleSelectionChange" style="width: 100%" :row-style="rowStyle"
 					:cell-style="cellStyle">
@@ -134,12 +140,12 @@
 
 					<el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label"
 						:prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" />
-					<el-table-column label="操作" align="center" fixed="right">
+					<!-- <el-table-column label="操作" align="center" fixed="right">
 						<template slot-scope="scope">
 							<el-button type="success" size="small" plain @click="sampleDetail(scope.row.sample_id)">删除
 							</el-button>
 						</template>
-					</el-table-column>
+					</el-table-column> -->
 				</el-table>
 				<!--    分页器区域-->
 				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
@@ -152,10 +158,18 @@
 				<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()">导出总览</el-button>
 					<el-button type="success" size="mini" @click="next">返回</el-button>
 				</div>
 			</el-tab-pane>
+			
+				<el-dialog title="生成监测报告" :visible.sync="dialogVisible2" width="50%">
+					<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>
+				</div>
+				</el-dialog>
 
 
 
@@ -399,7 +413,8 @@
 				}
 			},
 			// 机构与地域---删除
-			async sampleDetail() {
+			async sampleDetail(id) {
+				console.log(id)
 				// 判断任务是否为该创建者创建
 				for (let i = 0; i < this.multipleSelection.length; i++) {
 					if (rybh != this.multipleSelection[i].releaser) {
@@ -418,7 +433,7 @@
 					console.log(this.multipleSelection[i])
 					this.delarr.push(this.multipleSelection[i].id);
 				}
-				const result = await this.$http.post('', {
+				const result = await this.$http.post('delUnderTask', {
 					delarr: that.delarr,
 					token: token
 				})
@@ -427,7 +442,7 @@
 						type: 'success',
 						message: '删除成功!'
 					});
-					that.gettaskList()
+					that.getUnderTask()
 				} else {
 					this.$message({
 						type: 'error',
@@ -558,8 +573,13 @@
 				})
 			},
 			// 导出总览
-			exportOverview() {
-				htmlToPdf.downloadPDF(document.querySelector('#pdf'), '监测任务总览')
+				exportOverview() {
+				var that = this
+				that.dialogVisible2 = true
+			},
+			// 导出总览pdf
+			exportOverviewpdf() {
+				htmlToPdf.downloadPDF(document.querySelector('#pdf1'), '监测任务总览')
 			},
 			handleClick(tab, event) {
 				console.log(tab, event);
@@ -585,6 +605,7 @@
 					}
 				}
 				this.readForm = res.data
+				console.log(this.readForm)
 
 				this.bindForm.endtime_cydsb = res.data.endtime_cydsb
 			},

+ 5 - 1
src/components/jc/setTaskcd.vue

@@ -98,7 +98,7 @@
 				<div class="footer">
 					<el-button type="success" size="mini" @click="input()">填报抽样单</el-button>
 					<!-- <el-button type="success" size="mini" @click="next">导出总览</el-button> -->
-					<el-button type="success" size="mini">返回</el-button>
+					<el-button type="success" size="mini" @click="back">返回</el-button>
 				</div>
 			</el-tab-pane>
 
@@ -809,6 +809,10 @@
 						id: this.readForm.id
 					}
 				})
+			},
+			// 返回
+			back() {
+
 			},
 			// 上传抽样信息
 			async appear() {

+ 90 - 8
src/components/jc/specialMonitorqt.vue

@@ -41,16 +41,12 @@
 					<el-button style="height: 28px;margin-left: 5px;" type="success"  size="mini" @click="reset()">重置</el-button>
 				</el-form>
 			</el-row>
-			<!--  头部钮区域-->
-			<!-- <el-row :gutter="90" style="margin-right: 0px;">
+			<!--  头部钮区域-->
+			<el-row :gutter="90" style="margin-right: 0px;">
 				<div style="display: flex;flex-direction: row;float: right;">
-					<el-button type="primary" size="small" plain icon="el-icon-plus" @click="add()">新增</el-button>
-					<el-button type="primary" size="small" plain icon="el-icon-edit-outline" @click="ispublic()">发布</el-button>
-					<el-button type="primary" size="small" plain icon="el-icon-scissors" @click="repeal()">废止</el-button>
-					<el-button type="primary" size="small" plain icon="el-icon-delete" @click="delArray()">删除</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> -->
+			</el-row>
 			<!--  表格数据区域-->
 					<el-table ref="multipleTable" :data="tableData" border stripe highlight-current-row style="width: 100%"
 				:row-style="rowStyle" :cell-style="cellStyle" @selection-change="handleSelectionChange">
@@ -104,6 +100,34 @@
 </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: 'level'
+			}, {
+				title: '任务状态',
+				key: 'ispublic'
+			}
+		]
 	export default {
 		name: '',
 		data() {
@@ -366,6 +390,64 @@
 				}
 				this.gettaskList()
 			},
+				// 导出Excel
+			async exportData() {
+			
+				// for (var key in this.exportInfo) {
+				// 	if (this.exportInfo[key] == '') {
+				// 		delete this.exportInfo[key]
+				// 	}
+				// }
+			
+				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]))
+			},
 
 		},
 	}

+ 5 - 3
src/components/jc/taskdetail.vue

@@ -1,5 +1,5 @@
 <template>
-	<div>
+	<div id="pdf1">
 		<el-descriptions class="margin-top" :title="readForm.task_class+'任务'" :column="2" :size="size" border>
 			<el-descriptions-item>
 				<template slot="label">
@@ -81,8 +81,7 @@
 				<span v-for="item in readForm.pesticides">{{item.test_name}}、</span>
 			</el-descriptions-item>
 		</el-descriptions>
-		<el-table :data="underTask" border stripe highlight-current-row style="width: 100%" :row-style="rowStyle"
-			:cell-style="cellStyle">
+		<el-table :data="underTask" border stripe highlight-current-row style="width: 100%">
 			<el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label" :prop="table.prop"
 				align="center" :width="table.width" :fixed="table.fixed" />
 		</el-table>
@@ -100,6 +99,9 @@
 				id: 0,
 				task_id: this.task_id,
 				readForm: {},
+				// rowStyle: '',
+				// cellStyle: '',
+				// size: '',
 				// 机构地域表格数据
 				underTask: [],
 				underTasktotal: 0,