index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. ></org-tree>
  12. </el-col>
  13. <el-col :span="20" :xs="24">
  14. <div class="main-right-box">
  15. <div class="main-search-box">
  16. <!-- 搜索条件 -->
  17. <el-form
  18. :model="queryParams"
  19. ref="queryParams"
  20. size="small"
  21. :inline="true"
  22. v-show="showSearch"
  23. >
  24. <el-form-item label="任务名称" prop="title">
  25. <el-input
  26. style="width: 200px"
  27. v-model="queryParams.title"
  28. placeholder="请输入任务名称"
  29. clearable
  30. @keyup.enter.native="handleQuery"
  31. :maxlength="50"
  32. @input="inputTitle"
  33. />
  34. </el-form-item>
  35. <el-form-item label="检查人员" prop="roleId">
  36. <el-select
  37. v-model="queryParams.roleId"
  38. placeholder="请选择用户角色"
  39. clearable
  40. >
  41. <el-option
  42. v-for="item in selectRoleOptions"
  43. :key="item.id"
  44. :label="item.roleName"
  45. :value="item.id"
  46. ></el-option>
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item label="受检机构" prop="orgName">
  50. <!-- <el-input
  51. v-model="queryParams.orgName"
  52. placeholder="请输入受检机构"
  53. clearable
  54. @keyup.enter.native="handleQuery"
  55. :maxlength="50" @input="inputRestriction"
  56. /> -->
  57. <div style="width: 200px; height: 30px">
  58. <org-tree-select
  59. size="mini"
  60. v-model="queryParams.checkOrgIds"
  61. ref="checkorgTreeSelect"
  62. :disable="true"
  63. @change="getList"
  64. >
  65. </org-tree-select>
  66. </div>
  67. </el-form-item>
  68. <el-form-item label="任务进度" prop="status">
  69. <el-select
  70. style="width: 200px"
  71. v-model="queryParams.status"
  72. placeHolder="请选择任务进度"
  73. clearable
  74. >
  75. <el-option
  76. v-for="item in dict.type.safety_check_status"
  77. :key="item.value"
  78. :label="item.label"
  79. :value="item.value"
  80. ></el-option>
  81. </el-select>
  82. </el-form-item>
  83. <!-- <el-form-item label="检查周期" prop="executeCycle">
  84. <el-select
  85. v-model="queryParams.executeCycle"
  86. placeHolder="请选择检查周期"
  87. @change="changeType($event)"
  88. >
  89. <el-option
  90. v-for="item in dict.type.resumption_plan_cycle"
  91. :key="item.value"
  92. :label="item.label"
  93. :value="item.value"
  94. ></el-option>
  95. </el-select>
  96. </el-form-item> -->
  97. <!-- <el-form-item
  98. class="searchTitle"
  99. label="开始日期"
  100. prop="planStartTime"
  101. >
  102. <el-date-picker
  103. style="width: 200px;"
  104. v-model="queryParams.planStartTime"
  105. :clearable="timeClearable"
  106. type="date"
  107. placeholder="选择时间"
  108. value-format="yyyy-MM-dd"
  109. @change="updatePlanStartTime"
  110. >
  111. </el-date-picker>
  112. </el-form-item> -->
  113. <el-form-item
  114. class="searchTitle"
  115. label="任务时间"
  116. prop="planStartTime"
  117. >
  118. <DataRangePicker
  119. type="daterange"
  120. value-format="yyyy-MM-dd HH:mm:ss"
  121. :default-time="['00:00:00', '23:59:59']"
  122. start-placeholder="开始日期"
  123. end-placeholder="结束日期"
  124. v-model="queryParams.range"
  125. >
  126. </DataRangePicker>
  127. </el-form-item>
  128. <el-row>
  129. <el-form-item style="margin-left: 35px">
  130. <el-button
  131. type="primary"
  132. icon="el-icon-search"
  133. size="mini"
  134. @click="getList"
  135. >搜索</el-button
  136. >
  137. <el-button
  138. type="primary"
  139. icon="el-icon-refresh"
  140. size="mini"
  141. @click="resetQuery"
  142. >重置</el-button
  143. >
  144. <el-button
  145. type="primary"
  146. icon="el-icon-plus"
  147. size="mini"
  148. @click="handleAdd"
  149. v-hasPermi="['core:safetycheck:tempregister']"
  150. >临时登记</el-button
  151. >
  152. <el-button
  153. type="primary"
  154. icon="el-icon-download"
  155. size="mini"
  156. @click="handleExport"
  157. v-hasPermi="['system:user:export']"
  158. >导出</el-button
  159. >
  160. </el-form-item>
  161. </el-row>
  162. </el-form>
  163. <!-- 按纽 -->
  164. </div>
  165. <el-table
  166. border
  167. height="596"
  168. size="small"
  169. v-loading="loading"
  170. :data="pageData"
  171. >
  172. <el-table-column
  173. type="index"
  174. fixed
  175. align="center"
  176. width="80px"
  177. label="序号"
  178. v-if="columns[0].visible"
  179. >
  180. </el-table-column>
  181. <el-table-column
  182. header-align="center"
  183. prop="title"
  184. label="任务名称"
  185. width="250px"
  186. :show-overflow-tooltip="true"
  187. v-if="columns[1].visible"
  188. >
  189. </el-table-column>
  190. <el-table-column
  191. header-align="center"
  192. prop="checkOrgName"
  193. label="检查主体"
  194. width="180px"
  195. v-if="columns[5].visible"
  196. >
  197. </el-table-column>
  198. <el-table-column
  199. prop="roleName"
  200. label="检查人员"
  201. align="center"
  202. width="180px"
  203. v-if="columns[6].visible"
  204. >
  205. <template slot-scope="r">
  206. {{
  207. r.row.roles
  208. ? r.row.roles.map((r) => r.roleName).join("||")
  209. : ""
  210. }}
  211. </template>
  212. </el-table-column>
  213. <el-table-column
  214. prop="status"
  215. label="任务进度"
  216. align="center"
  217. width="120px"
  218. v-if="columns[10].visible"
  219. >
  220. <template slot-scope="r">
  221. <span>
  222. <!-- <i class="circle" :style="statusColor(r.row.status, true)" /> -->
  223. <!-- <label :style="statusColor(r.row.status, false)"> -->
  224. <label>
  225. {{
  226. getLabel(dict.type.safety_check_status, r.row.status)
  227. }}</label
  228. >
  229. </span>
  230. </template>
  231. </el-table-column>
  232. <el-table-column
  233. prop="orgName"
  234. label="受检机构"
  235. header-align="center"
  236. width="180px"
  237. v-if="columns[4].visible"
  238. >
  239. </el-table-column>
  240. <el-table-column
  241. prop="planStartTime"
  242. label="任务时间"
  243. header-align="center"
  244. width="300px"
  245. v-if="columns[2].visible"
  246. ><template slot-scope="r">
  247. {{
  248. r.row.planStartTime
  249. ? dayjs(r.row.planStartTime).format("YYYY年-MM月-DD日")
  250. : ""
  251. }}~{{
  252. r.row.planEndTime
  253. ? dayjs(r.row.planEndTime).format("YYYY年-MM月-DD日")
  254. : ""
  255. }}
  256. </template></el-table-column
  257. >
  258. <el-table-column
  259. prop="planEndTime"
  260. label="截止日期"
  261. align="center"
  262. width="180px"
  263. v-if="false"
  264. ><template slot-scope="r">
  265. {{
  266. r.row.planEndTime
  267. ? dayjs(r.row.planEndTime).format("YYYY-MM-DD")
  268. : ""
  269. }}
  270. </template></el-table-column
  271. >
  272. <el-table-column
  273. prop="submitBy"
  274. label="检查人"
  275. align="center"
  276. width="180px"
  277. v-if="false"
  278. ></el-table-column>
  279. <el-table-column label="检查时间" min-width="120" v-if="false">
  280. <template slot-scope="r">{{
  281. r.row.submitTime | dateTime
  282. }}</template>
  283. </el-table-column>
  284. <el-table-column
  285. align="center"
  286. prop="exceptionCount"
  287. label="隐患问题数"
  288. width="120px"
  289. v-if="columns[9].visible"
  290. >
  291. </el-table-column>
  292. <el-table-column
  293. prop="des"
  294. label="备注"
  295. align="center"
  296. width="180px"
  297. v-if="false"
  298. >
  299. </el-table-column>
  300. <el-table-column
  301. label="操作"
  302. fixed="right"
  303. header-align="center"
  304. width="240px"
  305. >
  306. <template slot-scope="r">
  307. <!-- <el-button v-if="
  308. r.row.status == 'WAIT' &&
  309. queryParams.type == 'QUARTER'
  310. " type="text" @click="onEdit(r.row.id)">检查</el-button>
  311. <el-button v-else-if="
  312. r.row.status != 'NA' &&
  313. r.row.status != 'NOT' &&
  314. r.row.status != 'WAIT'
  315. " type="text" @click="onEdit(r.row.id, { isRead: true })">查看</el-button> -->
  316. <el-button
  317. type="text"
  318. @click="showDetail(r.row)"
  319. v-hasPermi="['core:task:query']"
  320. icon="el-icon-view"
  321. >详情</el-button
  322. >
  323. <el-button
  324. type="text"
  325. @click="showscanRecord(r.row)"
  326. v-if="r.row.status == 2 || r.row.status == 3"
  327. v-hasPermi="['core:task:query']"
  328. icon="el-icon-view"
  329. >扫描记录</el-button
  330. >
  331. <el-button
  332. type="text"
  333. icon="el-icon-s-check"
  334. @click="showRegister(r.row)"
  335. v-if="showRegisterBtn(r.row)"
  336. >任务登记</el-button
  337. >
  338. <el-button
  339. type="text"
  340. slot="reference"
  341. icon="el-icon-delete"
  342. @click="handleDel(r.row.id)"
  343. v-if="
  344. r.row.status == 3 &&
  345. r.row.submitorId == userId &&
  346. r.row.sourceType == 1
  347. "
  348. >删除</el-button
  349. >
  350. <el-button
  351. icon="el-icon-document-copy"
  352. type="text"
  353. v-if="r.row.pdfUrl"
  354. @click="onDown(r.row.pdfUrl)"
  355. >登记簿
  356. </el-button>
  357. </template>
  358. </el-table-column>
  359. </el-table>
  360. <pagination
  361. v-show="total > 0"
  362. :total="total"
  363. :page.sync="queryParams.pageNum"
  364. :limit.sync="queryParams.pageSize"
  365. @pagination="getList"
  366. />
  367. </div>
  368. </el-col>
  369. </el-row>
  370. <!-- 详情 -->
  371. <dialog-detail ref="detaildialog"></dialog-detail>
  372. <dialog-scan-record ref="scanrecorddialog"></dialog-scan-record>
  373. </div>
  374. </template>
  375. <script>
  376. import { mapGetters } from "vuex";
  377. import { allRole } from "@/api/system/role";
  378. import DialogDetail from "./dialog.detail";
  379. import DialogScanRecord from "./dialog.scanrecord";
  380. import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
  381. import OrgTree from "@/components/orgTree";
  382. import * as api from "@/api/safetycheck/task.js";
  383. import { getLabel } from "@/views/commonOption.js";
  384. import OrgTreeSelect from "@/components/orgTreeSelect";
  385. import { checkPermi } from "@/utils/permission.js";
  386. import dayjs from "dayjs";
  387. import request from "@/utils/request";
  388. export default {
  389. name: "checkTaskList",
  390. dicts: ["resumption_plan_cycle", "resumption_status", "safety_check_status"],
  391. components: {
  392. DialogDetail,
  393. DialogScanRecord,
  394. DataRangePicker,
  395. OrgTreeSelect,
  396. OrgTree,
  397. },
  398. data() {
  399. return {
  400. loading: false,
  401. showSearch: true,
  402. total: 0,
  403. timeClearable: false,
  404. options: [],
  405. roleOptions: [],
  406. selectRoleOptions: [],
  407. planList: [],
  408. queryParams: {
  409. checkSub: true,
  410. orgId: null,
  411. orgName: null,
  412. status: null,
  413. planId: null,
  414. pageNum: 1,
  415. pageSize: 10,
  416. planStartTime: null,
  417. title: null,
  418. checkOrgIds: null,
  419. range: [],
  420. },
  421. selectedOrgName: null,
  422. pageData: [],
  423. columns: [
  424. { key: 0, label: `序号`, visible: true },
  425. { key: 1, label: `计划名称`, visible: true },
  426. { key: 2, label: `开始时间`, visible: true },
  427. { key: 3, label: `结束时间`, visible: true },
  428. { key: 4, label: `上级机构`, visible: true },
  429. { key: 5, label: `检查机构`, visible: true },
  430. { key: 6, label: `检查角色`, visible: true },
  431. { key: 7, label: `提交人`, visible: true },
  432. { key: 8, label: `提交时间`, visible: true },
  433. { key: 9, label: `异常个数`, visible: true },
  434. { key: 10, label: `任务状态`, visible: true },
  435. ],
  436. };
  437. },
  438. props: {},
  439. watch: {
  440. statusVal(value) {
  441. if (value == undefined) return;
  442. if (value == "all") this.queryParams.status = null;
  443. else this.queryParams.status = value;
  444. },
  445. planVal(value) {
  446. if (value == undefined) return;
  447. if (value == -1) this.queryParams.planId = null;
  448. else this.queryParams.planId = value;
  449. },
  450. $route(v) {
  451. //this.queryParams.type = this.$route.params.type.toUpperCase();
  452. },
  453. // 0每日;1每周;2每月;3每季度;4每半年;5每年
  454. },
  455. computed: {
  456. ...mapGetters(["orgName", "userId", "roleList", "orgId"]),
  457. },
  458. methods: {
  459. async onDown(pdfUrl) {
  460. window.open(pdfUrl);
  461. },
  462. dayjs,
  463. updatePlanStartTime(value) {
  464. // console.log(this.queryParams.planStartTime,"前");
  465. this.queryParams.planStartTime = value;
  466. // console.log(this.queryParams.planStartTime,"后");
  467. },
  468. inputRestriction() {
  469. // 限制只允许输入汉字、英文和数字
  470. this.queryParams.orgName = this.queryParams.orgName.replace(
  471. /[^\u4e00-\u9fa5a-zA-Z0-9]/g,
  472. ""
  473. );
  474. },
  475. inputTitle() {
  476. // 限制只允许输入汉字、英文和数字
  477. this.queryParams.title = this.queryParams.title.replace(
  478. /[^\u4e00-\u9fa5a-zA-Z0-9]/g,
  479. ""
  480. );
  481. },
  482. getLabel,
  483. showDetail(row) {
  484. let path = "/core/safetycheck/register/" + row.id;
  485. this.$router.push(path);
  486. },
  487. showscanRecord(row) {
  488. this.$refs.scanrecorddialog.show(row.id, row.orgId);
  489. },
  490. showRegisterBtn(row) {
  491. let userRoleId = this.roleList.map((r) => r.roleId);
  492. let taskRoleId = row.roles.map((r) => r.roleId);
  493. return (
  494. row.status != 3 &&
  495. ((row.checkOrgId == this.orgId &&
  496. userRoleId.find((ur) => taskRoleId.includes(ur)) &&
  497. checkPermi([
  498. "core:safetycheck:register",
  499. ])) ||
  500. row.grantUserId === this.userId)
  501. );
  502. },
  503. showRegister(row) {
  504. if (
  505. dayjs()
  506. .startOf("day")
  507. .isBefore(dayjs(row.planStartTime).startOf("day"))
  508. ) {
  509. this.$modal.alert("任务未到开始时间,不能操作");
  510. return;
  511. }
  512. if (
  513. dayjs()
  514. .endOf("day")
  515. .isAfter(dayjs(row.planEndTime).endOf("day"))
  516. ) {
  517. this.$modal.alert("任务已逾期,不能操作");
  518. return;
  519. }
  520. let path = "/core/safetycheck/register/" + row.id + "?mode=register";
  521. this.$router.push(path);
  522. },
  523. getDefaultKey(key) {
  524. this.queryParams.orgId = key;
  525. this.selectedOrgName = this.orgName;
  526. this.getList();
  527. this.loadRoles(key);
  528. // this.loadPlanList();
  529. },
  530. //单选框状态改变
  531. checkChange(state) {
  532. this.queryParams.checkSub = state;
  533. this.getList();
  534. },
  535. // 节点单击事件
  536. clickTreeNode(data) {
  537. this.queryParams.orgId = data.id;
  538. this.selectedOrgName = data.name;
  539. // this.loadPlanList();
  540. this.loadRoles();
  541. this.getList();
  542. },
  543. resetQuery() {
  544. this.queryParams.checkOrgIds = [];
  545. this.queryParams.range = [];
  546. this.resetForm("queryParams");
  547. this.getList();
  548. },
  549. handleAdd() {
  550. let path = "/safetycheck/tempregister/add";
  551. this.$router.push(path);
  552. },
  553. handleDel(taskId) {
  554. this.$modal
  555. .confirm("确认删除该临时登记?")
  556. .then(() => {
  557. return api.remove(taskId);
  558. })
  559. .then((r) => {
  560. if (r && r.data) {
  561. this.$message.info("删除成功");
  562. this.getList();
  563. } else {
  564. this.$message.warning("删除失败");
  565. }
  566. });
  567. },
  568. async getList() {
  569. console.log(this.queryParams, "this.queryParams");
  570. this.loading = true;
  571. api
  572. .page(this.queryParams)
  573. .then((r) => {
  574. this.isTableHaveData = r.rows.length > 0;
  575. this.pageData = r.rows;
  576. this.total = r.total;
  577. this.loading = false;
  578. })
  579. .catch((e) => {
  580. this.loading = false;
  581. });
  582. },
  583. loadRoles() {
  584. api
  585. .getRoles({
  586. orgId: this.queryParams.orgId,
  587. planCycle: this.queryParams.executeCycle,
  588. })
  589. .then((r) => (this.roleOptions = r.data));
  590. },
  591. selectLoadRoles() {
  592. allRole().then((r) => (this.selectRoleOptions = r.data));
  593. },
  594. // loadPlanList() {
  595. // api
  596. // .getPlans({
  597. // orgId: this.queryParams.orgId,
  598. // // planCycle: this.queryParams.executeCycle,
  599. // })
  600. // .then((r) => {
  601. // this.planList = r.data;
  602. // });
  603. // },
  604. /** 导出按钮操作 */
  605. handleExport() {
  606. this.download(
  607. "core/safetyTask/export",
  608. {
  609. ...this.queryParams,
  610. },
  611. `${this.orgName+'-检查登记跟踪-'+this.formatTime(new Date(),'YYYYMMDD')}.xlsx`
  612. );
  613. },
  614. statusColor(status, isBackground) {
  615. let color = "";
  616. switch (status) {
  617. case "1":
  618. color = "#BFBFBF";
  619. break;
  620. case "2":
  621. color = "#1890FF";
  622. break;
  623. case "3":
  624. color = "#52C41A";
  625. break;
  626. case "4":
  627. color = "#F5222D";
  628. break;
  629. }
  630. if (isBackground) {
  631. return "background-color:" + color;
  632. } else {
  633. return "color:" + color;
  634. }
  635. },
  636. },
  637. async mounted() {
  638. this.selectLoadRoles();
  639. },
  640. };
  641. </script>
  642. <style lang="scss"></style>