index.vue 20 KB

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