|
@@ -1,43 +1,66 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
:visible.sync="visible"
|
|
|
+ title="导入数据"
|
|
|
append-to-body
|
|
|
- width="600px"
|
|
|
+ width="450px"
|
|
|
>
|
|
|
- <el-form ref="form" :model="uploadData" style="height:280px">
|
|
|
- <div class="flex center">
|
|
|
- <el-form-item prop="file" :rules="[{
|
|
|
- required: true,
|
|
|
- message: '请选择需要上传的文件'
|
|
|
- }]" style="width:360px;">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :model="uploadData"
|
|
|
+ label-width="80px"
|
|
|
+ style="height:200px"
|
|
|
+ >
|
|
|
+ <el-row :gutter="0">
|
|
|
+ <el-col :span="20">
|
|
|
+ <el-form-item prop="providerId" label="供应商" :rules="[{
|
|
|
+ required: true,
|
|
|
+ message: '请选择供应商'
|
|
|
+ }]">
|
|
|
+ <my-select
|
|
|
+ v-model="uploadData.providerId"
|
|
|
+ :options="providers"
|
|
|
+ filterable
|
|
|
+ placeholder="输入供应商全名或缩写"
|
|
|
+ ></my-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
|
|
|
- <el-upload
|
|
|
- ref="upload"
|
|
|
- drag
|
|
|
- action=""
|
|
|
- :auto-upload="false"
|
|
|
- :multiple="false"
|
|
|
- accept=".csv,.xlsx"
|
|
|
- :on-change="onFileChange"
|
|
|
- >
|
|
|
- <i class="el-icon-upload"></i>
|
|
|
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
- <div class="el-upload__tip" slot="tip">只能上传csv/excel文件</div>
|
|
|
- </el-upload>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
+ <el-row :gutter="0">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item prop="file" label="上传文件" :rules="[{
|
|
|
+ required: true,
|
|
|
+ message: '请选择需要上传的文件'
|
|
|
+ }]">
|
|
|
+ <el-input :value="uploadData.file ? uploadData.file.name : ''" read-only>
|
|
|
+ <template #append>
|
|
|
+ <el-upload
|
|
|
+ ref="upload"
|
|
|
+ action=""
|
|
|
+ :auto-upload="false"
|
|
|
+ :multiple="false"
|
|
|
+ :show-file-list="false"
|
|
|
+ accept=".csv"
|
|
|
+ :on-change="onFileChange"
|
|
|
+ >
|
|
|
+ <div class="el-button el-button--primary" style="border-radius: 0 4px 4px 0;">浏览</div>
|
|
|
+ </el-upload>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
<div class="flex center dialog-footer">
|
|
|
<el-button
|
|
|
- size="mini"
|
|
|
@click="onCloseBtnClick"
|
|
|
>取消</el-button>
|
|
|
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
- size="mini"
|
|
|
@click="onImportDataBtnClick"
|
|
|
>确定</el-button>
|
|
|
</div>
|
|
@@ -55,17 +78,27 @@ export default {
|
|
|
api: {
|
|
|
required: true,
|
|
|
type: Function
|
|
|
+ },
|
|
|
+ providers: {
|
|
|
+ required: true,
|
|
|
+ type: Array
|
|
|
}
|
|
|
},
|
|
|
data: () => ({
|
|
|
visible: false,
|
|
|
uploadData: {
|
|
|
+ providerId: null,
|
|
|
file: null
|
|
|
}
|
|
|
}),
|
|
|
methods: {
|
|
|
open () {
|
|
|
- this.uploadData.file = null
|
|
|
+ const { providers } = this
|
|
|
+ this.uploadData = {
|
|
|
+ providerId: providers.length > 0 ? providers[0].id : null,
|
|
|
+ file: null
|
|
|
+ }
|
|
|
+
|
|
|
this.visible = true
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.upload.clearFiles()
|
|
@@ -107,6 +140,20 @@ export default {
|
|
|
onCloseBtnClick () {
|
|
|
this.close()
|
|
|
}
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ providers (providers) {
|
|
|
+ if (providers.length === 0 || !this.visible) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const { uploadData } = this
|
|
|
+ if (uploadData.providerId !== null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ uploadData.providerId = providers[0].id
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|