index.vue 8.0 KB

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