diff --git a/src/api/device.ts b/src/api/device.ts index aa26e7e..2ec15e8 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import dashboard from '@/router/routes/modules/dashboard'; export interface DeviceRecord { size: number; @@ -17,7 +18,7 @@ export interface DeviceCreateRecord { name?: string; hardwareVersion: string; firmwareVersion: string; - extendParams: string; + extendParams: string[]; properties: string; productId: number; } @@ -46,6 +47,14 @@ export function queryDeviceList(data: DeviceRecord) { export function queryDeviceDetail(id: number) { return axios.get(`/api/rest/device/${id}`); } +// 名称模糊查询 +export function queryDeviceByName(data: any) { + return axios({ + url: `/api/rest/product/fuzzy`, + method: 'get', + params: data, + }); +} // 新增 export function createDevice(data: DeviceCreateRecord) { @@ -54,7 +63,7 @@ export function createDevice(data: DeviceCreateRecord) { // 修改 export function updateDevice(data:DeviceUpdateRecord) { - return axios.put(`/api/rest/device/${data.id}`, data); + return axios.patch(`/api/rest/device/${data.id}`, data); } // 删除 export function deleteDevice(id: number) { diff --git a/src/api/message-mgmt.ts b/src/api/message-mgmt.ts index 34e575d..23ea754 100644 --- a/src/api/message-mgmt.ts +++ b/src/api/message-mgmt.ts @@ -26,25 +26,25 @@ export interface MessageCreateRecord { // 查看详情 export function queryMessage(userId: number, messageId: number) { - return axios.get(`/api/rest/message/${userId}/${messageId}`); + return axios.get(`/api/rest/notice/${userId}/${messageId}`); } // 分页查询 export function queryMessageList(data: MessageRecord) { return axios({ - url: '/api/rest/message', + url: '/api/rest/notice', method: 'get', params: data, }); } // 创建消息 export function createMessage(data: MessageCreateRecord) { - return axios.post('/api/rest/message', data); + return axios.post('/api/rest/notice', data); } // 获取消息推送方式 export function getMessageTypes() { - return axios.get('/api/rest/message/setting'); + return axios.get('/api/rest/notice/setting'); } // 设置消息推送方式 export function setMessageTypes(data: string[]) { - return axios.patch('/api/rest/message/setting', data); + return axios.patch('/api/rest/notice/setting', data); } \ No newline at end of file diff --git a/src/api/messages.ts b/src/api/messages.ts index 5081bbd..fc9475c 100644 --- a/src/api/messages.ts +++ b/src/api/messages.ts @@ -49,7 +49,7 @@ export interface MessagesRecord { } export interface MessageStatus { - ids: string[]; + ids: number[]; } export type MessageListType = MessagesList[]; diff --git a/src/components/menu/index.vue b/src/components/menu/index.vue index e61e9a6..9bb6edc 100644 --- a/src/components/menu/index.vue +++ b/src/components/menu/index.vue @@ -71,7 +71,7 @@ return result; }; - listenerRouteChange((newRoute) => { + listenerRouteChange((newRoute) => { const { requiresAuth, activeMenu, hideInMenu } = newRoute.meta; if (requiresAuth && (!hideInMenu || activeMenu)) { const menuOpenKeys = findMenuOpenKeys( diff --git a/src/components/message-box/index.vue b/src/components/message-box/index.vue index 49b2f33..c4d9f4b 100644 --- a/src/components/message-box/index.vue +++ b/src/components/message-box/index.vue @@ -6,7 +6,7 @@ {{ item.title }}{{ formatUnreadLength(item.key) }} - + -
  • - {{ userStore.permissions }} -
  • + + +
  • 0) { - const hasPermission = intersection(value, authorities).length > 0; + const hasPermission = intersection(value, permissions).length > 0; if (!hasPermission && el.parentNode) { el.parentNode.removeChild(el); diff --git a/src/router/routes/modules/dashboard.ts b/src/router/routes/modules/dashboard.ts index b697493..2073d42 100644 --- a/src/router/routes/modules/dashboard.ts +++ b/src/router/routes/modules/dashboard.ts @@ -7,6 +7,7 @@ const DASHBOARD: AppRouteRecordRaw = { component: DEFAULT_LAYOUT, meta: { locale: 'menu.dashboard', + title: '首页', requiresAuth: true, icon: 'icon-dashboard', // 设置图标 order: 0, // 排序路由菜单项。如果设置该值,值越高,越靠前 @@ -17,7 +18,8 @@ const DASHBOARD: AppRouteRecordRaw = { name: 'Workplace', component: () => import('@/views/dashboard/workplace/index.vue'), meta: { - locale: 'menu.dashboard.workplace', + locale:'menu.dashboard.workplace', + title: '工作台', requiresAuth: true, permissions: ['*'], }, diff --git a/src/router/routes/modules/iot.ts b/src/router/routes/modules/iot.ts index 2cd262f..ec8dca4 100644 --- a/src/router/routes/modules/iot.ts +++ b/src/router/routes/modules/iot.ts @@ -18,7 +18,7 @@ const IOT: AppRouteRecordRaw = { name: 'Product', component: () => import('@/views/iot/product/index.vue'), meta: { - // locale: 'menu.system.dept', + locale: 'menu.system.product', title: '产品管理', requiresAuth: true, permissions: ['*'], @@ -29,7 +29,7 @@ const IOT: AppRouteRecordRaw = { name: 'Device', component: () => import('@/views/iot/device/index.vue'), meta: { - // locale: 'menu.system.role', + locale: 'menu.system.device', title: '设备管理', requiresAuth: true, permissions: ['*'], @@ -40,6 +40,7 @@ const IOT: AppRouteRecordRaw = { name: 'productDetail', component: () => import('@/views/iot/product/components/product-detail.vue'), meta: { + locale:'menu.system.product', title: '产品详情', requiresAuth: true, showInMenu: false, @@ -51,6 +52,7 @@ const IOT: AppRouteRecordRaw = { name: 'deviceDetail', component: () => import('@/views/iot/device/components/device-detail.vue'), meta: { + locale: 'menu.system.deviceDetail', title: '设备详情', requiresAuth: true, showInMenu: false, @@ -62,6 +64,7 @@ const IOT: AppRouteRecordRaw = { name: 'productTsl', component: () => import('@/views/iot/product/components/product-tsl.vue'), meta: { + locale: 'menu.system.productTsl', title: '物模型', requiresAuth: true, showInMenu: false, diff --git a/src/router/routes/modules/notification.ts b/src/router/routes/modules/notification.ts index 7bda508..29ea699 100644 --- a/src/router/routes/modules/notification.ts +++ b/src/router/routes/modules/notification.ts @@ -7,6 +7,7 @@ const NOTIFICATION: AppRouteRecordRaw = { component: DEFAULT_LAYOUT, meta: { locale: '通知管理', + title: '通知管理', requiresAuth: true, icon: 'icon-message', // 设置图标 order: 0, // 排序路由菜单项。如果设置该值,值越高,越靠前 @@ -18,6 +19,7 @@ const NOTIFICATION: AppRouteRecordRaw = { component: () => import('@/views/notification/notice/index.vue'), meta: { locale: '公告通知', + title: '公告通知', requiresAuth: true, permissions: ['*'], }, @@ -28,6 +30,7 @@ const NOTIFICATION: AppRouteRecordRaw = { component: () => import('@/views/notification/noticeSet/index.vue'), meta: { locale: '公告管理', + title: '公告管理', requiresAuth: true, permissions: ['*'], }, diff --git a/src/router/routes/modules/system.ts b/src/router/routes/modules/system.ts index 0a29a08..f8aba44 100644 --- a/src/router/routes/modules/system.ts +++ b/src/router/routes/modules/system.ts @@ -27,6 +27,7 @@ const SYSTEM: AppRouteRecordRaw = { name: 'Role', component: () => import('@/views/system/role/index.vue'), meta: { + title: '角色管理', requiresAuth: true, permissions: ['*'], }, @@ -36,6 +37,7 @@ const SYSTEM: AppRouteRecordRaw = { name: 'Dept', component: () => import('@/views/system/dept/index.vue'), meta: { + title: '部门管理', requiresAuth: true, permissions: ['*'], }, @@ -45,14 +47,17 @@ const SYSTEM: AppRouteRecordRaw = { name: 'User', component: () => import('@/views/system/user/index.vue'), meta: { + title: '用户管理', requiresAuth: true, permissions: ['*'], }, }, { path: 'authority', + name: 'Authority', component: () => import('@/views/system/authority/index.vue'), meta: { + title: '权限管理', requiresAuth: true, permissions: ['*'], }, diff --git a/src/store/index.ts b/src/store/index.ts index 0b1f119..b91c76a 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -6,6 +6,11 @@ import useTabBarStore from './modules/tab-bar'; import useRoleStore from './modules/role'; import useDeptStore from './modules/dept'; import useAuthStore from './modules/auth'; +import useMessagesStore from './modules/messages'; +import useBulletinsStore from './modules/bulletins'; +import useMessageStore from './modules/message-mgmt'; +import useBulletinStore from './modules/bulle-mgmt'; + const pinia = createPinia(); pinia.use(piniaPluginPersistedstate); @@ -17,5 +22,9 @@ export { useDeptStore, useRoleStore, useAuthStore, + useMessagesStore, + useBulletinsStore, + useMessageStore, + useBulletinStore }; export default pinia; diff --git a/src/store/modules/dept/index.ts b/src/store/modules/dept/index.ts index 25b6817..039badc 100644 --- a/src/store/modules/dept/index.ts +++ b/src/store/modules/dept/index.ts @@ -6,7 +6,7 @@ import { queryDeptList, enabled, remove, - update, + update, getAllDeptTree } from '@/api/dept'; import { deptStore } from './type'; @@ -25,6 +25,11 @@ const useDeptStore = defineStore('dept', { }, }, actions: { + // 获取所有部门树 + async getAllDeptTree(id: number | string) { + return getAllDeptTree(id); + }, + // 获取所有的角色列表 async getDeptList(data: DeptRecord) { return queryDeptList(data); diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index b6928c1..498ed4e 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -49,7 +49,6 @@ const useUserStore = defineStore('user', { setInfo(partial: Partial) { this.$patch(partial); }, - // Reset user's information resetInfo() { this.$reset(); diff --git a/src/utils/excel.ts b/src/utils/excel.ts index 9045539..326c48e 100644 --- a/src/utils/excel.ts +++ b/src/utils/excel.ts @@ -1,68 +1,68 @@ -// // 新建 @/utils/excel.ts -// -// import saveAs from 'file-saver'; // https://www.npmjs.com/package/file-saver -// import ExcelJS from 'exceljs'; // https://github.com/exceljs/exceljs/blob/master/README_zh.md -// import * as XLSX from 'xlsx'; // https://www.npmjs.com/package/xlsx -// import { Message } from '@arco-design/web-vue'; // https://arco.design/vue/component/message -// import { FileItem } from '@arco-design/web-vue/es/upload/interfaces'; // arco类型 -// -// export interface DownloadExcelPrams { -// columns: { title: string; key: string }[]; -// rows: object[]; -// name: string; -// } -// -// // 导出下载文件 -// export function downloadExcel({ -// columns, -// rows, -// name = '未命名文件', -// }: DownloadExcelPrams) { -// const workbook = new ExcelJS.Workbook(); -// workbook.creator = 'Start-front'; -// workbook.lastModifiedBy = 'Start-front'; -// workbook.created = new Date(1985, 8, 30); -// workbook.modified = new Date(); -// workbook.lastPrinted = new Date(2016, 9, 27); -// -// // 将工作簿添加一个sheet页sheet1 -// const sheet1 = workbook.addWorksheet(name); -// // 表头数据添加 -// sheet1.columns = columns.map((item) => ({ -// header: item.title, -// key: item.key, -// width: 20, -// })); -// // 表格内容添加 -// rows.map((item) => sheet1.addRow(item)); -// workbook.xlsx.writeBuffer().then((buffer) => { -// saveAs( -// new Blob([buffer], { type: 'application/octet-stream' }), -// `${name}.xlsx` -// ); -// }); -// } -// -// // 读取文件为json格式 -// export function readExcle(fileItem: FileItem) { -// return new Promise((resove, reject) => { -// try { -// let workbook: XLSX.Sheet; -// const reader = new FileReader(); -// reader.readAsBinaryString(fileItem.file as File); // 发起异步请求 -// reader.onload = function (ev) { -// const data = ev.target?.result; -// workbook = XLSX.read(data, { type: 'binary' }); -// const sheetNames = workbook.SheetNames; // 工作表名称集合 -// sheetNames.forEach((name: string) => { -// const worksheet = workbook.Sheets[name]; // 只能通过工作表名称来获取指定工作表 -// const jsonres = XLSX.utils.sheet_to_json(worksheet); -// resove(jsonres); -// }); -// }; // onload -// } catch (error) { -// Message.error('读取失败,请选择正确文件'); -// reject(error); -// } -// }); -// } +// 新建 @/utils/excel.ts + +import saveAs from 'file-saver'; // https://www.npmjs.com/package/file-saver +import ExcelJS from 'exceljs'; // https://github.com/exceljs/exceljs/blob/master/README_zh.md +import * as XLSX from 'xlsx'; // https://www.npmjs.com/package/xlsx +import { Message } from '@arco-design/web-vue'; // https://arco.design/vue/component/message +import { FileItem } from '@arco-design/web-vue/es/upload/interfaces'; // arco类型 + +export interface DownloadExcelPrams { + columns: { title: string; key: string }[]; + rows: object[]; + name: string; +} + +// 导出下载文件 +export function downloadExcel({ + columns, + rows, + name = '未命名文件', +}: DownloadExcelPrams) { + const workbook = new ExcelJS.Workbook(); + workbook.creator = 'Start-front'; + workbook.lastModifiedBy = 'Start-front'; + workbook.created = new Date(1985, 8, 30); + workbook.modified = new Date(); + workbook.lastPrinted = new Date(2016, 9, 27); + + // 将工作簿添加一个sheet页sheet1 + const sheet1 = workbook.addWorksheet(name); + // 表头数据添加 + sheet1.columns = columns.map((item) => ({ + header: item.title, + key: item.key, + width: 20, + })); + // 表格内容添加 + rows.map((item) => sheet1.addRow(item)); + workbook.xlsx.writeBuffer().then((buffer) => { + saveAs( + new Blob([buffer], { type: 'application/octet-stream' }), + `${name}.xlsx` + ); + }); +} + +// 读取文件为json格式 +export function readExcle(fileItem: FileItem) { + return new Promise((resove, reject) => { + try { + let workbook: XLSX.Sheet; + const reader = new FileReader(); + reader.readAsBinaryString(fileItem.file as File); // 发起异步请求 + reader.onload = function (ev) { + const data = ev.target?.result; + workbook = XLSX.read(data, { type: 'binary' }); + const sheetNames = workbook.SheetNames; // 工作表名称集合 + sheetNames.forEach((name: string) => { + const worksheet = workbook.Sheets[name]; // 只能通过工作表名称来获取指定工作表 + const jsonres = XLSX.utils.sheet_to_json(worksheet); + resove(jsonres); + }); + }; // onload + } catch (error) { + Message.error('读取失败,请选择正确文件'); + reject(error); + } + }); +} diff --git a/src/views/iot/device/components/device-edit.vue b/src/views/iot/device/components/device-edit.vue index 7254c53..17165dd 100644 --- a/src/views/iot/device/components/device-edit.vue +++ b/src/views/iot/device/components/device-edit.vue @@ -16,6 +16,7 @@ @@ -23,23 +24,26 @@ - {{item}} + {{ + item.name + }} @@ -49,10 +53,7 @@ :rules="[{ required: true, message: '设备名称不能为空' }]" :validate-trigger="['change']" > - + @@ -75,29 +76,57 @@ > + + + - - - - - + + + + +
    -
    - - - - - - +
    + + + + + +
    - +
    @@ -105,22 +134,31 @@ diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index 462d1ed..5a55790 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -215,7 +215,6 @@ import usePagination from '@/hooks/pagination'; import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface'; import type { TableColumnData } from '@arco-design/web-vue/es/table/interface'; - import { useBulletinStore } from '@/store'; import useTableOption from '@/hooks/table-option'; import { Message } from '@arco-design/web-vue'; import { useRouter } from 'vue-router'; @@ -248,7 +247,6 @@ deepClone, } = useTableOption(); - const bulletinStore = useBulletinStore(); const columns = computed(() => [ { diff --git a/src/views/iot/product/components/product-edit.vue b/src/views/iot/product/components/product-edit.vue index fd2404a..b9b3f26 100644 --- a/src/views/iot/product/components/product-edit.vue +++ b/src/views/iot/product/components/product-edit.vue @@ -81,7 +81,7 @@ field="remark" label="备注" > - @@ -143,8 +143,8 @@ - - + +
    @@ -348,11 +348,11 @@ ]); const typeOptions = computed(() => [ { - label: '物模型输入', + label: '输入', value: 'INPUT', }, { - label: '物模型输出', + label: '输出', value: 'OUTPUT', }, { @@ -365,6 +365,7 @@ const fetchData = async (Id: number | undefined) => { const res = await queryProductDetail(Id); formData.value = res.data; + paramsData.value = res.data.params; }; // 组件被点击 const handleClick = () => { diff --git a/src/views/iot/product/components/product-tsl.vue b/src/views/iot/product/components/product-tsl.vue index 7ea5aba..230e4af 100644 --- a/src/views/iot/product/components/product-tsl.vue +++ b/src/views/iot/product/components/product-tsl.vue @@ -80,7 +80,7 @@ - - + + @@ -208,8 +208,8 @@ - - + + @@ -245,7 +245,7 @@ - + - - + + @@ -404,11 +401,11 @@ ]); const typeOptions = computed(() => [ { - label: '物模型输入', + label: '输入', value: 'INPUT', }, { - label: '物模型输出', + label: '输出', value: 'OUTPUT', }, { @@ -416,6 +413,16 @@ value: 'RW', }, ]); + const eventTypeOptions = computed(() => [ + { + label: '主动', + value: 'ACTIVE', + }, + { + label: '被动', + value: 'PASSIVE', + }, + ]); const propertyAddData = ref({ productId:id, }); diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 089cf6e..3a2f19b 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -113,6 +113,7 @@ (() => [ const fetchData = async (params?: Partial) => { setLoading(true); try { - const res = await deptStore.getDeptList(params); + const res = await deptStore.getAllDeptTree(1); - renderData.value = res.data.records; - pagination.page = res.data.page; - pagination.current = res.data.current; - pagination.total = res.data.total; + renderData.value = res.data; + // pagination.page = res.data.page; + // pagination.current = res.data.current; + // pagination.total = res.data.total; } catch (err) { // you can report use errorHandler or other } finally { diff --git a/src/views/system/message/components/message-edit.vue b/src/views/system/message/components/message-edit.vue index b33ef4a..0ab4d80 100644 --- a/src/views/system/message/components/message-edit.vue +++ b/src/views/system/message/components/message-edit.vue @@ -30,7 +30,7 @@ { message: '请输入用戶' }, ]" > - - 全选 + 全选