diff --git a/.env.development b/.env.development index 90e68200..75b92971 100644 --- a/.env.development +++ b/.env.development @@ -6,7 +6,7 @@ VITE_PUBLIC_PATH = / # Cross-domain proxy, you can configure multiple # Please note that no line breaks -VITE_PROXY = [["/api","http://lcny-api.peidikeji.cn"]] +VITE_PROXY = [["/api","http://lcny-api.peidikeji.cn"],["/upload","http://lcny-api.peidikeji.cn/api/web/upload"]] # Delete console VITE_DROP_CONSOLE = false @@ -15,7 +15,7 @@ VITE_DROP_CONSOLE = false VITE_GLOB_API_URL=/api # File upload address, optional -VITE_GLOB_UPLOAD_URL=/api +VITE_GLOB_UPLOAD_URL=/upload # Interface prefix VITE_GLOB_API_URL_PREFIX= diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts index e4f1b521..7fd664de 100644 --- a/src/api/sys/user.ts +++ b/src/api/sys/user.ts @@ -855,3 +855,59 @@ export function updateFriendinks(params, mode: ErrorMessageMode = 'modal') { }, ) } +/** + * @description:新增友情链接 + */ +export function createFriendinks(data, mode: ErrorMessageMode = 'modal') { + return defHttp.post( + { + url: `/api/friend-links`, + data, + }, + { + errorMessageMode: mode, + }, + ) +} +/** + * @description:删除友情链接 + */ +export function deleteFriendinks(id, mode: ErrorMessageMode = 'modal') { + return defHttp.delete( + { + url: `/api/friend-links/${id}`, + }, + { + errorMessageMode: mode, + }, + ) +} + +/** + * @description:报警记录 + */ +export function getWarningLogs(params, mode: ErrorMessageMode = 'modal') { + return defHttp.get( + { + url: `/api/device-warning-logs`, + params, + }, + { + errorMessageMode: mode, + isTransformResponse: false, + }, + ) +} +/** + * @description:标记处理警报记录 + */ +export function markWarningLogs(id, mode: ErrorMessageMode = 'modal') { + return defHttp.put( + { + url: `/api/device-warning-mark/${id}`, + }, + { + errorMessageMode: mode, + }, + ) +} diff --git a/src/api/upload.ts b/src/api/upload.ts index 9c104193..ddbce4c9 100644 --- a/src/api/upload.ts +++ b/src/api/upload.ts @@ -18,9 +18,16 @@ export function uploadApi( ) { return defHttp.uploadFile( { - url: uploadUrl + '/api/web/upload', + url: uploadUrl, onUploadProgress, }, params, ) } + +export function uploadPostApi(data) { + return defHttp.post({ + url: '/api/web/upload', + data, + }) +} diff --git a/src/components/Tinymce/src/ImgUpload.vue b/src/components/Tinymce/src/ImgUpload.vue index f878709d..233c0446 100644 --- a/src/components/Tinymce/src/ImgUpload.vue +++ b/src/components/Tinymce/src/ImgUpload.vue @@ -1,11 +1,13 @@ diff --git a/src/views/device/warning/warning.data.ts b/src/views/device/warning/warning.data.ts new file mode 100644 index 00000000..508e204a --- /dev/null +++ b/src/views/device/warning/warning.data.ts @@ -0,0 +1,90 @@ +import { BasicColumn, FormSchema } from '/@/components/Table' +import dayjs from 'dayjs' +import { h } from 'vue' +import { Tag } from 'ant-design-vue' +import { ColEx } from '/@/components/Form/src/types' + +const colProps: Partial = { + xs: 24, + sm: 12, + md: 8, + lg: 6, + xl: 6, + xxl: 4, +} + +const statusOptions = [ + { + value: 0, + color: 'red', + label: '未处理', + }, + { + value: 1, + color: 'green', + label: '已处理', + }, + { + value: 2, + color: 'pink', + label: '已忽略', + }, +] + +export const columns: BasicColumn[] = [ + { + title: 'ID', + dataIndex: 'id', + }, + { + title: '内容', + dataIndex: 'content', + }, + { + title: '等级', + dataIndex: 'lv', + width: 100, + }, + { + title: '状态', + dataIndex: 'status', + width: 100, + customRender: ({ record }) => { + const status = record.status + + const list = statusOptions + const item = list.find((e) => e.value === status) + const color = item?.color ?? 'red' + const text = item?.label ?? status + return h(Tag, { color: color }, () => text) + }, + }, + { + title: '开始时间', + dataIndex: 'created_at', + width: 180, + customRender: ({ text }) => { + if (!text) return '' + return dayjs.unix(text).format('YYYY-MM-DD HH:mm:ss') + }, + }, + { + width: 90, + title: '操作', + dataIndex: 'action', + align: 'center', + fixed: undefined, + }, +] + +export const searchFormSchema: FormSchema[] = [ + { + field: 'status', + label: '状态', + component: 'Select', + componentProps: { + options: statusOptions, + }, + colProps, + }, +] diff --git a/src/views/system/links/LinksDrawer.vue b/src/views/system/links/LinksDrawer.vue index 25f24ee4..5bcf5e8b 100644 --- a/src/views/system/links/LinksDrawer.vue +++ b/src/views/system/links/LinksDrawer.vue @@ -16,26 +16,42 @@ import { accountFormSchema } from './links.data' import { BasicModal, useModalInner } from '/@/components/Modal' import { defaultsDeep } from 'lodash-es' - import { createDevice, getDeviceTypes, updateDevice } from '/@/api/sys/other' + import { createFriendinks, updateFriendinks } from '/@/api/sys/user' + const emits = defineEmits(['success', 'register']) const isUpdate = ref(false) const getTitle = computed(() => (!isUpdate.value ? '新增链接' : '编辑链接')) - const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ - labelWidth: 60, + const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({ + labelWidth: 80, baseColProps: { span: 24 }, schemas: accountFormSchema, showActionButtonGroup: false, }) + + const isTrueFalse = (e) => !!e + const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { resetFields() setModalProps({ confirmLoading: false }) isUpdate.value = data?.isUpdate if (unref(isUpdate)) { const obj = Object.assign({}, { ...data, ...data?.extends }) - const deviceTypes = await getDeviceTypes() + updateSchema({ + field: 'type', + dynamicDisabled: true, + }) + console.log({ + ...obj, + agricultural_base_id: obj.base_id, + is_show: isTrueFalse(obj.is_show), + is_recommend: isTrueFalse(obj.is_recommend), + [`content${obj.type}`]: obj.type == 2 ? [obj.content] : obj.content, + }) await setFieldsValue({ ...obj, agricultural_base_id: obj.base_id, - type: formatDataByObject(deviceTypes).find((e) => e.label == obj.type)?.value, + is_show: isTrueFalse(obj.is_show), + is_recommend: isTrueFalse(obj.is_recommend), + [`content${obj.type}`]: obj.type == 2 ? [obj.content] : obj.content, }) } }) @@ -56,27 +72,30 @@ return object } const handleSubmit = async () => { - const values = await validate() - console.log(values) + try { + const values = await validate() + let params: any = {} + for (const key in values) { + params = defaultsDeep({}, params, setValue(key.split('.'), values[key])) + } + if (params.type == 2) { + params.content = params.content2[0] + } else { + params.content = params[`content${params.type}`] + } - // try { - // const values = await validate() - // let params = {} - // for (const key in values) { - // params = defaultsDeep({}, params, setValue(key.split('.'), values[key])) - // } - // setModalProps({ confirmLoading: true }) - // if (values.id) { - // // 修改 - // await updateDevice(values.id, params) - // } else { - // // 新增 - // await createDevice(params) - // } - // closeModal() - // emits('success') - // } finally { - // setModalProps({ confirmLoading: false }) - // } + setModalProps({ confirmLoading: true }) + if (values.id) { + // 修改 + await updateFriendinks(params) + } else { + // 新增 + await createFriendinks(params) + } + closeModal() + emits('success') + } finally { + setModalProps({ confirmLoading: false }) + } } diff --git a/src/views/system/links/index.vue b/src/views/system/links/index.vue index 6e790be9..f2a2a14e 100644 --- a/src/views/system/links/index.vue +++ b/src/views/system/links/index.vue @@ -4,6 +4,25 @@ + @@ -11,9 +30,9 @@ diff --git a/src/views/visualization/index.vue b/src/views/visualization/index.vue index 2ce4a933..978fee89 100644 --- a/src/views/visualization/index.vue +++ b/src/views/visualization/index.vue @@ -2,7 +2,7 @@ -
+
ids.findIndex((id) => e.id == id) < 0) + const arr = ids.concat( + fliterData.reduce((p, c) => { + p.push(c.id) + return p + }, []), + ) + + localStorage.setItem('warning_id', arr.join(',')) + + fliterData.forEach((e, index) => { + openNotificationWithIcon(e.content, 4.5 + index * 0.5) + }) + } + + const openNotificationWithIcon = (message: string, duration = 4.5) => { + notification.warning({ + message: '报警', + duration: duration, + class: 'warning-class', + style: { + backgroundColor: 'rgba(28, 44, 52, 0.8)', + color: '#fff', + }, + getContainer: (): any => { + return document.body.querySelector(`.visualization—xx`) + }, + description: message, + }) + } + createVContext({ rootEmitter: vEmitter, }) @@ -130,13 +168,18 @@ const visibleMapModal = ref(false) onMounted(() => { - timer1 = setInterval(() => vEmitter.emit('interval:auto'), 1000 * 60) + timer1 = setInterval(() => { + getWarning() + vEmitter.emit('interval:auto') + }, 1000 * 60) timer2 = setInterval(() => vEmitter.emit('interval:tab'), 1000 * 30) timer3 = setInterval(() => vEmitter.emit('interval:tab1'), 1000 * 10) new Build(cavsRef).run() // Am(unref(cavsRef)) }) onBeforeMount(() => { + getWarning() + vEmitter.on('map:click', () => { // visibleMapModal.value = true }) @@ -161,7 +204,15 @@ }, }) +