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) {
export async function repairExport(data) {
return request({
url: `/rest/repair/export`,
method: 'GET',
method: 'POST',
data,
noLoading: true
})
......
......@@ -40,7 +40,7 @@
</view>
<view class="buttons-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>
</u-button>
</view>
......@@ -74,12 +74,14 @@ export default {
return {
show: false,
daterange: [],
currentIndex: 1
currentIndex: 1,
loading: false
}
},
watch: {
visible(val) {
this.show = val
this.loading = false
},
},
computed: {
......@@ -120,8 +122,9 @@ export default {
this.$emit('update:visible', val)
},
handleClickConfirm() {
this.changeVisibleValue(false)
this.$emit('confirm', this.currentIndex == 0 ? [] : this.daterange)
// this.changeVisibleValue(false)
this.loading = true
this.$emit('confirm', this.currentIndex == 0 ? null : this.daterange)
},
handleClose() {
this.changeVisibleValue(false)
......
......@@ -135,8 +135,8 @@ export default {
},
handleClickConfirm(range) {
console.log(range);
let startTime = '';
let endTime = '';
let startTime = null;
let endTime = null;
if (range) {
startTime = range[0];
endTime = range[1];
......
......@@ -156,7 +156,7 @@ import {
repairSettle,
repairSync,
repairDelete,
repairSend,
repairSend
} from '@/api/maintain/index.js'
export default {
......@@ -492,7 +492,6 @@ export default {
var index = 0
for (var item of pages) {
if (item.route.indexOf('pages/maintain-bill/index') != -1) {
console.log('---back----', pages.length - index)
uni.navigateBack({
delta: pages.length - index - 1,
})
......
......@@ -6,7 +6,7 @@
text="导出账单"
imageWidth="20"
:image="outImage"
@click="handlClickOut"
@click="handlClicExport"
/>
<view class="search-bar">
<u-search
......@@ -86,17 +86,14 @@
:image="currentNoData.image"
:text="currentNoData.text"
/>
<view class="loading-view" v-if="loading && !_freshing"
><u-loading mode="flower"></u-loading
></view>
</scroll-view>
</view>
<PopExport
:visible.sync="visible"
@confirm="handleClickConfirm"
/>
<view class="loading-view" v-if="loading && !_freshing"
><u-loading mode="flower"></u-loading
></view>
<PopExport :visible.sync="visible" @confirm="handleClickConfirm" />
<FabView @click="handleClickFab" />
<u-toast ref="uToast" />
<u-toast ref="uToast" />
</view>
</template>
......@@ -108,6 +105,7 @@ import FabView from '@/components/fab-view'
import NoData from '@/components/no-data'
import PopExport from '@/components/pop-export-bill'
import { repairExport, repair } from '@/api/maintain/index.js'
import { downLoad } from '@/utils/download.js'
export default {
components: {
......@@ -166,10 +164,14 @@ export default {
: ''
},
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() {
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() {
......@@ -281,11 +283,43 @@ export default {
params: {},
})
},
handlClickOut() {
handlClicExport() {
this.visible = true
},
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,16 +408,16 @@ export default {
.load-more-view {
padding-bottom: 44rpx;
}
.loading-view {
width: 100%;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
top: 50%;
left: 0;
position: fixed;
}
}
.loading-view {
width: 100%;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
top: 50%;
left: 0;
position: fixed;
}
}
</style>
......@@ -128,7 +128,7 @@
confirmText="确认"
content="确认删除该条明细吗?"
/>
<u-toast ref="uToast" />
<u-toast ref="uToast" />
</view>
</template>
......@@ -237,8 +237,7 @@ export default {
},
onReady() {},
onUnload() {},
onShow() {
},
onShow() {},
methods: {
repairDetail() {
this.loading = true
......@@ -322,7 +321,7 @@ export default {
.then((res) => {
if (res.code == 0) {
uni.$emit('maintain-bill-detail')
this.toDetailPage()
this.toPage()
this.buttonLoading = false
}
})
......@@ -330,6 +329,21 @@ export default {
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() {
this.$u.route({
url: 'pages/maintain-bill/detail',
......@@ -340,7 +354,7 @@ export default {
})
},
handleClickSkip(date) {
this.toDetailPage()
this.toPage()
},
handleClickSure() {
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