Showing
6 changed files
with
227 additions
and
0 deletions
| @@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
| 18 | import { useGlobSetting } from '/@/hooks/setting'; | 18 | import { useGlobSetting } from '/@/hooks/setting'; |
| 19 | import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; | 19 | import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; |
| 20 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; | 20 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; |
| 21 | + import { PublicApiDrawer } from './publicApi/index'; | ||
| 21 | 22 | ||
| 22 | const listColumn = ref(5); | 23 | const listColumn = ref(5); |
| 23 | 24 | ||
| @@ -88,6 +89,8 @@ | @@ -88,6 +89,8 @@ | ||
| 88 | 89 | ||
| 89 | const [registerDrawer, { openDrawer }] = useDrawer(); | 90 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 90 | 91 | ||
| 92 | + const [registerPublicDrawer, { openDrawer: openPublicApiDrawer }] = useDrawer(); | ||
| 93 | + | ||
| 91 | const handleCreateOrUpdate = (record?: BigScreenCenterItemsModel) => { | 94 | const handleCreateOrUpdate = (record?: BigScreenCenterItemsModel) => { |
| 92 | if (record) { | 95 | if (record) { |
| 93 | openDrawer(true, { | 96 | openDrawer(true, { |
| @@ -101,6 +104,8 @@ | @@ -101,6 +104,8 @@ | ||
| 101 | } | 104 | } |
| 102 | }; | 105 | }; |
| 103 | 106 | ||
| 107 | + const handleCreateOrUpdatePublicApi = () => openPublicApiDrawer(true); | ||
| 108 | + | ||
| 104 | const { largeDesignerPrefix } = useGlobSetting(); | 109 | const { largeDesignerPrefix } = useGlobSetting(); |
| 105 | 110 | ||
| 106 | const handlePreview = (record: BigScreenCenterItemsModel) => { | 111 | const handlePreview = (record: BigScreenCenterItemsModel) => { |
| @@ -143,6 +148,8 @@ | @@ -143,6 +148,8 @@ | ||
| 143 | (listContainerEl.style.overflowY = 'auto') && | 148 | (listContainerEl.style.overflowY = 'auto') && |
| 144 | (listContainerEl.style.overflowX = 'hidden'); | 149 | (listContainerEl.style.overflowX = 'hidden'); |
| 145 | }); | 150 | }); |
| 151 | + | ||
| 152 | + const getPublicApiListData = () => {}; | ||
| 146 | </script> | 153 | </script> |
| 147 | 154 | ||
| 148 | <template> | 155 | <template> |
| @@ -166,6 +173,9 @@ | @@ -166,6 +173,9 @@ | ||
| 166 | <Authority :value="ConfigurationPermission.CREATE"> | 173 | <Authority :value="ConfigurationPermission.CREATE"> |
| 167 | <Button type="primary" @click="handleCreateOrUpdate()">新增大屏</Button> | 174 | <Button type="primary" @click="handleCreateOrUpdate()">新增大屏</Button> |
| 168 | </Authority> | 175 | </Authority> |
| 176 | + <Authority :value="ConfigurationPermission.CREATE"> | ||
| 177 | + <Button type="primary" @click="handleCreateOrUpdatePublicApi()">公共接口管理</Button> | ||
| 178 | + </Authority> | ||
| 169 | <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" /> | 179 | <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" /> |
| 170 | <Tooltip title="刷新"> | 180 | <Tooltip title="刷新"> |
| 171 | <Button type="primary" @click="getListData"> | 181 | <Button type="primary" @click="getListData"> |
| @@ -251,6 +261,7 @@ | @@ -251,6 +261,7 @@ | ||
| 251 | </List> | 261 | </List> |
| 252 | </section> | 262 | </section> |
| 253 | <ConfigurationCenterDrawer @register="registerDrawer" @success="getListData" /> | 263 | <ConfigurationCenterDrawer @register="registerDrawer" @success="getListData" /> |
| 264 | + <PublicApiDrawer @register="registerPublicDrawer" @success="getPublicApiListData" /> | ||
| 254 | </PageWrapper> | 265 | </PageWrapper> |
| 255 | </template> | 266 | </template> |
| 256 | 267 |
src/views/dataview/publicApi/config.ts
0 → 100644
| 1 | +import { BasicColumn, FormSchema } from '/@/components/Table'; | ||
| 2 | +import { h } from 'vue'; | ||
| 3 | +import { Tag } from 'ant-design-vue'; | ||
| 4 | +import { findDictItemByCode } from '/@/api/system/dict'; | ||
| 5 | + | ||
| 6 | +// 表格配置 | ||
| 7 | +export const columns: BasicColumn[] = [ | ||
| 8 | + { | ||
| 9 | + title: '接口名称', | ||
| 10 | + dataIndex: 'name', | ||
| 11 | + width: 80, | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + title: '请求方式', | ||
| 15 | + dataIndex: 'method', | ||
| 16 | + width: 120, | ||
| 17 | + }, | ||
| 18 | + { | ||
| 19 | + title: '接口内容', | ||
| 20 | + dataIndex: 'content', | ||
| 21 | + width: 120, | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + title: '状态', | ||
| 25 | + dataIndex: 'status', | ||
| 26 | + width: 120, | ||
| 27 | + customRender: ({ record }) => { | ||
| 28 | + const status = record.status; | ||
| 29 | + const color = status == 0 ? 'green' : 'red'; | ||
| 30 | + const text = status == 0 ? '发布' : '未发布'; | ||
| 31 | + return h(Tag, { color: color }, () => text); | ||
| 32 | + }, | ||
| 33 | + }, | ||
| 34 | +]; | ||
| 35 | + | ||
| 36 | +//模拟数据 | ||
| 37 | +export const list = [ | ||
| 38 | + { | ||
| 39 | + name: '传感器趋势图', | ||
| 40 | + method: 'get', | ||
| 41 | + content: '/api/sensor', | ||
| 42 | + status: 0, | ||
| 43 | + }, | ||
| 44 | + { | ||
| 45 | + name: '报警器趋势图', | ||
| 46 | + method: 'get', | ||
| 47 | + content: '/api/alarm', | ||
| 48 | + status: 1, | ||
| 49 | + }, | ||
| 50 | +]; | ||
| 51 | + | ||
| 52 | +//表单配置 | ||
| 53 | +// 新增编辑配置 | ||
| 54 | +export const schemas: FormSchema[] = [ | ||
| 55 | + { | ||
| 56 | + field: 'name', | ||
| 57 | + label: '接口名称', | ||
| 58 | + colProps: { span: 24 }, | ||
| 59 | + required: true, | ||
| 60 | + component: 'Input', | ||
| 61 | + componentProps: { | ||
| 62 | + maxLength: 64, | ||
| 63 | + placeholder: '请输入接口名称', | ||
| 64 | + }, | ||
| 65 | + }, | ||
| 66 | + { | ||
| 67 | + field: 'address', | ||
| 68 | + label: '接口地址', | ||
| 69 | + colProps: { span: 24 }, | ||
| 70 | + required: true, | ||
| 71 | + component: 'Input', | ||
| 72 | + componentProps: { | ||
| 73 | + maxLength: 64, | ||
| 74 | + placeholder: '请输入接口地址', | ||
| 75 | + }, | ||
| 76 | + }, | ||
| 77 | + { | ||
| 78 | + field: 'method', | ||
| 79 | + label: '选择方式', | ||
| 80 | + component: 'ApiSelect', | ||
| 81 | + required: true, | ||
| 82 | + colProps: { span: 24 }, | ||
| 83 | + componentProps: { | ||
| 84 | + placeholder: '请选择选择方式', | ||
| 85 | + api: findDictItemByCode, | ||
| 86 | + params: { | ||
| 87 | + dictCode: 'dataview_select_methods', | ||
| 88 | + }, | ||
| 89 | + labelField: 'itemText', | ||
| 90 | + valueField: 'itemValue', | ||
| 91 | + }, | ||
| 92 | + }, | ||
| 93 | +]; |
src/views/dataview/publicApi/form.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <BasicDrawer | ||
| 4 | + showFooter | ||
| 5 | + v-bind="$attrs" | ||
| 6 | + @register="registerDrawer" | ||
| 7 | + width="50%" | ||
| 8 | + @ok="handleOnSubmit" | ||
| 9 | + > | ||
| 10 | + <BasicForm @register="registerForm" /> | ||
| 11 | + </BasicDrawer> | ||
| 12 | + </div> | ||
| 13 | +</template> | ||
| 14 | +<script lang="ts" setup name="publicApi"> | ||
| 15 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
| 16 | + import { BasicForm, useForm } from '/@/components/Form'; | ||
| 17 | + import { schemas } from './config'; | ||
| 18 | + | ||
| 19 | + const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({ | ||
| 20 | + labelWidth: 120, | ||
| 21 | + schemas, | ||
| 22 | + showActionButtonGroup: false, | ||
| 23 | + }); | ||
| 24 | + | ||
| 25 | + const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { | ||
| 26 | + await resetFields(); | ||
| 27 | + const title = `${!data.isUpdate ? '新增' : '修改'}公共接口`; | ||
| 28 | + setDrawerProps({ title }); | ||
| 29 | + setFieldsValue({ ...data.record }); | ||
| 30 | + }); | ||
| 31 | + | ||
| 32 | + const handleOnSubmit = async () => { | ||
| 33 | + const values = await validate(); | ||
| 34 | + if (!values) return; | ||
| 35 | + console.log('Get values', values); | ||
| 36 | + }; | ||
| 37 | +</script> |
src/views/dataview/publicApi/index.ts
0 → 100644
src/views/dataview/publicApi/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="公共接口管理页" width="50%"> | ||
| 4 | + <PublicApiList /> | ||
| 5 | + </BasicDrawer> | ||
| 6 | + </div> | ||
| 7 | +</template> | ||
| 8 | +<script lang="ts" setup name="publicApi"> | ||
| 9 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
| 10 | + import { PublicApiList } from './index'; | ||
| 11 | + | ||
| 12 | + const [registerDrawer] = useDrawerInner(); | ||
| 13 | +</script> |
src/views/dataview/publicApi/list.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <BasicTable @register="registerTable"> | ||
| 4 | + <template #toolbar> | ||
| 5 | + <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增公共接口 </a-button> | ||
| 6 | + </template> | ||
| 7 | + <template #action="{ record }"> | ||
| 8 | + <TableAction | ||
| 9 | + :actions="[ | ||
| 10 | + { | ||
| 11 | + label: '修改', | ||
| 12 | + icon: 'clarity:note-edit-line', | ||
| 13 | + onClick: handleCreateOrEdit.bind(null, record), | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + label: '删除', | ||
| 17 | + icon: 'ant-design:delete-outlined', | ||
| 18 | + color: 'error', | ||
| 19 | + popConfirm: { | ||
| 20 | + title: '是否确认删除', | ||
| 21 | + confirm: handleDeleteOrBatchDelete.bind(null, record), | ||
| 22 | + }, | ||
| 23 | + }, | ||
| 24 | + ]" | ||
| 25 | + /> | ||
| 26 | + </template> | ||
| 27 | + </BasicTable> | ||
| 28 | + </div> | ||
| 29 | + <PublicApiForm @register="registerDrawer" /> | ||
| 30 | +</template> | ||
| 31 | +<script lang="ts" setup name="list"> | ||
| 32 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
| 33 | + import { useDrawer } from '/@/components/Drawer'; | ||
| 34 | + import { columns, list } from './config'; | ||
| 35 | + import { PublicApiForm } from './index'; | ||
| 36 | + | ||
| 37 | + const [registerTable] = useTable({ | ||
| 38 | + // api: exportPage, | ||
| 39 | + dataSource: list, | ||
| 40 | + columns, | ||
| 41 | + showIndexColumn: false, | ||
| 42 | + clickToRowSelect: false, | ||
| 43 | + showTableSetting: true, | ||
| 44 | + bordered: true, | ||
| 45 | + actionColumn: { | ||
| 46 | + width: 200, | ||
| 47 | + title: '操作', | ||
| 48 | + dataIndex: 'action', | ||
| 49 | + slots: { customRender: 'action' }, | ||
| 50 | + fixed: 'right', | ||
| 51 | + }, | ||
| 52 | + }); | ||
| 53 | + | ||
| 54 | + const [registerDrawer, { openDrawer }] = useDrawer(); | ||
| 55 | + | ||
| 56 | + const handleDeleteOrBatchDelete = (record) => { | ||
| 57 | + console.log(record); | ||
| 58 | + }; | ||
| 59 | + | ||
| 60 | + const handleCreateOrEdit = (record) => { | ||
| 61 | + const isUpdate = record === null ? false : true; | ||
| 62 | + const recordContent = record === null ? null : record; | ||
| 63 | + openDrawer(true, { | ||
| 64 | + isUpdate, | ||
| 65 | + record: recordContent, | ||
| 66 | + }); | ||
| 67 | + }; | ||
| 68 | +</script> |