order.vue 8.1 KB

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