|
@@ -2,13 +2,6 @@
|
|
|
<div class="system-edit-user-container">
|
|
|
<el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" width="800px" draggable
|
|
|
:close-on-click-modal="false">
|
|
|
- <div>第一步:请点击下面的链接下载Excel模板,并按照模板填写信息。</div>
|
|
|
- <a :href="state.download_file_url" target="target" download>
|
|
|
- <el-button class="download-file" key="primary" type="default">
|
|
|
- 下载模板
|
|
|
- </el-button>
|
|
|
- </a>
|
|
|
- <div class="two">第二步:导入Excel模板文件。</div>
|
|
|
<el-form :model="state.ruleForm" ref="refForm">
|
|
|
<el-form-item label="文件" prop="path" :rules="[{ required: true, message: '请上传文件' }]">
|
|
|
<el-upload ref="uploadEle" class="upload-demo" drag :action="state.uploadUrl" :limit="1"
|
|
@@ -24,7 +17,6 @@
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
-
|
|
|
<template #footer>
|
|
|
<span class="dialog-footer">
|
|
|
<el-button @click="onCancel">取 消</el-button>
|
|
@@ -36,14 +28,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup name="payrollModuleAttendanceImport">
|
|
|
-import { reactive, ref, nextTick } from 'vue';
|
|
|
-import { ElMessageBox, ElMessage, ElLoading, genFileId } from 'element-plus';
|
|
|
+import { reactive, ref, } from 'vue';
|
|
|
+import { ElMessage, genFileId } from 'element-plus';
|
|
|
import type { ElForm, UploadInstance, UploadProps, UploadRawFile } from 'element-plus';
|
|
|
import { UploadFilled } from '@element-plus/icons-vue';
|
|
|
type FormInstance = InstanceType<typeof ElForm>;
|
|
|
-// import noPacking from '/@/api/noPacking/noPacking.ts';
|
|
|
-import Good from '/@/api/model/Good'; //gzs:引入模型
|
|
|
-import config from '/@/config.ts';
|
|
|
+import config from '/@/config';
|
|
|
import { Session } from '/@/utils/storage';
|
|
|
|
|
|
// 定义子组件向父组件传值/事件
|
|
@@ -66,7 +56,7 @@ const state = reactive<any>({
|
|
|
},
|
|
|
isTips: false,
|
|
|
fileUrl: '',
|
|
|
- uploadUrl: config.host + '/admin/good/import',
|
|
|
+ uploadUrl: config.host + '/admin/upload/attachment',
|
|
|
download_file_url: config.file + '/public/static/execl/GOOD_TEMPLATE.xlsx',
|
|
|
getToken: Session.get('token')
|
|
|
});
|
|
@@ -78,8 +68,8 @@ const openDialog = () => {
|
|
|
};
|
|
|
ClearFiles();
|
|
|
state.dialog.isShowDialog = true;
|
|
|
- state.dialog.title = '导入物品记录表';
|
|
|
- state.dialog.submitTxt = '导 入';
|
|
|
+ state.dialog.title = '上传附件';
|
|
|
+ state.dialog.submitTxt = '上传';
|
|
|
};
|
|
|
// 关闭弹窗
|
|
|
const closeDialog = () => {
|
|
@@ -89,7 +79,6 @@ const closeDialog = () => {
|
|
|
const onCancel = () => {
|
|
|
closeDialog();
|
|
|
};
|
|
|
-
|
|
|
// 清除文件缓存
|
|
|
const ClearFiles = () => {
|
|
|
console.log('uploadEle.value=>', uploadEle.value);
|
|
@@ -103,6 +92,7 @@ const ClearFiles = () => {
|
|
|
// 新增
|
|
|
const onSubmit = () => {
|
|
|
uploadEle.value!.submit()
|
|
|
+ closeDialog();
|
|
|
};
|
|
|
//替换上一次文件
|
|
|
const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
@@ -111,44 +101,6 @@ const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
|
file.uid = genFileId()
|
|
|
uploadEle.value!.handleStart(file)
|
|
|
}
|
|
|
-// const onSubmit = (formEl: FormInstance | undefined) => {
|
|
|
-// console.log('state.ruleForm.path', state.ruleForm.path);
|
|
|
-// console.log('onSubmit formEl', formEl);
|
|
|
-// // if (!state.ruleForm.path) {
|
|
|
-// // ElMessage.error('请先上传');
|
|
|
-// // return;
|
|
|
-// // }
|
|
|
-// if (!formEl) return;
|
|
|
-// formEl.validate(async (valid) => {
|
|
|
-// console.log('valid', valid);
|
|
|
-// if (valid) {
|
|
|
-// const loadingInstance = ElLoading.service({ fullscreen: true,text: "正在导入中" })
|
|
|
-// let res: any = null;
|
|
|
-// res = await Good.import(state.ruleForm);
|
|
|
-// if (res.code != 0) {
|
|
|
-// nextTick(() => {
|
|
|
-// loadingInstance.close()
|
|
|
-// })
|
|
|
-// clearData();
|
|
|
-// closeDialog();
|
|
|
-// ElMessage.error(res.msg);
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// clearData();
|
|
|
-// closeDialog();
|
|
|
-// ElMessage.success(res.msg);
|
|
|
-// console.log('submit succ!');
|
|
|
-// emit('refresh');
|
|
|
-// nextTick(() => {
|
|
|
-// loadingInstance.close()
|
|
|
-// })
|
|
|
-// } else {
|
|
|
-// ElMessage.error('导入失败,请检查表格是否正确');
|
|
|
-// console.log('error submit!');
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// });
|
|
|
-// };
|
|
|
|
|
|
const clearData = () => {
|
|
|
state.isTips = false;
|
|
@@ -162,9 +114,11 @@ const handleAvatarSuccess = (res: any, file: any) => {
|
|
|
ElMessage.success('上传成功!');
|
|
|
console.log('res=>', res);
|
|
|
console.log('file=>', file);
|
|
|
- state.ruleForm.path = res.data.file;
|
|
|
+ state.ruleForm.path = res.data.path;
|
|
|
state.fileUrl = res.data.url;
|
|
|
state.isTips = true;
|
|
|
+
|
|
|
+ emit('refresh', [state.ruleForm.path, file.name]);
|
|
|
}
|
|
|
};
|
|
|
|