order.vue 8.1 KB

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