|
@@ -12,10 +12,13 @@
|
|
|
:limit="1"
|
|
|
accept=".xlsx, .xls"
|
|
|
:headers="upload.headers"
|
|
|
+ :data="reqData"
|
|
|
:action="upload.url"
|
|
|
:disabled="upload.isUploading"
|
|
|
+ :before-upload="handleBeforeUpload"
|
|
|
:on-progress="handleFileUploadProgress"
|
|
|
:on-success="handleFileSuccess"
|
|
|
+ :http-request="reqUploadFile"
|
|
|
:auto-upload="false"
|
|
|
drag
|
|
|
>
|
|
@@ -38,7 +41,9 @@
|
|
|
<script>
|
|
|
|
|
|
import { mapGetters } from 'vuex'
|
|
|
-import { getToken } from "@/utils/auth";
|
|
|
+import { getToken, getSign } from "@/utils/auth"
|
|
|
+import { randomStr20 } from '@/utils/util'
|
|
|
+import { importTicket, importTemplate} from "@/api/business/ticket";
|
|
|
export default {
|
|
|
props: {
|
|
|
dialogVisible: {
|
|
@@ -52,7 +57,7 @@ export default {
|
|
|
loading: false,
|
|
|
// 表单参数
|
|
|
form: {},
|
|
|
- detail: {},
|
|
|
+ reqData: {},
|
|
|
// 盲票导入参数
|
|
|
upload: {
|
|
|
// 是否显示弹出层(盲票导入)
|
|
@@ -96,8 +101,19 @@ export default {
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
+ // 上传前loading加载
|
|
|
+ handleBeforeUpload(file) {
|
|
|
+ this.getHttpHeader()
|
|
|
+ this.vloading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "正在导入.....",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
/** 下载模板操作 */
|
|
|
importTemplate() {
|
|
|
+ console.log("importTemplate ====================")
|
|
|
importTemplate().then(response => {
|
|
|
this.download(response.msg);
|
|
|
});
|
|
@@ -119,6 +135,48 @@ export default {
|
|
|
this.$refs.upload.submit();
|
|
|
},
|
|
|
|
|
|
+ // 自定义文件上传的实现
|
|
|
+ reqUploadFile(param) {
|
|
|
+ var data = this.reqData || {}
|
|
|
+ var params = {
|
|
|
+ file: param.file,
|
|
|
+ ...data
|
|
|
+ }
|
|
|
+ importTicket(params, this.headers).then(response => {
|
|
|
+ // console.log("importTicket============ response.msg"+response.msg)
|
|
|
+ this.upload.open = false;
|
|
|
+ this.upload.isUploading = false;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
|
|
|
+ // this.$emit('saveSuccess')
|
|
|
+ this.vloading.close();
|
|
|
+ this.close()
|
|
|
+
|
|
|
+ }).catch(response => {
|
|
|
+ console.log("导入 shibia==========")
|
|
|
+ this.upload.open = false;
|
|
|
+ this.upload.isUploading = false;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
|
|
|
+ this.vloading.close();
|
|
|
+ //param.onError()
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 请求头
|
|
|
+ getHttpHeader() {
|
|
|
+ let timestamp = parseInt(new Date().getTime()),
|
|
|
+ nonce = randomStr20();
|
|
|
+ var sign = getSign(this.reqData || {}, timestamp)
|
|
|
+ let url = this.uploadImgUrl + '?sign=' + sign + '&nonce=' + nonce;
|
|
|
+ this.fileSaveUrl = url
|
|
|
+ var headers = {
|
|
|
+ "Authorization": "Bearer " + getToken(),
|
|
|
+ "x-zz-timestamp": timestamp
|
|
|
+ }
|
|
|
+ this.headers = headers
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 关闭窗口
|
|
|
*/
|