addFailSafePlan.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /**
  2. * 计划管理 计划列表 新建防错计划
  3. */
  4. <template>
  5. <div style="height: 100%">
  6. <el-row class="top-main" style="height: 15%;">
  7. <!-- 面包屑导航 -->
  8. <el-breadcrumb separator-class="el-icon-arrow-right">
  9. <el-breadcrumb-item>点检管理</el-breadcrumb-item>
  10. <el-breadcrumb-item>点检保养列表</el-breadcrumb-item>
  11. <el-breadcrumb-item>
  12. {{ buttonStatus === 1 ? "新建" : "编辑" }}保养表</el-breadcrumb-item
  13. >
  14. </el-breadcrumb>
  15. <h3>{{ buttonStatus === 1 ? "新建" : "编辑" }}保养表</h3>
  16. </el-row>
  17. <el-row class="body-main" style="min-height: 85%">
  18. <el-card>
  19. <div slot="header" style="font-size: 20px">
  20. <span>基础信息</span>
  21. </div>
  22. <el-row class="info-full">
  23. <el-col :span="spanSIX">
  24. <div class="info-style">点检保养表名称</div>
  25. <el-input
  26. size="medium"
  27. v-model="spotData.name"
  28. placeholder="请输入点检保养表名称"
  29. ></el-input>
  30. </el-col>
  31. <el-col :offset="spanTWO" :span="spanSIX">
  32. <div class="info-style">设备编号</div>
  33. <el-input
  34. size="medium"
  35. v-model="spotData.deviceNo"
  36. placeholder="请输入设备编号"
  37. ></el-input>
  38. </el-col>
  39. <el-col :offset="spanTWO" :span="spanSIX">
  40. <div class="info-style">设备名称</div>
  41. <el-input
  42. size="medium"
  43. v-model="spotData.deviceName"
  44. placeholder="请输入设备名称"
  45. ></el-input>
  46. </el-col>
  47. </el-row>
  48. <el-row class="info-full">
  49. <el-col :span="spanSIX">
  50. <div class="info-style">型号</div>
  51. <el-input
  52. size="medium"
  53. v-model="spotData.deviceType"
  54. placeholder="请输入型号"
  55. ></el-input>
  56. </el-col>
  57. <el-col :offset="spanTWO" :span="spanSIX">
  58. <div class="info-style">责任人</div>
  59. <el-select
  60. clearable
  61. size="medium"
  62. v-model="spotData.principleOne"
  63. placeholder="请选择责任人"
  64. style="width: 100%"
  65. >
  66. <el-option
  67. v-for="item in principleData"
  68. :label="item.name"
  69. :value="item.id"
  70. :key="item.id"
  71. ></el-option>
  72. </el-select>
  73. </el-col>
  74. <el-col :offset="spanTWO" :span="spanSIX">
  75. <div class="info-style">责任人2</div>
  76. <el-select
  77. clearable
  78. size="medium"
  79. v-model="spotData.principleTwo"
  80. placeholder="请选择责任人"
  81. style="width: 100%"
  82. >
  83. <el-option
  84. v-for="item in principleData"
  85. :label="item.name"
  86. :value="item.id"
  87. :key="item.id"
  88. ></el-option>
  89. </el-select>
  90. </el-col>
  91. </el-row>
  92. <el-row class="info-full">
  93. <el-col :span="spanSIX">
  94. <div class="info-style">巡检人</div>
  95. <el-select
  96. size="medium"
  97. v-model="spotData.tourId"
  98. placeholder="请选择巡检人"
  99. style="width: 100%"
  100. >
  101. <el-option
  102. v-for="item in tourData"
  103. :label="item.name"
  104. :value="item.id"
  105. :key="item.id"
  106. ></el-option>
  107. </el-select>
  108. </el-col>
  109. <el-col :offset="spanTWO" :span="spanSIX">
  110. <div class="info-style">编号</div>
  111. <el-input
  112. size="medium"
  113. v-model="spotData.nos"
  114. placeholder="请输入编号"
  115. ></el-input>
  116. </el-col>
  117. <el-col :offset="spanTWO" :span="spanSIX">
  118. <div class="info-style">生效日期</div>
  119. <el-date-picker
  120. size="medium"
  121. v-model="spotData.beginDate"
  122. type="date"
  123. time-arrow-control
  124. style="width: 100%"
  125. value-format="yyyy-MM-dd"
  126. placeholder="选择日期"
  127. >
  128. </el-date-picker>
  129. </el-col>
  130. </el-row>
  131. </el-card>
  132. <el-card v-for="(item, index) in procedures" :key="index">
  133. <div slot="header" style="font-size: 20px; display: flex">
  134. <div style="width: 5%; line-height: 42px">流程</div>
  135. <el-input
  136. size="medium"
  137. v-model="item.flow"
  138. placeholder="请输入流程名称"
  139. style="width: 30%"
  140. ></el-input>
  141. </div>
  142. <el-row
  143. class="info-full"
  144. v-for="(iten, indey) in item.projectStandards"
  145. :key="indey"
  146. >
  147. <el-col :span="spanSIX">
  148. <div class="info-style">项目</div>
  149. <el-input
  150. size="medium"
  151. v-model="iten.longdyProject"
  152. placeholder="请输入项目"
  153. ></el-input>
  154. </el-col>
  155. <el-col :offset="spanTWO" :span="spanSIX">
  156. <div class="info-style">标准</div>
  157. <el-input
  158. size="medium"
  159. v-model="iten.standard"
  160. placeholder="请输入标准"
  161. ></el-input>
  162. </el-col>
  163. <el-col :offset="spanTWO" :span="spanSIX">
  164. <div class="info-style">检查频次</div>
  165. <!-- <el-input
  166. size="medium"
  167. v-model="iten.frequency"
  168. placeholder="请选择检查频次"
  169. ></el-input> -->
  170. <el-select
  171. size="medium"
  172. v-model="iten.frequency"
  173. placeholder="请选择"
  174. style="width: 100%"
  175. >
  176. <el-option
  177. v-for="frequency in frequencys"
  178. :label="frequency.value"
  179. :value="frequency.id"
  180. :key="frequency.id"
  181. ></el-option>
  182. </el-select>
  183. </el-col>
  184. <el-col :span="spanTWO" class="jj-img">
  185. <img
  186. v-if="item.projectStandards.length - 1 === indey"
  187. src="../../assets/img/jia.png"
  188. @click="addInfo(index)"
  189. />
  190. <img
  191. v-else
  192. src="../../assets/img/jian.png"
  193. @click="removeInfo(index, indey)"
  194. />
  195. </el-col>
  196. </el-row>
  197. <div class="jg-line"></div>
  198. <div
  199. class="xx-line"
  200. v-if="index === procedures.length - 1"
  201. @click="addFlow"
  202. >
  203. 新增流程
  204. </div>
  205. <div
  206. class="xx-line"
  207. v-if="procedures.length !== 1"
  208. @click="delFlow(index)"
  209. >
  210. 删除流程
  211. </div>
  212. </el-card>
  213. <el-row style="margin: 50px 0 50px 50px">
  214. <el-button
  215. v-if="buttonStatus"
  216. size="medium"
  217. type="primary"
  218. @click="submit(0)"
  219. :loading="loading"
  220. >提交</el-button
  221. >
  222. <el-button
  223. v-else
  224. size="medium"
  225. type="primary"
  226. :loading="loading"
  227. @click="submit(1)"
  228. >确认</el-button
  229. >
  230. <el-button size="medium" @click="$router.back()">取消</el-button>
  231. </el-row>
  232. </el-row>
  233. </div>
  234. </template>
  235. <script>
  236. import {
  237. insertProofing,
  238. shiftList,
  239. getInspector,
  240. insertProofingInfo,
  241. getPrinciple,
  242. getTour,
  243. updateProofing,
  244. } from "@/api/project";
  245. import { getYyMmDdTimeStamp, getNowDay } from "@/utils/datetime";
  246. export default {
  247. data() {
  248. return {
  249. spotData: {
  250. name: "",
  251. deviceNo: "",
  252. deviceName: "",
  253. deviceType: "",
  254. principleOne: "",
  255. principleTwo: "",
  256. tourId: "",
  257. nos: "",
  258. beginDate: "",
  259. },
  260. procedures: [
  261. {
  262. flow: "",
  263. projectStandards: [
  264. { longdyProject: "", standard: "", frequency: "" },
  265. ],
  266. },
  267. ],
  268. // 责任人数据
  269. principleData: [],
  270. // 巡检人
  271. tourData: [],
  272. spanTWO: 2,
  273. spanTHREE: 3,
  274. spanFIVE: 5,
  275. spanSIX: 6,
  276. spanSEVEN: 7,
  277. spanEIGHT: 8,
  278. spanTWELVE: 12,
  279. // 频次
  280. frequencys: [
  281. { id: 1, value: "每日", show: true },
  282. { id: 2, value: "每周", show: true },
  283. { id: 3, value: "每月", show: true },
  284. { id: 4, value: "季度", show: true },
  285. { id: 5, value: "半年", show: true }
  286. ],
  287. // 检验频次数 默认1
  288. // verifyNum: 1,
  289. // 校验日期
  290. verifyData: "检验响应日期:",
  291. shiftsList: [],
  292. userList: [],
  293. // 检测员列表
  294. verifyPeopleList: [
  295. { shiftId: "", shiftName: "", userId: "", userName: "" },
  296. ],
  297. // 确认提交按钮 1 提交 0 确认
  298. buttonStatus: 1,
  299. loading: false,
  300. verifyPeoples: [],
  301. userOne: "",
  302. oneChange: false,
  303. userTwo: "",
  304. twoChange: false,
  305. shiftOneId: "",
  306. shiftTwoId: "",
  307. };
  308. },
  309. created() {
  310. this.getPrincipleData();
  311. this.getTourData();
  312. if (this.$route.query.id) {
  313. this.versionId = this.$route.query.id;
  314. this.buttonStatus = 0;
  315. this.getUpdateInfo();
  316. } else {
  317. this.buttonStatus = 1;
  318. }
  319. },
  320. methods: {
  321. // 获取修改信息
  322. getUpdateInfo() {
  323. this.loading = true;
  324. insertProofingInfo({ versionId: this.versionId }).then((res) => {
  325. if (res.status === "20000") {
  326. let data = res.data;
  327. this.spotData.name = data.name;
  328. this.spotData.deviceNo = data.deviceNo;
  329. this.spotData.deviceName = data.deviceName;
  330. this.spotData.deviceType = data.deviceType;
  331. this.spotData.principleOne = data.principleOne;
  332. this.spotData.principleTwo = data.principleTwo;
  333. this.spotData.tourId = data.tourId;
  334. this.spotData.nos = data.nos;
  335. this.spotData.beginDate = data.beginDate;
  336. this.procedures = data.procedures;
  337. this.loading = false;
  338. } else {
  339. this.loading = false;
  340. this.$message.error(res.message);
  341. }
  342. });
  343. },
  344. // 获取责任人
  345. getPrincipleData() {
  346. getPrinciple().then((res) => {
  347. if (res.status === "20000") {
  348. this.principleData = res.data;
  349. }
  350. });
  351. },
  352. // 获取巡检人
  353. getTourData() {
  354. getTour().then((res) => {
  355. if (res.status === "20000") {
  356. this.tourData = res.data;
  357. }
  358. });
  359. },
  360. // 提交
  361. submit(index) {
  362. this.loading = true;
  363. this.spotData.procedures = this.procedures;
  364. if (!index) {
  365. insertProofing(this.spotData).then((res) => {
  366. if (res.status === "20000") {
  367. this.loading = false;
  368. this.$message.success("提交成功");
  369. setTimeout(() => {
  370. this.$router.back();
  371. }, 500);
  372. } else {
  373. this.loading = false;
  374. this.$message.error(res.message);
  375. }
  376. });
  377. } else {
  378. this.spotData.id = this.versionId;
  379. updateProofing(this.spotData).then((res) => {
  380. if (res.status === "20000") {
  381. this.loading = false;
  382. this.$message.success("修改成功");
  383. setTimeout(() => {
  384. this.$router.back();
  385. }, 500);
  386. } else {
  387. this.loading = false;
  388. this.$message.error(res.message);
  389. }
  390. });
  391. }
  392. },
  393. addFlow() {
  394. this.procedures.push({
  395. flow: "",
  396. projectStandards: [{ longdyProject: "", standard: "", frequency: "" }],
  397. });
  398. },
  399. delFlow(index) {
  400. this.procedures.splice(index, 1);
  401. },
  402. addInfo(index) {
  403. this.procedures[index].projectStandards.push({
  404. flow: "",
  405. standard: "",
  406. frequency: "",
  407. });
  408. },
  409. removeInfo(index, indey) {
  410. this.procedures[index].projectStandards.splice(indey, 1);
  411. },
  412. // 新增检测人员
  413. addVerifyList() {
  414. this.verifyPeopleList.push({
  415. shiftId: "",
  416. shiftName: "",
  417. userId: "",
  418. userName: "",
  419. });
  420. },
  421. // 删除检测人员
  422. removeVerifyList() {
  423. this.verifyPeopleList.pop();
  424. },
  425. // 获取频率数据
  426. getFrequencys() {
  427. this.frequencys = this.frequencys.filter((item) => item.show === true);
  428. },
  429. // 选中值
  430. checkFrequency(e) {
  431. // this.frequencys.find((item) => item.id === e).show = false;
  432. console.log(e);
  433. },
  434. // 添加频次
  435. addFrequency() {
  436. this.proofingSubReqs.push({
  437. frequency: "",
  438. proofingSubOpReqs: [
  439. {
  440. checkContent: [""],
  441. manual: 1,
  442. op: "",
  443. },
  444. ],
  445. reqStartTime: "",
  446. responseDayNum: "",
  447. responseEndTime: "",
  448. });
  449. },
  450. // 删除频次
  451. removeFrequency(index) {
  452. // this.proofingSubReqs.pop();
  453. this.proofingSubReqs.splice(index, 1);
  454. },
  455. // 增加op
  456. addOP(index) {
  457. this.proofingSubReqs[index].proofingSubOpReqs.push({
  458. checkContent: [""],
  459. manual: 1,
  460. op: "",
  461. });
  462. },
  463. // 删除OP
  464. removeOP(index, indey) {
  465. // this.proofingSubReqs[index].proofingSubOpReqs.pop();
  466. this.proofingSubReqs[index].proofingSubOpReqs.splice(indey, 1);
  467. },
  468. // 增加校验工具 [indey].children().push({ num: 1 });
  469. addCheckToolsInfo(index, indey) {
  470. this.proofingSubReqs[index].proofingSubOpReqs[indey].checkContent.push(
  471. ""
  472. );
  473. },
  474. // 删除校验工具
  475. removeCheckToolsInfo(index, indey, indez) {
  476. // this.proofingSubReqs[index].proofingSubOpReqs[indey].checkContent.pop();
  477. this.proofingSubReqs[index].proofingSubOpReqs[indey].checkContent.splice(
  478. indez,
  479. 1
  480. );
  481. },
  482. // 上传图片前
  483. beforeAvatarUpload(file) {
  484. const isLt2M = file.size / 1024 / 1024 < 10;
  485. if (!isLt2M) {
  486. this.$message.error("上传图片大小不能超过 10MB!");
  487. return false;
  488. } else {
  489. return true;
  490. }
  491. },
  492. // 执行上传
  493. successUpload(res) {
  494. this.planData.guideFile = res.data.id;
  495. this.planData.url = res.data.url;
  496. this.planData.fileName = res.data.originalName;
  497. },
  498. // 获取班次列表
  499. async getShiftList() {
  500. await shiftList().then((res) => {
  501. if (res.status === "20000") {
  502. this.shiftsList = res.data;
  503. }
  504. });
  505. },
  506. // 选中的班次
  507. getShift(val, index) {
  508. this.verifyPeopleList[index].shiftId = val;
  509. this.verifyPeopleList[index].shiftName = this.shiftsList.find(
  510. (item) => item.id === val
  511. ).name;
  512. this.verifyPeopleList[index].userId = "";
  513. this.verifyPeopleList[index].userName = "";
  514. },
  515. // 根据工位获取用户
  516. getUserList(index) {
  517. let shiftId = "";
  518. if (this.buttonStatus) {
  519. shiftId = this.verifyPeopleList[index].shiftId;
  520. } else {
  521. if (!index) {
  522. shiftId = this.shiftOneId;
  523. } else {
  524. shiftId = this.shiftTwoId;
  525. }
  526. }
  527. getInspector({ id: shiftId }).then((res) => {
  528. // 去除已选中的用户
  529. // if (index) {
  530. // this.userList = res.data.filter(
  531. // (item) => item.id !== this.verifyPeopleList[0].userId
  532. // );
  533. // } else {
  534. this.userList = res.data;
  535. // }
  536. });
  537. },
  538. // 执行添加
  539. addVerifyPeople(val, index) {
  540. if (index) {
  541. this.twoChange = true;
  542. } else {
  543. this.oneChange = true;
  544. }
  545. this.verifyPeopleList[index].userId = val;
  546. this.verifyPeopleList[index].userName = this.userList.find(
  547. (item) => item.id === val
  548. ).name;
  549. },
  550. // 获取当前天的下一天
  551. getNextDay() {
  552. let date = getNowDay();
  553. let num = parseInt(date.charAt(date.length - 1)) + 1;
  554. let nextDay = date.slice(0, date.length - 1) + num;
  555. return nextDay;
  556. },
  557. },
  558. };
  559. </script>
  560. <style scoped>
  561. .top-main {
  562. padding: 20px 20px 0 20px;
  563. height: 100%;
  564. }
  565. .body-main {
  566. border: 20px solid #f0f2f5;
  567. padding: 20px;
  568. }
  569. .el-card {
  570. margin-bottom: 20px;
  571. }
  572. .info-full {
  573. margin-bottom: 30px;
  574. height: 80px;
  575. }
  576. .info-style {
  577. font-size: 18px;
  578. margin-bottom: 15px;
  579. }
  580. .jj-img {
  581. display: flex;
  582. align-items: flex-end;
  583. justify-content: center;
  584. height: 100%;
  585. }
  586. .el-form-item {
  587. margin: 0;
  588. }
  589. .jg-line {
  590. width: 100%;
  591. height: 2px;
  592. background: #eee;
  593. margin: 5px 0;
  594. }
  595. .xx-line {
  596. width: 100%;
  597. height: 50px;
  598. margin-top: 30px;
  599. border: 2px dashed#eee;
  600. display: flex;
  601. align-items: center;
  602. justify-content: center;
  603. font-size: 18px;
  604. cursor: pointer;
  605. }
  606. .user-search {
  607. margin-top: 20px;
  608. }
  609. .el-radio {
  610. margin-right: 5px;
  611. }
  612. /deep/ .el-radio__label {
  613. padding-left: 5px;
  614. }
  615. /deep/ .el-input--medium .el-input__inner {
  616. height: 42px;
  617. }
  618. </style>