Showing
6 changed files
with
276 additions
and
0 deletions
src/locales/lang/zh-CN/equipment/category.ts
0 → 100644
| 1 | +<template> | |
| 2 | + <div> | |
| 3 | + <BasicModal | |
| 4 | + v-bind="$attrs" | |
| 5 | + width="35rem" | |
| 6 | + :title="getTitle" | |
| 7 | + @register="register" | |
| 8 | + @cancel="handleCancel" | |
| 9 | + @ok="handleOk" | |
| 10 | + destroyOnClose | |
| 11 | + > | |
| 12 | + <div> | |
| 13 | + <BasicForm @register="registerForm" /> | |
| 14 | + </div> | |
| 15 | + </BasicModal> | |
| 16 | + </div> | |
| 17 | +</template> | |
| 18 | +<script setup lang="ts"> | |
| 19 | +import {BasicModal, useModalInner} from "/@/components/Modal"; | |
| 20 | +import {BasicForm, useForm} from "/@/components/Form"; | |
| 21 | +import {computed, ref, unref} from "vue"; | |
| 22 | +import {useI18n} from "/@/hooks/web/useI18n"; | |
| 23 | +import {schemas} from "/@/views/equipment/category/index"; | |
| 24 | +import {ipRegex} from "/@/utils/rules"; | |
| 25 | +import {deleteFormField} from "/@/views/device/deviceaccess/index"; | |
| 26 | +import { | |
| 27 | + deviceProfileAccessInformation, | |
| 28 | + updateDeviceProfileAccessInformation | |
| 29 | +} from "/@/api/device/deviceAccess"; | |
| 30 | +import {useMessage} from "/@/hooks/web/useMessage"; | |
| 31 | +const isUpdate = ref<Boolean>(false); | |
| 32 | +const { t } = useI18n(); | |
| 33 | +const emit = defineEmits(['handleReload', 'register']); | |
| 34 | +const { createMessage } = useMessage(); | |
| 35 | + | |
| 36 | +const [registerForm, { getFieldsValue, setFieldsValue, validate, resetFields }] = useForm({ | |
| 37 | + labelWidth: 150, | |
| 38 | + schemas, | |
| 39 | + actionColOptions: { | |
| 40 | + span: 14, | |
| 41 | + }, | |
| 42 | + showActionButtonGroup: false, | |
| 43 | +}); | |
| 44 | + | |
| 45 | +const recordInfo = ref<Recordable>({}); | |
| 46 | + | |
| 47 | +const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { | |
| 48 | + await resetFields(); | |
| 49 | + setModalProps({ confirmLoading: false, loading: true }); | |
| 50 | + isUpdate.value = data?.isUpdate; | |
| 51 | + recordInfo.value = data?.record; | |
| 52 | + if (data?.record) { | |
| 53 | + const intranetIpAndPort = { | |
| 54 | + inputIp: data?.record.intranetIp, | |
| 55 | + inputPort: data?.record.intranetPort, | |
| 56 | + }; | |
| 57 | + const outerIpAndPort = { | |
| 58 | + inputIp: data?.record.outerNetIp, | |
| 59 | + inputPort: data?.record.outerNetPort, | |
| 60 | + }; | |
| 61 | + setFieldsValue(data?.record); | |
| 62 | + setFieldsValue({ ...data?.record?.sipExtend }); | |
| 63 | + setFieldsValue({ intranetIpAndPort, outerIpAndPort }); | |
| 64 | + } | |
| 65 | + setModalProps({ loading: false }); | |
| 66 | +}); | |
| 67 | + | |
| 68 | +const getTitle = computed(() => | |
| 69 | + !unref(isUpdate) | |
| 70 | + ? t('equipment.category.createCategoryText') | |
| 71 | + : t('equipment.category.editCategoryText') | |
| 72 | +); | |
| 73 | + | |
| 74 | +const handleCancel = () => closeModal(); | |
| 75 | + | |
| 76 | +const handleOk = async () => { | |
| 77 | + await validate(); | |
| 78 | + let values = getFieldsValue(); | |
| 79 | + const { intranetIpAndPort, outerIpAndPort } = values; | |
| 80 | + // values.intranetIp = intranetIpAndPort.inputIp; | |
| 81 | + // values.intranetPort = intranetIpAndPort.inputPort; | |
| 82 | + // values.outerNetIp = outerIpAndPort.inputIp; | |
| 83 | + // values.outerNetPort = outerIpAndPort.inputPort; | |
| 84 | + // if (!ipRegex.test(values.intranetIp)) { | |
| 85 | + // return createMessage.error(t('deviceManagement.deviceAccess.ipRuleText')); | |
| 86 | + // } | |
| 87 | + | |
| 88 | + const sipExtend = { | |
| 89 | + serverId: values['serverId'], | |
| 90 | + serverDomain: values['serverDomain'], | |
| 91 | + serverPassword: values['serverPassword'], | |
| 92 | + }; | |
| 93 | + values.sipExtend = sipExtend; | |
| 94 | + deleteFormField.forEach((deleteItem) => { | |
| 95 | + Reflect.deleteProperty(values, deleteItem); | |
| 96 | + }); | |
| 97 | + if (unref(isUpdate)) { | |
| 98 | + // 更新 | |
| 99 | + values = { ...values, id: unref(recordInfo).id }; | |
| 100 | + // await updateDeviceProfileAccessInformation(values); | |
| 101 | + } else { | |
| 102 | + // await deviceProfileAccessInformation(values); | |
| 103 | + } | |
| 104 | + createMessage.success(t('equipment.category.operationSuccessText')); | |
| 105 | + emit('handleReload'); | |
| 106 | + handleCancel(); | |
| 107 | +}; | |
| 108 | + | |
| 109 | +</script> | ... | ... |
src/views/equipment/category/index.less
0 → 100644
| 1 | +.category-tree { | |
| 2 | + flex: 1 1 auto; | |
| 3 | + margin: 16px; | |
| 4 | + padding: 32px; | |
| 5 | + max-width: 100%; | |
| 6 | + background: #ffffff; | |
| 7 | + border-radius: 2px; | |
| 8 | + &-search { | |
| 9 | + width: 50%; | |
| 10 | + margin-bottom: 20px; | |
| 11 | + } | |
| 12 | + .ant-tree-treenode-switcher-close:hover { | |
| 13 | + background-color: #f4f4f5 !important; | |
| 14 | + border-radius: 4px !important; | |
| 15 | + } | |
| 16 | + .ant-tree-node-content-wrapper { | |
| 17 | + width: 100%; | |
| 18 | + } | |
| 19 | + .ant-tree-title { | |
| 20 | + display: flex; | |
| 21 | + } | |
| 22 | + .tree-node { | |
| 23 | + align-items: center; | |
| 24 | + justify-content: space-between; | |
| 25 | + width: 100%; | |
| 26 | + | |
| 27 | + .but_operation { | |
| 28 | + display: none; // 默认隐藏按钮 | |
| 29 | + } | |
| 30 | + | |
| 31 | + | |
| 32 | + } | |
| 33 | + .tree-node:hover { | |
| 34 | + &:hover .but_operation { | |
| 35 | + display: inline-block; // 悬停时显示按钮 | |
| 36 | + .but_type { | |
| 37 | + margin-left: 32px; | |
| 38 | + color: red; | |
| 39 | + } | |
| 40 | + } | |
| 41 | + } | |
| 42 | +} | ... | ... |
src/views/equipment/category/index.ts
0 → 100644
| 1 | + | |
| 2 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
| 3 | + | |
| 4 | +const { t } = useI18n(); | |
| 5 | +import { FormSchema } from '/@/components/Table'; | |
| 6 | + | |
| 7 | +//表单字段 | |
| 8 | +export const schemas: FormSchema[] = [ | |
| 9 | + { | |
| 10 | + field: 'intranetIpAndPort', | |
| 11 | + label: t('deviceManagement.deviceAccess.intranetIPWithPortText'), | |
| 12 | + component: 'FormInputGroup', | |
| 13 | + required: true, | |
| 14 | + componentProps: { | |
| 15 | + inputPlaceholder: t('deviceManagement.deviceAccess.intranetIPPlaceholderText'), | |
| 16 | + inputNumberPlaceholder: t('deviceManagement.deviceAccess.intranetPortPlaceholderText'), | |
| 17 | + }, | |
| 18 | + colProps: { span: 24 }, | |
| 19 | + }, | |
| 20 | + { | |
| 21 | + field: 'outerIpAndPort', | |
| 22 | + label: t('deviceManagement.deviceAccess.outernetIPWithPortText'), | |
| 23 | + component: 'FormInputGroup', | |
| 24 | + required: true, | |
| 25 | + componentProps: { | |
| 26 | + inputPlaceholder: t('deviceManagement.deviceAccess.outernetIPPlaceholderText'), | |
| 27 | + inputNumberPlaceholder: t('deviceManagement.deviceAccess.outernetPortPlaceholderText'), | |
| 28 | + }, | |
| 29 | + colProps: { span: 24 }, | |
| 30 | + } | |
| 31 | +]; | ... | ... |
src/views/equipment/category/index.vue
0 → 100644
| 1 | +<template> | |
| 2 | + | |
| 3 | + <PageWrapper dense contentFullHeight contentClass="flex"> | |
| 4 | + <div class="category-tree"> | |
| 5 | + <div class="category-tree-search"> | |
| 6 | + <a-input-search | |
| 7 | + placeholder="请输入关键字搜索" | |
| 8 | + enter-button | |
| 9 | + size="large" | |
| 10 | + /> | |
| 11 | + </div> | |
| 12 | + <a-tree :tree-data="treeData" default-expand-all show-icon :default-selected-keys="['0-0']"> | |
| 13 | + <template #custom="{ title }"> | |
| 14 | + <div class="tree-node"> | |
| 15 | + <span>{{ title }}</span> | |
| 16 | + <div class="but_operation"> | |
| 17 | + <span class="but_type" @click="handleAdd(key)">新增</span> | |
| 18 | + <span class="but_type">编辑</span> | |
| 19 | + <span class="but_type">删除</span> | |
| 20 | + </div> | |
| 21 | + </div> | |
| 22 | + </template> | |
| 23 | + </a-tree> | |
| 24 | + <categoryModal @register="registerModal" @handleReload="handleReload"/> | |
| 25 | + </div> | |
| 26 | + </PageWrapper> | |
| 27 | + | |
| 28 | +</template> | |
| 29 | +<script setup lang="ts"> | |
| 30 | +import {PageWrapper} from "/@/components/Page"; | |
| 31 | +import './index.less'; | |
| 32 | +import {categoryModal} from './components/index'; | |
| 33 | +import {useModal} from "/@/components/Modal"; | |
| 34 | + | |
| 35 | +const [registerModal, {openModal}] = useModal(); | |
| 36 | +const treeData = [ | |
| 37 | + { | |
| 38 | + title: '全部', | |
| 39 | + key: '0-0', | |
| 40 | + slots: {title: 'custom'}, // 添加 title: 'custom' | |
| 41 | + children: [ | |
| 42 | + { | |
| 43 | + title: '德风石化有限公司', | |
| 44 | + key: '0-0-0', | |
| 45 | + slots: {title: 'custom'}, // 添加 title: 'custom' | |
| 46 | + children: [ | |
| 47 | + { | |
| 48 | + title: '公共工程', | |
| 49 | + key: '0-0-0-0', | |
| 50 | + slots: {title: 'custom'}, // 添加 title: 'custom' | |
| 51 | + children: [ | |
| 52 | + { | |
| 53 | + title: '中心控制室', | |
| 54 | + key: '0-0-0-0-0', | |
| 55 | + slots: {title: 'custom'} | |
| 56 | + }, | |
| 57 | + {title: '辅料管区', key: '0-0-0-0-1', slots: {title: 'custom'}}, | |
| 58 | + {title: 'PSA伐区', key: '0-0-0-0-2', slots: {title: 'custom'}}, | |
| 59 | + {title: '导热油房区', key: '0-0-0-0-3', slots: {title: 'custom'}}, | |
| 60 | + {title: '甲醇裂解区', key: '0-0-0-0-4', slots: {title: 'custom'}}, | |
| 61 | + {title: '机柜间', key: '0-0-0-0-5', slots: {title: 'custom'}} | |
| 62 | + ] | |
| 63 | + }, | |
| 64 | + {title: '污水处理站', key: '0-0-0-1', slots: {title: 'custom'}} // 添加 title: 'custom' | |
| 65 | + ] | |
| 66 | + } | |
| 67 | + ] | |
| 68 | + } | |
| 69 | +]; | |
| 70 | + | |
| 71 | +// 处理新建按钮点击事件 | |
| 72 | +const handleAdd = (key: string) => { | |
| 73 | + openModal(true, { | |
| 74 | + isUpdate: false, // 表示是新建操作 | |
| 75 | + parentKey: key, // 传递当前节点的 key | |
| 76 | + }); | |
| 77 | +}; | |
| 78 | + | |
| 79 | + | |
| 80 | +const handleReload = () => { | |
| 81 | + | |
| 82 | +}; | |
| 83 | +</script> | ... | ... |