index.vue 8.2 KB

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