myTicket.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. <template>
  2. <view class="kd-work-container">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="orderType == 1 ? '工单待办' : '工单已办'"
  4. right-icon="scan" @clickLeft="back">
  5. <view slot="right">
  6. <view @click="HandlScanCode" class="scan_btn"></view>
  7. </view>
  8. </uni-nav-bar>
  9. <view class="top-wrapper">
  10. <view class="tab_box rx-sc">
  11. <view class="tab_item" :class="{active: activeIndex == item.index}" v-for="(item,index) in tabList"
  12. :key="index">
  13. <view @click="handleTabChange(item)">
  14. {{item.name}}
  15. </view>
  16. </view>
  17. </view>
  18. <view class="more_search">
  19. <image src="~@/static/moreSearch.svg" mode="" @click="searchShow = true"></image>
  20. </view>
  21. </view>
  22. <view class="work-list">
  23. <u-list @scrolltolower="scrolltolower" :key="activeType" :preLoadScreen="page * 10">
  24. <u-list-item v-for="(item, index) in dataList" :key="index">
  25. <CardTime :time="item.createTime" />
  26. <KdCard :orderTitle="orderTitle" :title="item.code" @handleDetail="handleDetail" :status="true"
  27. :item="item" :type="activeType" />
  28. </u-list-item>
  29. <u-list-item v-if="dataList.length === 0">
  30. <view class="nodata">暂无数据</view>
  31. </u-list-item>
  32. </u-list>
  33. </view>
  34. <SearchPopup mode="top" v-if="searchShow">
  35. <template v-slot:list>
  36. <view class="search_list">
  37. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  38. <u-form-item v-if="orderType == 1" label="类型:" class="required-form" borderBottom
  39. prop="assetType">
  40. <u-checkbox-group v-model="searchFrom.orderStatus" placement="row" size="30"
  41. @change="statusChange">
  42. <u-checkbox v-for="(item, index) in statusRange[activeType]"
  43. :customStyle="{ marginRight: '8px' }" :label="item.text" :name="item.value"
  44. labelSize="30" iconSize="30" activeColor="#157A2C"></u-checkbox>
  45. </u-checkbox-group>
  46. </u-form-item>
  47. <u-form-item label="编号:" class="required-form" borderBottom prop="assetType">
  48. <input type="text" placeholder="请输入编号" v-model="searchFrom.code" />
  49. </u-form-item>
  50. </u-form>
  51. </view>
  52. </template>
  53. <template v-slot:operate>
  54. <view class="operate_box rx-bc">
  55. <u-button size="small" class="u-reset-button mg-20" @click="searchShow = false">取消</u-button>
  56. <u-button type="warning" size="small" class="u-reset-button mg-20" @click="reset">重置</u-button>
  57. <u-button type="success" size="small" class="u-reset-button" @click="doSearch">确定</u-button>
  58. </view>
  59. </template>
  60. </SearchPopup>
  61. </view>
  62. </template>
  63. <script>
  64. import SearchPopup from '@/pages/pda/components/searchPopup.vue'
  65. import {
  66. getWorkOrderList,
  67. statistics,
  68. deviceListQrCode
  69. } from '@/api/myTicket'
  70. import KdCard from '../components/KdCard/index.vue'
  71. import CardTime from '../components/CardTime.vue'
  72. import {
  73. getByFixCode
  74. } from '@/api/repair'
  75. import {
  76. nextTick
  77. } from 'vue'
  78. // import { postJ } from '@/utils/api'
  79. let [isEnd] = [false]
  80. export default {
  81. components: {
  82. KdCard,
  83. CardTime,
  84. SearchPopup
  85. },
  86. data() {
  87. return {
  88. formData: {},
  89. orderTitle: '',
  90. tabsCurrent: 0, // tabs初始位置
  91. doneRange: [{
  92. value: 1,
  93. text: '普通'
  94. },
  95. {
  96. value: 2,
  97. text: '紧急'
  98. },
  99. {
  100. value: 3,
  101. text: '重要'
  102. }
  103. ],
  104. tabList: [
  105. // {
  106. // name: '计划维修工单',
  107. // type: 'repair',
  108. // workOrderType: 4,
  109. // url: `/pages/maintain_service/detail/detail?`,
  110. // badge: {
  111. // value: 0
  112. // }
  113. // },
  114. {
  115. name: '保养工单',
  116. type: 'maintenance',
  117. workOrderType: 2,
  118. index: 0,
  119. url: `/pages/maintenance/detail/detail?`,
  120. badge: {
  121. value: 0
  122. }
  123. },
  124. {
  125. name: '巡点检工单',
  126. type: 'patrol',
  127. workOrderType: 1,
  128. index: 1,
  129. url: `/pages/tour_tally/detail/detail?`,
  130. badge: {
  131. value: 0
  132. }
  133. },
  134. // {
  135. // name: '量具送检工单',
  136. // type: 'quantity',
  137. // workOrderType: 5,
  138. // index: 2,
  139. // url: `/pages/quantity/detail/detail?`,
  140. // badge: {
  141. // value: 0
  142. // }
  143. // },
  144. {
  145. name: '维修工单',
  146. type: 'repair',
  147. workOrderType: 3,
  148. index: 2,
  149. // url: `/pages/maintain_service/detail/detail?`,
  150. url: `/pages/maintenanceWorkorder/detail/detail?`,
  151. badge: {
  152. value: 0
  153. }
  154. }
  155. ],
  156. activeType: 'maintenance',
  157. activeIndex: 0,
  158. dataList: [],
  159. searchShow: false,
  160. statusRange: {
  161. repair: [{
  162. value: 0,
  163. text: '待接收'
  164. },
  165. {
  166. value: 2,
  167. text: '执行中'
  168. }
  169. // {
  170. // value: 0,
  171. // text: '待接收'
  172. // },
  173. // {
  174. // value: 2,
  175. // text: '待审核'
  176. // },
  177. // {
  178. // value: 4,
  179. // text: '已撤回'
  180. // },
  181. // {
  182. // value: 6,
  183. // text: '已驳回'
  184. // },
  185. // {
  186. // value: 8,
  187. // text: '已派单'
  188. // },
  189. // {
  190. // value: 1,
  191. // text: '执行中'
  192. // },
  193. // {
  194. // value: 5,
  195. // text: '待验收'
  196. // },
  197. // {
  198. // value: 3,
  199. // text: '已完成'
  200. // },
  201. // {
  202. // value: 7,
  203. // text: '未修复'
  204. // }
  205. ],
  206. maintenance: [{
  207. value: 0,
  208. text: '待接收'
  209. },
  210. {
  211. value: 2,
  212. text: '执行中'
  213. }
  214. // {
  215. // value: 3,
  216. // text: '完成'
  217. // }
  218. ],
  219. patrol: [{
  220. value: 0,
  221. text: '待接收'
  222. },
  223. {
  224. value: 2,
  225. text: '执行中'
  226. }
  227. // {
  228. // value: 3,
  229. // text: '完成'
  230. // }
  231. ],
  232. quantity: [{
  233. value: 0,
  234. text: '待接收'
  235. },
  236. {
  237. value: 2,
  238. text: '执行中'
  239. },
  240. {
  241. value: 3,
  242. text: '完成'
  243. }
  244. ],
  245. check: [{
  246. value: 0,
  247. text: '待接收'
  248. },
  249. {
  250. value: 1,
  251. text: '执行中'
  252. },
  253. {
  254. value: 2,
  255. text: '待审核'
  256. },
  257. {
  258. value: 3,
  259. text: '完成'
  260. },
  261. {
  262. value: 4,
  263. text: '已撤回'
  264. },
  265. {
  266. value: 5,
  267. text: '待验收'
  268. },
  269. {
  270. value: 6,
  271. text: '已驳回'
  272. },
  273. {
  274. value: 7,
  275. text: '未修复'
  276. },
  277. {
  278. value: 8,
  279. text: '已派单'
  280. }
  281. ]
  282. },
  283. searchFrom: {
  284. code: '',
  285. orderStatus: []
  286. },
  287. page: 1,
  288. isInstall: true, // 是否首次进入页面
  289. orderType: 1,
  290. codeData: [],
  291. }
  292. },
  293. onLoad(e) {
  294. this.$nextTick(() => {
  295. console.log(this)
  296. this.isInstall = false
  297. this.orderType = e.orderType // 1待办 2完成
  298. this.tabsCurrent = Number(e.index) ? Number(e.index) : 0
  299. this.$nextTick(async () => {
  300. if (this.orderType == 1) {
  301. await this.getCount()
  302. }
  303. this.handleTabChange(this.tabList[this.tabsCurrent])
  304. })
  305. })
  306. },
  307. onShow(e) {
  308. if (this.isInstall) return
  309. this.dataList = []
  310. this.getList()
  311. this.getCount()
  312. },
  313. methods: {
  314. // 相机扫码
  315. HandlScanCode() {
  316. // uni.scanCode({
  317. // success: res => {
  318. // let obj = {}
  319. // if (res.result.includes('&')) {
  320. // this.dataArray = res.result.split('&')
  321. // console.log(this.dataArray, 'this.dataArray')
  322. // obj = {
  323. // fixCode: this.dataArray[0],
  324. // code: ''
  325. // }
  326. // } else {
  327. // obj = {
  328. // fixCode: '',
  329. // code: res.result
  330. // }
  331. // }
  332. // console.log(obj,'obj')
  333. // getByFixCode(obj).then(res => {
  334. // uni.navigateTo({
  335. // url: `/pages/home/myTicket/detail?deviceId=${res.id}&type=${this.tabList[this.activeIndex].workOrderType}&codes=${this.dataArray[1]}`
  336. // })
  337. // })
  338. // }
  339. // })
  340. uni.scanCode({
  341. success: res => {
  342. console.log(res.result)
  343. let obj = {}
  344. if (res.result.includes('&')) {
  345. this.codeData = res.result.split('&')
  346. obj = {
  347. fixCode: '',
  348. code: this.codeData[0]
  349. }
  350. } else if (res.result.includes('/')) {
  351. let dataArray = res.result.split('/')
  352. obj = {
  353. fixCode: dataArray[0],
  354. code: ''
  355. }
  356. } else {
  357. obj = {
  358. fixCode: '',
  359. code: res.result
  360. }
  361. }
  362. getByFixCode(obj).then(res => {
  363. let params = {
  364. type: this.tabList[this.activeIndex].workOrderType,
  365. deviceId: res.id
  366. }
  367. deviceListQrCode(params).then(data => {
  368. if (data.length > 1) {
  369. uni.navigateTo({
  370. url: `/pages/home/myTicket/detail?deviceId=${res.id}&type=${this.tabList[this.activeIndex].workOrderType}`
  371. })
  372. } else {
  373. uni.navigateTo({
  374. url: `/pages/tour_tally/check/index?id=${data[0].id}&codes=${this.codeData[1]}`
  375. })
  376. }
  377. })
  378. })
  379. }
  380. })
  381. },
  382. // 紧急度选择
  383. doneChange(id) {},
  384. doSearch() {
  385. this.dataList = []
  386. this.page = 1
  387. this.getList()
  388. this.searchShow = false
  389. },
  390. reset() {
  391. this.searchFrom = {
  392. code: '',
  393. orderStatus: []
  394. }
  395. if (this.orderType == 1) {
  396. // 待办 执行中
  397. this.searchFrom.orderStatus = [0, 2, 3]
  398. } else {
  399. // 已完成
  400. this.searchFrom.orderStatus = [4]
  401. }
  402. this.doSearch()
  403. },
  404. statusChange(value) {
  405. console.log(value)
  406. this.searchFrom.orderStatus = value
  407. },
  408. handleDetail(item) {
  409. let url = this.tabList[this.activeIndex]?.url
  410. if (!url) return
  411. // url += `id=${item.id}&workOrderCode=${item.workOrderCode}&BizType=${item.bizType}`
  412. url += `id=${item.id}&planId=${item.planId}&code=${item.code}&&orderType=${this.orderType}`
  413. console.log(url)
  414. uni.navigateTo({
  415. url
  416. })
  417. },
  418. scrolltolower() {
  419. if (isEnd) return
  420. this.page++
  421. this.getList()
  422. },
  423. handleTabChange(item) {
  424. console.log(item, 'mmmmm')
  425. console.log(item)
  426. this.activeType = item.type
  427. this.activeIndex = item.index
  428. this.dataList = []
  429. this.page = 1
  430. this.reset()
  431. this.searchShow = false
  432. },
  433. getCount() {
  434. statistics().then(data => {
  435. console.log('onsole.log(data)-----------')
  436. console.log(data)
  437. this.tabList = this.tabList.map(item => {
  438. switch (item.type) {
  439. case 'maintenance':
  440. return {
  441. ...item, badge: {
  442. value: data.maintenanceNum
  443. }
  444. }
  445. case 'patrol':
  446. return {
  447. ...item, badge: {
  448. value: data.patrolInspection
  449. }
  450. }
  451. case 'quantity':
  452. return {
  453. ...item, badge: {
  454. value: data.quantityNum
  455. }
  456. }
  457. case 'repair':
  458. return {
  459. ...item, badge: {
  460. value: data.repairsNum
  461. }
  462. }
  463. }
  464. })
  465. })
  466. // Promise.all(
  467. // this.tabList.map(item =>
  468. // getWorkOrderList(
  469. // {
  470. // type: item.workOrderType
  471. // },
  472. // false
  473. // )
  474. // )
  475. // ).then(res => {
  476. // res.forEach((item, index) => {
  477. // console.log(item)
  478. // // if (item?.success) {
  479. // // this.tabList[index].badge.value = item.data.count
  480. // // }
  481. // })
  482. // })
  483. },
  484. getList() {
  485. uni.showLoading({
  486. title: '加载中'
  487. })
  488. console.log('this.searchFrom-----------------')
  489. console.log(this.searchFrom)
  490. const params = {
  491. type: this.tabList[this.activeIndex].workOrderType,
  492. pageNum: this.page,
  493. size: 10,
  494. ...this.searchFrom
  495. }
  496. // 维修
  497. if (this.tabList[this.activeIndex].workOrderType == 3) {
  498. let userInfo = uni.getStorageSync('userInfo')
  499. params.executeUserId = userInfo.userId
  500. if (this.orderType == 1) {
  501. if (!params.orderStatus.includes(3)) {
  502. params.orderStatus.push(3)
  503. }
  504. }
  505. } else {
  506. if (this.orderType == 1) {
  507. if (params.orderStatus.includes(3)) {
  508. let index = params.orderStatus.indexOf(3)
  509. params.orderStatus.splice(index, 1)
  510. }
  511. } else {
  512. params.orderStatus = [3]
  513. }
  514. }
  515. isEnd = false
  516. console.log(params);
  517. getWorkOrderList(params)
  518. .then(res => {
  519. if (res.list?.length > 0 && params.type === this.tabList[this.activeIndex].workOrderType) {
  520. // if (params.page === 1) {
  521. // this.dataList = []
  522. // }
  523. // this.dataList.push(...res.data.list.records)
  524. this.dataList = this.dataList.concat(res.list)
  525. isEnd = this.dataList.length >= res.count
  526. } else {
  527. this.dataList = []
  528. }
  529. console.log(this.dataList)
  530. uni.hideLoading()
  531. })
  532. .catch(() => {
  533. uni.hideLoading()
  534. })
  535. }
  536. //(1:巡点检;2:保养;3:维修;4:盘点)
  537. // _getMyWorkOrderList(params, loading = true) {
  538. // let str = ''
  539. // for (let key in params) {
  540. // str += '&' + key + '=' + params[key]
  541. // }
  542. // return postJ(this.apiUrl + `/eam/PdaWorkOrder/list?${str.substr(1)}`, {}, loading)
  543. // }
  544. }
  545. }
  546. </script>
  547. <style lang="scss" scoped>
  548. scroll-view ::v-deep ::-webkit-scrollbar {
  549. width: 0;
  550. height: 0;
  551. color: transparent;
  552. }
  553. .scan_btn {
  554. background: url('../../../static/scan.png');
  555. background-size: 100% 100%;
  556. background-repeat: no-repeat;
  557. width: 50rpx;
  558. height: 50rpx;
  559. }
  560. .kd-work-container {
  561. height: 100vh;
  562. overflow: hidden;
  563. display: flex;
  564. flex-direction: column;
  565. .work-list {
  566. flex: 1;
  567. overflow: hidden;
  568. padding: 0 24rpx 16rpx 24rpx;
  569. background-color: $page-bg;
  570. .u-list {
  571. height: 100% !important;
  572. }
  573. }
  574. .nodata {
  575. font-size: 40rpx;
  576. text-align: center;
  577. padding-top: 30rpx;
  578. }
  579. }
  580. .top-wrapper {
  581. display: flex;
  582. align-items: center;
  583. background-color: #fff;
  584. position: relative;
  585. .tab_box {
  586. width: 100%;
  587. height: 68rpx;
  588. .tab_item {
  589. height: 68rpx;
  590. line-height: 68rpx;
  591. padding: 0 20rpx;
  592. font-size: 32rpx;
  593. // color: #979C9E;
  594. }
  595. .active {
  596. box-sizing: border-box;
  597. border-bottom: 6rpx solid $theme-color;
  598. color: $theme-color;
  599. }
  600. }
  601. .slide-search {
  602. position: absolute;
  603. top: 100%;
  604. left: 0;
  605. right: 0;
  606. z-index: 10;
  607. background-color: #fff;
  608. .timerange {
  609. width: 90%;
  610. margin: 0 auto 10rpx;
  611. }
  612. .select-box {
  613. display: flex;
  614. padding: 0 10rpx;
  615. .uni-stat__select+.uni-stat__select {
  616. margin-left: 10rpx;
  617. }
  618. }
  619. .more-search {
  620. padding-bottom: 20rpx;
  621. .cell {
  622. display: flex;
  623. align-items: center;
  624. padding-right: 20rpx;
  625. &+.cell {
  626. margin-top: 10rpx;
  627. }
  628. /deep/uni-input {
  629. flex: 1;
  630. height: 70rpx;
  631. border: 1rpx solid #e5e5e5;
  632. border-radius: 8rpx;
  633. font-size: 28rpx;
  634. padding-left: 20rpx;
  635. box-sizing: border-box;
  636. }
  637. .label {
  638. width: 180rpx;
  639. text-align: right;
  640. padding-right: 20rpx;
  641. }
  642. }
  643. /deep/.uni-date__x-input {
  644. height: 70rpx !important;
  645. }
  646. .btn-search {
  647. text-align: right;
  648. padding: 10rpx 10rpx 0;
  649. button {
  650. display: inline-block;
  651. width: 200rpx;
  652. height: 60rpx;
  653. line-height: 58rpx;
  654. font-size: 28rpx;
  655. margin-left: 20rpx;
  656. &.primary {
  657. background-color: $j-primary-border-green;
  658. color: #fff;
  659. }
  660. }
  661. }
  662. }
  663. }
  664. .top-tabs {
  665. flex: 1;
  666. }
  667. .more_search {
  668. padding: 0 20rpx;
  669. }
  670. /deep/.u-input {
  671. border: 1rpx solid #ccc;
  672. .u-input__content__field-wrapper__field {
  673. height: 40rpx !important;
  674. }
  675. }
  676. image {
  677. width: 52rpx;
  678. height: 52rpx;
  679. margin-left: 10rpx;
  680. }
  681. }
  682. .search_list {
  683. min-height: 100rpx;
  684. /deep/ .baseForm {
  685. padding: 10rpx 20rpx;
  686. }
  687. }
  688. .operate_box {
  689. padding: 10rpx;
  690. box-sizing: border-box;
  691. }
  692. .mg-20 {
  693. margin-right: 20rpx;
  694. }
  695. </style>