导入组件修改,导出添加提示
This commit is contained in:
1 parent
8d3629e66e
commit
e7eb50df3d
3 files changed
+115
-105
No files matched your search
+113
-103
@@ -1,155 +1,165 @@
|
|||||||
<!-- excel 导入组件 -->
|
<!-- excel 导入组件 -->
|
||||||
<template>
|
<template>
|
||||||
<el-dialog :title="prop.title" v-model="state.upload.open" :close-on-click-modal="false" draggable>
|
<el-dialog :title="prop.title" v-model="state.upload.open" :close-on-click-modal="false" draggable>
|
||||||
<el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="headers"
|
<el-upload
|
||||||
:action="baseURL + other.adaptationUrl(url)" :disabled="state.upload.isUploading"
|
v-loading="state.upload.isUploading"
|
||||||
:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :on-error="handleFileError"
|
ref="uploadRef"
|
||||||
:auto-upload="false" drag>
|
:limit="1"
|
||||||
<i class="el-icon-upload"></i>
|
accept=".xlsx, .xls"
|
||||||
<div class="el-upload__text">
|
:headers="headers"
|
||||||
{{ $t('excel.operationNotice') }}
|
:action="baseURL + other.adaptationUrl(url)"
|
||||||
<em>{{ $t('excel.clickUpload') }}</em>
|
:disabled="state.upload.isUploading"
|
||||||
</div>
|
:on-progress="handleFileUploadProgress"
|
||||||
<template #tip>
|
:on-success="handleFileSuccess"
|
||||||
<div class="el-upload__tip text-center">
|
:on-error="handleFileError"
|
||||||
<span>{{ $t('excel.fileFormat') }}</span>
|
:auto-upload="false"
|
||||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
|
drag
|
||||||
@click="downExcelTemp" v-if="tempUrl">{{ $t('excel.downloadTemplate') }}
|
>
|
||||||
</el-link>
|
<i class="el-icon-upload"></i>
|
||||||
</div>
|
<div class="el-upload__text">
|
||||||
</template>
|
{{ $t("excel.operationNotice") }}
|
||||||
</el-upload>
|
<em>{{ $t("excel.clickUpload") }}</em>
|
||||||
<template #footer>
|
</div>
|
||||||
<el-button type="primary" @click="submitFileForm">{{ $t('common.confirmButtonText') }}</el-button>
|
<template #tip>
|
||||||
<el-button @click="state.upload.open = false">{{ $t('common.cancelButtonText') }}</el-button>
|
<div class="el-upload__tip text-center">
|
||||||
</template>
|
<span>{{ $t("excel.fileFormat") }}</span>
|
||||||
</el-dialog>
|
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="downExcelTemp" v-if="tempUrl"
|
||||||
|
>{{ $t("excel.downloadTemplate") }}
|
||||||
|
</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="submitFileForm" :disabled="state.upload.isUploading">
|
||||||
|
{{ $t("common.confirmButtonText") }}
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="state.upload.open = false">{{ $t("common.cancelButtonText") }}</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<!--校验失败错误数据-->
|
<!--校验失败错误数据-->
|
||||||
<el-dialog :title="$t('excel.validationFailureData')" v-model="state.errorVisible">
|
<el-dialog :title="$t('excel.validationFailureData')" v-model="state.errorVisible" :close-on-click-modal="false" draggable>
|
||||||
<el-table :data="state.errorData">
|
<el-table :data="state.errorData">
|
||||||
<el-table-column property="lineNum" align="center" :label="$t('excel.lineNumbers')" width="100"></el-table-column>
|
<el-table-column property="row" align="center" :label="$t('excel.lineNumbers')" width="100" />
|
||||||
<el-table-column property="errors" align="center" :label="$t('excel.misDescription')" show-overflow-tooltip>
|
<el-table-column property="reasons" align="center" :label="$t('excel.misDescription')" show-overflow-tooltip>
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-tag type="danger" v-for="error in scope.row.errors" :key="error">{{ error }}</el-tag>
|
<el-tag type="danger" v-for="error in scope.row.reasons" :key="error">{{ error }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="upload-excel">
|
<script setup lang="ts" name="upload-excel">
|
||||||
import { useMessage } from '/@/hooks/message';
|
import { useMessage } from "/@/hooks/message"
|
||||||
import other from '/@/utils/other';
|
import other from "/@/utils/other"
|
||||||
import { Session } from '/@/utils/storage';
|
import { Session } from "/@/utils/storage"
|
||||||
|
|
||||||
const emit = defineEmits(['sizeChange', 'refreshDataList']);
|
const emit = defineEmits(["sizeChange", "refreshDataList"])
|
||||||
const prop = defineProps({
|
const prop = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
tempUrl: {
|
tempUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
const uploadRef = ref();
|
const uploadRef = ref()
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
errorVisible: false,
|
errorVisible: false,
|
||||||
errorData: [],
|
errorData: [],
|
||||||
dialog: {
|
dialog: {
|
||||||
title: '',
|
title: "",
|
||||||
isShowDialog: false,
|
isShowDialog: false,
|
||||||
},
|
},
|
||||||
upload: {
|
upload: {
|
||||||
open: false,
|
open: false,
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载模板文件
|
* 下载模板文件
|
||||||
*/
|
*/
|
||||||
const downExcelTemp = async () => {
|
const downExcelTemp = async () => {
|
||||||
try {
|
try {
|
||||||
await other.downBlobFile(other.adaptationUrl(prop.tempUrl), {}, 'temp.xlsx');
|
await other.downBlobFile(other.adaptationUrl(prop.tempUrl), {}, "temp.xlsx")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
useMessage().error('模板下载失败,请先维护模板文件');
|
useMessage().error("模板下载失败,请先维护模板文件")
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传进度条变化事件
|
* 上传进度条变化事件
|
||||||
*/
|
*/
|
||||||
const handleFileUploadProgress = () => {
|
const handleFileUploadProgress = () => {
|
||||||
state.upload.isUploading = true;
|
state.upload.isUploading = true
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传失败事件处理
|
* 上传失败事件处理
|
||||||
*/
|
*/
|
||||||
const handleFileError = () => {
|
const handleFileError = () => {
|
||||||
useMessage().error('上传失败,数据格式不合法!');
|
useMessage().error("上传失败,数据格式不合法!")
|
||||||
state.upload.open = false;
|
state.upload.open = false
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传成功事件处理
|
* 上传成功事件处理
|
||||||
* @param {any} response - 上传成功的响应结果
|
* @param {any} response - 上传成功的响应结果
|
||||||
*/
|
*/
|
||||||
const handleFileSuccess = (response: any) => {
|
const handleFileSuccess = (response: any) => {
|
||||||
state.upload.isUploading = false;
|
state.upload.isUploading = false
|
||||||
state.upload.open = false;
|
state.upload.open = false
|
||||||
uploadRef.value.clearFiles();
|
uploadRef.value.clearFiles()
|
||||||
|
|
||||||
// 校验失败
|
// 校验失败
|
||||||
if (response.code === 1) {
|
if (response.code === 1) {
|
||||||
useMessage().error('导入失败,以下数据不合法');
|
useMessage().error(response.msg ? response.msg : "导入失败,以下数据不合法")
|
||||||
state.errorVisible = true;
|
state.errorVisible = true
|
||||||
state.errorData = response.data;
|
state.errorData = response.data?.errors
|
||||||
uploadRef.value.clearFiles();
|
uploadRef.value.clearFiles()
|
||||||
// 刷新表格
|
// 刷新表格
|
||||||
emit?.('refreshDataList');
|
emit?.("refreshDataList")
|
||||||
} else {
|
} else {
|
||||||
useMessage().success(response.msg ? response.msg : '导入成功');
|
useMessage().success(response.msg ? response.msg : "导入成功")
|
||||||
// 刷新表格
|
// 刷新表格
|
||||||
emit?.('refreshDataList');
|
emit?.("refreshDataList")
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交表单,触发上传
|
* 提交表单,触发上传
|
||||||
*/
|
*/
|
||||||
const submitFileForm = () => {
|
const submitFileForm = () => {
|
||||||
uploadRef.value.submit();
|
uploadRef.value.submit()
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示上传文件对话框,并清除上传信息
|
* 显示上传文件对话框,并清除上传信息
|
||||||
*/
|
*/
|
||||||
const show = () => {
|
const show = () => {
|
||||||
state.upload.isUploading = false;
|
state.upload.isUploading = false
|
||||||
state.upload.open = true;
|
state.upload.open = true
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算请求头部信息
|
* 计算请求头部信息
|
||||||
*/
|
*/
|
||||||
const headers = computed(() => {
|
const headers = computed(() => {
|
||||||
return {
|
return {
|
||||||
Authorization: 'Bearer ' + Session.getToken(),
|
Authorization: "Bearer " + Session.getToken(),
|
||||||
'TENANT-ID': Session.getTenant(),
|
"TENANT-ID": Session.getTenant(),
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// 暴露变量
|
// 暴露变量
|
||||||
defineExpose({
|
defineExpose({
|
||||||
show,
|
show,
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -219,6 +219,7 @@ export function useTable(options?: BasicTableProps) {
|
|||||||
* @returns 返回一个Promise对象,用于异步处理结果
|
* @returns 返回一个Promise对象,用于异步处理结果
|
||||||
*/
|
*/
|
||||||
const downBlobFile = (url: string, query: any, fileName: string) => {
|
const downBlobFile = (url: string, query: any, fileName: string) => {
|
||||||
|
ElMessage.info("下载中,请稍后")
|
||||||
return other.downBlobFile(url, query, fileName)
|
return other.downBlobFile(url, query, fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@
|
|||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="visible = false">取消</el-button>
|
<el-button @click="visible = false">取消</el-button>
|
||||||
<el-button v-if="currentTabPaneIndex != 0" type="primary" @click="currentTabPaneIndex--">上一步</el-button>
|
<el-button v-if="currentTabPaneIndex != 0" type="primary" @click="currentTabPaneIndex--" :disabled="loading">上一步</el-button>
|
||||||
<el-button v-if="currentTabPaneIndex != 3" type="primary" @click="currentTabPaneIndex++">下一步</el-button>
|
<el-button v-if="currentTabPaneIndex != 3" type="primary" @click="currentTabPaneIndex++">下一步</el-button>
|
||||||
<el-button v-if="currentTabPaneIndex == 3" type="primary" @click="onSubmit" :disabled="loading">确 认</el-button>
|
<el-button v-if="currentTabPaneIndex == 3" type="primary" @click="onSubmit" :disabled="loading">确 认</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -156,7 +156,6 @@
|
|||||||
import { useDict } from "/@/hooks/dict"
|
import { useDict } from "/@/hooks/dict"
|
||||||
import { useMessage } from "/@/hooks/message"
|
import { useMessage } from "/@/hooks/message"
|
||||||
import { getObj, addObj, putObj, getSupermarketCategory, getSupermarketBrand } from "/@/api/supermarketerp/supermarketSpu"
|
import { getObj, addObj, putObj, getSupermarketCategory, getSupermarketBrand } from "/@/api/supermarketerp/supermarketSpu"
|
||||||
import { getSupplierTypeSimpleAll } from "/@/api/supermarketerp/smErpSupplierType"
|
|
||||||
import { rule } from "/@/utils/validate"
|
import { rule } from "/@/utils/validate"
|
||||||
import SupermarketUnit from "./components/supermarketUnit.vue"
|
import SupermarketUnit from "./components/supermarketUnit.vue"
|
||||||
import supermarketInventory from "./components/supermarketInventory.vue"
|
import supermarketInventory from "./components/supermarketInventory.vue"
|
||||||
|
|||||||
Reference in new issue
Block a user