subjDtList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <template>
  2. <div style="width: 100%">
  3. <div slot="header" class="clearfix">
  4. <el-breadcrumb separator-class="el-icon-arrow-right">
  5. <el-breadcrumb-item >首页</el-breadcrumb-item>
  6. <el-breadcrumb-item>监测任务</el-breadcrumb-item>
  7. <el-breadcrumb-item>例行监测</el-breadcrumb-item>
  8. <el-breadcrumb-item>任务列表</el-breadcrumb-item>
  9. </el-breadcrumb>
  10. </div>
  11. <!-- 头部查询栏 -->
  12. <div class="headSearch">
  13. <el-row :gutter="50" style="margin-right: 0px;">
  14. <el-form :inline="true">
  15. <!-- <el-form style="display: flex; flex-direction: row;" > -->
  16. <el-form-item label="年度" class="select" size="small">
  17. <el-date-picker v-model="queryInfo.year" style="width: 110px;" value-format="yyyy" type="year" clearable />
  18. </el-form-item>
  19. <el-form-item label="任务状态" class="select" size="small">
  20. <el-select v-model="queryInfo.ispublic" style="width: 110px;" clearable>
  21. <el-option
  22. v-for="item in taskispublic"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value" >
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="任务时间" class="select" size="small">
  30. <el-date-picker v-model="queryInfo.starttime" style="width: 180px;" align="right" type="date"
  31. :picker-options="pickerOptions" clearable value-format="yyyy-MM-dd" />
  32. </el-form-item>
  33. <el-form-item label="--" class="select" style="margin-left: 10px;" size="small">
  34. <el-date-picker v-model="queryInfo.endtime" style="width: 180px;" align="right" type="date"
  35. :picker-options="pickerOptions" clearable />
  36. </el-form-item>
  37. <el-form-item label="任务名称" class="select" size="small">
  38. <el-input v-model="queryInfo.task_name"></el-input>
  39. </el-form-item>
  40. <!-- 查询 -->
  41. <el-button size="mini" style="height: 40px;margin-left: 10px;" type="success" @click="searchData()">查询</el-button>
  42. <!-- 重置 -->
  43. <el-button size="mini" style="height: 40px;margin-left: 5px;" type="success" @click="reset()">重置</el-button>
  44. </el-form>
  45. </el-row>
  46. </div>
  47. <!--头部右侧按钮区域-->
  48. <div class="rightButton">
  49. <el-row :gutter="90" style="margin-right: 0px;">
  50. <div style="display: flex;flex-direction: row;float: right;">
  51. <el-button type="primary" size="small" plain icon="el-icon-plus" @click="add()">新增</el-button>
  52. <el-button type="primary" size="small" plain icon="el-icon-edit-outline" @click="ispublic()">发布
  53. </el-button>
  54. <el-button type="primary" size="small" plain icon="el-icon-scissors" @click="repeal()">废止</el-button>
  55. <el-button type="primary" size="small" plain icon="el-icon-delete" @click="delArray()">删除</el-button>
  56. <!-- <el-button type="primary" size="small" plain icon="el-icon-download">导出</el-button> -->
  57. </div>
  58. </el-row>
  59. </div>
  60. <!-- 表格数据区域-->
  61. <el-table ref="multipleTable"
  62. :data="tableData"
  63. border stripe highlight-current-row
  64. style="width: 100%"
  65. :row-style="rowStyle"
  66. :cell-style="cellStyle"
  67. @selection-change="handleSelectionChange">
  68. <el-table-column type="selection" width="50"></el-table-column>
  69. <el-table-column label="序号" width="50px">
  70. <template slot-scope="scope">
  71. {{ scope.$index+1 }}
  72. </template>
  73. </el-table-column>
  74. <el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label" :prop="table.prop" align="center"
  75. :width="table.width" :fixed="table.fixed" />
  76. <el-table-column prop="status" label="任务状态" width="130" align="center" >
  77. <template slot-scope="scope">
  78. <el-tag v-if="scope.row.ispublic==0">未发布</el-tag>
  79. <el-tag type="warning" v-if="scope.row.ispublic==1">已发布</el-tag>
  80. <el-tag type="danger" v-if="scope.row.ispublic==2">已废止</el-tag>
  81. <el-tag type="info" v-if="scope.row.ispublic==3">已结束,未完成</el-tag>
  82. <el-tag type="success" v-if="scope.row.ispublic==4">已结束,已完成</el-tag>
  83. <el-tag type="success" effect="plain" v-if="scope.row.ispublic==5">执行中</el-tag>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="level" label="任务优先级" width="95" align="center">
  87. <template slot-scope="scope">
  88. <el-tag type="success" v-if="scope.row.level==0">一般</el-tag>
  89. <el-tag type="warning" v-if="scope.row.level==1">紧急</el-tag>
  90. <el-tag type="danger" v-if="scope.row.level==2">特急</el-tag>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" align="center" fixed="right">
  94. <!-- 操作按钮区域的作用域插槽 -->
  95. <template slot-scope="scope">
  96. <el-col style="margin-bottom: 5px;">
  97. <el-button type="success" size="mini" @click="readDialogVisible1(scope.row)" style="margin-top:5px">详情</el-button>
  98. <el-button type="success" size="mini" plain @click="takeTheLeadReportList(scope.row.id)" style="margin-top:5px">牵头单位报告</el-button>
  99. </el-col>
  100. <el-col style="margin-bottom: 5px;">
  101. <el-button type="success" size="mini" plain @click="undertakeReport(scope.row.id)">承担单位报告</el-button>
  102. <el-button type="success" size="mini" plain @click="taskSample(scope.row.id)">抽样单</el-button>
  103. </el-col>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <!-- 分页器区域-->
  108. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  109. :current-page="queryInfo.pageNum" :page-sizes="[10, 15, 20]" :page-size="queryInfo.pageSize"
  110. layout="total, sizes, prev, pager, next, jumper" :total="total" background />
  111. <!-- 任务详情对话框-->
  112. <el-dialog title="查看" :visible.sync="readDialogVisible" width="30%" :close-on-click-modal="false"
  113. class="dialogItem">
  114. <el-form v-if="readDialogVisible" :model="readForm" label-width="100px">
  115. <el-form-item label="任务名称:" prop="task_name" class="labelItem">
  116. <div>{{readForm.task_name}}</div>
  117. </el-form-item>
  118. <el-form-item label="任务优先级:" prop="level" class="labelItem">
  119. <div v-if="readForm.level=='0'">一般</div>
  120. <div v-else-if="readForm.level=='1'">紧急</div>
  121. <div v-else>特急</div>
  122. </el-form-item>
  123. <el-form-item label="监测类型:" prop="task_class" width="70px" class="labelItem">
  124. <div>{{readForm.task_class}}</div>
  125. </el-form-item>
  126. <el-form-item label="年度:" prop="year" class="labelItem">
  127. <div>{{readForm.year}}</div>
  128. </el-form-item>
  129. <el-form-item label="批次:" prop="batch" width="200px" class="labelItem">
  130. <div>{{readForm.batch}}</div>
  131. </el-form-item>
  132. <el-form-item label="任务时间:" prop="starttime" width="200px" class="labelItem">
  133. <div>{{readForm.starttime}} 至 {{readForm.endtime}}</div>
  134. </el-form-item>
  135. <el-form-item label="发布单位:" prop="creater" class="labelItem">
  136. <div>{{readForm.creater.name}}</div>
  137. </el-form-item>
  138. <!-- <el-form-item label="牵头单位:" prop="main_unit" class="labelItem">
  139. <div>{{readForm.main_unit}}</div>
  140. </el-form-item> -->
  141. <el-form-item label="附件:" prop="file_url" class="labelItem">
  142. <!-- <div>{{readForm.file_url}}</div> -->
  143. <el-link :href="readForm.file_url" type="primary">{{readForm.file_name}}</el-link>
  144. </el-form-item>
  145. <el-form-item label="文件号:" prop="filenum" width="230px" class="labelItem">
  146. <div v-if="readForm.filenum==null">无</div>
  147. <div v-else>{{readForm.filenum}}</div>
  148. </el-form-item>
  149. <el-form-item label="备注:" prop="log" class="labelItem">
  150. <div v-if="readForm.log==null">无</div>
  151. <div v-else>{{readForm.log}}</div>
  152. </el-form-item>
  153. <div class="footer">
  154. <el-button type="success" @click="readDialogVisible = false">返回</el-button>
  155. </div>
  156. </el-form>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. const token = window.sessionStorage.getItem('token')
  162. const rybh = window.sessionStorage.getItem('rybh')
  163. const rymc = window.sessionStorage.getItem('rymc')
  164. export default {
  165. name: '',
  166. data() {
  167. return {
  168. queryInfo:{
  169. year:'',
  170. task_name:'',
  171. starttime:'',
  172. endtime:'',
  173. ispublic:'',
  174. pageSize:10,
  175. pageNum:1,
  176. task_class:'例行监测'
  177. },
  178. total:0,
  179. cellStyle: {
  180. padding: 2 + 'px'
  181. },
  182. rowStyle: {
  183. height: 35 + 'px'
  184. },
  185. tableHeader: [{
  186. label: '任务名称',
  187. prop: 'task_name',
  188. width: 150
  189. // fixed: 'left'
  190. },
  191. {
  192. label: '开始时间',
  193. prop: 'starttime',
  194. width: 120
  195. },
  196. {
  197. label: '结束时间',
  198. prop: 'endtime',
  199. width: 120
  200. },
  201. {
  202. label: '年度',
  203. prop: 'year',
  204. width: 80
  205. // fixed: 'left'
  206. }, {
  207. label: '文件号',
  208. prop: 'filenum',
  209. width: 180
  210. // fixed: 'left'
  211. },
  212. {
  213. label: '创建者',
  214. prop: 'creater.name',
  215. width: 140
  216. },
  217. {
  218. label: '创建时间',
  219. prop: 'create_time',
  220. width: 180
  221. }
  222. ],
  223. // 数据表格数据
  224. tableData: [],
  225. // 批量删除选中数据
  226. multipleSelection: [],
  227. // 任务状态选项
  228. taskispublic: [{
  229. value: '',
  230. label: '全部'
  231. }, {
  232. value: '0',
  233. label: '未发布'
  234. }, {
  235. value: '1',
  236. label: '已发布'
  237. }, {
  238. value: '2',
  239. label: '废止'
  240. }, {
  241. value: '5',
  242. label: '执行中'
  243. }, {
  244. value: '3',
  245. label: '已结束,未完成'
  246. }, {
  247. value: '4',
  248. label: '已结束,已完成'
  249. }],
  250. // 日期选择器快捷选项
  251. pickerOptions: {
  252. // disabledDate(time) {
  253. // return time.getTime() > Date.now();
  254. // },
  255. shortcuts: [{
  256. text: '今天',
  257. onClick(picker) {
  258. picker.$emit('pick', new Date());
  259. }
  260. }, {
  261. text: '昨天',
  262. onClick(picker) {
  263. const date = new Date();
  264. date.setTime(date.getTime() - 3600 * 1000 * 24);
  265. picker.$emit('pick', date);
  266. }
  267. }, {
  268. text: '一周前',
  269. onClick(picker) {
  270. const date = new Date();
  271. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  272. picker.$emit('pick', date);
  273. }
  274. }]
  275. },
  276. // 查看任务详情
  277. readDialogVisible: false,
  278. readForm: {},
  279. multipleSelection: [],
  280. delarr: [],
  281. pubarr: []
  282. }
  283. },
  284. created() {
  285. this.getTasks()
  286. },
  287. methods: {
  288. add() {
  289. this.$router.push('addTask')
  290. },
  291. takeTheLeadReportList(id) {
  292. console.log(id)
  293. this.$router.push({
  294. name:'takeTheLeadReportList',
  295. params: {
  296. task_id: id,
  297. }
  298. })
  299. },
  300. undertakeReport(id){
  301. console.log(id)
  302. this.$router.push({
  303. name:'undertakeReport',
  304. params: {
  305. task_id: id,
  306. }
  307. })
  308. },
  309. taskSample(id){
  310. console.log(id)
  311. this.$router.push({
  312. name:'taskSample',
  313. params: {
  314. task_id: id,
  315. }
  316. })
  317. },
  318. // 搜索
  319. async searchData() {
  320. this.queryInfo.pageNum = 1
  321. this.gettaskList()
  322. },
  323. // 重置
  324. reset(){
  325. this.queryInfo={
  326. year:'',
  327. task_name:'',
  328. starttime:'',
  329. endtime:'',
  330. ispublic:'',
  331. pageSize:10,
  332. pageNum:1,
  333. task_class:'例行监测',
  334. task_id
  335. }
  336. this.getTasks()
  337. },
  338. /** 监听页码的改变 */
  339. handleCurrentChange(newPage) {
  340. this.queryInfo.pageNum = newPage
  341. this.getTasks()
  342. },
  343. /** 监听每页显示多少数据的改变 */
  344. handleSizeChange(newSize) {
  345. this.queryInfo.pageSize = newSize
  346. this.getTasks()
  347. },
  348. // 获取任务列表
  349. async getTasks() {
  350. for (var key in this.queryInfo) {
  351. if (this.queryInfo[key] == '') {
  352. delete this.queryInfo[key]
  353. }
  354. }
  355. const {
  356. data: res
  357. } = await this.$http.post(
  358. "getTasks", this.queryInfo
  359. );
  360. this.tableData = res.data.rows
  361. this.total = res.data.total
  362. },
  363. // 查看任务详情
  364. async readDialogVisible1(row) {
  365. this.readForm.batch = row.batch
  366. this.readForm.task_name = row.task_name
  367. this.readForm.task_class = row.task_class
  368. this.readForm.level = row.level
  369. // console.log(this.readForm.level)
  370. this.readForm.year = row.year
  371. this.readForm.starttime = row.starttime
  372. this.readForm.endtime = row.endtime
  373. this.readForm.releaser = row.releaser
  374. this.readForm.creater = row.creater
  375. this.readForm.main_unit = row.main_unit
  376. this.readForm.file_url = row.file_url
  377. this.readForm.file_name = row.file_name
  378. this.readForm.filenum = row.filenum
  379. this.readForm.log = row.log
  380. this.readDialogVisible = true
  381. },
  382. // 批量删除
  383. handleSelectionChange(val) {
  384. this.multipleSelection = val;
  385. // console.log(this.multipleSelection)
  386. },
  387. // 删除任务
  388. async delArray() {
  389. // 判断任务是否为该创建者创建
  390. // for (let i = 0; i < this.multipleSelection.length; i++) {
  391. // if (rybh != this.multipleSelection[i].releaser) {
  392. // this.$alert('任务仅创建者可以删除!', {
  393. // confirmButtonText: '确定',
  394. // callback: action => {
  395. // }
  396. // });
  397. // }
  398. // }
  399. var that = this;
  400. const length = this.multipleSelection.length;
  401. // var val = this.selectedData;
  402. for (let i = 0; i < length; i++) {
  403. // console.log(this.multipleSelection[i])
  404. this.delarr.push(this.multipleSelection[i].id);
  405. }
  406. const result = await this.$http.post('deleteTasks', {
  407. delarr: that.delarr,
  408. token: token
  409. })
  410. console.log(that.delarr);
  411. if (result.data.code == 0) {
  412. this.$message({
  413. type: 'success',
  414. message: '删除成功!'
  415. });
  416. that.getTasks()
  417. } else {
  418. this.$message({
  419. type: 'error',
  420. message: '删除失败!'
  421. });
  422. }
  423. // console.log(this.$refs.multipleTable);
  424. this.$refs.multipleTable.clearSelection();
  425. that.delarr = [];
  426. // this.$refs.multipleTable.clearSelectionFun();
  427. },
  428. // 发布任务
  429. async ispublic() {
  430. // 判断任务是否为该创建者创建
  431. // for (let i = 0; i < this.multipleSelection.length; i++) {
  432. // if (rybh != this.multipleSelection[i].releaser) {
  433. // this.$alert('任务仅创建者可以发布!', {
  434. // confirmButtonText: '确定',
  435. // callback: action => {
  436. // }
  437. // });
  438. // }
  439. // }
  440. var that = this;
  441. let canPub = 0
  442. const length = this.multipleSelection.length;
  443. // var val = this.selectedData;
  444. console.log(this.multipleSelection)
  445. // this.pubarr = this.multipleSelection;
  446. for (let i = 0; i < length; i++) {
  447. if (this.multipleSelection[i].ispublic != '0') {
  448. this.$alert('任务不在可发布状态!', {
  449. confirmButtonText: '确定',
  450. callback: action => {
  451. }
  452. });
  453. } else {
  454. this.multipleSelection[i].ispublic = 1
  455. canPub = 1
  456. }
  457. }
  458. if(canPub==1){
  459. const result = await this.$http.post('putTaskPublic', {
  460. pubarr: that.multipleSelection,
  461. token: token,
  462. })
  463. console.log(result.data.code)
  464. if (result.data.code == 0) {
  465. this.$message({
  466. type: 'success',
  467. message: '发布成功!'
  468. });
  469. that.getTasks()
  470. }else{
  471. this.$message({
  472. type: 'error',
  473. message: result.data.message})
  474. }
  475. }
  476. },
  477. // 废止任务
  478. async repeal() {
  479. // 判断任务是否为该创建者创建
  480. for (let i = 0; i < this.multipleSelection.length; i++) {
  481. if (rybh != this.multipleSelection[i].releaser) {
  482. this.$alert('任务仅创建者可以废止!', {
  483. confirmButtonText: '确定',
  484. callback: action => {}
  485. });
  486. }
  487. }
  488. var that = this;
  489. let canPub = 0
  490. const length = this.multipleSelection.length;
  491. // var val = this.selectedData;
  492. this.pubarr = this.multipleSelection;
  493. for (let i = 0; i < length; i++) {
  494. if (this.pubarr[i].ispublic == 1) {
  495. this.pubarr[i].ispublic = 2
  496. canPub = 1
  497. } else {
  498. this.$alert('任务不在可废止状态!', {
  499. confirmButtonText: '确定',
  500. callback: action => {
  501. }
  502. });
  503. }
  504. if(canPub==1){
  505. const result = await this.$http.post('putTaskPublic', {
  506. pubarr: that.pubarr,
  507. token: token
  508. })
  509. if (result.data.code == 0) {
  510. this.$message({
  511. type: 'success',
  512. message: '任务已废止!'
  513. });
  514. that.getTasks()
  515. }
  516. }
  517. }
  518. }
  519. },
  520. }
  521. </script>
  522. <style lang="less" scoped>
  523. .el-breadcrumb {
  524. margin-bottom: 20px;
  525. }
  526. .el-table {
  527. align-items: center;
  528. margin-top: 25px;
  529. }
  530. /deep/ .el-col {
  531. padding-right: 0 !important;
  532. }
  533. /deep/ .el-radio-group label {
  534. width: 180px;
  535. margin-right: 10px;
  536. }
  537. .el-pagination {
  538. margin-top: 25px;
  539. }
  540. // .el-cascader {
  541. // width: 290px;
  542. // }
  543. .el-select {
  544. width: 210px;
  545. height: 100%;
  546. }
  547. .select {
  548. // display: flex;
  549. flex-direction: row;
  550. // margin-left: 10px;
  551. }
  552. .dialogItem /deep/ .el-dialog__body {
  553. padding: 15px 12px 0;
  554. color: #606266;
  555. font-size: 14px;
  556. word-break: break-all;
  557. }
  558. .el-form-item {
  559. margin-bottom: 8px;
  560. }
  561. .labelItem /deep/ .el-form-item__label {
  562. // width: 80px;
  563. text-align: center;
  564. vertical-align: middle;
  565. float: left;
  566. font-size: 13px;
  567. color: #606266;
  568. // line-height: 40px;
  569. padding: 0 2px 0 0;
  570. -webkit-box-sizing: border-box;
  571. box-sizing: border-box;
  572. }
  573. .el-dialog__header {
  574. border-bottom: 1px solid #e5e5e5;
  575. }
  576. // .el-form-item__content{
  577. // margin-left: 0;
  578. // }
  579. .footer {
  580. padding: 5px 0;
  581. border-top: 1px solid #e5e5e5;
  582. text-align: center;
  583. }
  584. .rightButton{
  585. margin-top: 20px;
  586. }
  587. .headSearch{
  588. margin-left: 25px;
  589. }
  590. </style>