register.vue 17 KB

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