order copy.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="维修工单"
  8. @clickLeft="back"
  9. right-icon="scan"
  10. @clickRight="HandlScanCode"
  11. ></uni-nav-bar>
  12. <template>
  13. <view class="tab-title">
  14. <view
  15. v-for="(item, index) in tabList"
  16. :key="index"
  17. class="tab-item"
  18. :class="index === pickTabIndex ? 'active' : ''"
  19. @click="changeChartsTab(index)"
  20. >
  21. {{ item.label }}
  22. <text v-if="index == 0" class="title-red">{{ item.number }}</text>
  23. <text v-else class="title-num">({{ item.number }})</text>
  24. </view>
  25. </view>
  26. <view class="tab-title__placeholder"></view>
  27. </template>
  28. <OrderTask
  29. v-for="(item, index) in tabList"
  30. :key="index"
  31. v-show="index === pickTabIndex"
  32. :list="item.list"
  33. :type="tabList.value"
  34. >
  35. </OrderTask>
  36. </view>
  37. </template>
  38. <script>
  39. import OrderTask from './OrderTask.vue'
  40. import { post, postJ } from '@/utils/api.js'
  41. let [page, size, isEnd] = [1, 10, true]
  42. export default {
  43. components: {
  44. OrderTask
  45. },
  46. data () {
  47. return {
  48. tabList: [
  49. {
  50. value: 0,
  51. label: '待执行',
  52. list: [],
  53. number: 0
  54. },
  55. {
  56. value: 1,
  57. label: '执行中',
  58. list: [],
  59. number: 0
  60. },
  61. {
  62. value: 2,
  63. label: '已报工',
  64. list: [],
  65. number: 0
  66. }
  67. ],
  68. pickTabIndex: 0,
  69. qrContent: null,
  70. barType: 0
  71. }
  72. },
  73. onShow () {
  74. this.getFirstList()
  75. this.getStatus()
  76. let _this = this
  77. uni.$off('scancode') // 每次进来先 移除全局自定义事件监听器
  78. uni.$on('scancode', function (data) {
  79. _this.qrContent = data.code.trim()
  80. let index = _this.qrContent.indexOf('@_@')
  81. if (index == -1) {
  82. _this.barType = 0
  83. } else {
  84. _this.barType = _this.qrContent.substring(index + 3, index + 4)
  85. }
  86. _this.getData()
  87. })
  88. },
  89. onReachBottom: function () {
  90. if (isEnd) {
  91. return
  92. }
  93. // 显示加载图标
  94. uni.showLoading({
  95. title: '数据加载中'
  96. })
  97. this.getMoreLists()
  98. },
  99. methods: {
  100. getStatus () {
  101. postJ(this.apiUrl + `/workOrder/getWorkOrderTotal`, {
  102. workOrderType: 3
  103. }).then(res => {
  104. let data = res.data
  105. this.tabList[0].number = data.waitExecutionNum
  106. this.tabList[1].number = data.executoryNum
  107. this.tabList[2].number = data.finishNum
  108. })
  109. },
  110. // 扫码
  111. HandlScanCode () {
  112. uni.navigateTo({
  113. url: '/pages/ScanCode/ScanCode'
  114. })
  115. },
  116. // 根据条码请求设备数据
  117. getData () {
  118. let par = {
  119. barType: this.barType,
  120. qrContent: this.qrContent
  121. }
  122. postJ(this.apiUrl + '/scan/getAssetInfo', par).then(res => {
  123. let data = res.data
  124. this.matchEquipment(data)
  125. })
  126. },
  127. matchEquipment (data) {
  128. let par = {
  129. EquiCode: data.assetCode
  130. }
  131. console.log('par', par)
  132. post(this.apiUrl + '/workOrder/getWorkOrderByEquiCode', par).then(res => {
  133. let data = res.data
  134. if (!data) {
  135. uni.showModal({
  136. title: '提示',
  137. content: '该设备无维修工单记录!',
  138. confirmText: '好的', //这块是确定按钮的文字
  139. showCancel: false,
  140. success: function (res) {
  141. if (res.confirm) {
  142. // 执行确认后的操作
  143. } else {
  144. // 执行取消后的操作
  145. }
  146. }
  147. })
  148. } else {
  149. uni.navigateTo({
  150. url: `/pages/maintain_service/detail/detail?workOrderCode=${data}`
  151. })
  152. }
  153. })
  154. },
  155. getFirstList: function () {
  156. page = 1
  157. isEnd = true
  158. uni.showLoading({
  159. title: '数据加载中'
  160. })
  161. this.getList()
  162. },
  163. getMoreLists: function () {
  164. //获取更多数据
  165. page++
  166. this.getList()
  167. },
  168. getList () {
  169. uni.showLoading({
  170. title: '加载中'
  171. })
  172. let data = {
  173. page,
  174. size
  175. }
  176. let searchStatus = this.tabList[this.pickTabIndex].value
  177. let par = this.URLSearchParams(data)
  178. //2 - 99 [已完成]
  179. postJ(this.apiUrl + '/repair/info/getWorkOrderList?' + par, {
  180. searchStatus,
  181. workOrderType: 3,
  182. page,
  183. size
  184. })
  185. .then(res => {
  186. let data = res.data.records
  187. let pageTotal = res.data.pages
  188. if (page === 1) {
  189. this.tabList[this.pickTabIndex].list = res.data.records
  190. } else {
  191. data.forEach(element => {
  192. this.tabList[this.pickTabIndex].list.push(element)
  193. })
  194. }
  195. page < pageTotal ? (isEnd = false) : (isEnd = true)
  196. })
  197. .then(() => {
  198. uni.hideLoading()
  199. })
  200. },
  201. changeChartsTab (index) {
  202. this.pickTabIndex = index
  203. this.getFirstList()
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .tab-title {
  210. position: fixed;
  211. z-index: 99;
  212. width: 100%;
  213. padding: 0 30rpx 10rpx;
  214. // display: flex;
  215. // justify-content: space-between;
  216. height: $tab-height;
  217. line-height: $tab-height;
  218. background-color: #ffffff;
  219. border-bottom: 1px solid #f2f2f2;
  220. // box-sizing: border-box;
  221. white-space: nowrap;
  222. overflow: auto hidden;
  223. &::-webkit-scrollbar {
  224. /*滚动条整体样式*/
  225. width: 10px;
  226. /*高宽分别对应横竖滚动条的尺寸*/
  227. height: 1px;
  228. }
  229. &::-webkit-scrollbar-thumb {
  230. /*滚动条里面小方块*/
  231. border-radius: 10px;
  232. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  233. background: #535353;
  234. }
  235. &::-webkit-scrollbar-track {
  236. /*滚动条里面轨道*/
  237. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  238. border-radius: 10px;
  239. background: #ededed;
  240. }
  241. .tab-item {
  242. width: 30%;
  243. text-align: center;
  244. display: inline-block;
  245. font-size: 32rpx;
  246. color: $uni-text-color-grey;
  247. }
  248. .tab-item.active {
  249. color: $j-primary-border-green;
  250. border-bottom: 1px solid $j-primary-border-green;
  251. }
  252. .title-num {
  253. font-size: 26rpx;
  254. }
  255. .title-red {
  256. display: inline-block;
  257. font-size: 22rpx;
  258. padding: 0 10rpx;
  259. border-radius: 50rpx;
  260. color: #ffffff;
  261. background: red;
  262. line-height: 38rpx;
  263. position: absolute;
  264. top: 10rpx;
  265. min-width: 18rpx;
  266. }
  267. }
  268. </style>