清美业务每日数据增加导入功能。
This commit is contained in:
@@ -37,3 +37,19 @@ export function deleteLbDailyUserTrade(id) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function importLbDailyUserTrade(file, defaultReportDate) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
if (defaultReportDate) {
|
||||
formData.append('defaultReportDate', defaultReportDate)
|
||||
}
|
||||
return request({
|
||||
url: '/lbDailyUserTrade/import',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
<el-card class="action-container" shadow="never">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
||||
<el-button type="success" icon="el-icon-upload2" :loading="importLoading" @click="openImportDialog">导入数据</el-button>
|
||||
</el-card>
|
||||
|
||||
<el-card class="table-container" shadow="never">
|
||||
@@ -129,6 +130,42 @@
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="导入当天交易数据" :visible.sync="importDialogVisible" width="520px" @close="resetImportForm">
|
||||
<el-form ref="importFormRef" :model="importForm" :rules="importRules" label-width="120px">
|
||||
<el-form-item label="Excel文件" prop="file">
|
||||
<el-upload
|
||||
ref="importUploadRef"
|
||||
drag
|
||||
action="#"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
:on-change="handleImportFileChange"
|
||||
:on-remove="handleImportFileRemove"
|
||||
:file-list="importFileList"
|
||||
:http-request="() => {}"
|
||||
accept=".xls,.xlsx"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div slot="tip" class="el-upload__tip">仅支持 .xls/.xlsx 格式</div>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="默认报表日期">
|
||||
<el-date-picker
|
||||
v-model="importForm.defaultReportDate"
|
||||
type="date"
|
||||
placeholder="可选,格式 yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="importDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="importLoading" @click="submitImport">开始导入</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -137,6 +174,7 @@ import {
|
||||
addLbDailyUserTrade,
|
||||
deleteLbDailyUserTrade,
|
||||
getLbDailyUserTradeList,
|
||||
importLbDailyUserTrade,
|
||||
updateLbDailyUserTrade
|
||||
} from '@/api/lb-daily-user-trade'
|
||||
|
||||
@@ -146,11 +184,14 @@ export default {
|
||||
return {
|
||||
loading: false,
|
||||
submitLoading: false,
|
||||
importLoading: false,
|
||||
list: [],
|
||||
total: 0,
|
||||
dialogVisible: false,
|
||||
importDialogVisible: false,
|
||||
dialogTitle: '',
|
||||
isEdit: false,
|
||||
importFileList: [],
|
||||
queryParams: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
@@ -177,6 +218,13 @@ export default {
|
||||
formRules: {
|
||||
tenantId: [{ required: true, message: '请输入租户ID', trigger: 'blur' }],
|
||||
userId: [{ required: true, message: '请输入用户ID', trigger: 'blur' }]
|
||||
},
|
||||
importForm: {
|
||||
file: null,
|
||||
defaultReportDate: ''
|
||||
},
|
||||
importRules: {
|
||||
file: [{ required: true, message: '请上传Excel文件', trigger: 'change' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -288,6 +336,46 @@ export default {
|
||||
this.fetchList()
|
||||
}).catch(() => {})
|
||||
},
|
||||
openImportDialog() {
|
||||
this.importDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.importFormRef) this.$refs.importFormRef.clearValidate()
|
||||
})
|
||||
},
|
||||
handleImportFileChange(file, fileList) {
|
||||
this.importFileList = fileList.slice(-1)
|
||||
this.importForm.file = this.importFileList.length > 0 ? this.importFileList[0].raw : null
|
||||
if (this.$refs.importFormRef) this.$refs.importFormRef.validateField('file')
|
||||
},
|
||||
handleImportFileRemove(file, fileList) {
|
||||
this.importFileList = fileList
|
||||
this.importForm.file = null
|
||||
if (this.$refs.importFormRef) this.$refs.importFormRef.validateField('file')
|
||||
},
|
||||
submitImport() {
|
||||
this.$refs.importFormRef.validate((valid) => {
|
||||
if (!valid) return
|
||||
this.importLoading = true
|
||||
importLbDailyUserTrade(this.importForm.file, this.importForm.defaultReportDate)
|
||||
.then((res) => {
|
||||
this.$message.success(res.message || '导入成功')
|
||||
this.importDialogVisible = false
|
||||
this.fetchList()
|
||||
})
|
||||
.finally(() => {
|
||||
this.importLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
resetImportForm() {
|
||||
if (this.$refs.importFormRef) this.$refs.importFormRef.resetFields()
|
||||
if (this.$refs.importUploadRef) this.$refs.importUploadRef.clearFiles()
|
||||
this.importFileList = []
|
||||
this.importForm = {
|
||||
file: null,
|
||||
defaultReportDate: ''
|
||||
}
|
||||
},
|
||||
handleSubmit() {
|
||||
this.$refs.dataForm.validate((valid) => {
|
||||
if (!valid) return
|
||||
|
||||
Reference in New Issue
Block a user