index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. if (!this.keyWords) {
  85. this.filterList = this.equipList;
  86. } else {
  87. this.filterList = this.equipList.filter(item =>
  88. item.categoryCode.includes(this.keyWords)
  89. );
  90. }
  91. },
  92. handleSave() {
  93. let isAllPass = true
  94. isAllPass = this.equipList.every(item => item.status > -1)
  95. let params = {
  96. id: this.equipList[0].id,
  97. executeStatus: isAllPass ? 1 : 2,
  98. workItems: this.equipList.map(item => {
  99. return {
  100. content: item.content,
  101. name: item.name,
  102. norm: item.norm,
  103. operationGuide: item.operationGuide,
  104. result: item.result,
  105. serialNum: item.serialNum,
  106. status: item.status
  107. }
  108. })
  109. }
  110. mattersChecked(params).then(data => {
  111. uni.showToast({
  112. duration: 2000,
  113. title: '保存成功!'
  114. })
  115. this.back()
  116. })
  117. // let _this = this
  118. // const params = {
  119. // itemList: this.equipList,
  120. // planEquiId: this.pageId,
  121. // workOrderId: +this.workOrderId,
  122. // workOrderType: 1
  123. // }
  124. // postJ(this.apiUrl + `/workOrder/itemsInspect`, params, true).then(res => {
  125. // if (res?.success) {
  126. // if (res.data) {
  127. // uni.showModal({
  128. // title: '提示',
  129. // content: '所有设备已执行完,是否报工?',
  130. // cancelText: '取消', // 取消按钮的文字
  131. // confirmText: '报工', // 确认按钮的文字
  132. // showCancel: true, // 是否显示取消按钮,默认为 true
  133. // success: res => {
  134. // if (res.confirm) {
  135. // _this._report()
  136. // } else {
  137. // _this.back()
  138. // }
  139. // }
  140. // })
  141. // } else {
  142. // uni.showToast({
  143. // duration: 2000,
  144. // title: '保存成功!'
  145. // })
  146. // this.back()
  147. // }
  148. // }
  149. // })
  150. },
  151. handleClose() {
  152. this.$refs.inputDialog.close()
  153. },
  154. timeoutCauseConfirm(value) {
  155. if (!value) {
  156. uni.showToast({
  157. title: '请输入超时原因',
  158. icon: 'none'
  159. })
  160. return
  161. }
  162. this.$refs.inputDialog.close()
  163. this._report(value)
  164. },
  165. _report(timeoutCause = '') {
  166. let _this = this
  167. post(
  168. this.apiUrl + '/workOrder/reportWork', {
  169. workOrderId: this.workOrderId,
  170. timeoutCause
  171. },
  172. true,
  173. false
  174. )
  175. .then(res => {
  176. if (res?.success) {
  177. let data = res.data
  178. if (data.length) {
  179. uni.showModal({
  180. title: '提示',
  181. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  182. cancelText: '取消', // 取消按钮的文字
  183. confirmText: '报修', // 确认按钮的文字
  184. showCancel: true, // 是否显示取消按钮,默认为 true
  185. success: res => {
  186. if (res.confirm) {
  187. if (data.length > 1) {
  188. uni.navigateTo({
  189. url: `/pages/tour_tally/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.workOrderId}&chooseTab=true`
  190. })
  191. } else {
  192. uni.navigateTo({
  193. 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}`
  194. })
  195. }
  196. } else {
  197. _this.back()
  198. }
  199. }
  200. })
  201. } else {
  202. uni.showToast({
  203. icon: 'success',
  204. title: '操作成功!',
  205. duration: 2000
  206. })
  207. _this.back()
  208. }
  209. }
  210. })
  211. .catch(res => {
  212. if (res.code === '4444') {
  213. this.$refs.inputDialog.open()
  214. }
  215. })
  216. },
  217. getList() {
  218. getDeviceInfo({
  219. id: this.id
  220. }).then(data => {
  221. this.equiName = data.name
  222. this.equiCode = data.code
  223. this.equipList = data.workItems.map(item => {
  224. return {
  225. ...item,
  226. id: data.id,
  227. executeStatus: 1
  228. }
  229. })
  230. this.doSearch()
  231. })
  232. // const { page } = this
  233. // post(this.apiUrl + `/workOrder/getEquipmentItemsListApp?size=10&page=${page}`, { planEquiId: +this.pageId, workOrderId: this.workOrderId }, true).then(res => {
  234. // if (res?.success) {
  235. // res.data.records.forEach(item => {
  236. // item.isNormal = item.isNormal === null || item.isNormal === undefined ? 1 : item.isNormal
  237. // })
  238. // if (page === 1) {
  239. // this.equipList = res.data.records
  240. // } else {
  241. // this.equipList.push(...res.data.records)
  242. // }
  243. // this.isEnd = this.equipList.length >= res.data.total
  244. // }
  245. // })
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .top-wrapper {
  252. background-color: #fff;
  253. display: flex;
  254. width: 750rpx;
  255. height: 88rpx;
  256. padding: 16rpx 32rpx;
  257. align-items: center;
  258. gap: 16rpx;
  259. /deep/.uni-section {
  260. margin-top: 0px;
  261. }
  262. /deep/.uni-section-header {
  263. padding: 0px;
  264. }
  265. .search_btn {
  266. width: 120rpx;
  267. height: 70rpx;
  268. line-height: 70rpx;
  269. padding: 0 24rpx;
  270. background: $theme-color;
  271. font-size: 32rpx;
  272. color: #fff;
  273. margin: 0;
  274. margin-left: 26rpx;
  275. }
  276. .menu_icon {
  277. width: 44rpx;
  278. height: 44rpx;
  279. margin-left: 14rpx;
  280. }
  281. }
  282. .check-content {
  283. box-sizing: border-box;
  284. // height: calc(100vh - 88rpx);
  285. display: flex;
  286. flex-direction: column;
  287. padding-bottom: 100rpx;
  288. .title {
  289. line-height: 80rpx;
  290. display: flex;
  291. justify-content: space-between;
  292. padding: 0 30rpx;
  293. }
  294. .check-list {
  295. flex: 1;
  296. overflow: auto;
  297. padding: 0 30rpx 30rpx;
  298. }
  299. .footer {
  300. height: 100rpx;
  301. display: flex;
  302. border: 1rpx solid $j-primary-border-green;
  303. position: fixed;
  304. bottom: 0;
  305. width: 100vw;
  306. background: #fff;
  307. .btn {
  308. display: flex;
  309. flex: 1;
  310. justify-content: center;
  311. align-items: center;
  312. border-radius: 0;
  313. &.primary {
  314. background-color: $j-primary-border-green;
  315. color: #fff;
  316. }
  317. }
  318. }
  319. .mb20 {
  320. margin-bottom: 20rpx;
  321. }
  322. }
  323. </style>