addFailSafePlan.vue 17 KB

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