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. @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. 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-scan-record ref="scanrecorddialog"></dialog-scan-record>
  403. </div>
  404. </template>
  405. <script>
  406. import { mapGetters } from "vuex";
  407. import { allRole } from "@/api/system/role";
  408. import DialogScanRecord from "./dialog.scanrecord";
  409. import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
  410. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  411. import * as api from "@/api/safetycheck/task.js";
  412. import { getLabel } from "@/views/commonOption.js";
  413. import OrgTreeSelect from "@/components/orgTreeSelect";
  414. import { checkPermi } from "@/utils/permission.js";
  415. import dayjs from "dayjs";
  416. import { deptTreeSelect } from "@/api/system/public";
  417. import request from "@/utils/request";
  418. import {newline} from "js-beautify/js/src/javascript/acorn";
  419. export default {
  420. name: "Saftask",
  421. dicts: ["resumption_plan_cycle", "resumption_status", "safety_check_status"],
  422. components: {
  423. DialogScanRecord,
  424. DataRangePicker,
  425. OrgTreeSelect,
  426. OrgTree,
  427. },
  428. data() {
  429. return {
  430. // 机构树选项
  431. deptOptions: [],
  432. loading: false,
  433. showSearch: true,
  434. total: 0,
  435. timeClearable: false,
  436. options: [],
  437. roleOptions: [],
  438. selectRoleOptions: [],
  439. planList: [],
  440. queryParams: {
  441. checkSub: true,
  442. orgId: null,
  443. orgName: null,
  444. status: null,
  445. planId: null,
  446. pageNum: 1,
  447. pageSize: 10,
  448. planStartTime: null,
  449. title: null,
  450. checkOrgIds: null,
  451. range: [new Date(),new Date()],
  452. },
  453. selectedOrgName: null,
  454. pageData: [],
  455. columns: [
  456. { key: 0, label: `序号`, visible: true },
  457. { key: 1, label: `任务名称`, visible: true },
  458. { key: 2, label: `检查主体`, visible: true },
  459. { key: 3, label: `检查人员`, visible: true },
  460. { key: 4, label: `任务进度`, visible: true },
  461. { key: 5, label: `受检机构`, visible: true },
  462. { key: 6, label: `任务时间`, visible: true },
  463. { key: 7, label: `隐患问题数`, visible: true },
  464. ],
  465. };
  466. },
  467. props: {},
  468. watch: {
  469. statusVal(value) {
  470. if (value == undefined) return;
  471. if (value == "all") this.queryParams.status = null;
  472. else this.queryParams.status = value;
  473. },
  474. planVal(value) {
  475. if (value == undefined) return;
  476. if (value == -1) this.queryParams.planId = null;
  477. else this.queryParams.planId = value;
  478. },
  479. $route(v) {
  480. //this.queryParams.type = this.$route.params.type.toUpperCase();
  481. },
  482. // 0每日;1每周;2每月;3每季度;4每半年;5每年
  483. },
  484. computed: {
  485. ...mapGetters(["orgName", "userId", "roleList", "orgId"]),
  486. },
  487. activated() {
  488. // console.log("刷新");
  489. this.getList();
  490. },
  491. methods: {
  492. getDeptTree() {
  493. deptTreeSelect().then((response) => {
  494. // console.log(response,"sss")
  495. this.deptOptions = response.data;
  496. });
  497. },
  498. /** treeSelect组件自定义数据*/
  499. tenantIdnormalizer(node, instanceId) {
  500. if (node.children && !node.children.length) {
  501. delete node.children;
  502. }
  503. return {
  504. id: node.id,
  505. label: node.shortName,
  506. children: node.children,
  507. };
  508. },
  509. async onDown(pdfUrl) {
  510. window.open(pdfUrl);
  511. },
  512. dayjs,
  513. updatePlanStartTime(value) {
  514. // console.log(this.queryParams.planStartTime,"前");
  515. this.queryParams.planStartTime = value;
  516. // console.log(this.queryParams.planStartTime,"后");
  517. },
  518. inputRestriction() {
  519. // 限制只允许输入汉字、英文和数字
  520. this.queryParams.orgName = this.queryParams.orgName.replace(
  521. /[^\u4e00-\u9fa5a-zA-Z0-9]/g,
  522. ""
  523. );
  524. },
  525. inputTitle() {
  526. // 限制只允许输入汉字、英文和数字
  527. this.queryParams.title = this.queryParams.title.replace(
  528. /[^\u4e00-\u9fa5a-zA-Z0-9]/g,
  529. ""
  530. );
  531. },
  532. getLabel,
  533. showDetail(row) {
  534. let path = "/core/safetycheck/detail/" + row.id;
  535. // console.log(path,"path")
  536. this.$router.push(path);
  537. },
  538. showscanRecord(row) {
  539. this.$refs.scanrecorddialog.show(row.id, row.orgId);
  540. },
  541. showRegisterBtn(row) {
  542. let userRoleId = this.roleList.map((r) => r.roleId);
  543. let taskRoleId = row.roles.map((r) => r.roleId);
  544. return (
  545. row.status != 3 &&
  546. ((row.checkOrgId == this.orgId &&
  547. userRoleId.find((ur) => taskRoleId.includes(ur)) &&
  548. checkPermi(["core:safetycheck:register"])) ||
  549. row.grantUserId === this.userId)
  550. );
  551. },
  552. showRegister(row) {
  553. if (
  554. dayjs().startOf("day").isBefore(dayjs(row.planStartTime).startOf("day"))
  555. ) {
  556. this.$modal.alert("任务未到开始时间,不能操作");
  557. return;
  558. }
  559. if (dayjs().endOf("day").isAfter(dayjs(row.planEndTime).endOf("day"))) {
  560. this.$modal.alert("任务已逾期,不能操作");
  561. return;
  562. }
  563. let path = "/core/safetycheck/register/" + row.id;
  564. this.$router.push(path);
  565. },
  566. getDefaultOrg(node) {
  567. // console.log("wwewe")
  568. this.queryParams.orgId = node.id;
  569. this.selectedOrgName = node.shortName;
  570. this.getList();
  571. this.loadRoles(node.id);
  572. // this.loadPlanList();
  573. },
  574. //单选框状态改变
  575. checkChange(state) {
  576. this.queryParams.checkSub = state;
  577. this.getList();
  578. },
  579. // 节点单击事件
  580. clickTreeNode(data) {
  581. this.queryParams.orgId = data.id;
  582. this.selectedOrgName = data.shortName;
  583. // this.loadPlanList();
  584. this.loadRoles();
  585. this.getList();
  586. },
  587. resetQuery() {
  588. this.resetForm("queryParams");
  589. this.queryParams.checkOrgIds = null;
  590. this.queryParams.orgId = this.orgId;
  591. this.selectedOrgName = this.orgName;
  592. this.queryParams.checkSub = true;
  593. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub);
  594. this.queryParams.range = [new Date(),new Date()];
  595. },
  596. handleAdd() {
  597. let path = "/safetycheck/tempregister/add";
  598. this.$router.push(path);
  599. },
  600. handleDel(taskId) {
  601. this.$modal
  602. .confirm("确认删除该临时登记?")
  603. .then(() => {
  604. return api.remove(taskId);
  605. })
  606. .then((r) => {
  607. if (r && r.data) {
  608. this.$message.info("删除成功");
  609. this.getList();
  610. } else {
  611. this.$message.warning("删除失败");
  612. }
  613. });
  614. },
  615. async getList() {
  616. // console.log(this.queryParams, "this.queryParams2222");
  617. this.loading = true;
  618. api
  619. .page(this.queryParams)
  620. .then((r) => {
  621. this.isTableHaveData = r.rows.length > 0;
  622. this.pageData = r.rows;
  623. this.total = r.total;
  624. this.loading = false;
  625. })
  626. .catch((e) => {
  627. this.loading = false;
  628. });
  629. },
  630. loadRoles() {
  631. api
  632. .getRoles({
  633. orgId: this.queryParams.orgId,
  634. planCycle: this.queryParams.executeCycle,
  635. })
  636. .then((r) => (this.roleOptions = r.data));
  637. },
  638. selectLoadRoles() {
  639. allRole().then((r) => (this.selectRoleOptions = r.data));
  640. },
  641. // loadPlanList() {
  642. // api
  643. // .getPlans({
  644. // orgId: this.queryParams.orgId,
  645. // // planCycle: this.queryParams.executeCycle,
  646. // })
  647. // .then((r) => {
  648. // this.planList = r.data;
  649. // });
  650. // },
  651. /** 导出按钮操作 */
  652. handleExport() {
  653. this.download(
  654. "core/safetyTask/export",
  655. {
  656. ...this.queryParams,
  657. },
  658. `${this.selectedOrgName}-${this.$tab.getCurrentTabName()}-${dayjs(
  659. new Date()
  660. ).format("YYYYMMDD")}.xlsx`
  661. );
  662. },
  663. statusColor(status, isBackground) {
  664. let color = "";
  665. switch (status) {
  666. case "1":
  667. color = "#BFBFBF";
  668. break;
  669. case "2":
  670. color = "#1890FF";
  671. break;
  672. case "3":
  673. color = "#52C41A";
  674. break;
  675. case "4":
  676. color = "#F5222D";
  677. break;
  678. }
  679. if (isBackground) {
  680. return "background-color:" + color;
  681. } else {
  682. return "color:" + color;
  683. }
  684. },
  685. },
  686. async mounted() {
  687. this.selectLoadRoles();
  688. },
  689. created() {
  690. this.getDeptTree();
  691. },
  692. };
  693. </script>
  694. <style lang="scss"></style>