index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  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. :businessTree="true"
  12. ></org-tree>
  13. </el-col>
  14. <el-col :span="20" :xs="24">
  15. <!-- 搜索条件 -->
  16. <el-form
  17. :model="queryParams"
  18. ref="queryParams"
  19. size="small"
  20. :inline="true"
  21. v-show="showSearch"
  22. label-width="100px"
  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="executeRole">
  36. <el-select
  37. v-model="queryParams.executeRole"
  38. placeHolder="请选择检查角色"
  39. clearable
  40. >
  41. <el-option
  42. v-for="item in roleList"
  43. :key="item.id"
  44. :label="item.name"
  45. :value="item.id"
  46. ></el-option>
  47. </el-select>
  48. </el-form-item> -->
  49. <!-- <el-form-item label="检查周期" prop="executeCycle">
  50. <el-select
  51. v-model="queryParams.executeCycle"
  52. placeHolder="请选择检查周期"
  53. @change="changeType($event)"
  54. >
  55. <el-option
  56. v-for="item in dict.type.resumption_plan_cycle"
  57. :key="item.value"
  58. :label="item.label"
  59. :value="item.value"
  60. ></el-option>
  61. </el-select>
  62. </el-form-item> -->
  63. <el-form-item
  64. class="searchTitle"
  65. label="开始日期"
  66. prop="planStartTime"
  67. >
  68. <el-date-picker
  69. style="width: 200px;"
  70. v-model="queryParams.planStartTime"
  71. :clearable="timeClearable"
  72. type="date"
  73. placeholder="选择时间"
  74. value-format="yyyy-MM-dd"
  75. @change="updatePlanStartTime"
  76. >
  77. </el-date-picker>
  78. </el-form-item>
  79. <el-form-item label="检查状态" prop="status">
  80. <el-select
  81. style="width: 200px;"
  82. v-model="queryParams.status"
  83. placeHolder="请选择"
  84. clearable
  85. >
  86. <el-option
  87. v-for="item in dict.type.safety_check_status"
  88. :key="item.value"
  89. :label="item.label"
  90. :value="item.value"
  91. ></el-option>
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item label="受检机构" prop="orgName">
  95. <!-- <el-input
  96. v-model="queryParams.orgName"
  97. placeholder="请输入受检机构"
  98. clearable
  99. @keyup.enter.native="handleQuery"
  100. :maxlength="50" @input="inputRestriction"
  101. /> -->
  102. <div style="width: 200px;height: 30px;">
  103. <org-tree-select
  104. size="mini"
  105. v-model="queryParams.checkOrgIds"
  106. ref="checkorgTreeSelect"
  107. :disable="true"
  108. @change="getList"
  109. >
  110. </org-tree-select>
  111. </div>
  112. </el-form-item>
  113. <el-form-item style="margin-left: 35px">
  114. <el-button
  115. type="primary"
  116. icon="el-icon-search"
  117. size="mini"
  118. @click="getList"
  119. >搜索</el-button
  120. >
  121. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  122. >重置</el-button
  123. >
  124. </el-form-item>
  125. </el-form>
  126. <!-- 按纽 -->
  127. <el-row :gutter="10" class="mb8">
  128. <!-- <el-col :span="1.5">
  129. <el-button
  130. type="primary"
  131. plain
  132. icon="el-icon-download"
  133. size="mini"
  134. @click="exportExcel()"
  135. v-hasPermi="['resumption:taskManager:export']"
  136. >导出</el-button
  137. >
  138. </el-col> -->
  139. <right-toolbar
  140. :showSearch.sync="showSearch"
  141. @queryTable="getList"
  142. :columns="columns"
  143. ></right-toolbar>
  144. </el-row>
  145. <el-table
  146. border
  147. height="600"
  148. size="small"
  149. v-loading="loading"
  150. :data="pageData"
  151. >
  152. <el-table-column
  153. type="index"
  154. fixed
  155. min-width="50"
  156. label="序号"
  157. v-if="columns[0].visible"
  158. >
  159. </el-table-column>
  160. <el-table-column
  161. prop="title"
  162. label="检查名称"
  163. min-width="120"
  164. v-if="columns[1].visible"
  165. >
  166. </el-table-column>
  167. <el-table-column
  168. prop="checkOrgName"
  169. label="检查机构"
  170. min-width="140"
  171. v-if="columns[5].visible"
  172. >
  173. </el-table-column>
  174. <el-table-column
  175. prop="roleName"
  176. label="检查角色"
  177. min-width="150"
  178. v-if="columns[6].visible"
  179. >
  180. <template slot-scope="r">
  181. {{
  182. r.row.roles ? r.row.roles.map((r) => r.roleName).join("||") : ""
  183. }}
  184. </template>
  185. </el-table-column>
  186. <el-table-column
  187. prop="orgName"
  188. label="受检机构"
  189. min-width="140"
  190. v-if="columns[4].visible"
  191. >
  192. </el-table-column>
  193. <el-table-column
  194. prop="planStartTime"
  195. label="开始日期"
  196. min-width="100"
  197. v-if="columns[2].visible"
  198. ><template slot-scope="r">
  199. {{
  200. r.row.planStartTime
  201. ? dayjs(r.row.planStartTime).format("YYYY-MM-DD")
  202. : ""
  203. }}
  204. </template></el-table-column
  205. >
  206. <el-table-column
  207. prop="planEndTime"
  208. label="截止日期"
  209. min-width="100"
  210. v-if="columns[3].visible"
  211. ><template slot-scope="r">
  212. {{
  213. r.row.planEndTime
  214. ? dayjs(r.row.planEndTime).format("YYYY-MM-DD")
  215. : ""
  216. }}
  217. </template></el-table-column
  218. >
  219. <el-table-column
  220. prop="status"
  221. label="检查状态"
  222. width="100px"
  223. v-if="columns[10].visible"
  224. >
  225. <template slot-scope="r">
  226. <span>
  227. <i class="circle" :style="statusColor(r.row.status, true)" />
  228. <label :style="statusColor(r.row.status, false)">
  229. {{
  230. getLabel(dict.type.safety_check_status, r.row.status)
  231. }}</label
  232. >
  233. </span>
  234. </template>
  235. </el-table-column>
  236. <el-table-column
  237. prop="submitBy"
  238. label="检查人"
  239. min-width="100"
  240. v-if="columns[7].visible"
  241. ></el-table-column>
  242. <el-table-column
  243. label="检查时间"
  244. min-width="120"
  245. v-if="columns[8].visible"
  246. >
  247. <template slot-scope="r">{{
  248. r.row.submitTime | dateTime
  249. }}</template>
  250. </el-table-column>
  251. <el-table-column
  252. prop="exceptionCount"
  253. label="问题数量"
  254. min-width="80"
  255. v-if="columns[9].visible"
  256. >
  257. </el-table-column>
  258. <el-table-column
  259. prop="des"
  260. label="备注"
  261. min-width="80"
  262. v-if="columns[9].visible"
  263. >
  264. </el-table-column>
  265. <el-table-column label="操作" fixed="right" min-width="120px">
  266. <template slot-scope="r">
  267. <!-- <el-button v-if="
  268. r.row.status == 'WAIT' &&
  269. queryParams.type == 'QUARTER'
  270. " type="text" @click="onEdit(r.row.id)">检查</el-button>
  271. <el-button v-else-if="
  272. r.row.status != 'NA' &&
  273. r.row.status != 'NOT' &&
  274. r.row.status != 'WAIT'
  275. " type="text" @click="onEdit(r.row.id, { isRead: true })">查看</el-button> -->
  276. <el-button
  277. type="text"
  278. @click="showDetail(r.row)"
  279. v-hasPermi="['resumption:taskManager:query']"
  280. >详情</el-button
  281. >
  282. <el-button
  283. type="text"
  284. @click="showscanRecord(r.row)"
  285. v-hasPermi="['resumption:taskManager:query']"
  286. >扫描记录</el-button
  287. >
  288. <el-button
  289. type="text"
  290. @click="showRegister(r.row)"
  291. v-if="showRegisterBtn(r.row)"
  292. >登记</el-button
  293. >
  294. </template>
  295. </el-table-column>
  296. </el-table>
  297. <pagination
  298. v-show="total > 0"
  299. :total="total"
  300. :page.sync="queryParams.pageNum"
  301. :limit.sync="queryParams.pageSize"
  302. @pagination="getList"
  303. />
  304. </el-col>
  305. </el-row>
  306. <!-- 详情 -->
  307. <dialog-detail ref="detaildialog"></dialog-detail>
  308. <dialog-scan-record ref="scanrecorddialog"></dialog-scan-record>
  309. </div>
  310. </template>
  311. <script>
  312. import { mapGetters } from "vuex";
  313. import DialogDetail from "./dialog.detail";
  314. import DialogScanRecord from "./dialog.scanrecord";
  315. import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
  316. import OrgTree from "@/components/orgTree";
  317. import * as api from "@/api/safetycheck/task.js";
  318. import { getLabel } from "@/views/commonOption.js";
  319. import OrgTreeSelect from "@/components/orgTreeSelect";
  320. import { checkPermi } from "@/utils/permission.js";
  321. import dayjs from 'dayjs';
  322. export default {
  323. name: "checkTaskList",
  324. dicts: ["resumption_plan_cycle", "resumption_status", "safety_check_status"],
  325. components: {
  326. DialogDetail,
  327. DialogScanRecord,
  328. DataRangePicker,
  329. OrgTreeSelect,
  330. OrgTree,
  331. },
  332. data() {
  333. return {
  334. loading: false,
  335. showSearch: true,
  336. total: 0,
  337. timeClearable: false,
  338. options: [],
  339. roleOptions: [],
  340. planList: [],
  341. queryParams: {
  342. checkSub: true,
  343. orgId: null,
  344. orgName: null,
  345. status: null,
  346. planId: null,
  347. pageNum: 1,
  348. pageSize: 10,
  349. planStartTime: null,
  350. title: null,
  351. checkOrgIds: null,
  352. },
  353. selectedOrgName: null,
  354. pageData: [],
  355. columns: [
  356. { key: 0, label: `序号`, visible: true },
  357. { key: 1, label: `计划名称`, visible: true },
  358. { key: 2, label: `开始时间`, visible: true },
  359. { key: 3, label: `结束时间`, visible: true },
  360. { key: 4, label: `上级机构`, visible: true },
  361. { key: 5, label: `检查机构`, visible: true },
  362. { key: 6, label: `检查角色`, visible: true },
  363. { key: 7, label: `提交人`, visible: true },
  364. { key: 8, label: `提交时间`, visible: true },
  365. { key: 9, label: `异常个数`, visible: true },
  366. { key: 10, label: `任务状态`, visible: true },
  367. ],
  368. };
  369. },
  370. props: {},
  371. watch: {
  372. statusVal(value) {
  373. if (value == undefined) return;
  374. if (value == "all") this.queryParams.status = null;
  375. else this.queryParams.status = value;
  376. },
  377. planVal(value) {
  378. if (value == undefined) return;
  379. if (value == -1) this.queryParams.planId = null;
  380. else this.queryParams.planId = value;
  381. },
  382. $route(v) {
  383. //this.queryParams.type = this.$route.params.type.toUpperCase();
  384. },
  385. // 0每日;1每周;2每月;3每季度;4每半年;5每年
  386. },
  387. computed: {
  388. ...mapGetters(["orgName", "userId", "roleList", "orgId"]),
  389. },
  390. methods: {
  391. dayjs,
  392. updatePlanStartTime(value) {
  393. // console.log(this.queryParams.planStartTime,"前");
  394. this.queryParams.planStartTime = value;
  395. // console.log(this.queryParams.planStartTime,"后");
  396. },
  397. inputRestriction() {
  398. // 限制只允许输入汉字、英文和数字
  399. this.queryParams.orgName = this.queryParams.orgName.replace(
  400. /[^\u4e00-\u9fa5a-zA-Z0-9]/g,
  401. ""
  402. );
  403. },
  404. inputTitle() {
  405. // 限制只允许输入汉字、英文和数字
  406. this.queryParams.title = this.queryParams.title.replace(
  407. /[^\u4e00-\u9fa5a-zA-Z0-9]/g,
  408. ""
  409. );
  410. },
  411. getLabel,
  412. showDetail(row) {
  413. let path = "/core/safetycheck/register/" + row.id;
  414. this.$router.push(path);
  415. },
  416. showscanRecord(row) {
  417. this.$refs.scanrecorddialog.show(row.id, row.orgId);
  418. },
  419. showRegisterBtn(row) {
  420. let userRoleId = this.roleList.map((r) => r.roleId);
  421. let taskRoleId = row.roles.map((r) => r.roleId);
  422. return (
  423. row.status != 3 &&
  424. ((row.checkOrgId == this.orgId &&
  425. userRoleId.find((ur) => taskRoleId.includes(ur)) &&
  426. checkPermi([
  427. "core:safetycheck:register",
  428. "core:safetycheck:grant",
  429. ])) ||
  430. row.grantUserId === this.userId)
  431. );
  432. },
  433. showRegister(row) {
  434. let path = "/core/safetycheck/register/" + row.id + "?mode=register";
  435. this.$router.push(path);
  436. },
  437. getDefaultKey(key) {
  438. this.queryParams.orgId = key;
  439. this.selectedOrgName = this.orgName;
  440. this.getList();
  441. this.loadRoles(key);
  442. // this.loadPlanList();
  443. },
  444. //单选框状态改变
  445. checkChange(state) {
  446. this.queryParams.checkSub = state;
  447. this.getList();
  448. },
  449. // 节点单击事件
  450. clickTreeNode(data) {
  451. this.queryParams.orgId = data.id;
  452. this.selectedOrgName = data.name;
  453. // this.loadPlanList();
  454. this.loadRoles();
  455. this.getList();
  456. },
  457. resetQuery() {
  458. this.queryParams.checkOrgIds = [];
  459. this.resetForm("queryParams");
  460. this.getList();
  461. },
  462. async getList() {
  463. console.log(this.queryParams, "this.queryParams");
  464. this.loading = true;
  465. api
  466. .page(this.queryParams)
  467. .then((r) => {
  468. this.isTableHaveData = r.rows.length > 0;
  469. this.pageData = r.rows;
  470. this.total = r.total;
  471. this.loading = false;
  472. })
  473. .catch((e) => {
  474. this.loading = false;
  475. });
  476. },
  477. loadRoles() {
  478. api
  479. .getRoles({
  480. orgId: this.queryParams.orgId,
  481. planCycle: this.queryParams.executeCycle,
  482. })
  483. .then((r) => (this.roleOptions = r.data));
  484. },
  485. // loadPlanList() {
  486. // api
  487. // .getPlans({
  488. // orgId: this.queryParams.orgId,
  489. // // planCycle: this.queryParams.executeCycle,
  490. // })
  491. // .then((r) => {
  492. // this.planList = r.data;
  493. // });
  494. // },
  495. statusColor(status, isBackground) {
  496. let color = "";
  497. switch (status) {
  498. case "1":
  499. color = "#BFBFBF";
  500. break;
  501. case "2":
  502. color = "#1890FF";
  503. break;
  504. case "3":
  505. color = "#52C41A";
  506. break;
  507. case "4":
  508. color = "#F5222D";
  509. break;
  510. }
  511. if (isBackground) {
  512. return "background-color:" + color;
  513. } else {
  514. return "color:" + color;
  515. }
  516. },
  517. },
  518. async mounted() {},
  519. };
  520. </script>
  521. <style lang="scss"></style>