This commit is contained in:
njdaoyehu 2024-11-21 16:27:39 +08:00
parent 47e0406a8e
commit 0e86a393db
3 changed files with 38 additions and 9 deletions

View File

@ -35,11 +35,9 @@
isUpdate.value = !!data?.isUpdate; isUpdate.value = !!data?.isUpdate;
entity.value = data?.record; entity.value = data?.record;
if (unref(isUpdate)) { await setFieldsValue({
await setFieldsValue({ ...data.record,
...data.record, });
});
}
}); });
const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑')); const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));

View File

@ -7,7 +7,9 @@
<BasicTable @register="registerTable"> <BasicTable @register="registerTable">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleCreate" :icon="h(PlusOutlined)">新增</a-button> <a-button type="primary" @click="handleCreate" :icon="h(PlusOutlined)">新增</a-button>
<div style="width: 20px" /> <div style="width: 10px" />
<a-button type="default" @click="handleImport" :icon="h(ImportOutlined)">导入数据</a-button>
<div style="width: 10px" />
<a-button type="default" @click="handleDownload" :icon="h(DownloadOutlined)" :disabled="checkedKeys.length === 0">下发数据</a-button> <a-button type="default" @click="handleDownload" :icon="h(DownloadOutlined)" :disabled="checkedKeys.length === 0">下发数据</a-button>
<a-button type="default" @click="handleSync" :icon="h(SyncOutlined)" :disabled="checkedKeys.length === 0">同步数据</a-button> <a-button type="default" @click="handleSync" :icon="h(SyncOutlined)" :disabled="checkedKeys.length === 0">同步数据</a-button>
</template> </template>
@ -73,7 +75,12 @@
import { useMessage } from "@/hooks/web/useMessage"; import { useMessage } from "@/hooks/web/useMessage";
import {SvgIcon} from "@/components/Icon"; import {SvgIcon} from "@/components/Icon";
import {h, ref} from "vue"; import {h, ref} from "vue";
import {DownloadOutlined, PlusOutlined, SyncOutlined} from "@ant-design/icons-vue"; import {
DownloadOutlined,
ImportOutlined,
PlusOutlined,
SyncOutlined
} from "@ant-design/icons-vue";
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const { hasPermission } = usePermission(); const { hasPermission } = usePermission();
const go = useGo(); const go = useGo();
@ -167,12 +174,35 @@
go('/data/task/' + record.id); go('/data/task/' + record.id);
}; };
const handleImport = () => {
WebViewService.importExcel().then((str) => {
useMessage().createMessage.success("数据导入成功!");
const data = JSON.parse(str);
if (data.length === 0) return;
const taskName = data[0].name;
data.forEach(item => {
delete item.name;
})
const record = {
name: taskName,
paramJson: JSON.stringify(data),
};
//
openDrawer(true, {
record,
isUpdate: false,
});
}, error => {
useMessage().createMessage.error(error);
});
}
const handleDownload = (record: Recordable) => { const handleDownload = (record: Recordable) => {
const ids = [...new Set([...(record.id ? [record.id] : []), ...(checkedKeys.value.map(d => (d)))])] const ids = [...new Set([...(record.id ? [record.id] : []), ...(checkedKeys.value.map(d => (d)))])]
DeviceClientService.assignTasks(ids).then(() => { DeviceClientService.assignTasks(ids).then(() => {
useMessage().createMessage.success("下发任务成功!"); useMessage().createMessage.success("下发任务成功!");
}, error => { }, error => {
useMessage().createMessage(error); useMessage().createMessage.error(error);
}); });
}; };
@ -182,7 +212,7 @@
useMessage().createMessage.success("同步任务成功!"); useMessage().createMessage.success("同步任务成功!");
reload(); reload();
}, error => { }, error => {
useMessage().createMessage(error); useMessage().createMessage.error(error);
}); });
}; };
</script> </script>

1
types/index.d.ts vendored
View File

@ -29,3 +29,4 @@ declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>;
declare let AMap: any; declare let AMap: any;
declare interface DeviceClientService {} declare interface DeviceClientService {}
declare interface WebViewService {}