addTaskJcObject.vue 13 KB

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