69 lines
2.0 KiB
Vue
69 lines
2.0 KiB
Vue
<template>
|
|
<el-dialog title="下载桌码" width="400px" :visible.sync="dialogVisible" @open="reset">
|
|
<el-form ref="form" :model="form" label-position="left">
|
|
<el-form-item label="下载数量">
|
|
<el-input-number v-model="form.number" :min="1" :max="total * 2"></el-input-number>
|
|
</el-form-item>
|
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
<el-button type="primary" :loading="loading" @click="onSubmitHandle">下 载</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import { downloadFile } from "@/utils/index";
|
|
import { downloadTableCode } from '@/api/table'
|
|
export default {
|
|
props: {
|
|
total: {
|
|
type: [Number, String],
|
|
default: 1
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
dialogVisible: false,
|
|
loading: false,
|
|
form: {
|
|
number: 1
|
|
},
|
|
resetForm: ''
|
|
}
|
|
},
|
|
mounted() {
|
|
this.resetForm = { ...this.form }
|
|
},
|
|
methods: {
|
|
async onSubmitHandle() {
|
|
try {
|
|
this.loading = true
|
|
const file = await downloadTableCode({
|
|
count: this.form.number,
|
|
shopId: localStorage.getItem('shopId')
|
|
})
|
|
this.loading = false
|
|
this.dialogVisible = false
|
|
this.$message.success('下载成功')
|
|
downloadFile(file, "桌码", "zip");
|
|
} catch (error) {
|
|
this.loading = false
|
|
console.log(error);
|
|
}
|
|
},
|
|
show(obj) {
|
|
this.dialogVisible = true
|
|
// if (obj && obj.id) {
|
|
// this.form = JSON.parse(JSON.stringify(obj))
|
|
// }
|
|
},
|
|
close() {
|
|
this.dialogVisible = false
|
|
},
|
|
reset() {
|
|
this.form = { ...this.resetForm }
|
|
}
|
|
}
|
|
}
|
|
</script> |