addTaskJcObject copy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <div style="width: 100%">
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item>首页</el-breadcrumb-item>
  5. <el-breadcrumb-item>监测任务</el-breadcrumb-item>
  6. <el-breadcrumb-item>添加任务</el-breadcrumb-item>
  7. </el-breadcrumb>
  8. <div class="title">添加任务</div>
  9. <el-form :model="form" label-width="100px">
  10. <el-form-item prop="main_unit" label="抽样机构" required>
  11. <el-input v-model="form.main_unit" @focus="getOrganizationsShow1 = true"></el-input>
  12. </el-form-item>
  13. <el-form-item prop="check_unit" label="检测机构" required>
  14. <el-input v-model="form.check_unit" @focus="getOrganizationsShow2 = true"></el-input>
  15. </el-form-item>
  16. <el-form-item prop="sample_address" label="地区" >
  17. <el-cascader :options="region" v-model="sample_address"
  18. @change="handleChange" clearable>
  19. </el-cascader>
  20. </el-form-item>
  21. <!-- <el-form-item prop="sample_address" label="地区" >
  22. <el-cascader :options="options" :props="props" v-model="sample_address" clearable ></el-cascader>
  23. </el-form-item> -->
  24. <!-- 底部按钮 -->
  25. <el-form-item>
  26. <el-button type="success" @click="onSubmit()">保存</el-button>
  27. <el-button @click="reBack">返回</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <!-- 抽样机构 -->
  31. <!-- 选择抽样机构对话框 -->
  32. <template scope-slot="scope">
  33. <el-dialog title="机构选择" :visible.sync="getOrganizationsShow1" width="50%" :close-on-click-modal="false" @open="getOrganizations1()" class="dialogItem">
  34. <el-form v-if="getOrganizationsShow1" :model="getOrganizationsForm1">
  35. <!-- 表格数据区域-->
  36. <el-table ref="multipleTable" :data="testList" row-key="id" @selection-change="handleSelectionChange1"
  37. border stripe highlight-current-row style="width: 100%">
  38. <el-table-column type="selection" :reserve-selection="true" width="50"></el-table-column>
  39. <el-table-column label="序号" width="50px">
  40. <template slot-scope="scope">
  41. {{ scope.$index+1 }}
  42. </template>
  43. </el-table-column>
  44. <el-table-column :key="table.prop" v-for="table in tableHeader" :label="table.label"
  45. :prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" />
  46. </el-table>
  47. <div class="footer">
  48. <!--抽样机构分页器区域-->
  49. <el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
  50. :current-page="queryInfo1.pageNum" :page-sizes="[1,10, 15, 20]" :page-size="queryInfo1.pageSize"
  51. layout="total, sizes, prev, pager, next, jumper" :total="total" background />
  52. <el-button type="success" @click="choseTest1()">提交</el-button>
  53. </div>
  54. </el-form>
  55. </el-dialog>
  56. </template>
  57. <!-- 检测机构 -->
  58. <!-- 选择检测机构对话框 -->
  59. <el-dialog title="机构选择" :visible.sync="getOrganizationsShow2" width="50%" :close-on-click-modal="false" @open="getOrganizations2()" class="dialogItem">
  60. <el-form v-if="getOrganizationsShow2" :model="getOrganizationsForm2">
  61. <!-- 表格数据区域-->
  62. <el-table ref="multipleTable" :data="testList2" row-key="id" @selection-change="handleSelectionChange2"
  63. border stripe highlight-current-row style="width: 100%" >
  64. <el-table-column type="selection" :reserve-selection="true" width="50"></el-table-column>
  65. <el-table-column label="序号" width="50px">
  66. <template slot-scope="scope">
  67. {{ scope.$index+1 }}
  68. </template>
  69. </el-table-column>
  70. <el-table-column :key="table.prop" v-for="table in tableHeader" :label="table.label"
  71. :prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" />
  72. </el-table>
  73. <div class="footer">
  74. <!--检测机构分页器区域-->
  75. <el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
  76. :current-page="queryInfo2.pageNum" :page-sizes="[1,10, 15, 20]" :page-size="queryInfo2.pageSize"
  77. layout="total, sizes, prev, pager, next, jumper" :total="total2" background />
  78. <el-button type="success" @click="choseTest2()">提交</el-button>
  79. </div>
  80. </el-form>
  81. </el-dialog>
  82. <!-- 地区表格区域 -->
  83. <div class="diqubiaoge">
  84. <el-table ref="multipleTable" :data="regionList" row-key="id" border stripe highlight-current-row >
  85. <el-table-column :key="table.prop" v-for="table in tableHeader3" :label="table.label"
  86. :prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" />
  87. </el-table>
  88. </div>
  89. </div>
  90. </template>
  91. <script>
  92. import {
  93. regionData,
  94. CodeToText,
  95. regionDataPlus,
  96. } from 'element-china-area-data'
  97. const rymc = window.sessionStorage.getItem('rymc')
  98. const token = window.sessionStorage.getItem('token')
  99. export default {
  100. data() {
  101. return {
  102. // 地区单选
  103. props: { multiple: true },
  104. CodeToText:'',
  105. form: {
  106. // name:'',
  107. bear_unit: '',
  108. report_unit: '',
  109. sample_number: '',
  110. // sample_address: '',
  111. uploadtime: '',
  112. groupname:'',
  113. properties:'',
  114. main_unit:[],
  115. check_unit:[],
  116. sample_org_id:'',
  117. check_org_id:''
  118. },
  119. currentRow: null,
  120. currentRow2: null,
  121. //组别名称
  122. // group: [
  123. // {
  124. // value: '2',
  125. // label: '县级监管单位'
  126. // }, {
  127. // value: '3',
  128. // label: '市级监管单位'
  129. // },{
  130. // value: '4',
  131. // label: '省级监管单位'
  132. // }],
  133. //机构性质
  134. // field: [{
  135. // value: '1',
  136. // label: '政府部门'
  137. // }, {
  138. // value: '2',
  139. // label: '事业单位'
  140. // }, {
  141. // value: '3',
  142. // label: '企业'
  143. // }],
  144. // 抽样地区
  145. // region: regionData,
  146. region: regionData[11].children,
  147. sample_address:[],
  148. // 机构地域表格数据
  149. underTask: [],
  150. underTasktotal: 0,
  151. // 抽检分离选项
  152. divideOptions: [{
  153. id: 0,
  154. name: '否'
  155. },
  156. {
  157. id: 1,
  158. name: '是'
  159. }
  160. ],
  161. // myHeaders: {
  162. // Authorization: 'bearer'+ token//上传文件添加token
  163. // },
  164. // 优先级选项
  165. priority: [{
  166. value: '0',
  167. label: '一般'
  168. }, {
  169. value: '1',
  170. label: '紧急'
  171. }, {
  172. value: '2',
  173. label: '特急'
  174. }],
  175. // 批次选项
  176. batch: [{
  177. label: '一季度'
  178. }, {
  179. label: '二季度'
  180. }, {
  181. label: '三季度'
  182. }, {
  183. label: '四季度'
  184. }],
  185. // 弹出抽样机构弹窗
  186. getOrganizationsShow1: false,
  187. // 查询抽样机构请求参数
  188. queryInfo1: {
  189. pageNum: 1,
  190. pageSize: 10,
  191. name:'',
  192. sample_org_id:''
  193. },
  194. // 弹出检测机构弹窗
  195. getOrganizationsShow2: false,
  196. // 查询检测机构请求参数
  197. queryInfo2: {
  198. pageNum: 1,
  199. pageSize: 10,
  200. // keyWord: '',
  201. groupname:'检测机构',
  202. },
  203. //抽样机构列表
  204. testList: [],
  205. // 检测机构列表
  206. testList2: [],
  207. // 地区
  208. regionList: [],
  209. // 表头
  210. tableHeader: [{
  211. label: '单位名称',
  212. prop: 'name',
  213. width: 300
  214. // fixed: 'left'
  215. },
  216. {
  217. label: '机构类型',
  218. prop: 'properties',
  219. width:150
  220. // fixed: 'left'
  221. }, {
  222. label: '组别名称',
  223. prop: 'groupname',
  224. width: 300
  225. // fixed: 'left'
  226. }
  227. ],
  228. tableHeader3:[{
  229. label: '抽样机构',
  230. prop:'form.main_unit',
  231. width:260,
  232. },{
  233. label: '检测机构',
  234. prop:'form.check_unit',
  235. width:260,
  236. },{
  237. label: '地区',
  238. prop:'sample_address',
  239. // width:260,
  240. },
  241. ],
  242. // 总共多少条数据
  243. total: 0,
  244. total2: 0,
  245. // table表格多选选项
  246. // multipleSelection: null,
  247. getOrganizationsForm1: {},
  248. getOrganizationsForm2: {},
  249. // 选中的牵头单位
  250. orgs: [],
  251. orgs2: [],
  252. // 上传成功文件列表
  253. fileList: []
  254. }
  255. },
  256. created:function(){
  257. this.sample_org_id = this.id
  258. this.task_id= this.$route.params.task_id
  259. console.log(this.task_id)
  260. this.postTaskProfile()
  261. },
  262. mounted() {
  263. let that = this
  264. },
  265. methods: {
  266. // 添加任务step2
  267. async postTaskProfile() {
  268. const result = await this.$http.post('postTaskProfile', {
  269. task_id: this.task_id,
  270. sample_org_id:this.sample_org_id,
  271. check_org_id:this.check_org_id,
  272. sample_address:this.sample_address
  273. })
  274. this.sample_org_id = result.data.rows.id
  275. this.check_org_id = result.data.rows.id
  276. console.log(this.sample_org_id)
  277. },
  278. //搜索
  279. // async search(){
  280. // this.queryInfo1.pageNum = 1
  281. // this.getOrganizations()
  282. // },
  283. //搜索
  284. // async search2(){
  285. // this.queryInfo2.pageNum = 1
  286. // this.getOrganizations()
  287. // },
  288. // 获取选择抽样地区
  289. handleChange() {
  290. var that = this
  291. var loc = "";
  292. for (let i = 0; i < this.sample_address.length; i++) {
  293. loc += CodeToText[this.sample_address[i]];
  294. }
  295. that.form.sample_address = loc
  296. // console.log(loc)
  297. },
  298. //保存
  299. async onSubmit() {
  300. this.form['token'] = token
  301. this.form['groupname'] = this.groupname
  302. this.form['orgs'] = this.orgs
  303. this.form['releaser'] = window.sessionStorage.getItem('rymc')
  304. this.form['task_class'] = '例行监测'
  305. this.form['ispublic'] = 0
  306. this.form['sample_org_id'] = this.sample_org_id
  307. this.form['check_org_id'] = this.check_org_id
  308. this.form['task_id'] = this.task_id
  309. const result = await this.$http.post('postTaskProfile', this.form)
  310. // 判断业务逻辑
  311. if (result.data.code == 0) {
  312. this.$router.push('routineMonitor')
  313. } else {
  314. this.$message({
  315. type: 'error',
  316. message: result.data.message
  317. })
  318. }
  319. },
  320. reBack() {
  321. this.$router.push('addTask')
  322. },
  323. // 获取抽样机构列表
  324. async getOrganizations1() {
  325. this.queryInfo1['token'] = token
  326. const result = await this.$http.post('getOrganizations', this.queryInfo1)
  327. this.testList = result.data.data.rows
  328. this.total = result.data.data.total
  329. this.sample_org_id = result.data.rows.id
  330. console.log(result.data.data.rows.id)
  331. },
  332. // 获取检测机构列表
  333. async getOrganizations2() {
  334. this.queryInfo2['token'] = token
  335. const result = await this.$http.post('getOrganizations', this.queryInfo2)
  336. this.testList2 = result.data.data.rows
  337. this.total2 = result.data.data.total
  338. // this.check_org_id = result.data.rows.id
  339. },
  340. /** 修复当用户在大于1的分页进行数据搜索没有返回值的问题 */
  341. setPageNum() {
  342. this.queryInfo.pageNum = 1
  343. this.getOrganizations1()
  344. },
  345. setSelectedRow() {
  346. // 设置当前页已选项
  347. this.hander = true
  348. this.testList.forEach(item => {
  349. if (this.list.includes(item[this.uniqueKey])) {
  350. this.$refs.multipleTable.toggleRowSelection(item, true)
  351. }
  352. })
  353. this.hander = false
  354. },
  355. //抽样机构页码
  356. /** 监听每页显示多少数据的改变 */
  357. handleSizeChange1(newSize) {
  358. this.queryInfo1.pageSize = newSize
  359. this.getOrganizations1()
  360. },
  361. /** 监听页码的改变 */
  362. handleCurrentChange1(newPage) {
  363. this.queryInfo1.pageNum = newPage
  364. this.getOrganizations1()
  365. },
  366. //检测机构页码
  367. /** 监听每页显示多少数据的改变 */
  368. handleSizeChange2(newSize) {
  369. this.queryInfo2.pageSize = newSize
  370. this.getOrganizations2()
  371. },
  372. /** 监听页码的改变 */
  373. handleCurrentChange2(newPage) {
  374. this.queryInfo2.pageNum = newPage
  375. this.getOrganizations2()
  376. },
  377. //选中抽样(单选)
  378. handleSelectionChange1(val) {
  379. this.currentRow = val;
  380. console.log(this.currentRow)
  381. console.log(this.currentRow[0].name)
  382. this.sample_org_id = this.currentRow[0].id
  383. console.log(this.sample_org_id)
  384. },
  385. //选中检测(单选)
  386. handleSelectionChange2(val) {
  387. this.currentRow2 = val;
  388. this.check_org_id = this.currentRow2[0].id
  389. console.log(this.currentRow2)
  390. console.log(this.currentRow2[0].name)
  391. console.log(this.check_org_id)
  392. },
  393. // 抽样单位提交
  394. async choseTest1() {
  395. let that = this
  396. that.form.main_unit = that.currentRow[0].name
  397. that.getOrganizationsShow1 = false
  398. that.form.sample_org_id = that.currentRow[0].id
  399. console.log(that.form.sample_org_id)
  400. },
  401. // 检测单位提交
  402. choseTest2() {
  403. let that = this
  404. that.form.check_unit = that.currentRow2[0].name
  405. that.form.check_org_id = that.currentRow2[0].id
  406. that.getOrganizationsShow2 = false
  407. console.log(that.form.check_org_id)
  408. },
  409. }
  410. }
  411. </script>
  412. <style lang="less" scoped>
  413. .title {
  414. margin-left: 50%;
  415. margin-bottom: 20px;
  416. }
  417. .el-form {
  418. width: 800px;
  419. margin: 0 auto;
  420. }
  421. .footer {
  422. margin-top: 5px;
  423. display: flex;
  424. flex-direction: row;
  425. justify-content: space-between;
  426. }
  427. .diqubiaoge{
  428. display: flex;
  429. justify-content: center;
  430. width: 50%
  431. }
  432. </style>