93 lines
1.9 KiB
Vue
93 lines
1.9 KiB
Vue
|
|
<template>
|
||
|
|
<UploadFile
|
||
|
|
ref="uploadFileRef"
|
||
|
|
:options="options"
|
||
|
|
:relatedRules="relatedRules"
|
||
|
|
:relatedOptions="relatedOptions"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup>
|
||
|
|
import { ref } from "vue";
|
||
|
|
import { ElMessage } from "element-plus";
|
||
|
|
|
||
|
|
import UploadFile from "../../operate/uploadFile.vue";
|
||
|
|
|
||
|
|
const uploadFileRef = ref(null);
|
||
|
|
const formClone = ref([]);
|
||
|
|
|
||
|
|
const options = {
|
||
|
|
limit: 1,
|
||
|
|
accept: ".xlsx",
|
||
|
|
action: "",
|
||
|
|
multiple: false,
|
||
|
|
listType: "text",
|
||
|
|
autoUpload: false,
|
||
|
|
};
|
||
|
|
|
||
|
|
const relatedRules = {
|
||
|
|
card_id: {
|
||
|
|
value: "",
|
||
|
|
label: "卡号",
|
||
|
|
},
|
||
|
|
card_imsi: {
|
||
|
|
value: "",
|
||
|
|
label: "IMSI号",
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
const relatedOptions = [
|
||
|
|
{
|
||
|
|
value: "0",
|
||
|
|
label: "卡号",
|
||
|
|
disabled: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
value: "1",
|
||
|
|
label: "IMSI号",
|
||
|
|
disabled: false,
|
||
|
|
},
|
||
|
|
];
|
||
|
|
|
||
|
|
const emit = defineEmits(["addBdCard"]);
|
||
|
|
|
||
|
|
const resetCheckForm = () => {
|
||
|
|
if (!uploadFileRef) return;
|
||
|
|
uploadFileRef.value.handleExceed();
|
||
|
|
};
|
||
|
|
|
||
|
|
const confirm = async () => {
|
||
|
|
if (!uploadFileRef) return;
|
||
|
|
formClone.value = [];
|
||
|
|
const length = uploadFileRef.value.loadData.length;
|
||
|
|
if (length == 0) return ElMessage.error("请先上传文件!");
|
||
|
|
const flag = await uploadFileRef.value.confirm();
|
||
|
|
if (!flag) return ElMessage.error("请先选择表格关联项!");
|
||
|
|
ElMessage({
|
||
|
|
message: `正在上传数据中,请稍等...`,
|
||
|
|
type: "success",
|
||
|
|
});
|
||
|
|
setTimeout(() => {
|
||
|
|
uploadFileRef.value.loadData.forEach((ExcleForm) => {
|
||
|
|
ExcleForm.forEach((worksheet) => {
|
||
|
|
let context = [...worksheet];
|
||
|
|
context.shift();
|
||
|
|
context.forEach((item) => {
|
||
|
|
if (item.length != 0) {
|
||
|
|
formClone.value.push({
|
||
|
|
card_id: item[relatedRules.card_id.value],
|
||
|
|
card_imsi: item[relatedRules.card_imsi.value],
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
emit("addBdCard", formClone.value);
|
||
|
|
}, 3000);
|
||
|
|
};
|
||
|
|
|
||
|
|
defineExpose({ resetCheckForm, confirm, formClone });
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped></style>
|