|
@@ -39,55 +39,55 @@
|
|
|
</n-form>
|
|
|
<template #action>
|
|
|
<div class="flex justify-end">
|
|
|
- <n-button type="primary" @click="getData">查询</n-button>
|
|
|
+ <n-button type="primary" @click="getDataList">查询</n-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </n-card>
|
|
|
+ <n-card title="数据总量">
|
|
|
+ <template #header-extra>
|
|
|
+ <n-spin :show="spinShow">
|
|
|
+ <n-progress
|
|
|
+ type="dashboard"
|
|
|
+ gap-position="bottom"
|
|
|
+ :percentage="100"
|
|
|
+ >
|
|
|
+ <span class="text-center font-bold"
|
|
|
+ >{{ percentage }}/{{ total }}</span
|
|
|
+ >
|
|
|
+ </n-progress>
|
|
|
+ </n-spin>
|
|
|
+ </template>
|
|
|
+ <n-descriptions bordered class="mt-auto">
|
|
|
+ <n-descriptions-item label="SN">
|
|
|
+ {{ formValue.T_sn }}
|
|
|
+ </n-descriptions-item>
|
|
|
+ <n-descriptions-item label="探头编号">
|
|
|
+ {{ formValue.T_id }}
|
|
|
+ </n-descriptions-item>
|
|
|
+ </n-descriptions>
|
|
|
+ <template #action>
|
|
|
+ <div class="flex justify-end">
|
|
|
+ <n-popconfirm @positive-click="handleImport">
|
|
|
+ <template #trigger>
|
|
|
+ <n-button type="primary">导入</n-button>
|
|
|
+ </template>
|
|
|
+ 是否确认导入?
|
|
|
+ </n-popconfirm>
|
|
|
</div>
|
|
|
</template>
|
|
|
</n-card>
|
|
|
- <n-spin :show="show">
|
|
|
- <n-card class="h-full" title="导入后的参数">
|
|
|
- <template #header-extra>
|
|
|
- <n-statistic label="数据总量" :value="data.Num" />
|
|
|
- </template>
|
|
|
- <n-descriptions bordered class="mt-auto">
|
|
|
- <n-descriptions-item label="SN">
|
|
|
- {{ formValue.T_sn }}
|
|
|
- </n-descriptions-item>
|
|
|
- <n-descriptions-item label="探头编号">
|
|
|
- {{ formValue.T_id }}
|
|
|
- </n-descriptions-item>
|
|
|
- </n-descriptions>
|
|
|
- <template #action>
|
|
|
- <div class="flex justify-end">
|
|
|
- <n-popconfirm @positive-click="handleImport">
|
|
|
- <template #trigger>
|
|
|
- <n-button type="primary">导入</n-button>
|
|
|
- </template>
|
|
|
- 是否确认导入?
|
|
|
- </n-popconfirm>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </n-card>
|
|
|
- </n-spin>
|
|
|
</n-space>
|
|
|
</n-modal>
|
|
|
- <n-modal
|
|
|
- v-model:show="showModal1"
|
|
|
- :show-icon="false"
|
|
|
- preset="dialog"
|
|
|
- title="进度"
|
|
|
- >
|
|
|
- <n-progress type="circle" :percentage="20">
|
|
|
- <span style="text-align: center">20% 很小</span>
|
|
|
- </n-progress>
|
|
|
- </n-modal>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { getV3DataList, addTaskData } from '@/api';
|
|
|
-import { NStatistic, useMessage } from 'naive-ui';
|
|
|
+import { useMessage } from 'naive-ui';
|
|
|
|
|
|
const message = useMessage();
|
|
|
|
|
|
+const notification = useNotification();
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
task: {
|
|
|
required: true,
|
|
@@ -97,13 +97,15 @@ const props = defineProps({
|
|
|
|
|
|
// 是否展示 Modal
|
|
|
const showModal = ref(false);
|
|
|
-const showModal1 = ref(false);
|
|
|
|
|
|
-//
|
|
|
-const show = ref(false);
|
|
|
+// 是否展示 Spinner
|
|
|
+const spinShow = ref(false);
|
|
|
|
|
|
//
|
|
|
-const data = ref({});
|
|
|
+const dataList = ref([]);
|
|
|
+
|
|
|
+// 总数
|
|
|
+const total = ref(0);
|
|
|
|
|
|
// 表单数据
|
|
|
const formValue = reactive({
|
|
@@ -115,6 +117,9 @@ const formValue = reactive({
|
|
|
page_z: 9999,
|
|
|
});
|
|
|
|
|
|
+// 当前完成数
|
|
|
+const percentage = ref(0);
|
|
|
+
|
|
|
// 显示导入
|
|
|
const showImportModal = () => {
|
|
|
showModal.value = true;
|
|
@@ -122,20 +127,24 @@ const showImportModal = () => {
|
|
|
formValue.Time_end = null;
|
|
|
formValue.T_sn = null;
|
|
|
formValue.T_id = null;
|
|
|
+ total.value = 0;
|
|
|
+ percentage.value = 0;
|
|
|
};
|
|
|
|
|
|
-//
|
|
|
-const handleImport = () => {
|
|
|
- if (data.value.Data) {
|
|
|
- data.value.Data.forEach((item) => {
|
|
|
- return addTask(item);
|
|
|
- });
|
|
|
- showModal1.value = true;
|
|
|
- } else {
|
|
|
- message.info('无数据');
|
|
|
+// 批量导入
|
|
|
+const handleImport = async () => {
|
|
|
+ if (dataList.value.length === 0) {
|
|
|
+ return message.info('无数据');
|
|
|
}
|
|
|
+ dataList.value.forEach(async (item) => {
|
|
|
+ const code = await addTask(item);
|
|
|
+ if (code !== 200) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
+// 导入任务
|
|
|
const addTask = async (item) => {
|
|
|
const { data: res } = await addTaskData({
|
|
|
T_task_id: props.task.T_task_id,
|
|
@@ -145,15 +154,23 @@ const addTask = async (item) => {
|
|
|
T_rh: item.T_rh,
|
|
|
T_time: item.T_time,
|
|
|
});
|
|
|
- if (res.Code !== 200) {
|
|
|
- return false;
|
|
|
+ if (res.Code === 200) {
|
|
|
+ percentage.value += 1;
|
|
|
+ if (percentage.value === total.value) {
|
|
|
+ notification.success({
|
|
|
+ title: res.Msg,
|
|
|
+ duration: 2500,
|
|
|
+ keepAliveOnHover: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+ return res.Code;
|
|
|
};
|
|
|
|
|
|
-//
|
|
|
-const getData = async () => {
|
|
|
+// 查询数据
|
|
|
+const getDataList = async () => {
|
|
|
try {
|
|
|
- show.value = true;
|
|
|
+ spinShow.value = true;
|
|
|
const { data: res } = await getV3DataList({
|
|
|
Time_start: formValue.Time_start + '',
|
|
|
Time_end: formValue.Time_end + '',
|
|
@@ -161,10 +178,12 @@ const getData = async () => {
|
|
|
page: 1,
|
|
|
page_z: 9999,
|
|
|
});
|
|
|
- show.value = false;
|
|
|
- data.value = res.Data || {};
|
|
|
+ dataList.value = res.Data.Data || [];
|
|
|
+ total.value = res.Data.Num || 0;
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
+ } finally {
|
|
|
+ spinShow.value = false;
|
|
|
}
|
|
|
};
|
|
|
</script>
|