index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="检查中" @clickLeft="back"></uni-nav-bar>
  4. <view class="check-content">
  5. <view class="title">
  6. {{ equiName }}
  7. <text>{{ equiCode }}</text>
  8. </view>
  9. <view class="check-list">
  10. <CheckCard v-for="(item, index) in equipList" :item="item" class="mb20" :index="index"></CheckCard>
  11. </view>
  12. <view class="footer">
  13. <view class="btn" @click="back">返回</view>
  14. <view class="btn primary" @click="handleSave">保存</view>
  15. </view>
  16. </view>
  17. <uni-popup ref="inputDialog" type="dialog">
  18. <uni-popup-dialog
  19. ref="inputClose"
  20. mode="input"
  21. title="您当前已超出计划完成时间,请填写原因"
  22. placeholder="请输入内容"
  23. :before-close="true"
  24. @close="handleClose"
  25. @confirm="timeoutCauseConfirm"></uni-popup-dialog>
  26. </uni-popup>
  27. </view>
  28. </template>
  29. <script>
  30. import { getDeviceInfo, mattersChecked } from '@/api/myTicket/index.js'
  31. import { post, postJ } from '@/utils/api.js'
  32. import CheckCard from '@/pages/tour_tally/check/components/CheckCard.vue'
  33. export default {
  34. components: { CheckCard },
  35. data() {
  36. return {
  37. id: '',
  38. pageId: '',
  39. page: 1,
  40. equipList: [],
  41. isEnd: false,
  42. equiName: '',
  43. equiCode: '',
  44. workOrderId: '',
  45. workOrderCode: ''
  46. }
  47. },
  48. onLoad(options) {
  49. this.id = options.id
  50. // this.pageId = options.id
  51. // this.equiName = options.equiName
  52. // this.equiCode = options.equiCode
  53. // this.workOrderId = +options.workOrderId
  54. // this.workOrderCode = options.workOrderCode
  55. this.getList()
  56. },
  57. // onReachBottom() {
  58. // if (this.isEnd) return
  59. // this.page++
  60. // this.getList()
  61. // },
  62. methods: {
  63. back() {
  64. uni.navigateBack({
  65. delta: 1
  66. })
  67. },
  68. handleSave() {
  69. console.log(this.equipList)
  70. let isAllPass = true
  71. isAllPass = this.equipList.every(item => item.status > -1)
  72. let params = {
  73. id: this.equipList[0].id,
  74. executeStatus: isAllPass ? 1 : 2,
  75. workItems: this.equipList.map(item => {
  76. return {
  77. content: item.content,
  78. name: item.name,
  79. norm: item.norm,
  80. operationGuide: item.operationGuide,
  81. result: item.result,
  82. serialNum: item.serialNum,
  83. status: item.status
  84. }
  85. })
  86. }
  87. mattersChecked(params).then(data => {
  88. uni.showToast({
  89. duration: 2000,
  90. title: '保存成功!'
  91. })
  92. this.back()
  93. })
  94. // let _this = this
  95. // const params = {
  96. // itemList: this.equipList,
  97. // planEquiId: this.pageId,
  98. // workOrderId: +this.workOrderId,
  99. // workOrderType: 1
  100. // }
  101. // postJ(this.apiUrl + `/workOrder/itemsInspect`, params, true).then(res => {
  102. // if (res?.success) {
  103. // if (res.data) {
  104. // uni.showModal({
  105. // title: '提示',
  106. // content: '所有设备已执行完,是否报工?',
  107. // cancelText: '取消', // 取消按钮的文字
  108. // confirmText: '报工', // 确认按钮的文字
  109. // showCancel: true, // 是否显示取消按钮,默认为 true
  110. // success: res => {
  111. // if (res.confirm) {
  112. // _this._report()
  113. // } else {
  114. // _this.back()
  115. // }
  116. // }
  117. // })
  118. // } else {
  119. // uni.showToast({
  120. // duration: 2000,
  121. // title: '保存成功!'
  122. // })
  123. // this.back()
  124. // }
  125. // }
  126. // })
  127. },
  128. handleClose() {
  129. this.$refs.inputDialog.close()
  130. },
  131. timeoutCauseConfirm(value) {
  132. if (!value) {
  133. uni.showToast({
  134. title: '请输入超时原因',
  135. icon: 'none'
  136. })
  137. return
  138. }
  139. this.$refs.inputDialog.close()
  140. this._report(value)
  141. },
  142. _report(timeoutCause = '') {
  143. let _this = this
  144. post(
  145. this.apiUrl + '/workOrder/reportWork',
  146. {
  147. workOrderId: this.workOrderId,
  148. timeoutCause
  149. },
  150. true,
  151. false
  152. )
  153. .then(res => {
  154. if (res?.success) {
  155. let data = res.data
  156. if (data.length) {
  157. uni.showModal({
  158. title: '提示',
  159. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  160. cancelText: '取消', // 取消按钮的文字
  161. confirmText: '报修', // 确认按钮的文字
  162. showCancel: true, // 是否显示取消按钮,默认为 true
  163. success: res => {
  164. if (res.confirm) {
  165. if (data.length > 1) {
  166. uni.navigateTo({
  167. url: `/pages/tour_tally/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.workOrderId}&chooseTab=true`
  168. })
  169. } else {
  170. uni.navigateTo({
  171. url: `/pages/repair/repair/index?source=5&workOrderCode=${this.workOrderCode}&equiCode=${data[0].equiCode}&equiId=${data[0].equiId}&workOrderId=${this.pageId}&equiName=${data[0].equiName}&equiModel=${data[0].equiModel}&equiLocation=${data[0].equiLocation}`
  172. })
  173. }
  174. } else {
  175. _this.back()
  176. }
  177. }
  178. })
  179. } else {
  180. uni.showToast({
  181. icon: 'success',
  182. title: '操作成功!',
  183. duration: 2000
  184. })
  185. _this.back()
  186. }
  187. }
  188. })
  189. .catch(res => {
  190. if (res.code === '4444') {
  191. this.$refs.inputDialog.open()
  192. }
  193. })
  194. },
  195. getList() {
  196. getDeviceInfo({ id: this.id }).then(data => {
  197. this.equiName = data.name
  198. this.equiCode = data.code
  199. this.equipList = data.workItems.map(item => {
  200. return {
  201. ...item,
  202. id: data.id,
  203. executeStatus: 1
  204. }
  205. })
  206. })
  207. // const { page } = this
  208. // post(this.apiUrl + `/workOrder/getEquipmentItemsListApp?size=10&page=${page}`, { planEquiId: +this.pageId, workOrderId: this.workOrderId }, true).then(res => {
  209. // if (res?.success) {
  210. // res.data.records.forEach(item => {
  211. // item.isNormal = item.isNormal === null || item.isNormal === undefined ? 1 : item.isNormal
  212. // })
  213. // if (page === 1) {
  214. // this.equipList = res.data.records
  215. // } else {
  216. // this.equipList.push(...res.data.records)
  217. // }
  218. // this.isEnd = this.equipList.length >= res.data.total
  219. // }
  220. // })
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .check-content {
  227. box-sizing: border-box;
  228. // height: calc(100vh - 88rpx);
  229. display: flex;
  230. flex-direction: column;
  231. padding-bottom: 100rpx;
  232. .title {
  233. line-height: 80rpx;
  234. display: flex;
  235. justify-content: space-between;
  236. padding: 0 30rpx;
  237. }
  238. .check-list {
  239. flex: 1;
  240. overflow: auto;
  241. padding: 0 30rpx 30rpx;
  242. }
  243. .footer {
  244. height: 100rpx;
  245. display: flex;
  246. border: 1rpx solid $j-primary-border-green;
  247. position: fixed;
  248. bottom: 0;
  249. width: 100vw;
  250. background: #fff;
  251. .btn {
  252. display: flex;
  253. flex: 1;
  254. justify-content: center;
  255. align-items: center;
  256. border-radius: 0;
  257. &.primary {
  258. background-color: $j-primary-border-green;
  259. color: #fff;
  260. }
  261. }
  262. }
  263. .mb20 {
  264. margin-bottom: 20rpx;
  265. }
  266. }
  267. </style>