index.vue 22 KB

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