index.vue 8.1 KB

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