|
@@ -19,7 +19,7 @@
|
|
|
</template>
|
|
|
</el-upload>
|
|
|
<div style="text-align: right">
|
|
|
- <el-button class="ml-3" type="success" @click="confirm"> 导入 </el-button>
|
|
|
+ <el-button class="ml-3" type="success" :loading="uploading" @click="confirm"> 导入 </el-button>
|
|
|
</div>
|
|
|
</LJDialog>
|
|
|
</template>
|
|
@@ -30,6 +30,9 @@ import { ElMessage } from "element-plus";
|
|
|
import { ImportMtrlPrice } from "@/api/modules/basicinfo";
|
|
|
import LJDialog from "@/components/LjDialog/index.vue";
|
|
|
import { base64 } from "js-md5";
|
|
|
+import { ElNotification } from "element-plus";
|
|
|
+import { TYPE, useToast, POSITION } from "vue-toastification";
|
|
|
+import ToastErrCopy from "@/components/ToastWidget/ToastErrCopy/index.vue";
|
|
|
//import type { FileParams } from "../index.vue";
|
|
|
|
|
|
interface UploadWidgetProps {
|
|
@@ -59,11 +62,40 @@ const uploadRef = ref();
|
|
|
const afterReader = async (data: any) => {
|
|
|
console.log("afterReader :>> ", data);
|
|
|
|
|
|
- await ImportMtrlPrice({
|
|
|
+ let res = await ImportMtrlPrice({
|
|
|
filename: data[0].fileName,
|
|
|
base64: data[0].base64
|
|
|
});
|
|
|
+ console.log("afterReader res :>> ", res);
|
|
|
|
|
|
+ let errmsg = "";
|
|
|
+ if (res?.messageList.length > 0) {
|
|
|
+ errmsg = `,以下类别或物料不存在 <br />` + res.messageList.join(" <br />");
|
|
|
+ }
|
|
|
+ // ElNotification({
|
|
|
+ // title: "温馨提示",
|
|
|
+ // message: `读取${res.allqty}条数据,成功录入${res.successqty}个价格,失败${res?.messageList.length}个物料` + errmsg,
|
|
|
+ // type: "warning"
|
|
|
+ // });
|
|
|
+
|
|
|
+ const toast = useToast();
|
|
|
+ toast(
|
|
|
+ {
|
|
|
+ component: ToastErrCopy,
|
|
|
+ props: {
|
|
|
+ type: "info",
|
|
|
+ title: "温馨提示",
|
|
|
+ message: `读取${res.allqty}条数据,成功录入${res.successqty}个价格,失败${res?.messageList.length}个物料` + errmsg
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ position: POSITION.TOP_RIGHT,
|
|
|
+ icon: false,
|
|
|
+ timeout: 0,
|
|
|
+ closeButton: true,
|
|
|
+ toastClassName: "longjoe-toast"
|
|
|
+ }
|
|
|
+ );
|
|
|
// setTimeout(() => {
|
|
|
ElMessage.success("导入成功");
|
|
|
successStatus.value = true;
|
|
@@ -72,6 +104,8 @@ const afterReader = async (data: any) => {
|
|
|
|
|
|
emit("closed");
|
|
|
}, 500);
|
|
|
+
|
|
|
+ uploading.value = false;
|
|
|
// closeTimer.value = setInterval(() => {
|
|
|
// toCloseTime.value--;
|
|
|
// if (toCloseTime.value <= 0) {
|
|
@@ -116,6 +150,8 @@ const confirm = async () => {
|
|
|
console.log("reader.result :>> ", index, successKey, reader.result);
|
|
|
if (successKey == fileList.value.length) {
|
|
|
afterReader(base64List);
|
|
|
+ } else {
|
|
|
+ uploading.value = false;
|
|
|
}
|
|
|
};
|
|
|
});
|