Browse Source

退回任务

yyfang 3 years ago
parent
commit
7746ed6bff
1 changed files with 129 additions and 149 deletions
  1. 129 149
      src/components/admin/nextStep.vue

+ 129 - 149
src/components/admin/nextStep.vue

@@ -1,14 +1,11 @@
 <template>
 	<div style="width: 100%">
 		<el-breadcrumb separator-class="el-icon-arrow-right">
-
 			<el-breadcrumb-item>首页</el-breadcrumb-item>
 			<el-breadcrumb-item>退回任务</el-breadcrumb-item>
 			<el-breadcrumb-item>编辑</el-breadcrumb-item>
 		</el-breadcrumb>
-		<div class="title">
-			退回任务
-		</div>
+
 		<el-form :model="form" label-width="100px">
 			<el-form-item prop="main_unit" label="抽样机构"  required>
 				<el-input v-model="form.main_unit" @focus="getOrganizationsShow1 = true"></el-input>
@@ -18,46 +15,25 @@
 			</el-form-item>
 			<el-form-item prop="sample_address" label="地区"   >
 				<el-cascader  :options="region" v-model="sample_address"
-					@change="handleChange">
+					@change="handleChange" clearable >
 				</el-cascader>
 			</el-form-item>
+
+				<!-- <el-form-item prop="sample_address" label="地区"   >
+					<el-cascader :options="options" :props="props" v-model="sample_address" clearable ></el-cascader>
+				</el-form-item> -->
 		<!-- 底部按钮 -->
 			<el-form-item>
 				<el-button type="success" @click="onSubmit()">保存</el-button>
 				<el-button @click="reBack">返回</el-button>
 			</el-form-item>
 		</el-form>
-
+<!-- 抽样机构 -->
 		<!-- 选择抽样机构对话框 -->
-		<el-dialog title="机构选择" :visible.sync="getOrganizationsShow1" width="50%" :close-on-click-modal="false" @open="getOrganizations1()" class="dialogItem">
+		<template scope-slot="scope">
+			<el-dialog title="机构选择" :visible.sync="getOrganizationsShow1" width="50%" :close-on-click-modal="false" @open="getOrganizations1()" class="dialogItem">
 			<el-form v-if="getOrganizationsShow1" :model="getOrganizationsForm1">
-		<!-- 检索功能 -->
-		<!-- <el-row :gutter="20">
-			<el-col :span="6"> -->
-				<!-- 组别名称 -->
-				<!-- <el-form-item label="组别名称">
-					<el-select v-model="form.groupname" clearable>
-						<el-option v-for="item in group" :key="item.value" :label="item.label" :value="item.value">
-						</el-option>
-					</el-select>
-				</el-form-item>
-			</el-col>
-			<el-col :span="6"> -->
-				<!-- 机构性质 -->
-				<!-- <el-form-item label="机构性质">
-						<el-select v-model="form.properties" clearable>
-							<el-option v-for="item in field" :key="item.value" :label="item.label" :value="item.value">
-							</el-option>
-						</el-select>
-				</el-form-item>
-			</el-col>
-			<el-col :span="6">
-			</el-col>
-			<el-col :span="6">
-			<el-button type="success" @click="querySearch()" style="margin-top:40px">搜索</el-button>
-			</el-col>
-		</el-row> -->
-				<!--  表格数据区域-->
+			<!--  表格数据区域-->
 				<el-table ref="multipleTable" :data="testList" row-key="id" @selection-change="handleSelectionChange1"
 					border stripe highlight-current-row style="width: 100%">
 					<el-table-column type="selection" :reserve-selection="true" width="50"></el-table-column>
@@ -69,51 +45,25 @@
 					<el-table-column :key="table.prop" v-for="table in tableHeader" :label="table.label"
 						:prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" />
 				</el-table>
-				<div class="footer">
-					<!--    分页器区域-->
-					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
-						:current-page="queryInfo1.pageNum" :page-sizes="[1,10, 15, 20]" :page-size="queryInfo1.pageSize"
-						layout="total, sizes, prev, pager, next, jumper" :total="total" background />
-					<el-button type="success" @click="choseTest1()">提交</el-button>
-				</div>
-				
+		<div class="footer">
+	<!--抽样机构分页器区域-->
+			<el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
+				:current-page="queryInfo1.pageNum" :page-sizes="[1,10, 15, 20]" :page-size="queryInfo1.pageSize"
+				layout="total, sizes, prev, pager, next, jumper" :total="total" background />
+			<el-button type="success" @click="choseTest1()">提交</el-button>
+		</div>
+		
 			</el-form>
 		</el-dialog>
-
+		</template>
+		
+<!-- 检测机构 -->
 		<!-- 选择检测机构对话框 -->
 		<el-dialog title="机构选择" :visible.sync="getOrganizationsShow2" width="50%" :close-on-click-modal="false" @open="getOrganizations2()" class="dialogItem">
 			<el-form v-if="getOrganizationsShow2" :model="getOrganizationsForm2">
-		<!-- 检索功能 -->
-		<!-- <el-row :gutter="20">
-			<el-col :span="6"> -->
-				<!-- 组别名称 -->
-				<!-- <el-form-item label="组别名称">
-					<el-select v-model="form.groupname" clearable>
-						<el-option v-for="item in group" :key="item.value" :label="item.label" :value="item.value">
-						</el-option>
-					</el-select>
-				</el-form-item>
-			</el-col>
-			<el-col :span="6"> -->
-				<!-- 机构性质 -->
-				<!-- <el-form-item label="机构性质">
-						<el-select v-model="form.properties" clearable>
-							<el-option v-for="item in field" :key="item.value" :label="item.label" :value="item.value">
-							</el-option>
-						</el-select>
-				</el-form-item>
-			</el-col>
-			<el-col :span="6">
-			</el-col>
-			<el-col :span="6">
-			<el-button type="success" @click="choseTest()" style="margin-top:40px">搜索</el-button>
-			</el-col> -->
-		<!-- </el-row> -->
 				<!--  表格数据区域-->
 				<el-table ref="multipleTable" :data="testList2" row-key="id" @selection-change="handleSelectionChange2"
 					border stripe highlight-current-row style="width: 100%" >
-					<!-- <el-table :data="testList" border stripe highlight-current-row  @current-change="handleSelectionChange2" style="width: 100%"
-					:row-style="rowStyle" :cell-style="cellStyle"> -->
 					<el-table-column type="selection" :reserve-selection="true" width="50"></el-table-column>
 					<el-table-column label="序号" width="50px">
 						<template slot-scope="scope">
@@ -124,13 +74,13 @@
 						:prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" />
 				</el-table>
 				<div class="footer">
-					<!--    分页器区域-->
-					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
+	<!--检测机构分页器区域-->
+					<el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
 						:current-page="queryInfo2.pageNum" :page-sizes="[1,10, 15, 20]" :page-size="queryInfo2.pageSize"
-						layout="total, sizes, prev, pager, next, jumper" :total="total" background />
+						layout="total, sizes, prev, pager, next, jumper" :total="total2" background />
+
 					<el-button type="success" @click="choseTest2()">提交</el-button>
 				</div>
-				
 			</el-form>
 		</el-dialog>
 			
@@ -140,6 +90,7 @@
 <script>
 import {
 		regionData,
+		CodeToText,
 		regionDataPlus,
 	} from 'element-china-area-data'
 	const rymc = window.sessionStorage.getItem('rymc')
@@ -147,49 +98,52 @@ import {
 	export default {
 		data() {
 			return {
+				// 地区单选
+				props: { multiple: true },
+				CodeToText:'',
 					form: {
+					// name:'',
 					bear_unit: '',
 					report_unit: '',
-					// check_unit: '',
 					sample_number: '',
-					sample_address: '',
+					// sample_address: '',
 					uploadtime: '',
 					groupname:'',
 					properties:'',
 					main_unit:[],
-					check_unit:[]
+					check_unit:[], 
+					sample_org_id:'',
+					check_org_id:''
 				},
 				currentRow: null,
 				currentRow2: null,
 				//组别名称
-				group: [{
-					value: '1',
-					label: '检测机构'
-				}, {
-					value: '2',
-					label: '县级监管单位'
-				}, {
-					value: '3',
-					label: '市级监管单位'
-				},{
-					value: '4',
-					label: '省级监管单位'
-				}],
+				// group: [
+				// {
+				// 	value: '2',
+				// 	label: '县级监管单位'
+				// }, {
+				// 	value: '3',
+				// 	label: '市级监管单位'
+				// },{
+				// 	value: '4',
+				// 	label: '省级监管单位'
+				// }],
 				//机构性质
-				field: [{
-					value: '1',
-					label: '政府部门'
-				}, {
-					value: '2',
-					label: '事业单位'
-				}, {
-					value: '3',
-					label: '企业'
-				}],
-
+				// field: [{
+				// 	value: '1',
+				// 	label: '政府部门'
+				// }, {
+				// 	value: '2',
+				// 	label: '事业单位'
+				// }, {
+				// 	value: '3',
+				// 	label: '企业'
+				// }],
 				// 抽样地区
-				region: regionData,
-				// sample_address: [],
+				// region: regionData,
+				region: regionData[11].children,
+				sample_address:[],
 				// 机构地域表格数据
 				underTask: [],
 				underTasktotal: 0,
@@ -203,17 +157,8 @@ import {
 						name: '是'
 					}
 				],
-				// rymc: rymc,		//从本地缓存获取发布单位
-				myHeaders: {
-					Authorization: 'bearer'+ token			//上传文件添加token
-				},
-				// 任务表单
-				// form: {
-				// 	main_unit: [],	
-				// 	check_unit: [],				
-				// },
-				// form: {
-				// 	check_unit: [],			
+				// myHeaders: {
+				// 	Authorization: 'bearer'+ token//上传文件添加token
 				// },
 				// 优先级选项
 				priority: [{
@@ -239,11 +184,12 @@ import {
 
 				// 弹出抽样机构弹窗
 				getOrganizationsShow1: false,
-				// 查询检测机构请求参数
+				// 查询抽样机构请求参数
 				queryInfo1: {
 					pageNum: 1,
 					pageSize: 10,
-					keyWord: ''
+					name:'',
+					sample_org_id:''
 				},
 
 				// 弹出检测机构弹窗
@@ -252,9 +198,11 @@ import {
 				queryInfo2: {
 					pageNum: 1,
 					pageSize: 10,
-					keyWord: '',
-					groupname:'检测机构'
+					// keyWord: '',
+					groupname:'检测机构',
 				},
+				//抽样机构列表
+				testList: [],
 				// 检测机构列表
 				testList2: [],
 				// 表头
@@ -288,9 +236,13 @@ import {
 				orgs2: [],
 				// 上传成功文件列表
 				fileList: []
+				
 			}
 		},
 		created:function(){
+			this.sample_org_id = this.id
+			this.task_id= this.$route.params.task_id
+			console.log(this.task_id)
 			this.postTaskProfile()
 		},
 		
@@ -298,23 +250,38 @@ import {
 			let that = this
 		},
 		methods: {
-			// 获取机构列表
-				async postTaskProfile() {
+			// 添加任务step2
+			async postTaskProfile() {
 				const result = await this.$http.post('postTaskProfile', {
 					task_id: this.task_id,
-					// pageSize:this.queryInfo.pageSize,
-					// pageNum:this.queryInfo.pageNum
-				})},
+					sample_org_id:this.sample_org_id,
+					check_org_id:this.check_org_id,
+					sample_address:this.sample_address
+				})
+				this.sample_org_id = result.data.rows.id
+				this.check_org_id = result.data.rows.id
+				console.log(this.sample_org_id)
+			},
+			//搜索
+			// async search(){
+			// 	this.queryInfo1.pageNum = 1
+			// 		this.getOrganizations()
+			// },
+			//搜索
+			// async search2(){
+			// 	this.queryInfo2.pageNum = 1
+			// 		this.getOrganizations()
+			// },
+			
 			// 获取选择抽样地区
 			handleChange() {
 				var that = this
 				var loc = "";
-				// console.log(this.form.place)
 				for (let i = 0; i < this.sample_address.length; i++) {
 					loc += CodeToText[this.sample_address[i]];
 				}
-				// console.log(loc)
 				that.form.sample_address = loc
+				// console.log(loc)
 			},
 			//保存
 			async onSubmit() {
@@ -324,8 +291,11 @@ import {
 				this.form['releaser'] = window.sessionStorage.getItem('rymc')
 				this.form['task_class'] = 'retask'
 				this.form['ispublic'] = 0
-				
+				this.form['sample_org_id'] = this.sample_org_id
+				this.form['check_org_id'] = this.check_org_id
+				this.form['task_id'] = this.task_id
 				const result = await this.$http.post('postTaskProfile', this.form)
+
 				// 判断业务逻辑
 				if (result.data.code == 0) {
 					this.$router.push('reTask')
@@ -337,31 +307,27 @@ import {
 				}
 			},
 			reBack() {
-				this.$router.push('editInformation')
+				this.$router.push('addTask')
 			},		
 			// 获取抽样机构列表
 			async getOrganizations1() {
 				this.queryInfo1['token'] = token
 				const result = await this.$http.post('getOrganizations', this.queryInfo1)
-				console.log(result.data.code);
-				// 判断业务逻辑
-				if (result.data.code == 0) {
 					this.testList = result.data.data.rows
 					this.total = result.data.data.total
-				}
+					this.sample_org_id = result.data.rows.id
+					console.log(result.data.data.rows.id)
 			},
 
 			// 获取检测机构列表
 			async getOrganizations2() {
 				this.queryInfo2['token'] = token
 				const result = await this.$http.post('getOrganizations', this.queryInfo2)
-				console.log(result.data.code);
-				// 判断业务逻辑
-				if (result.data.code == 0) {
 					this.testList2 = result.data.data.rows
 					this.total2 = result.data.data.total
-				}
+					// this.check_org_id = result.data.rows.id
 			},
+
 			/** 修复当用户在大于1的分页进行数据搜索没有返回值的问题 */
 			setPageNum() {
 				this.queryInfo.pageNum = 1
@@ -377,47 +343,61 @@ import {
 				})
 				this.hander = false
 			},
-
+//抽样机构页码
 			/** 监听每页显示多少数据的改变 */
-			handleSizeChange(newSize) {
+			handleSizeChange1(newSize) {
 				this.queryInfo1.pageSize = newSize
 				this.getOrganizations1()
 			},
-
 			/** 监听页码的改变 */
-			handleCurrentChange(newPage) {
+			handleCurrentChange1(newPage) {
 				this.queryInfo1.pageNum = newPage
 				this.getOrganizations1()
 			},
-			//批量勾选
-			// handleSelectionChange(val) {
-			// 	this.multipleSelection = val
-			// 	if (this.hander) return false
-			// 	this.setSelectRows() // 处理选中的方法
-			// },
+//检测机构页码
+			/** 监听每页显示多少数据的改变 */
+			handleSizeChange2(newSize) {
+				this.queryInfo2.pageSize = newSize
+				this.getOrganizations2()
+			},
+			/** 监听页码的改变 */
+			handleCurrentChange2(newPage) {
+				this.queryInfo2.pageNum = newPage
+				this.getOrganizations2()
+			},
+
 			//选中抽样(单选)
 			handleSelectionChange1(val) {
 				this.currentRow = val;
 				console.log(this.currentRow)
 				console.log(this.currentRow[0].name)
+				this.sample_org_id = this.currentRow[0].id
+				console.log(this.sample_org_id)
 			},
 			//选中检测(单选)
 			handleSelectionChange2(val) {
 				this.currentRow2 = val;
+				this.check_org_id = this.currentRow2[0].id
 				console.log(this.currentRow2)
 				console.log(this.currentRow2[0].name)
+				console.log(this.check_org_id)
 			},
-			// 抽样单位提交
-			choseTest1() {
+// 抽样单位提交
+			async choseTest1() {
 				let that = this
 				that.form.main_unit = that.currentRow[0].name
 				that.getOrganizationsShow1 = false
+				that.form.sample_org_id = that.currentRow[0].id
+				console.log(that.form.sample_org_id)
+
 			},
-			// 检测单位提交
+// 检测单位提交
 			choseTest2() {
 				let that = this
 				that.form.check_unit = that.currentRow2[0].name
+				that.form.check_org_id = that.currentRow2[0].id
 				that.getOrganizationsShow2 = false
+				console.log(that.form.check_org_id)
 			},
 		}
 	}