Commit 84df2036 authored by Facius's avatar Facius

feat: 导出维修账单

parent cd001626
Pipeline #2926 canceled with stages
...@@ -44,7 +44,7 @@ export async function repair(data) { ...@@ -44,7 +44,7 @@ export async function repair(data) {
export async function repairExport(data) { export async function repairExport(data) {
return request({ return request({
url: `/rest/repair/export`, url: `/rest/repair/export`,
method: 'GET', method: 'POST',
data, data,
noLoading: true noLoading: true
}) })
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</view> </view>
<view class="buttons-view"> <view class="buttons-view">
<view class="right-view"> <view class="right-view">
<u-button :custom-style="customConFirm" @click="handleClickConfirm"> <u-button :custom-style="customConFirm" @click="handleClickConfirm" :loading="loading">
<view class="confirm-view">{{ confirmText }}</view> <view class="confirm-view">{{ confirmText }}</view>
</u-button> </u-button>
</view> </view>
...@@ -74,12 +74,14 @@ export default { ...@@ -74,12 +74,14 @@ export default {
return { return {
show: false, show: false,
daterange: [], daterange: [],
currentIndex: 1 currentIndex: 1,
loading: false
} }
}, },
watch: { watch: {
visible(val) { visible(val) {
this.show = val this.show = val
this.loading = false
}, },
}, },
computed: { computed: {
...@@ -120,8 +122,9 @@ export default { ...@@ -120,8 +122,9 @@ export default {
this.$emit('update:visible', val) this.$emit('update:visible', val)
}, },
handleClickConfirm() { handleClickConfirm() {
this.changeVisibleValue(false) // this.changeVisibleValue(false)
this.$emit('confirm', this.currentIndex == 0 ? [] : this.daterange) this.loading = true
this.$emit('confirm', this.currentIndex == 0 ? null : this.daterange)
}, },
handleClose() { handleClose() {
this.changeVisibleValue(false) this.changeVisibleValue(false)
......
...@@ -135,8 +135,8 @@ export default { ...@@ -135,8 +135,8 @@ export default {
}, },
handleClickConfirm(range) { handleClickConfirm(range) {
console.log(range); console.log(range);
let startTime = ''; let startTime = null;
let endTime = ''; let endTime = null;
if (range) { if (range) {
startTime = range[0]; startTime = range[0];
endTime = range[1]; endTime = range[1];
......
...@@ -156,7 +156,7 @@ import { ...@@ -156,7 +156,7 @@ import {
repairSettle, repairSettle,
repairSync, repairSync,
repairDelete, repairDelete,
repairSend, repairSend
} from '@/api/maintain/index.js' } from '@/api/maintain/index.js'
export default { export default {
...@@ -492,7 +492,6 @@ export default { ...@@ -492,7 +492,6 @@ export default {
var index = 0 var index = 0
for (var item of pages) { for (var item of pages) {
if (item.route.indexOf('pages/maintain-bill/index') != -1) { if (item.route.indexOf('pages/maintain-bill/index') != -1) {
console.log('---back----', pages.length - index)
uni.navigateBack({ uni.navigateBack({
delta: pages.length - index - 1, delta: pages.length - index - 1,
}) })
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
text="导出账单" text="导出账单"
imageWidth="20" imageWidth="20"
:image="outImage" :image="outImage"
@click="handlClickOut" @click="handlClicExport"
/> />
<view class="search-bar"> <view class="search-bar">
<u-search <u-search
...@@ -86,15 +86,12 @@ ...@@ -86,15 +86,12 @@
:image="currentNoData.image" :image="currentNoData.image"
:text="currentNoData.text" :text="currentNoData.text"
/> />
</scroll-view>
</view>
<view class="loading-view" v-if="loading && !_freshing" <view class="loading-view" v-if="loading && !_freshing"
><u-loading mode="flower"></u-loading ><u-loading mode="flower"></u-loading
></view> ></view>
</scroll-view> <PopExport :visible.sync="visible" @confirm="handleClickConfirm" />
</view>
<PopExport
:visible.sync="visible"
@confirm="handleClickConfirm"
/>
<FabView @click="handleClickFab" /> <FabView @click="handleClickFab" />
<u-toast ref="uToast" /> <u-toast ref="uToast" />
</view> </view>
...@@ -108,6 +105,7 @@ import FabView from '@/components/fab-view' ...@@ -108,6 +105,7 @@ import FabView from '@/components/fab-view'
import NoData from '@/components/no-data' import NoData from '@/components/no-data'
import PopExport from '@/components/pop-export-bill' import PopExport from '@/components/pop-export-bill'
import { repairExport, repair } from '@/api/maintain/index.js' import { repairExport, repair } from '@/api/maintain/index.js'
import { downLoad } from '@/utils/download.js'
export default { export default {
components: { components: {
...@@ -166,10 +164,14 @@ export default { ...@@ -166,10 +164,14 @@ export default {
: '' : ''
}, },
start() { start() {
return this.daterange.length > 0 && this.daterange[0] ? this.daterange[0] + ' 00:00:00' : '' return this.daterange.length > 0 && this.daterange[0]
? this.daterange[0] + ' 00:00:00'
: ''
}, },
end() { end() {
return this.daterange.length > 0 && this.daterange[1] ? this.daterange[1] + ' 00:00:00' : '' return this.daterange.length > 0 && this.daterange[1]
? this.daterange[1] + ' 00:00:00'
: ''
}, },
}, },
onLoad() { onLoad() {
...@@ -281,11 +283,43 @@ export default { ...@@ -281,11 +283,43 @@ export default {
params: {}, params: {},
}) })
}, },
handlClickOut() { handlClicExport() {
this.visible = true this.visible = true
}, },
handleClickConfirm(range) { handleClickConfirm(range) {
var param = {
end: null,
start: null,
}
if (range) {
param = {
end: range[0] + ' 00:00:00',
start: range[1] + ' 00:00:00',
}
}
// 导出 // 导出
repairExport(param)
.then((res) => {
if (res) {
this.saveFile(res)
}
this.loading = false
})
.catch((res) => {
if (res) {
this.saveFile(res)
}
this.loading = false
})
},
async saveFile(file) {
try {
let res = await downLoad(file)
this.visible = false
} catch (e) {
this.visible = false
console.log('saveFile_error', e)
}
}, },
}, },
} }
...@@ -374,6 +408,7 @@ export default { ...@@ -374,6 +408,7 @@ export default {
.load-more-view { .load-more-view {
padding-bottom: 44rpx; padding-bottom: 44rpx;
} }
}
.loading-view { .loading-view {
width: 100%; width: 100%;
background-color: transparent; background-color: transparent;
...@@ -384,6 +419,5 @@ export default { ...@@ -384,6 +419,5 @@ export default {
left: 0; left: 0;
position: fixed; position: fixed;
} }
}
} }
</style> </style>
...@@ -237,8 +237,7 @@ export default { ...@@ -237,8 +237,7 @@ export default {
}, },
onReady() {}, onReady() {},
onUnload() {}, onUnload() {},
onShow() { onShow() {},
},
methods: { methods: {
repairDetail() { repairDetail() {
this.loading = true this.loading = true
...@@ -322,7 +321,7 @@ export default { ...@@ -322,7 +321,7 @@ export default {
.then((res) => { .then((res) => {
if (res.code == 0) { if (res.code == 0) {
uni.$emit('maintain-bill-detail') uni.$emit('maintain-bill-detail')
this.toDetailPage() this.toPage()
this.buttonLoading = false this.buttonLoading = false
} }
}) })
...@@ -330,6 +329,21 @@ export default { ...@@ -330,6 +329,21 @@ export default {
this.buttonLoading = false this.buttonLoading = false
}) })
}, },
toPage() {
var pages = getCurrentPages()
var index = 0
for (var item of pages) {
if (item.route.indexOf('pages/maintain-bill/detail') != -1) {
uni.navigateBack({
delta: pages.length - index - 1,
})
return
}
index++
}
// 回首页
this.toDetailPage()
},
toDetailPage() { toDetailPage() {
this.$u.route({ this.$u.route({
url: 'pages/maintain-bill/detail', url: 'pages/maintain-bill/detail',
...@@ -340,7 +354,7 @@ export default { ...@@ -340,7 +354,7 @@ export default {
}) })
}, },
handleClickSkip(date) { handleClickSkip(date) {
this.toDetailPage() this.toPage()
}, },
handleClickSure() { handleClickSure() {
this.editeRepair() this.editeRepair()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment