order.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="巡点检工单" @clickLeft="back"></uni-nav-bar>
  4. <view class="search-box">
  5. <uni-section>
  6. <uni-easyinput @clear="clearSearch" prefixIcon="search" style="width: 460rpx" v-model="code"
  7. placeholder="工单编号">
  8. </uni-easyinput>
  9. </uni-section>
  10. <button class="search_btn" @click="doSearch">搜索</button>
  11. <image class="menu_icon" @click="showSearch" src="~@/static/pda/menu.svg"></image>
  12. </view>
  13. <view v-show="showTab">
  14. <view class="top-wrapper">
  15. <view class="tab_box rx-sc">
  16. <view class="tab_item" v-for="(item,index) in tabList" :key="index"
  17. :class="{active: pickTabIndex == index}">
  18. <view @click="changeChartsTab(index)" class="badge-c">
  19. {{item.label}}
  20. <u-badge max="99" :value="item.number" absolute></u-badge>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <OrderTask v-for="(item, index) in tabList" :key="index" v-show="index === pickTabIndex" :list="item.list"
  27. :type="tabList.value"></OrderTask>
  28. <u-toast ref="uToast"></u-toast>
  29. <MySearch :show.sync="searchShow" :formItems="formItems" @search="confirmSearch" ref="mySearchRef"></MySearch>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. isObjectEmpty
  35. } from '@/utils/utils.js'
  36. import {
  37. getWorkOrderList,
  38. getRuleList,
  39. workPage
  40. } from '@/api/myTicket'
  41. import OrderTask from './OrderTask.vue'
  42. import {
  43. post,
  44. postJ
  45. } from '@/utils/api.js'
  46. export default {
  47. components: {
  48. OrderTask
  49. },
  50. data() {
  51. return {
  52. showTab: true,
  53. page: 1,
  54. size: 10,
  55. isEnd: false,
  56. tabList: [{
  57. value: 0,
  58. label: '待接收',
  59. list: [],
  60. number: 0
  61. },
  62. {
  63. value: 2,
  64. label: '执行中',
  65. list: [],
  66. number: 0
  67. },
  68. {
  69. value: 3,
  70. label: '已完成',
  71. list: [],
  72. number: 0
  73. },
  74. {
  75. value: 4,
  76. label: '全部',
  77. list: [],
  78. isNone: !this.$isAuthorities('eam:tour_tally:listAll'),
  79. number: 0
  80. }
  81. ],
  82. pickTabIndex: 0,
  83. qrContent: null,
  84. barType: 0,
  85. searchShow: false,
  86. code: '',
  87. searchForm: {},
  88. formItems: [{
  89. label: '规则名称:',
  90. prop: 'ruleId',
  91. component: 'MySelect',
  92. props: {
  93. localdata: [],
  94. dataKey: 'name',
  95. dataValue: 'id'
  96. }
  97. },
  98. {
  99. label: '时间:',
  100. prop: 'startEndTime',
  101. component: 'MyDateRange',
  102. props: {
  103. type: 'daterange',
  104. }
  105. }
  106. ]
  107. }
  108. },
  109. onLoad() {
  110. this.getRuleList()
  111. },
  112. onShow() {
  113. this.getFirstList()
  114. this.getStatus()
  115. },
  116. onReachBottom() {
  117. this.getList()
  118. },
  119. methods: {
  120. getStatus() {
  121. getWorkOrderList({
  122. orderStatus: [0],
  123. type: 1,
  124. pageNum: 1,
  125. size: 1
  126. }).then(res => {
  127. console.log(res, 'res ===')
  128. this.tabList[0].number = res.count
  129. })
  130. getWorkOrderList({
  131. orderStatus: [2],
  132. type: 1,
  133. pageNum: 1,
  134. size: 1
  135. }).then(res => {
  136. this.tabList[1].number = res.count
  137. })
  138. },
  139. getCount() {
  140. statistics().then(data => {
  141. console.log('onsole.log(data)-----------')
  142. console.log(data)
  143. this.tabList = this.tabList.map(item => {
  144. switch (item.value) {
  145. case '0':
  146. return {
  147. ...item, badge: {
  148. value: data.maintenanceNum
  149. }
  150. }
  151. case '2':
  152. return {
  153. ...item, badge: {
  154. value: data.patrolInspection
  155. }
  156. }
  157. case '3':
  158. return {
  159. ...item, badge: {
  160. value: data.quantityNum
  161. }
  162. }
  163. case '4':
  164. return {
  165. ...item, badge: {
  166. value: data.repairsNum
  167. }
  168. }
  169. }
  170. })
  171. })
  172. },
  173. getFirstList: function() {
  174. this.page = 1
  175. this.isEnd = false
  176. this.getList()
  177. },
  178. getList() {
  179. if (this.isEnd) {
  180. this.$refs.uToast.show({
  181. message: "暂无更多数据",
  182. duration: 1000
  183. })
  184. return
  185. }
  186. uni.showLoading({
  187. title: '加载中'
  188. })
  189. let params = {
  190. orderStatus: [this.tabList[this.pickTabIndex].value],
  191. type: 1,
  192. pageNum: this.page,
  193. size: this.size,
  194. ...this.searchForm
  195. }
  196. console.log(this.showTab);
  197. if (!this.showTab || this.pickTabIndex == 3) {
  198. delete params.orderStatus
  199. }
  200. let api = this.pickTabIndex == 3 ? workPage : getWorkOrderList
  201. // return
  202. api(params)
  203. .then(res => {
  204. // this.tabList[this.pickTabIndex].list = res.list
  205. // isEnd = this.tabList[this.pickTabIndex].list >= res.count
  206. if (this.page == 1) {
  207. this.tabList[this.pickTabIndex].list = res.list;
  208. } else {
  209. this.tabList[this.pickTabIndex].list.push(...res.list);
  210. }
  211. this.page += 1
  212. this.isEnd = this.tabList[this.pickTabIndex].list.length >= res.count;
  213. uni.hideLoading();
  214. })
  215. .catch(() => {
  216. uni.hideLoading();
  217. })
  218. },
  219. changeChartsTab(index) {
  220. this.pickTabIndex = index;
  221. this.getFirstList();
  222. },
  223. async getRuleList() {
  224. let params = {
  225. status: 1,
  226. type: 1,
  227. pageNum: 1,
  228. size: -1
  229. }
  230. const res = await getRuleList(params)
  231. this.formItems.find(item => item.prop === 'ruleId').props.localdata = res
  232. },
  233. clearSearch() {
  234. this.code = ''
  235. this.doSearch()
  236. },
  237. doSearch() {
  238. this.isEnd = false;
  239. this.page = 1;
  240. this.searchForm.code = this.code
  241. this.showTab = isObjectEmpty(this.searchForm)
  242. this.getList();
  243. },
  244. showSearch() {
  245. this.searchShow = true
  246. },
  247. confirmSearch(e) {
  248. console.log(e);
  249. let data = JSON.parse(JSON.stringify(e))
  250. if (data.startEndTime) {
  251. var [startTime, endTime] = data.startEndTime
  252. delete data.startEndTime
  253. this.searchForm = {
  254. ...data,
  255. startTime,
  256. endTime
  257. }
  258. } else {
  259. this.searchForm = {
  260. ...data
  261. }
  262. }
  263. console.log(this.searchForm);
  264. this.doSearch()
  265. },
  266. }
  267. }
  268. </script>
  269. <style lang="scss" scoped>
  270. .top-wrapper {
  271. display: flex;
  272. align-items: center;
  273. background-color: #fff;
  274. position: relative;
  275. .tab_box {
  276. width: 100%;
  277. height: 68rpx;
  278. .tab_item {
  279. height: 68rpx;
  280. line-height: 68rpx;
  281. padding: 0 20rpx;
  282. font-size: 32rpx;
  283. // color: #979C9E;
  284. }
  285. .active {
  286. box-sizing: border-box;
  287. border-bottom: 6rpx solid $theme-color;
  288. color: $theme-color;
  289. }
  290. }
  291. }
  292. .tab-title {
  293. position: fixed;
  294. z-index: 99;
  295. width: 100%;
  296. padding: 10rpx;
  297. // display: flex;
  298. // justify-content: space-between;
  299. height: $tab-height;
  300. line-height: $tab-height;
  301. background-color: #ffffff;
  302. border-bottom: 1px solid #f2f2f2;
  303. // box-sizing: border-box;
  304. white-space: nowrap;
  305. overflow: auto hidden;
  306. display: flex;
  307. &::-webkit-scrollbar {
  308. /*滚动条整体样式*/
  309. width: 10px;
  310. /*高宽分别对应横竖滚动条的尺寸*/
  311. height: 1px;
  312. }
  313. &::-webkit-scrollbar-thumb {
  314. /*滚动条里面小方块*/
  315. border-radius: 10px;
  316. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  317. background: #535353;
  318. }
  319. &::-webkit-scrollbar-track {
  320. /*滚动条里面轨道*/
  321. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  322. border-radius: 10px;
  323. background: #ededed;
  324. }
  325. .tab-item {
  326. flex: 1;
  327. text-align: center;
  328. display: inline-block;
  329. font-size: 32rpx;
  330. color: $uni-text-color-grey;
  331. }
  332. .tab-item.active {
  333. color: $j-primary-border-green;
  334. border-bottom: 1px solid $j-primary-border-green;
  335. }
  336. .title-num {
  337. font-size: 26rpx;
  338. }
  339. .title-red {
  340. display: inline-block;
  341. font-size: 22rpx;
  342. padding: 0 10rpx;
  343. border-radius: 50rpx;
  344. color: #ffffff;
  345. background: red;
  346. line-height: 38rpx;
  347. position: absolute;
  348. top: 10rpx;
  349. min-width: 18rpx;
  350. }
  351. }
  352. .badge-c {
  353. position: relative;
  354. }
  355. /deep/.u-badge {
  356. top: 0;
  357. right: 0;
  358. transform: translate(90%, 20%);
  359. }
  360. .search-box {
  361. background-color: #fff;
  362. display: flex;
  363. width: 750rpx;
  364. height: 88rpx;
  365. padding: 16rpx 32rpx;
  366. align-items: center;
  367. gap: 16rpx;
  368. justify-content: space-between;
  369. /deep/.uni-section {
  370. margin-top: 0px;
  371. }
  372. /deep/.uni-section-header {
  373. padding: 0px;
  374. }
  375. .search_btn {
  376. width: 120rpx;
  377. height: 70rpx;
  378. line-height: 70rpx;
  379. padding: 0 24rpx;
  380. background: $theme-color;
  381. font-size: 32rpx;
  382. color: #fff;
  383. margin: 0;
  384. margin-left: 26rpx;
  385. }
  386. .menu_icon {
  387. width: 44rpx;
  388. height: 44rpx;
  389. margin-left: 14rpx;
  390. }
  391. }
  392. </style>