index.vue 21 KB

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