submitted_ministry.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="保养工单报工" @clickLeft="back">
  4. <!-- <template slot="float">
  5. <view class="nav-icon-caozuo iconfont icon-caozuo" @click="setOptionShow"></view>
  6. </template> -->
  7. </uni-nav-bar>
  8. <!-- 进度组件 根据状态显示不同列表 -->
  9. <!-- <popupOper :optionShow="optionShow" @operate="operate"
  10. :operationList="operationList.filter(el=> el.type == status)"></popupOper> -->
  11. <view class="page-bottom-padding">
  12. <!-- 保养工单项目 -->
  13. <!-- <template v-if="worksheetInfo.rule">
  14. <CellTip title="保养规则"> </CellTip>
  15. <uni-collapse ref="collapse" v-for="item in worksheetInfo.rule.ruleItem" :key="item.id">
  16. <uni-collapse-item :open="false" :typeOpen="false" titleStyle="background-color: #ffffff">
  17. <OrderDetail slot="typeOpenShow" lable1="项目名称:" :value1="item.itemName" lable2="项目内容:"
  18. :value2="item.itemContent" lable3="保养标准:" :value3="item.itemStandard">
  19. </OrderDetail>
  20. <view class="content-status" @click.stop>
  21. <OrderDetail v-for="el in item.saveSparePart" lable1="备件名称:" :value1="el.name"
  22. lable2="规格型号:" :value2="el.model" lable3="数量:" :value3="el.num" lable4="单位:"
  23. :value4="el.unit">
  24. </OrderDetail>
  25. </view>
  26. </uni-collapse-item>
  27. </uni-collapse>
  28. </template> -->
  29. <!-- 待处理 -->
  30. <template v-if="detailsIng.length">
  31. <CellTip title="待处理"> </CellTip>
  32. <!-- <OrderDetail border v-for="(item,index) in detailsIng" :key="item.id" :value1="item.equiCode"
  33. :value2="item.equiName" :value3="item.equiTypeName" :value4="item.equiTypeId"
  34. :value5="item.equiLocation">
  35. <template slot="custSlot">
  36. <view class="btn-status">
  37. <view class="iconfont icon-shangchuanzhaopian" @click="chooseImage"></view>
  38. <view>
  39. <text class="btn btn-warning" @click="bindChange(item.id, 2, item)">
  40. 报修
  41. </text>
  42. <text class="btn btn-success" @click="goSparepart(item.id)">
  43. 选择备品备件
  44. </text>
  45. <text class="btn btn-primary" @click="bindChange(item.id, 1)">
  46. 保养完成
  47. </text>
  48. </view>
  49. </view>
  50. </template>
  51. </OrderDetail> -->
  52. <uni-collapse ref="collapse" v-for="(item,index) in detailsIng" :key="item.id">
  53. <uni-collapse-item :open="false" :typeOpen="false" titleStyle="background-color: #ffffff">
  54. <OrderDetail slot="typeOpenShow" :value1="item.equiCode" :value2="item.equiName"
  55. :value3="item.equiTypeName" :value4="item.equiTypeId" :value5="item.equiLocation">
  56. <!-- <template>
  57. </template> -->
  58. </OrderDetail>
  59. <view class="content-status" @click.stop>
  60. <view class="title cell font-grey">
  61. 保养项目
  62. </view>
  63. <!-- <uni-collapse ref="collapse" v-for="items in item.ruleItems" :key="items.id">
  64. <uni-collapse-item :open="false" :typeOpen="false"
  65. titleStyle="background-color: #ffffff">
  66. <OrderDetail slot="typeOpenShow" lable1="项目名称:" :value1="items.itemName"
  67. lable2="项目内容:" :value2="items.itemContent" lable3="保养标准:"
  68. :value3="items.itemStandard">
  69. </OrderDetail>
  70. <view class="content-status" @click.stop>
  71. <view class="minTitle cell font-grey">
  72. 所需备件
  73. </view>
  74. <OrderDetail v-for="el in items.saveSparePart" lable1="备件名称:" :value1="el.name"
  75. lable2="规格型号:" :value2="el.model" lable3="数量:" :value3="el.num" lable4="单位:"
  76. :value4="el.unit">
  77. </OrderDetail>
  78. </view>
  79. </uni-collapse-item>
  80. </uni-collapse> -->
  81. <!-- <view class="tip cell border-bottom">
  82. {{worksheetInfo.maintainName}}
  83. <text>{{item.maintainType == '1' ? '常规保养' : '润滑保养'}}</text>
  84. </view> -->
  85. <!-- 没有做过事项处理 -->
  86. <view class="" v-for="(items,idx) in item.ruleItems" :key="items.id">
  87. <view class="cell " style="margin-top: 20rpx;">
  88. <text class="font-grey">保养周期:</text>
  89. <text>{{worksheetInfo.rule.cycleType | filterCycle(worksheetInfo.rule.cycleValue)}}</text>
  90. </view>
  91. <view class="cell ">
  92. <text class="font-grey">操作标准:</text>
  93. <text>{{items.itemStandard}}</text>
  94. </view>
  95. <view class="cell ">
  96. <text class="font-grey">保养内容:</text>
  97. <text>{{items.itemContent}}</text>
  98. </view>
  99. <!-- <view class="cell ">
  100. <text class="font-grey">选择的备件:</text>
  101. <view v-for="el in items.spareParts">
  102. <Cell :title="el.name +'/'+ el.code" :more="'x'+ el.num + el.unit">
  103. </Cell>
  104. </view>
  105. </view> -->
  106. <view class="btn-status" v-if="items.status === null">
  107. <!-- <view class="iconfont icon-shangchuanzhaopian" @click="chooseImage"></view> -->
  108. <view>
  109. <text class="btn btn-primary" @click="bindChange(items.id, 1)">
  110. 正常
  111. </text>
  112. <!-- <text class="btn btn-success" @click="goSparepart(item.id,index,idx)">
  113. 选择备品备件
  114. </text> -->
  115. <text class="btn btn-warning" @click="bindChange(items.id, 2, item.id,item)">
  116. 缺陷
  117. </text>
  118. </view>
  119. </view>
  120. <view class="btn-status" v-else>
  121. <text v-if="items.status===0" class="btn btn-warning"
  122. @click="bindChange(items.id, 1)">
  123. 消陷
  124. </text>
  125. <text v-else
  126. :class="['showBtn',items.status===1?'green':'red']">{{items.status==1?"正常":"缺陷"}}</text>
  127. </view>
  128. </view>
  129. <view class="content-status"
  130. v-if="item.spareParts&&item.spareParts.length!==0">
  131. <view class="cell ">
  132. <text class="font-grey">备品备件:</text>
  133. <view v-for="el in item.spareParts">
  134. <Cell :title="el.name +'/'+ el.code" :more="'x'+ el.num + el.unit">
  135. </Cell>
  136. </view>
  137. </view>
  138. </view>
  139. <view class="btn-status select-right" @click.stop>
  140. <text class="btn btn-success" @click="goSparepart(item.id,index)">
  141. 选择备品备件
  142. </text>
  143. <text class="btn btn-primary" @click="maintenance(item)">
  144. 保养完成
  145. </text>
  146. </view>
  147. </view>
  148. </uni-collapse-item>
  149. </uni-collapse>
  150. </template>
  151. <!-- 已处理 -->
  152. <template v-if="detailsEd.length">
  153. <CellTip title="已处理"> </CellTip>
  154. <!-- <OrderDetail border v-for="(item,index) in detailsEd" :key="item.id" :value1="item.equiCode"
  155. :value2="item.equiName" :value3="item.equiTypeName" :value4="item.equiTypeId"
  156. :value5="item.equiLocation">
  157. <template slot="custSlot">
  158. <text :class="['showBtn',item.status===1?'green':'red']">{{item.status==1?"正常":"缺陷"}}</text>
  159. </template>
  160. </OrderDetail> -->
  161. <uni-collapse ref="collapse" v-for="item in detailsEd" :key="item.id">
  162. <uni-collapse-item :open="false" :typeOpen="false" titleStyle="background-color: #ffffff">
  163. <OrderDetail slot="typeOpenShow" :value1="item.equiCode" :value2="item.equiName"
  164. :value3="item.equiTypeName" :value4="item.equiTypeId" :value5="item.equiLocation">
  165. <!-- <template slot="custSlot">
  166. <text :class="['showBtn',item.status===1?'green':'red']">{{item.status==1?"正常":"缺陷"}}</text>
  167. </template> -->
  168. <!-- <template>
  169. </template> -->
  170. </OrderDetail>
  171. <view class="content-status" @click.stop>
  172. <view @click="goDetail(item.id, item.status)">
  173. <view class="title cell font-grey">
  174. 保养项目
  175. </view>
  176. <!-- <view class="tip cell border-bottom">
  177. {{items.itemName}}
  178. </view> -->
  179. <!-- 没有做过事项处理 -->
  180. <view class="" v-for="(items,idx) in item.ruleItems" :key="items.id">
  181. <view class="cell " style="margin-top: 20rpx;">
  182. <text class="font-grey">保养周期:</text>
  183. <text>{{worksheetInfo.rule.cycleType | filterCycle(worksheetInfo.rule.cycleValue)}}</text>
  184. </view>
  185. <view class="cell ">
  186. <text class="font-grey">操作标准:</text>
  187. <text>{{items.itemStandard}}</text>
  188. </view>
  189. <view class="cell ">
  190. <text class="font-grey">保养内容:</text>
  191. <text>{{items.itemContent}}</text>
  192. </view>
  193. <view class="btn-status">
  194. <text
  195. :class="['showBtn',items.status===1?'green':'red']">{{items.status==1?"正常":"缺陷"}}</text>
  196. </view>
  197. <!-- <view class="cell ">
  198. <text class="font-grey">选择的备件:</text>
  199. <view v-for="items in item.spareParts">
  200. <Cell :title="items.name +'/'+ items.code"
  201. :more="'x'+ items.num + items.unit">
  202. </Cell>
  203. </view>
  204. </view> -->
  205. </view>
  206. <view class="content-status" v-if="item.spareParts&&item.spareParts.length!==0">
  207. <view class="cell ">
  208. <text class="font-grey">备品备件:</text>
  209. <view v-for="el in item.spareParts">
  210. <Cell :title="el.name +'/'+ el.code" :more="'x'+ el.num + el.unit">
  211. </Cell>
  212. </view>
  213. </view>
  214. </view>
  215. </view>
  216. </view>
  217. </uni-collapse-item>
  218. </uni-collapse>
  219. </template>
  220. </view>
  221. <button class="btn-submit" @click="bindSubmitFn">
  222. 报工
  223. </button>
  224. <!-- <view class="btn-submit" @click="bindSubmitFn" v-if="worksheetInfo && worksheetInfo.status.id != '99'">
  225. 报工
  226. </view> -->
  227. </view>
  228. </template>
  229. <script>
  230. import {
  231. get,
  232. postJ,
  233. post
  234. } from "@/utils/api.js"
  235. import Cell from '@/components/Cell.vue'
  236. import CellTip from '@/components/CellTip.vue'
  237. import OrderDetail from '../components/OrderDetail.vue'
  238. import popupOper from '@/components/PopupOper.vue'
  239. export default {
  240. components: {
  241. Cell,
  242. CellTip,
  243. OrderDetail,
  244. popupOper
  245. },
  246. filters: {
  247. filterCycle(v1, v2) {
  248. let str = ""
  249. switch (v1) {
  250. case "HOUR":
  251. str = "小时";
  252. break
  253. case "DAY":
  254. str = "天";
  255. break
  256. case "WEEK":
  257. str = "周";
  258. break
  259. case "MONTH":
  260. str = "月";
  261. break
  262. case "YEAR":
  263. str = "年";
  264. break
  265. default:
  266. console.log(type)
  267. break
  268. }
  269. return `${v2}${str}/${v2}次`
  270. }
  271. },
  272. data() {
  273. return {
  274. worksheetInfo: {},
  275. detailsIng: [],
  276. detailsEd: [],
  277. sparepartList: [],
  278. sparepartIndex: "",
  279. equiIndex: "",
  280. optionShow: false,
  281. status: '1', //1 执行 0 暂停
  282. operationList: [{
  283. title: '暂停',
  284. class: 'iconfont icon-zhuanpai',
  285. type: 1
  286. }, {
  287. title: '执行',
  288. class: 'iconfont icon-zhuanpai',
  289. type: 0
  290. }],
  291. }
  292. },
  293. onLoad(options) {
  294. this.pageId = options.id;
  295. this.getInfo();
  296. // this.toImplement('1'); //进页面自动执行
  297. },
  298. onShow() {
  299. if (this.worksheetInfo) {
  300. this.getInfo();
  301. }
  302. },
  303. methods: {
  304. //自动执行
  305. toImplement(state) {
  306. postJ(this.apiUrl + "/api/maintain/worksheet/implement", {
  307. id: this.pageId,
  308. state: state
  309. }).then(res => {
  310. this.state = state == "1" ? "0" : "1"; //状态更换
  311. console.log(res)
  312. }).catch(err => {
  313. console.log(err)
  314. })
  315. },
  316. getInfo(id) {
  317. get(this.apiUrl + "/maintain/order/getDetail/" + this.pageId).then(res => {
  318. this.worksheetInfo = res.data;
  319. this.detailsIng = res.data.equiList.filter(item => item.status === 0)
  320. this.detailsEd = res.data.equiList.filter(item => item.status !== 0)
  321. this.sparepartList = this.$store.state.maintenance.sparepart
  322. this.sparepartIndex = this.$store.state.maintenance.idx
  323. if (this.sparepartList && this.sparepartList.length !== 0) {
  324. // console.log(this.sparepartList)
  325. this.sparepartList.forEach(item => {
  326. this.detailsIng[this.sparepartIndex].spareParts.push(item)
  327. })
  328. // console.log(this.worksheetInfo)
  329. }
  330. })
  331. },
  332. bindChange(id, status, bizEquiId, item) {
  333. //已报修
  334. if (status == 2) {
  335. get(this.apiUrl + "/repair/info/isExistRepair/" + bizEquiId).then(res => {
  336. // console.log(res)
  337. if (res.success) {
  338. if (res.data) {
  339. uni.showToast({
  340. title: "当前设备不能报修",
  341. icon: "none"
  342. })
  343. return
  344. }
  345. uni.navigateTo({
  346. url: '../defects/defects?id=' + this.pageId + "&executeUserName=" + this
  347. .worksheetInfo
  348. .workOrder.executeUserName + "&equiName=" + item.equiName +
  349. "&equiCode=" + item
  350. .equiCode + "&cycleType=" + this
  351. .worksheetInfo.rule.cycleType + "&cycleValue=" + this.worksheetInfo
  352. .rule.cycleValue +
  353. "&bizEquiId=" + bizEquiId + "&ruleItemId=" + id
  354. })
  355. }
  356. })
  357. } else {
  358. postJ(this.apiUrl + "/rule/item/editStatus", {
  359. status,
  360. ruleItemId: id
  361. })
  362. .then(
  363. res => {
  364. // console.log(res)
  365. uni.showToast({
  366. title: '提交成功'
  367. })
  368. this.getInfo();
  369. }).catch(err => {
  370. console.log(err)
  371. uni.showToast({
  372. title: err.message,
  373. icon: 'none'
  374. })
  375. })
  376. }
  377. },
  378. bindSubmitFn() {
  379. if (this.detailsIng.length) {
  380. uni.showToast({
  381. title: '有未处理事项,请先处理',
  382. icon: 'none'
  383. })
  384. return
  385. }
  386. get(this.apiUrl + "/maintain/order/report/" + this.pageId).then(res => {
  387. uni.navigateTo({
  388. url: '/pages/promp/promp?title=保养工单'
  389. })
  390. }).catch(err => {
  391. // console.log(err)
  392. uni.showToast({
  393. title: err.message || '报工失败',
  394. icon: 'none',
  395. duration: 3000
  396. })
  397. })
  398. },
  399. // 保养完成
  400. maintenance(data) {
  401. let bol = data.ruleItems.every(item => item.status === 1)
  402. if (!bol) {
  403. uni.showToast({
  404. title: "请处理保养项目",
  405. icon: "none"
  406. })
  407. return
  408. }
  409. postJ(this.apiUrl + "/maintain/order/done", {
  410. bizEquiId: data.id,
  411. spareParts: data.spareParts
  412. }).then(res => {
  413. uni.showToast({
  414. title: '保养完成'
  415. })
  416. this.getInfo();
  417. })
  418. // console.log("可以完成了")
  419. },
  420. //选择备件
  421. goSparepart(id, index) {
  422. uni.navigateTo({
  423. url: '../sparepart/sparepart?id=' + id + "&idx=" + index
  424. })
  425. },
  426. goDetail(id, status) {
  427. //已报修
  428. if (status.id == '2') {
  429. uni.navigateTo({
  430. url: '../defects/defects?id=' + id + "&parentsId=" + this.pageId + "&type=details"
  431. })
  432. }
  433. },
  434. chooseImage() {
  435. uni.chooseImage({
  436. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  437. success: function(res) {
  438. console.log(JSON.stringify(res.tempFilePaths));
  439. }
  440. })
  441. },
  442. //点击显示弹窗
  443. setOptionShow() {
  444. this.optionShow = !this.optionShow;
  445. },
  446. //选择对应的操作
  447. operate(type) {
  448. if (type === 1) { //暂停
  449. this.toImplement('0');
  450. this.setOptionShow();
  451. }
  452. },
  453. }
  454. }
  455. </script>
  456. <style lang="scss" scoped>
  457. @import "@/components/submitted.scss";
  458. .minTitle {
  459. font-weight: 700;
  460. text-indent: 0;
  461. }
  462. .content-status {
  463. padding: 20rpx 0 20rpx;
  464. }
  465. .cell {
  466. padding: 10rpx 30rpx;
  467. }
  468. .cell-box {
  469. width: 94%;
  470. margin: 0 auto;
  471. padding: 20rpx;
  472. border-radius: 20rpx;
  473. box-sizing: border-box;
  474. // background-color: #fff;
  475. .tip {
  476. position: relative;
  477. margin-bottom: 20rpx;
  478. }
  479. .tip .dian {
  480. padding-right: 10rpx;
  481. font-size: 30rpx;
  482. font-weight: bold;
  483. color: $uni-text-color;
  484. }
  485. .tip .status {
  486. position: absolute;
  487. right: 0;
  488. color: $uni-text-color-grey;
  489. }
  490. margin-bottom: 20rpx;
  491. }
  492. .btn-status {
  493. padding: 30rpx 30rpx 20rpx;
  494. display: flex;
  495. align-items: center;
  496. justify-content: flex-end;
  497. font-size: $uni-font-size-base;
  498. .icon-shangchuanzhaopian {
  499. font-size: 60rpx;
  500. color: $uni-text-color-grey;
  501. }
  502. }
  503. .showBtn {
  504. display: flex;
  505. justify-content: flex-end;
  506. padding-right: 20rpx;
  507. }
  508. .green {
  509. color: green
  510. }
  511. .red {
  512. color: red;
  513. }
  514. .select-right {
  515. float: right;
  516. }
  517. </style>