|
@@ -20,10 +20,17 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+import { getDictValueByKey } from '@/api/system/dict';
|
|
|
|
|
+import {downExcelTemp} from "@/api/common";
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
name: "UploadExcelDialog",
|
|
name: "UploadExcelDialog",
|
|
|
props: {
|
|
props: {
|
|
|
uploadAfter: Function,
|
|
uploadAfter: Function,
|
|
|
|
|
+ // 导入模板的key,用于下载模板时使用
|
|
|
|
|
+ templateKey: String,
|
|
|
|
|
+ // 下载模板后的名称
|
|
|
|
|
+ templateName: String
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -53,12 +60,12 @@ export default {
|
|
|
tip: "请上传 .xls,.xlsx 标准格式文件",
|
|
tip: "请上传 .xls,.xlsx 标准格式文件",
|
|
|
action: this.url,
|
|
action: this.url,
|
|
|
},
|
|
},
|
|
|
- // {
|
|
|
|
|
- // label: "模板下载",
|
|
|
|
|
- // prop: "excelTemplate",
|
|
|
|
|
- // formslot: true,
|
|
|
|
|
- // span: 24,
|
|
|
|
|
- // },
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ label: "模板下载",
|
|
|
|
|
+ prop: "excelTemplate",
|
|
|
|
|
+ formslot: true,
|
|
|
|
|
+ span: 24,
|
|
|
|
|
+ },
|
|
|
],
|
|
],
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -75,10 +82,19 @@ export default {
|
|
|
done();
|
|
done();
|
|
|
},
|
|
},
|
|
|
handleTemplate() {
|
|
handleTemplate() {
|
|
|
- this.$message.warning("暂未设置模板");
|
|
|
|
|
- // exportBlob(`/api/kd-system/region/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
|
|
|
|
|
- // downloadXls(res.data, "技术人员花名册.xlsx");
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ getDictValueByKey('import-template', this.templateKey).then(({ data }) => {
|
|
|
|
|
+ if (data.code == 200) {
|
|
|
|
|
+ if (typeof data.data === 'object') {
|
|
|
|
|
+ this.$message.error('暂未配置模板');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ let urlObj = new URL(data.data);
|
|
|
|
|
+ const link = document.createElement('a');
|
|
|
|
|
+ link.href = window.location.origin + '/oss' + urlObj.pathname;
|
|
|
|
|
+ link.download = this.templateName + '.xls'; // 设置下载文件名
|
|
|
|
|
+ link.click();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|