index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <!--
  2. * @Title:
  3. * @Description: 巡检遗留问题列表
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <el-row>
  12. <el-col :span="24">
  13. <basic-container>
  14. <avue-crud :option="option" :table-loading="loading" :page.sync="page" :data="data" ref="crud"
  15. v-model="form" :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate"
  16. @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
  17. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  18. @refresh-change="refreshChange" @on-load="onLoad">
  19. <template slot-scope="scope" slot="menuLeft">
  20. <el-button type="primary" icon="el-icon-download" size="small"
  21. @click="monthRemainingProblemsExportHandle">导出当前汛期巡检遗留问题表</el-button>
  22. <el-button type="primary" icon="el-icon-download" size="small"
  23. @click="uncloseRemainingProblemsExportHandle">导出当前汛期未关闭巡检遗留问题表</el-button>
  24. </template>
  25. <template slot-scope="{ row, index }" slot="menu">
  26. <el-button type="text" size="small" @click="openReportDetail(row)"
  27. icon="el-icon-edit-outline">填报详情
  28. </el-button>
  29. <el-button v-if="permission.remainingproblems_close == 1 && row.remainQuestionState == 1"
  30. type="text" size="small" style="color:lightcoral" @click="closeRemainingProblem(row)"
  31. icon="el-icon-circle-close">关闭问题
  32. </el-button>
  33. </template>
  34. </avue-crud>
  35. </basic-container>
  36. </el-col>
  37. </el-row>
  38. <el-drawer title="巡检填报信息" :visible.sync="reportDialog" v-if="reportDialog" :size="drawerSize" :direction="direction"
  39. :close-on-click-modal="false" append-to-body>
  40. <inspectionreportdetail :id="id" ref="inspectionreportdetail"></inspectionreportdetail>
  41. </el-drawer>
  42. </div>
  43. </template>
  44. <script>
  45. import {
  46. getRemainingproblemsPage,
  47. closeRemainingProblem,
  48. monthRemainingProblemsExport,
  49. uncloseRemainingProblemsExport
  50. } from "@/api/business/inspection/inspection.js";
  51. import { mapGetters } from "vuex";
  52. import inspectionreportdetail from "../inspectionreportdetail.vue";
  53. export default {
  54. components: {
  55. inspectionreportdetail,
  56. },
  57. data() {
  58. return {
  59. id: '',
  60. drawerSize: '50%',
  61. reportDialog: false,
  62. form: {},
  63. selectionList: [],
  64. query: {},
  65. loading: true,
  66. page: {
  67. pageSize: 10,
  68. currentPage: 1,
  69. total: 0,
  70. },
  71. option: {
  72. labelWidth: 120,
  73. viewLabelWidth: 100,
  74. searchlabelWidth: 100,
  75. height: "auto",
  76. calcHeight: 80,
  77. align: "center",
  78. headerAlign: "center",
  79. tip: false,
  80. simplePage: true,
  81. searchShow: true,
  82. searchMenuSpan: 6,
  83. addBtn: false,
  84. border: true,
  85. index: true,
  86. editBtn: false,
  87. delBtn: false,
  88. viewBtn: false,
  89. menuWidth: 200,
  90. dialogType: "drawer",
  91. columnBtn: false,
  92. dialogClickModal: false,
  93. column: [
  94. {
  95. label: "测站编码",
  96. prop: "rtuCode",
  97. span: 12,
  98. search: true,
  99. searchSpan: 4,
  100. width: 120,
  101. },
  102. {
  103. label: "测站名称",
  104. prop: "rtuName",
  105. span: 12,
  106. search: true,
  107. searchSpan: 4,
  108. width: 160,
  109. // html: true,
  110. // formatter: (val) => {
  111. // if (val.rtuName) {
  112. // return '<b>' + val.rtuName + '</b>/' + '<b style="color:grey">' + val.rtuCode + '</b>'
  113. // } else {
  114. // return '<b>' + val.rtuName + '</b>'
  115. // }
  116. // }
  117. },
  118. {
  119. label: "行政区",
  120. prop: "adCity",
  121. span: 12,
  122. width: 160,
  123. editDisplay: false,
  124. addDisplay: false,
  125. html: true,
  126. formatter: (val) => {
  127. if (val.adCity && val.adDist) {
  128. return '<b>' + val.adCity + '</b>/' + '<b>' + val.adDist + '</b>'
  129. } else {
  130. return '<b>' + val.adCity + '</b>'
  131. }
  132. }
  133. },
  134. {
  135. label: "巡检年度",
  136. prop: "inspectionYear",
  137. span: 24,
  138. hide: true,
  139. search: true,
  140. searchSpan: 4,
  141. type: "year",
  142. rules: [{
  143. required: true,
  144. }],
  145. format: 'yyyy年',
  146. valueFormat: 'yyyy-MM-dd',
  147. },
  148. {
  149. search: true,
  150. label: "汛期",
  151. prop: "rainSeasonKind",
  152. type: 'select',
  153. span: 24,
  154. width: 160,
  155. searchSpan: 4,
  156. props: {
  157. label: 'dictValue',
  158. value: 'id'
  159. },
  160. dicData: [{
  161. dictValue: '汛前巡检',
  162. id: 1,
  163. },
  164. {
  165. dictValue: '汛中(一)巡检',
  166. id: 2,
  167. },
  168. {
  169. dictValue: '汛中(二)巡检',
  170. id: 3,
  171. }],
  172. },
  173. // {
  174. // label: "测站类型",
  175. // prop: "rtuKindDesc",
  176. // span: 24,
  177. // width: 160,
  178. // },
  179. // {
  180. // label: "测站状态",
  181. // prop: "runStatusId",
  182. // span: 12,
  183. // slot: true,
  184. // width: 100,
  185. // html: true,
  186. // formatter: (val) => {
  187. // if (val.runStatusId == 0) {
  188. // return '<b style="color:blue">正常</b>'
  189. // } else {
  190. // return '<b style="color:orangered">疑似故障</b>'
  191. // }
  192. // }
  193. // },
  194. {
  195. label: "填报总结说明",
  196. prop: "reportDesc",
  197. span: 12,
  198. hide: true,
  199. },
  200. {
  201. label: "填报人",
  202. prop: "servicePersonName",
  203. span: 12,
  204. width: 120,
  205. },
  206. {
  207. label: "填报时间",
  208. prop: "createTime",
  209. span: 12,
  210. width: 140,
  211. },
  212. {
  213. label: "遗留问题",
  214. prop: "remainQuestion",
  215. span: 24,
  216. overHidden: true,
  217. minWidth: 160,
  218. },
  219. {
  220. label: "问题处理状态",
  221. prop: "remainQuestionState",
  222. span: 12,
  223. slot: true,
  224. width: 120,
  225. html: true,
  226. formatter: (val) => {
  227. if (val.remainQuestionState == 1) {
  228. return '<b style="color:red">待处理</b>'
  229. } else if (val.remainQuestionState == 2) {
  230. return '<b style="color:blue">已完成</b>'
  231. }
  232. }
  233. },
  234. {
  235. label: "遗留问题处理意见",
  236. prop: "remainQuestionResolution",
  237. span: 24,
  238. overHidden: true,
  239. minWidth: 160,
  240. },
  241. ],
  242. },
  243. data: [],
  244. };
  245. },
  246. computed: {
  247. ...mapGetters(["userInfo", "permission"]),
  248. permissionList() {
  249. return {
  250. remainingproblemsCloseBtn: this.vaildData(this.permission.remainingproblems_close, false),
  251. };
  252. },
  253. },
  254. created() {
  255. },
  256. watch: {
  257. // 'editForm.planId': {
  258. // handler(val) {
  259. // if (val != '' && val != undefined && val != null) {
  260. // this.planId = val;
  261. // this.$message.success(this.planId)
  262. // }
  263. // },
  264. // immediate: true
  265. // }
  266. },
  267. methods: {
  268. toOss(path) {
  269. console.log("oss " + path);
  270. return this.website.ossServer + path;
  271. },
  272. closeRemainingProblem(item) {
  273. this.$prompt("请输入处理意见", "确认关闭此遗留问题?", {
  274. confirmButtonText: "确定",
  275. cancelButtonText: "取消",
  276. })
  277. .then(({ value }) => {
  278. closeRemainingProblem({ id: item.id, remainQuestionResolution: value }).then((res) => {
  279. if (res.data.code == 200) {
  280. this.$message({
  281. type: "success",
  282. message: "操作成功",
  283. });
  284. this.refreshChange();
  285. }
  286. });
  287. })
  288. .catch(() => { });
  289. },
  290. monthRemainingProblemsExportHandle() {
  291. let that = this;
  292. this.$confirm("确认导出当前汛期遗留问题信息表?", "提示", {
  293. confirmButtonText: "确定",
  294. cancelButtonText: "取消",
  295. type: "warning",
  296. })
  297. .then(() => {
  298. monthRemainingProblemsExport().then(
  299. (res) => {
  300. window.console.log(JSON.stringify(res));
  301. that.exportDialog = false;
  302. if (res.data.data.status == 1) {
  303. this.$message({
  304. type: "success",
  305. message: "导出成功!",
  306. });
  307. var url = res.data.data.url;
  308. var filename = res.data.data.filename;
  309. that.getBlob(this.toOss(url)).then(res => {
  310. that.saveAs(res, filename + ".xlsx");
  311. });
  312. } else {
  313. that.$message({
  314. type: "fail",
  315. message: "操作失败!",
  316. });
  317. }
  318. },
  319. (error) => {
  320. that.exportDialog = false;
  321. window.console.log(error);
  322. this.$message({
  323. type: "fail",
  324. message: "操作失败!",
  325. });
  326. }
  327. );
  328. })
  329. .catch(() => { });
  330. },
  331. uncloseRemainingProblemsExportHandle() {
  332. let that = this;
  333. this.$confirm("确认导出当前汛期未关闭的遗留问题信息表?", "提示", {
  334. confirmButtonText: "确定",
  335. cancelButtonText: "取消",
  336. type: "warning",
  337. })
  338. .then(() => {
  339. uncloseRemainingProblemsExport().then(
  340. (res) => {
  341. window.console.log(JSON.stringify(res));
  342. that.exportDialog = false;
  343. if (res.data.data.status == 1) {
  344. this.$message({
  345. type: "success",
  346. message: "导出成功!",
  347. });
  348. var url = res.data.data.url;
  349. var filename = res.data.data.filename;
  350. that.getBlob(this.toOss(url)).then(res => {
  351. that.saveAs(res, filename + ".xlsx");
  352. });
  353. } else {
  354. that.$message({
  355. type: "fail",
  356. message: "操作失败!",
  357. });
  358. }
  359. },
  360. (error) => {
  361. that.exportDialog = false;
  362. window.console.log(error);
  363. this.$message({
  364. type: "fail",
  365. message: "操作失败!",
  366. });
  367. }
  368. );
  369. })
  370. .catch(() => { });
  371. },
  372. getBlob(url) {
  373. return new Promise(resolve => {
  374. const xhr = new XMLHttpRequest();
  375. xhr.open("GET", url, true);
  376. xhr.responseType = "blob";
  377. xhr.crossOrigin = "*";
  378. xhr.onload = () => {
  379. if (xhr.status === 200) {
  380. resolve(xhr.response);
  381. }
  382. };
  383. xhr.send();
  384. })
  385. },
  386. saveAs(blob, filename) {
  387. const link = document.createElement('a');
  388. const body = document.querySelector("body");
  389. link.href = window.URL.createObjectURL(blob);
  390. link.download = filename;
  391. link.style.display = "none";
  392. body.appendChild(link);
  393. link.click();
  394. body.removeChild(link);
  395. window.URL.revokeObjectURL(link.href);
  396. },
  397. openReportDetail(item) {
  398. this.reportDialog = true;
  399. this.id = item.id;
  400. this.$nextTick(() => {
  401. this.$refs["inspectionreportdetail"].init();
  402. });
  403. },
  404. searchReset() {
  405. this.query = {};
  406. this.query['adCode'] = this.treeCode;
  407. this.page.currentPage = 1;
  408. this.onLoad(this.page);
  409. },
  410. searchChange(params, done) {
  411. console.log(JSON.stringify(params))
  412. this.query = params;
  413. this.page.currentPage = 1;
  414. this.onLoad(this.page);
  415. done();
  416. },
  417. selectionChange(list) {
  418. this.selectionList = list;
  419. },
  420. selectionClear() {
  421. this.selectionList = [];
  422. this.$refs.crud.toggleSelection();
  423. },
  424. beforeOpen(done, type) {
  425. if (["edit", "view"].includes(type)) {
  426. // getDetail(this.form.id).then((res) => {
  427. // this.form = res.data.data;
  428. // });
  429. }
  430. done();
  431. },
  432. currentChange(currentPage) {
  433. this.page.currentPage = currentPage;
  434. },
  435. sizeChange(pageSize) {
  436. this.page.pageSize = pageSize;
  437. },
  438. refreshChange() {
  439. var params = {};
  440. this.onLoad(this.page, params);
  441. },
  442. onLoad(page, params = {}) {
  443. this.loading = true;
  444. getRemainingproblemsPage(
  445. page.currentPage,
  446. page.pageSize,
  447. Object.assign(params, this.query)
  448. ).then((res) => {
  449. const data = res.data.data;
  450. this.page.total = data.total;
  451. this.data = data.records;
  452. this.loading = false;
  453. this.selectionClear();
  454. });
  455. },
  456. },
  457. };
  458. </script>
  459. <style lang="scss" scoped>
  460. .common-dialog {
  461. display: flex;
  462. align-items: center;
  463. justify-content: center;
  464. overflow: hidden;
  465. .el-dialog {
  466. margin: 0 auto !important;
  467. position: relative;
  468. overflow: hidden;
  469. .el-dialog__header {
  470. position: absolute;
  471. left: 0;
  472. right: 0;
  473. bottom: 0;
  474. width: 100%;
  475. height: 60px;
  476. z-index: 1;
  477. }
  478. .el-dialog__body {
  479. position: relative;
  480. left: 0;
  481. top: 60px;
  482. bottom: 0;
  483. right: 0;
  484. padding: 0;
  485. width: 100%;
  486. overflow: hidden;
  487. overflow-y: auto;
  488. max-height: 90vh;
  489. padding-top: 80px;
  490. padding-bottom: 100px;
  491. z-index: 1;
  492. }
  493. .el-dialog__footer {
  494. position: absolute;
  495. left: 0;
  496. right: 0;
  497. bottom: 0;
  498. width: 100%;
  499. height: 80px;
  500. z-index: 1;
  501. }
  502. }
  503. }
  504. </style>