|
@@ -2,6 +2,8 @@
|
|
|
import { dicts } from "./dicts";
|
|
|
import useColumns from "./columns";
|
|
|
import { LIST, mbDownload } from "@/api/business/purchase/apply";
|
|
|
+// 导入的token
|
|
|
+import { getToken } from "@/utils/auth";
|
|
|
|
|
|
export default {
|
|
|
name: "PuchaseApply",
|
|
@@ -21,6 +23,21 @@ export default {
|
|
|
const page = this.$init.page();
|
|
|
const params = this.$init.params(SearchColumns);
|
|
|
return {
|
|
|
+ // 导入参数
|
|
|
+ upload: {
|
|
|
+ // 是否显示弹出层(导入)
|
|
|
+ open: false,
|
|
|
+ // 弹出层标题(导入)
|
|
|
+ title: "数据导入",
|
|
|
+ // 是否禁用上传
|
|
|
+ isUploading: false,
|
|
|
+ // 是否更新已经存在的用户数据
|
|
|
+ updateSupport: 1,
|
|
|
+ // 设置上传的请求头部
|
|
|
+ headers: { Authorization: "Bearer " + getToken() },
|
|
|
+ // 上传的地址
|
|
|
+ url: process.env.VUE_APP_BASE_API + "/pu/priceApply/import"
|
|
|
+ },
|
|
|
size: "mini",
|
|
|
loading: false,
|
|
|
params: params,
|
|
@@ -99,9 +116,32 @@ export default {
|
|
|
this.$modal.closeLoading();
|
|
|
})
|
|
|
},
|
|
|
+ // 文件上传中处理
|
|
|
+ handleFileUploadProgress(event, file, fileList) {
|
|
|
+ this.upload.isUploading = true;
|
|
|
+ this.$modal.loading("正在导入数据,请稍后...");
|
|
|
+ },
|
|
|
+ // 文件上传成功处理
|
|
|
+ handleFileSuccess(response, file, fileList) {
|
|
|
+ this.$modal.closeLoading();
|
|
|
+ this.upload.open = false;
|
|
|
+ this.upload.isUploading = false;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
|
|
|
+ this.useQuery(this.params, this.page);
|
|
|
+ },
|
|
|
+ errorFile(err) {
|
|
|
+ this.$modal.closeLoading();
|
|
|
+ this.$modal.notifyError("文件已变动,请重新上传");
|
|
|
+ },
|
|
|
+ // 提交上传文件
|
|
|
+ submitFileForm() {
|
|
|
+ this.$refs.upload.submit();
|
|
|
+ },
|
|
|
// 导入数据
|
|
|
importMb() {
|
|
|
-
|
|
|
+ this.upload.title = "文件导入"
|
|
|
+ this.upload.open = true
|
|
|
},
|
|
|
},
|
|
|
};
|
|
@@ -190,6 +230,36 @@ export default {
|
|
|
@pagination="useQuery(params, page)"
|
|
|
>
|
|
|
</el-super-table>
|
|
|
+ <!-- 文件导入对话框 -->
|
|
|
+ <el-dialog title="文件导入" :visible.sync="upload.open" width="400px">
|
|
|
+ <el-upload
|
|
|
+ ref="upload"
|
|
|
+ :limit="1"
|
|
|
+ accept=".xlsx, .xls"
|
|
|
+ :headers="upload.headers"
|
|
|
+ :action="upload.url + '?updateSupport=' + upload.updateSupport"
|
|
|
+ :disabled="upload.isUploading"
|
|
|
+ :on-progress="handleFileUploadProgress"
|
|
|
+ :on-success="handleFileSuccess"
|
|
|
+ :on-error="errorFile"
|
|
|
+ :auto-upload="false"
|
|
|
+ drag
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text">
|
|
|
+ 将文件拖到此处,或
|
|
|
+ <em>点击上传</em>
|
|
|
+ </div>
|
|
|
+ <!-- <div class="el-upload__tip" slot="tip">
|
|
|
+ <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
|
|
|
+ </div> -->
|
|
|
+ <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
|
|
|
+ </el-upload>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button size="mini" type="primary" @click="submitFileForm">确 定</el-button>
|
|
|
+ <el-button size="mini" @click="upload.open = false">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</el-card>
|
|
|
</template>
|
|
|
<style scoped lang="scss">
|