index.vue 6.0 KB

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