| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <view>
- <uni-nav-bar
- fixed="true"
- statusBar="true"
- left-icon="back"
- title="维修工单"
- @clickLeft="back"
- right-icon="scan"
- @clickRight="HandlScanCode"
- ></uni-nav-bar>
- <template>
- <view class="tab-title">
- <view
- v-for="(item, index) in tabList"
- :key="index"
- class="tab-item"
- :class="index === pickTabIndex ? 'active' : ''"
- @click="changeChartsTab(index)"
- >
- {{ item.label }}
- <text v-if="index == 0" class="title-red">{{ item.number }}</text>
- <text v-else class="title-num">({{ item.number }})</text>
- </view>
- </view>
- <view class="tab-title__placeholder"></view>
- </template>
- <OrderTask
- v-for="(item, index) in tabList"
- :key="index"
- v-show="index === pickTabIndex"
- :list="item.list"
- :type="tabList.value"
- >
- </OrderTask>
- </view>
- </template>
- <script>
- import OrderTask from './OrderTask.vue'
- import { post, postJ } from '@/utils/api.js'
- let [page, size, isEnd] = [1, 10, true]
- export default {
- components: {
- OrderTask
- },
- data () {
- return {
- tabList: [
- {
- value: 0,
- label: '待执行',
- list: [],
- number: 0
- },
- {
- value: 1,
- label: '执行中',
- list: [],
- number: 0
- },
- {
- value: 2,
- label: '已报工',
- list: [],
- number: 0
- }
- ],
- pickTabIndex: 0,
- qrContent: null,
- barType: 0
- }
- },
- onShow () {
- this.getFirstList()
- this.getStatus()
- let _this = this
- uni.$off('scancode') // 每次进来先 移除全局自定义事件监听器
- uni.$on('scancode', function (data) {
- _this.qrContent = data.code.trim()
- let index = _this.qrContent.indexOf('@_@')
- if (index == -1) {
- _this.barType = 0
- } else {
- _this.barType = _this.qrContent.substring(index + 3, index + 4)
- }
- _this.getData()
- })
- },
- onReachBottom: function () {
- if (isEnd) {
- return
- }
- // 显示加载图标
- uni.showLoading({
- title: '数据加载中'
- })
- this.getMoreLists()
- },
- methods: {
- getStatus () {
- postJ(this.apiUrl + `/workOrder/getWorkOrderTotal`, {
- workOrderType: 3
- }).then(res => {
- let data = res.data
- this.tabList[0].number = data.waitExecutionNum
- this.tabList[1].number = data.executoryNum
- this.tabList[2].number = data.finishNum
- })
- },
- // 扫码
- HandlScanCode () {
- uni.navigateTo({
- url: '/pages/ScanCode/ScanCode'
- })
- },
- // 根据条码请求设备数据
- getData () {
- let par = {
- barType: this.barType,
- qrContent: this.qrContent
- }
- postJ(this.apiUrl + '/scan/getAssetInfo', par).then(res => {
- let data = res.data
- this.matchEquipment(data)
- })
- },
- matchEquipment (data) {
- let par = {
- EquiCode: data.assetCode
- }
- console.log('par', par)
- post(this.apiUrl + '/workOrder/getWorkOrderByEquiCode', par).then(res => {
- let data = res.data
- if (!data) {
- uni.showModal({
- title: '提示',
- content: '该设备无维修工单记录!',
- confirmText: '好的', //这块是确定按钮的文字
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- // 执行确认后的操作
- } else {
- // 执行取消后的操作
- }
- }
- })
- } else {
- uni.navigateTo({
- url: `/pages/maintain_service/detail/detail?workOrderCode=${data}`
- })
- }
- })
- },
- getFirstList: function () {
- page = 1
- isEnd = true
- uni.showLoading({
- title: '数据加载中'
- })
- this.getList()
- },
- getMoreLists: function () {
- //获取更多数据
- page++
- this.getList()
- },
- getList () {
- uni.showLoading({
- title: '加载中'
- })
- let data = {
- page,
- size
- }
- let searchStatus = this.tabList[this.pickTabIndex].value
- let par = this.URLSearchParams(data)
- //2 - 99 [已完成]
- postJ(this.apiUrl + '/repair/info/getWorkOrderList?' + par, {
- searchStatus,
- workOrderType: 3,
- page,
- size
- })
- .then(res => {
- let data = res.data.records
- let pageTotal = res.data.pages
- if (page === 1) {
- this.tabList[this.pickTabIndex].list = res.data.records
- } else {
- data.forEach(element => {
- this.tabList[this.pickTabIndex].list.push(element)
- })
- }
- page < pageTotal ? (isEnd = false) : (isEnd = true)
- })
- .then(() => {
- uni.hideLoading()
- })
- },
- changeChartsTab (index) {
- this.pickTabIndex = index
- this.getFirstList()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .tab-title {
- position: fixed;
- z-index: 99;
- width: 100%;
- padding: 0 30rpx 10rpx;
- // display: flex;
- // justify-content: space-between;
- height: $tab-height;
- line-height: $tab-height;
- background-color: #ffffff;
- border-bottom: 1px solid #f2f2f2;
- // box-sizing: border-box;
- white-space: nowrap;
- overflow: auto hidden;
- &::-webkit-scrollbar {
- /*滚动条整体样式*/
- width: 10px;
- /*高宽分别对应横竖滚动条的尺寸*/
- height: 1px;
- }
- &::-webkit-scrollbar-thumb {
- /*滚动条里面小方块*/
- border-radius: 10px;
- -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
- background: #535353;
- }
- &::-webkit-scrollbar-track {
- /*滚动条里面轨道*/
- -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
- border-radius: 10px;
- background: #ededed;
- }
- .tab-item {
- width: 30%;
- text-align: center;
- display: inline-block;
- font-size: 32rpx;
- color: $uni-text-color-grey;
- }
- .tab-item.active {
- color: $j-primary-border-green;
- border-bottom: 1px solid $j-primary-border-green;
- }
- .title-num {
- font-size: 26rpx;
- }
- .title-red {
- display: inline-block;
- font-size: 22rpx;
- padding: 0 10rpx;
- border-radius: 50rpx;
- color: #ffffff;
- background: red;
- line-height: 38rpx;
- position: absolute;
- top: 10rpx;
- min-width: 18rpx;
- }
- }
- </style>
|