myTicket.vue 16 KB

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