register.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div class="app-container">
  3. <el-descriptions title="检查任务" border>
  4. <el-descriptions-item label="任务名称">{{
  5. taskInfo.taskName
  6. }}</el-descriptions-item>
  7. <el-descriptions-item label="检查主体">{{
  8. taskInfo.checkOrgName
  9. }}</el-descriptions-item>
  10. <el-descriptions-item label="受检机构">{{
  11. taskInfo.beCheckedOrgName
  12. }}</el-descriptions-item>
  13. <el-descriptions-item label="检查人员"
  14. >{{
  15. taskInfo.checkRoles
  16. ? taskInfo.checkRoles.map((r) => r.name).join(",")
  17. : ""
  18. }}
  19. </el-descriptions-item>
  20. <el-descriptions-item label="开始日期"
  21. >{{ dayjs(taskInfo.planStartTime).format("YYYY-MM-DD") }}
  22. </el-descriptions-item>
  23. <el-descriptions-item label="截止日期"
  24. >{{ dayjs(taskInfo.planEndTime).format("YYYY-MM-DD") }}
  25. </el-descriptions-item>
  26. <el-descriptions-item label="创建时间"
  27. >{{ dayjs(taskInfo.planStartTime).format("YYYY-MM-DD") }}
  28. </el-descriptions-item>
  29. <el-descriptions-item label="检查组成员"
  30. ><el-input
  31. style="width: 80%; margin-top: -8px"
  32. placeHolder="请输入检查组成员"
  33. v-model="taskInfo.checkTeam"
  34. maxlength="100"
  35. v-if="isRegister"
  36. ></el-input>
  37. <span v-else>{{ taskInfo.checkTeam }}</span>
  38. </el-descriptions-item>
  39. <el-descriptions-item label="检查状态"
  40. >{{ getLabel(dict.type.safety_check_status, taskInfo.status) }}
  41. </el-descriptions-item>
  42. </el-descriptions>
  43. <el-row class="el-row-button">
  44. <el-col>
  45. <span style="margin-right: 20px">检查区域</span>
  46. <el-button
  47. type="primary"
  48. size="mini"
  49. @click="onAddPoint()"
  50. v-if="isRegister"
  51. >新增检查内容</el-button
  52. >
  53. </el-col>
  54. </el-row>
  55. <div class="content">
  56. <div class="area_content" v-for="area in taskInfo.checkList">
  57. <div>
  58. {{ area.areaName }}
  59. </div>
  60. <div>
  61. <div class="safetycheck_item" v-for="(item, index) in area.itemList">
  62. <span>{{ index + 1 }}、{{ item.itemName }}</span>
  63. <div class="safetycheck_point" v-for="point in item.pointList">
  64. <div>
  65. <div class="pointName">
  66. <div style="display: flex; flex-direction: row">
  67. <i class="circle" />
  68. <pre>{{ point.pointName }}</pre>
  69. </div>
  70. </div>
  71. <el-radio-group v-model="point.status" v-if="isRegister">
  72. <el-radio :label="0">正常</el-radio>
  73. <el-radio :label="1">异常</el-radio>
  74. </el-radio-group>
  75. <span v-else>
  76. <span v-if="point.status === 0">
  77. <i class="circle" style="background-color: #1890ff" />
  78. <label style="color: #1890ff"> 正常</label> </span
  79. ><span v-else>
  80. <i class="circle" style="background-color: #f5222d" />
  81. <label style="color: #f5222d"> 异常</label>
  82. </span>
  83. </span>
  84. <el-button
  85. type="danger"
  86. size="mini"
  87. v-if="point.isAdd && isRegister"
  88. style="margin-left: 50px"
  89. @click="onDeletePoint(area, item, point)"
  90. >删除</el-button
  91. >
  92. </div>
  93. <div v-if="point.status == 1">
  94. <el-form
  95. :ref="'point_' + point.pointId"
  96. :model="point"
  97. :rules="exceptionRules"
  98. label-width="100px"
  99. v-if="isRegister"
  100. >
  101. <el-form-item label="情况描述" prop="remark">
  102. <el-input
  103. v-model.trim="point.remark"
  104. style="width: 250px"
  105. placeholder="请输入情况描述"
  106. maxlength="255"
  107. ></el-input>
  108. </el-form-item>
  109. <el-form-item label="异常图片" prop="image">
  110. <imgUpload
  111. type="more"
  112. :value="
  113. point.imgData
  114. ? point.imgData.map((d) => d.imgPath).join(',')
  115. : ''
  116. "
  117. @input="onImageChanged(point, $event)"
  118. ></imgUpload>
  119. </el-form-item>
  120. <el-form-item label="整改期限" prop="rectificationDeadline">
  121. <el-select
  122. v-model="point.rectificationDeadline"
  123. placeholder="请选择整改期限"
  124. >
  125. <el-option
  126. v-for="item in dict.type.rectification_deadline"
  127. :key="item.value"
  128. :value="item.value"
  129. :label="item.label"
  130. ></el-option>
  131. </el-select>
  132. </el-form-item>
  133. </el-form>
  134. <el-descriptions v-else :column="1">
  135. <el-descriptions-item label="情况描述">{{
  136. point.remark
  137. }}</el-descriptions-item>
  138. <el-descriptions-item label="整改期限">{{
  139. getLabel(
  140. dict.type.rectification_deadline,
  141. point.rectificationDeadline
  142. )
  143. }}</el-descriptions-item>
  144. <el-descriptions-item label="异常图片">
  145. <div class="imageList">
  146. <el-image
  147. style="width: 100px; height: 100px; margin: 10px"
  148. v-if="point.imgData"
  149. v-for="url in point.imgData"
  150. :src="url.imgPath"
  151. :preview-src-list="point.imgData.map((d) => d.imgPath)"
  152. >
  153. </el-image></div
  154. ></el-descriptions-item>
  155. </el-descriptions>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. <div class="dialog-footer">
  163. <el-button type="primary" @click="onSubmit()" v-if="showSaveBtn"
  164. >提交</el-button
  165. >
  166. <el-button @click="onSave" v-if="showSaveBtn">保存</el-button>
  167. <el-button
  168. @click="onGrant"
  169. v-if="showGrantBtn"
  170. >授权</el-button
  171. >
  172. <el-button @click="onClose">关闭</el-button>
  173. </div>
  174. <SelectPoint
  175. ref="SelectPoint"
  176. :orgType="[taskInfo.beCheckOrgType]"
  177. @select="onSelectPoint"
  178. ></SelectPoint>
  179. <UserSelector
  180. ref="UserSelector"
  181. @select="onUserSelect"
  182. :customTreeRequest="deptTreeWithSameTypeUp"
  183. :selectLimit="1"
  184. ></UserSelector>
  185. </div>
  186. </template>
  187. <script>
  188. import { mapGetters } from "vuex";
  189. import * as api from "@/api/safetycheck/register.js";
  190. import dayjs from "dayjs";
  191. import SelectPoint from "../../ruleManager/dialog.select.point.vue";
  192. import imgUpload from "@/components/ImageUpload/index.vue";
  193. import UserSelector from "@/components/userSelector/index.vue";
  194. import { getLabel } from "@/views/commonOption.js";
  195. import { checkPermi } from "@/utils/permission.js";
  196. import { deptTreeWithSameTypeUp } from "@/api/system/org.js";
  197. export default {
  198. name: "safetyCheckRegister",
  199. data() {
  200. return {
  201. taskInfo: {},
  202. exceptionRules: {
  203. remark: [{ required: true, message: "请输入情况描述" }],
  204. rectificationDeadline: [{ required: true, message: "请选择整改期限" }],
  205. },
  206. pointIdsWhenAdd: [],
  207. mode: null,
  208. };
  209. },
  210. dicts: ["rectification_deadline", "sys_user_is_lock", "safety_check_status"],
  211. components: { SelectPoint, imgUpload, UserSelector },
  212. computed: {
  213. ...mapGetters(["orgId", "roleList", "userId"]),
  214. isRegister() {
  215. let r = this.mode === "register";
  216. return r;
  217. },
  218. showSaveBtn() {
  219. return (
  220. this.isRegister &&
  221. this.taskInfo.status != 3 &&
  222. (checkPermi(["core:safetycheck:register"]) ||
  223. this.taskInfo.grantUserId == this.userId)
  224. );
  225. },
  226. showGrantBtn() {
  227. let userRoleIds = this.roleList.map((r) => r.roleId);
  228. let taskRoleIds = this.taskInfo.checkRoles
  229. ? this.taskInfo.checkRoles.map((r) => r.id)
  230. : [];
  231. return (
  232. this.isRegister &&
  233. this.taskInfo.status != 3 &&
  234. this.taskInfo.planType==3 &&
  235. this.taskInfo.checkOrgId == this.orgId &&
  236. userRoleIds.find((ur) => taskRoleIds.includes(ur))
  237. );
  238. },
  239. },
  240. mounted() {
  241. let id = this.$route.params.taskId;
  242. let mode = this.$route.query.mode;
  243. if (!mode) {
  244. mode = "info";
  245. }
  246. api.info(id).then((r) => {
  247. this.mode = mode;
  248. if (mode != "register") {
  249. this.taskInfo = r.data;
  250. return;
  251. }
  252. if (r.data.status == 3) {
  253. this.mode = "info";
  254. this.taskInfo = r.data;
  255. this.$message.info("任务已完成,将显示详情");
  256. return;
  257. }
  258. let userRoleIds = this.roleList.map((r) => r.roleId);
  259. let taskRoleIds = r.data.checkRoles.map((r) => r.id);
  260. if (
  261. (r.data.checkOrgId == this.orgId &&
  262. userRoleIds.find((ur) => taskRoleIds.includes(ur))) ||
  263. r.data.grantUserId == this.userId
  264. ) {
  265. this.taskInfo = r.data;
  266. } else {
  267. this.$message.warning("用户不能执行该任务");
  268. this.mode = "info";
  269. }
  270. });
  271. },
  272. methods: {
  273. dayjs,
  274. getLabel,
  275. deptTreeWithSameTypeUp,
  276. onAddPoint() {
  277. this.pointIdsWhenAdd = [];
  278. this.taskInfo.checkList.forEach((a) => {
  279. a.itemList.forEach((i) => {
  280. i.pointList.forEach((p) => {
  281. this.pointIdsWhenAdd.push(p.pointId);
  282. });
  283. });
  284. });
  285. this.$refs.SelectPoint.show(this.pointIdsWhenAdd);
  286. },
  287. onSelectPoint(selectedList) {
  288. let hasNew = false;
  289. for (let index in selectedList) {
  290. let p = selectedList[index];
  291. if (this.pointIdsWhenAdd.indexOf(p.id) >= 0) {
  292. continue;
  293. }
  294. let info = this.taskInfo;
  295. let area = info.checkList.find((a) => a.areaId === p.areaId);
  296. if (!area) {
  297. area = { areaId: p.areaId, areaName: p.areaName, itemList: [] };
  298. info.checkList.push(area);
  299. }
  300. let item = area.itemList.find((i) => i.itemId == p.itemId);
  301. if (!item) {
  302. item = { itemId: p.itemId, itemName: p.itemName, pointList: [] };
  303. area.itemList.push(item);
  304. }
  305. let point = item.pointList.find((i) => i.pointId == p.id);
  306. if (!point) {
  307. point = {
  308. pointId: p.id,
  309. pointName: p.pointName,
  310. mustCheck: 1,
  311. isAdd: 1,
  312. status: 0,
  313. remark: null,
  314. imgData: null,
  315. rectificationDeadline: null,
  316. submitBy: null,
  317. submitTime: null,
  318. };
  319. item.pointList.push(point);
  320. hasNew = true;
  321. }
  322. }
  323. if (!hasNew) {
  324. this.$message.info("没有可新增的检查内容");
  325. }
  326. },
  327. onClose() {
  328. this.$tab.closePageAndPushPrev();
  329. },
  330. onDeletePoint(area, item, point) {
  331. if (point.isAdd === 0) {
  332. this.$message.warning("不可删除计划的检查内容");
  333. return;
  334. }
  335. let index = item.pointList.indexOf(point);
  336. if (index >= 0) {
  337. item.pointList.splice(index, 1);
  338. }
  339. if (item.pointList.length === 0) {
  340. index = area.itemList.indexOf(item);
  341. area.itemList.splice(index, 1);
  342. }
  343. if (area.itemList.length === 0) {
  344. index = this.taskInfo.checkList.indexOf(area);
  345. this.taskInfo.checkList.splice(index, 1);
  346. }
  347. },
  348. onImageChanged(point, value) {
  349. point.imgData = value
  350. .split(",")
  351. .map((img) => ({ id: null, imgPath: img }));
  352. },
  353. onUserSelect(selected) {
  354. if (!selected || selected.length === 0) {
  355. this.$message.warning("请选择要授权的人员");
  356. return;
  357. }
  358. let { planId, beCheckedOrgId, id, ymdDate } = this.taskInfo;
  359. api
  360. .grant({
  361. planId,
  362. beCheckedOrgId,
  363. taskId: id,
  364. ymdDate,
  365. userId: selected[0].id,
  366. })
  367. .then((r) => {
  368. this.$message.info("授权成功");
  369. });
  370. //调用授权
  371. },
  372. onGrant() {
  373. this.$refs.UserSelector.show();
  374. },
  375. onSave() {
  376. if (
  377. dayjs()
  378. .startOf("day")
  379. .isBefore(dayjs(this.taskInfo.planStartTime).startOf("day"))
  380. ) {
  381. this.$modal.alert("任务未到开始时间,不能操作");
  382. return;
  383. }
  384. if (
  385. dayjs()
  386. .endOf("day")
  387. .isAfter(dayjs(this.taskInfo.planEndTime).endOf("day"))
  388. ) {
  389. this.$modal.alert("任务已逾期,不能操作");
  390. return;
  391. }
  392. this.taskInfo.isSubmit = 0;
  393. api.submit(this.taskInfo).then((r) => {
  394. this.$message.info("保存成功");
  395. });
  396. },
  397. async onSubmit() {
  398. if (
  399. dayjs()
  400. .startOf("day")
  401. .isBefore(dayjs(this.taskInfo.planStartTime).startOf("day"))
  402. ) {
  403. this.$modal.alert("任务未到开始时间,不能操作");
  404. return;
  405. }
  406. if (
  407. dayjs()
  408. .endOf("day")
  409. .isAfter(dayjs(this.taskInfo.planEndTime).endOf("day"))
  410. ) {
  411. this.$modal.alert("任务已逾期,不能操作");
  412. return;
  413. }
  414. let isOk = true;
  415. let r = this.$refs;
  416. for (let p in this.$refs) {
  417. if (p.startsWith("point")) {
  418. try {
  419. isOk &= await this.$refs[p][0].validate();
  420. } catch (e) {
  421. isOk &= false;
  422. console.error(e);
  423. }
  424. }
  425. }
  426. if (isOk) {
  427. this.taskInfo.isSubmit = 1;
  428. api.submit(this.taskInfo).then((r) => {
  429. this.$message.info("提交成功");
  430. this.$tab.closePageAndPushPrev();
  431. });
  432. }
  433. },
  434. },
  435. };
  436. </script>
  437. <style lang="scss" scoped>
  438. .el-row-button {
  439. margin-top: 20px;
  440. }
  441. .content {
  442. max-height: calc(100% - 300px);
  443. overflow-y: auto;
  444. margin-bottom: 20px;
  445. margin-top: 20px;
  446. flex-direction: column;
  447. }
  448. .area_content {
  449. border: #b8bdc0 1px solid;
  450. display: flex;
  451. flex-direction: row;
  452. width: 100%;
  453. }
  454. .content > .area_content:first-child {
  455. border-bottom: none;
  456. }
  457. .content > .area_content:last-child {
  458. border-bottom: #b8bdc0 1px solid;
  459. }
  460. .area_content > div:nth-child(1) {
  461. background-color: #f7f7f7;
  462. border-right: #b8bdc0 1px solid;
  463. padding-top: auto;
  464. width: 15%;
  465. display: flex;
  466. flex-direction: column;
  467. justify-content: center;
  468. text-align: center;
  469. }
  470. .area_content > div:nth-child(2) {
  471. width: 80%;
  472. padding-left: 10px;
  473. }
  474. .safetycheck_item {
  475. margin: 10px;
  476. margin-bottom: 20px;
  477. }
  478. .safetycheck_point {
  479. padding-top: 10px;
  480. padding-left: 30px;
  481. }
  482. // .safetycheck_point > div:nth-child(1) {
  483. // margin-bottom: 15px;
  484. // }
  485. .pointName {
  486. width: 400px;
  487. display: inline-block;
  488. margin-right: 50px;
  489. }
  490. .pointName pre {
  491. margin-left: 10px;
  492. width: calc(100% - 15px);
  493. }
  494. .dialog-footer {
  495. width: 100%;
  496. text-align: right;
  497. border-top: #b8bdc0 1px solid;
  498. padding-top: 10px;
  499. padding-right: 30px;
  500. position: absolute;
  501. bottom: 30px;
  502. right: 0px;
  503. }
  504. .circle {
  505. display: inline-block;
  506. width: 5px;
  507. height: 5px;
  508. border-radius: 5px;
  509. background-color: #b8bdc0;
  510. border: none;
  511. margin-bottom: 3px;
  512. margin-top: 6px;
  513. }
  514. .el-descriptions{
  515. ::v-deep .el-descriptions__body{
  516. background-color:transparent !important;
  517. }
  518. }
  519. </style>