Showing
13 changed files
with
547 additions
and
156 deletions
@@ -3,17 +3,20 @@ import type { | @@ -3,17 +3,20 @@ import type { | ||
3 | queryPageParams, | 3 | queryPageParams, |
4 | BigScreenCenterParams, | 4 | BigScreenCenterParams, |
5 | ConfigurationCenterInfo, | 5 | ConfigurationCenterInfo, |
6 | - BigScreenCenterItemsModal, | 6 | + BigScreenCenterItemsModel, |
7 | + BigScreenInterfaceParams, | ||
7 | } from './model/bigscreenCenterModel'; | 8 | } from './model/bigscreenCenterModel'; |
8 | import { getPageData } from '../../base'; | 9 | import { getPageData } from '../../base'; |
9 | import { FileUploadResponse } from '../../oem/model'; | 10 | import { FileUploadResponse } from '../../oem/model'; |
10 | enum API { | 11 | enum API { |
11 | basicUrl = '/data_view', | 12 | basicUrl = '/data_view', |
12 | UPLOAD = '/oss/upload', | 13 | UPLOAD = '/oss/upload', |
14 | + //大屏公共接口 | ||
15 | + DATA_VIEW_INTERFACE = '/data_view_interface', | ||
13 | } | 16 | } |
14 | 17 | ||
15 | export const getPage = (params: queryPageParams) => { | 18 | export const getPage = (params: queryPageParams) => { |
16 | - return getPageData<BigScreenCenterItemsModal>(params, API.basicUrl); | 19 | + return getPageData<BigScreenCenterItemsModel>(params, API.basicUrl); |
17 | }; | 20 | }; |
18 | 21 | ||
19 | export const saveConfigurationCenter = (params: BigScreenCenterParams) => { | 22 | export const saveConfigurationCenter = (params: BigScreenCenterParams) => { |
@@ -46,3 +49,46 @@ export const saveOrUpdateBigScreenCenter = (params: ConfigurationCenterInfo, isU | @@ -46,3 +49,46 @@ export const saveOrUpdateBigScreenCenter = (params: ConfigurationCenterInfo, isU | ||
46 | export const uploadThumbnail = (file: FormData) => { | 49 | export const uploadThumbnail = (file: FormData) => { |
47 | return defHttp.post<FileUploadResponse>({ url: API.UPLOAD, params: file }); | 50 | return defHttp.post<FileUploadResponse>({ url: API.UPLOAD, params: file }); |
48 | }; | 51 | }; |
52 | + | ||
53 | +/** | ||
54 | + * 大屏公共接口 | ||
55 | + */ | ||
56 | + | ||
57 | +export const getDataViewInterfacePage = (params: queryPageParams) => { | ||
58 | + return getPageData<BigScreenCenterItemsModel>(params, API.DATA_VIEW_INTERFACE); | ||
59 | +}; | ||
60 | + | ||
61 | +export const saveDataViewInterface = (params: BigScreenInterfaceParams) => { | ||
62 | + return defHttp.post({ | ||
63 | + url: API.DATA_VIEW_INTERFACE, | ||
64 | + data: params, | ||
65 | + }); | ||
66 | +}; | ||
67 | + | ||
68 | +export const updateDataViewInterface = (params: BigScreenInterfaceParams) => { | ||
69 | + return defHttp.put({ | ||
70 | + url: API.DATA_VIEW_INTERFACE, | ||
71 | + data: params, | ||
72 | + }); | ||
73 | +}; | ||
74 | + | ||
75 | +export const deleteBigViewInterface = (ids: string[]) => { | ||
76 | + return defHttp.delete({ | ||
77 | + url: API.DATA_VIEW_INTERFACE, | ||
78 | + data: { | ||
79 | + ids: ids, | ||
80 | + }, | ||
81 | + }); | ||
82 | +}; | ||
83 | + | ||
84 | +export function getPublish(id) { | ||
85 | + return defHttp.get({ | ||
86 | + url: API.DATA_VIEW_INTERFACE + '/publish/' + id, | ||
87 | + }); | ||
88 | +} | ||
89 | + | ||
90 | +export function getCancelPublish(id) { | ||
91 | + return defHttp.get({ | ||
92 | + url: API.DATA_VIEW_INTERFACE + '/cancel_publish/' + id, | ||
93 | + }); | ||
94 | +} |
@@ -25,3 +25,32 @@ export interface BigScreenCenterParams { | @@ -25,3 +25,32 @@ export interface BigScreenCenterParams { | ||
25 | defaultContent?: string; | 25 | defaultContent?: string; |
26 | } | 26 | } |
27 | export type ConfigurationCenterInfo = BigScreenCenterParams; | 27 | export type ConfigurationCenterInfo = BigScreenCenterParams; |
28 | + | ||
29 | +/** | ||
30 | + * 大屏公共接口 | ||
31 | + */ | ||
32 | +export interface BigScreenInterfaceParams { | ||
33 | + createTime: string; | ||
34 | + creator: string; | ||
35 | + defaultConfig: string; | ||
36 | + description: string; | ||
37 | + enabled: boolean; | ||
38 | + icon: string; | ||
39 | + id: string; | ||
40 | + interfaceName: string; | ||
41 | + name: string; | ||
42 | + remark: string; | ||
43 | + requestContentType: 0; | ||
44 | + requestHttpType: string; | ||
45 | + requestOriginUrl: string; | ||
46 | + requestParams: string; | ||
47 | + requestUrl: string; | ||
48 | + roleIds: [string]; | ||
49 | + state: number; | ||
50 | + tenantExpireTime: string; | ||
51 | + tenantId: string; | ||
52 | + tenantProfileId: string; | ||
53 | + tenantStatus: string; | ||
54 | + updateTime: string; | ||
55 | + updater: string; | ||
56 | +} |
@@ -230,7 +230,7 @@ | @@ -230,7 +230,7 @@ | ||
230 | { | 230 | { |
231 | text: '未发布', | 231 | text: '未发布', |
232 | auth: ConfigurationPermission.UPDATE, | 232 | auth: ConfigurationPermission.UPDATE, |
233 | - icon: 'ant-design:double-right-outlined', | 233 | + icon: 'ant-design:node-expand-outlined', |
234 | event: '', | 234 | event: '', |
235 | onClick: handleCreateOrUpdate.bind(null, item), | 235 | onClick: handleCreateOrUpdate.bind(null, item), |
236 | }, | 236 | }, |
1 | <template> | 1 | <template> |
2 | <div class="table-content"> | 2 | <div class="table-content"> |
3 | - <table align="center" style="width: 100%" cellspacing="0"> | 3 | + <!-- 采用的原生表格 --> |
4 | + <table align="center"> | ||
4 | <thead> | 5 | <thead> |
5 | <tr> | 6 | <tr> |
6 | <th></th> | 7 | <th></th> |
7 | <th>Key</th> | 8 | <th>Key</th> |
8 | <th>Value</th> | 9 | <th>Value</th> |
10 | + <th>是否必须</th> | ||
9 | <th>操作</th> | 11 | <th>操作</th> |
10 | </tr> | 12 | </tr> |
11 | </thead> | 13 | </thead> |
@@ -18,10 +20,9 @@ | @@ -18,10 +20,9 @@ | ||
18 | <Select | 20 | <Select |
19 | v-model:value="item.key" | 21 | v-model:value="item.key" |
20 | placeholder="请选择" | 22 | placeholder="请选择" |
21 | - notFoundContent="请选择" | ||
22 | style="width: 14rem" | 23 | style="width: 14rem" |
23 | :options="selectOptions" | 24 | :options="selectOptions" |
24 | - @change="handleChange" | 25 | + @change="handleChange(item.key)" |
25 | allowClear | 26 | allowClear |
26 | /> | 27 | /> |
27 | </td> | 28 | </td> |
@@ -34,6 +35,9 @@ | @@ -34,6 +35,9 @@ | ||
34 | /> | 35 | /> |
35 | </td> | 36 | </td> |
36 | <td> | 37 | <td> |
38 | + <a-switch v-model:checked="item.required" /> | ||
39 | + </td> | ||
40 | + <td> | ||
37 | <div> | 41 | <div> |
38 | <Button type="dashed" @click="add(item, index)"> | 42 | <Button type="dashed" @click="add(item, index)"> |
39 | <template #icon><PlusOutlined /></template | 43 | <template #icon><PlusOutlined /></template |
@@ -49,11 +53,10 @@ | @@ -49,11 +53,10 @@ | ||
49 | </div> | 53 | </div> |
50 | </template> | 54 | </template> |
51 | <script lang="ts" setup name="editCellTable"> | 55 | <script lang="ts" setup name="editCellTable"> |
52 | - import { reactive, ref, onMounted } from 'vue'; | 56 | + import { reactive, ref, onMounted, nextTick } from 'vue'; |
53 | import { Select, Button } from 'ant-design-vue'; | 57 | import { Select, Button } from 'ant-design-vue'; |
54 | import { findDictItemByCode } from '/@/api/system/dict'; | 58 | import { findDictItemByCode } from '/@/api/system/dict'; |
55 | import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue'; | 59 | import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue'; |
56 | - import { buildUUID } from '/@/utils/uuid'; | ||
57 | 60 | ||
58 | const props = defineProps({ | 61 | const props = defineProps({ |
59 | method: { | 62 | method: { |
@@ -61,7 +64,11 @@ | @@ -61,7 +64,11 @@ | ||
61 | }, | 64 | }, |
62 | }); | 65 | }); |
63 | 66 | ||
64 | - onMounted(async () => { | 67 | + onMounted(() => { |
68 | + getSelectOptions(); | ||
69 | + }); | ||
70 | + | ||
71 | + const getSelectOptions = async () => { | ||
65 | const res = await findDictItemByCode({ dictCode: 'dataview_builtin_params' }); | 72 | const res = await findDictItemByCode({ dictCode: 'dataview_builtin_params' }); |
66 | selectOptions.value = res.map((m) => ({ label: m.itemText, value: m.itemValue })); | 73 | selectOptions.value = res.map((m) => ({ label: m.itemText, value: m.itemValue })); |
67 | selectOptions.value.push({ | 74 | selectOptions.value.push({ |
@@ -70,15 +77,15 @@ | @@ -70,15 +77,15 @@ | ||
70 | }); | 77 | }); |
71 | if (props.method === '2') | 78 | if (props.method === '2') |
72 | selectOptions.value = selectOptions.value.filter((f) => f.value !== 'scope'); | 79 | selectOptions.value = selectOptions.value.filter((f) => f.value !== 'scope'); |
73 | - }); | 80 | + }; |
74 | 81 | ||
75 | const selectOptions = ref<{ label: string; value: string; disabled?: boolean }[]>([]); | 82 | const selectOptions = ref<{ label: string; value: string; disabled?: boolean }[]>([]); |
76 | 83 | ||
77 | type defaultItem = { | 84 | type defaultItem = { |
78 | - id: string; | ||
79 | key: null | string; | 85 | key: null | string; |
80 | value: string; | 86 | value: string; |
81 | editDisabled: boolean; | 87 | editDisabled: boolean; |
88 | + required: boolean; | ||
82 | }; | 89 | }; |
83 | 90 | ||
84 | const tableArray = reactive<{ | 91 | const tableArray = reactive<{ |
@@ -86,10 +93,10 @@ | @@ -86,10 +93,10 @@ | ||
86 | }>({ | 93 | }>({ |
87 | content: [ | 94 | content: [ |
88 | { | 95 | { |
89 | - id: buildUUID(), | ||
90 | key: null, | 96 | key: null, |
91 | value: '', | 97 | value: '', |
92 | editDisabled: false, | 98 | editDisabled: false, |
99 | + required: false, | ||
93 | }, | 100 | }, |
94 | ], | 101 | ], |
95 | }); | 102 | }); |
@@ -97,10 +104,10 @@ | @@ -97,10 +104,10 @@ | ||
97 | // 新增 | 104 | // 新增 |
98 | const add = (_, index: number) => { | 105 | const add = (_, index: number) => { |
99 | tableArray.content.splice(index + 1, 0, { | 106 | tableArray.content.splice(index + 1, 0, { |
100 | - id: buildUUID(), | ||
101 | key: null, | 107 | key: null, |
102 | value: '', | 108 | value: '', |
103 | editDisabled: false, | 109 | editDisabled: false, |
110 | + required: false, | ||
104 | }); | 111 | }); |
105 | }; | 112 | }; |
106 | 113 | ||
@@ -117,7 +124,8 @@ | @@ -117,7 +124,8 @@ | ||
117 | }; | 124 | }; |
118 | 125 | ||
119 | //Select互斥 | 126 | //Select互斥 |
120 | - const handleChange = () => { | 127 | + const handleChange = (value: string) => { |
128 | + console.log(value); | ||
121 | selectOptions.value.forEach((ele) => { | 129 | selectOptions.value.forEach((ele) => { |
122 | ele.disabled = false; | 130 | ele.disabled = false; |
123 | tableArray.content.forEach((element) => { | 131 | tableArray.content.forEach((element) => { |
@@ -135,20 +143,40 @@ | @@ -135,20 +143,40 @@ | ||
135 | 143 | ||
136 | //获取数据 | 144 | //获取数据 |
137 | const getValue = () => { | 145 | const getValue = () => { |
138 | - const params = {}; | ||
139 | - tableArray.content?.map((item: any) => { | ||
140 | - if (item?.key !== 'scope') params[item?.key] = item.value; | ||
141 | - params[`${(item?.key + item?.id).slice(0, 10)}`] = item.value; | ||
142 | - }); | ||
143 | - return params; | 146 | + return tableArray.content; |
144 | }; | 147 | }; |
145 | 148 | ||
146 | //设置数据 | 149 | //设置数据 |
147 | - const setValue = (data) => (tableArray.content = data); | 150 | + const setValue = (data) => { |
151 | + nextTick(() => (tableArray.content = data)); | ||
152 | + nextTick(() => | ||
153 | + setTimeout(() => { | ||
154 | + tableArray.content.forEach((it: any) => { | ||
155 | + handleChange(it.key); | ||
156 | + }); | ||
157 | + }, 20) | ||
158 | + ); | ||
159 | + }; | ||
148 | 160 | ||
161 | + //重置数据 | ||
162 | + const resetValue = () => { | ||
163 | + tableArray.content = []; | ||
164 | + tableArray.content.push({ | ||
165 | + key: null, | ||
166 | + value: '', | ||
167 | + editDisabled: false, | ||
168 | + required: false, | ||
169 | + }); | ||
170 | + nextTick(() => { | ||
171 | + tableArray.content.forEach((it: any) => { | ||
172 | + handleChange(it.key); | ||
173 | + }); | ||
174 | + }); | ||
175 | + }; | ||
149 | defineExpose({ | 176 | defineExpose({ |
150 | getValue, | 177 | getValue, |
151 | setValue, | 178 | setValue, |
179 | + resetValue, | ||
152 | }); | 180 | }); |
153 | </script> | 181 | </script> |
154 | 182 | ||
@@ -161,10 +189,11 @@ | @@ -161,10 +189,11 @@ | ||
161 | } | 189 | } |
162 | 190 | ||
163 | .table-content { | 191 | .table-content { |
164 | - margin-top: 20px; | ||
165 | - margin-right: 20px; | 192 | + overflow-x: auto; |
166 | 193 | ||
167 | table { | 194 | table { |
195 | + border-collapse: collapse; | ||
196 | + width: 100%; | ||
168 | &:extend(.table-border-color); | 197 | &:extend(.table-border-color); |
169 | } | 198 | } |
170 | 199 |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | - <a-radio-group v-model:value="getRequestBody.content.radioValue" @change="handleChange"> | 3 | + <a-radio-group |
4 | + v-model:value="getRequestBody.content.requestParamsBodyType" | ||
5 | + @change="handleChange" | ||
6 | + > | ||
4 | <a-radio v-for="item in RequestBodyTypeEnum" :key="item" :value="item">{{ item }}</a-radio> | 7 | <a-radio v-for="item in RequestBodyTypeEnum" :key="item" :value="item">{{ item }}</a-radio> |
5 | </a-radio-group> | 8 | </a-radio-group> |
6 | <div class="mt-3"> | 9 | <div class="mt-3"> |
7 | <a-textarea | 10 | <a-textarea |
8 | - v-if="getRequestBody.content.radioValue === 'none'" | 11 | + v-show="getRequestBody.content.requestParamsBodyType === 'none'" |
9 | disabled | 12 | disabled |
10 | placeholder="该接口没有 Body 体" | 13 | placeholder="该接口没有 Body 体" |
11 | :rows="2" | 14 | :rows="2" |
12 | /> | 15 | /> |
13 | <EditCellTable | 16 | <EditCellTable |
14 | - v-if=" | ||
15 | - getRequestBody.content.radioValue === 'form-data' || | ||
16 | - getRequestBody.content.radioValue === 'x-www-form-urlencoded' | 17 | + ref="editCellTableRef" |
18 | + v-show=" | ||
19 | + getRequestBody.content.requestParamsBodyType === 'form-data' || | ||
20 | + getRequestBody.content.requestParamsBodyType === 'x-www-form-urlencoded' | ||
17 | " | 21 | " |
18 | /> | 22 | /> |
19 | <a-textarea | 23 | <a-textarea |
20 | v-model:value="getRequestBody.content.json" | 24 | v-model:value="getRequestBody.content.json" |
21 | - v-if="getRequestBody.content.radioValue === 'json'" | 25 | + v-show="getRequestBody.content.requestParamsBodyType === 'json'" |
22 | placeholder="请输入json" | 26 | placeholder="请输入json" |
23 | :rows="6" | 27 | :rows="6" |
24 | /> | 28 | /> |
25 | <a-textarea | 29 | <a-textarea |
26 | v-model:value="getRequestBody.content.xml" | 30 | v-model:value="getRequestBody.content.xml" |
27 | - v-if="getRequestBody.content.radioValue === 'xml'" | 31 | + v-show="getRequestBody.content.requestParamsBodyType === 'xml'" |
28 | placeholder="请输入xml" | 32 | placeholder="请输入xml" |
29 | :rows="6" | 33 | :rows="6" |
30 | /> | 34 | /> |
@@ -32,7 +36,7 @@ | @@ -32,7 +36,7 @@ | ||
32 | </div> | 36 | </div> |
33 | </template> | 37 | </template> |
34 | <script lang="ts" setup name="body"> | 38 | <script lang="ts" setup name="body"> |
35 | - import { reactive } from 'vue'; | 39 | + import { reactive, ref, nextTick } from 'vue'; |
36 | import { RequestBodyTypeEnum } from '../../enum/index'; | 40 | import { RequestBodyTypeEnum } from '../../enum/index'; |
37 | import { EditCellTable } from '../EditCellTable/index'; | 41 | import { EditCellTable } from '../EditCellTable/index'; |
38 | 42 | ||
@@ -43,25 +47,65 @@ | @@ -43,25 +47,65 @@ | ||
43 | }); | 47 | }); |
44 | 48 | ||
45 | const getRequestBody = reactive({ | 49 | const getRequestBody = reactive({ |
46 | - content: { json: '', xml: '', radioValue: 'none' }, | 50 | + content: { |
51 | + requestParamsBodyType: 'none', | ||
52 | + json: '', | ||
53 | + xml: '', | ||
54 | + 'form-data': {}, | ||
55 | + 'x-www-form-urlencoded': {}, | ||
56 | + }, | ||
47 | }); | 57 | }); |
48 | 58 | ||
59 | + const editCellTableRef = ref<InstanceType<typeof EditCellTable>>(); | ||
60 | + | ||
49 | const handleChange = ({ target }) => { | 61 | const handleChange = ({ target }) => { |
50 | const { value } = target; | 62 | const { value } = target; |
51 | - getRequestBody.content.radioValue = value; | 63 | + getRequestBody.content.requestParamsBodyType = value; |
52 | }; | 64 | }; |
53 | 65 | ||
54 | //获取数据 | 66 | //获取数据 |
55 | const getValue = () => { | 67 | const getValue = () => { |
68 | + const type = Reflect.get(getRequestBody.content, 'requestParamsBodyType'); | ||
69 | + if (type === 'none') getRequestBody.content = {} as any; | ||
70 | + const values = editCellTableRef.value?.getValue(); | ||
71 | + if (type === 'form-data') getRequestBody.content['form-data'] = values as any; | ||
72 | + if (type === 'x-www-form-urlencoded') | ||
73 | + getRequestBody.content['x-www-form-urlencoded'] = values as any; | ||
56 | return getRequestBody.content; | 74 | return getRequestBody.content; |
57 | }; | 75 | }; |
58 | 76 | ||
59 | //设置数据 | 77 | //设置数据 |
60 | const setValue = (data) => { | 78 | const setValue = (data) => { |
61 | - getRequestBody.content = data; | 79 | + nextTick(() => { |
80 | + try { | ||
81 | + if (!data) return; | ||
82 | + const type = data?.requestParamsBodyType; | ||
83 | + getRequestBody.content.requestParamsBodyType = type; | ||
84 | + type === 'none' | ||
85 | + ? null | ||
86 | + : type === 'form-data' | ||
87 | + ? editCellTableRef.value?.setValue(data['form-data']) | ||
88 | + : type === 'x-www-form-urlencoded' | ||
89 | + ? editCellTableRef.value?.setValue(data['x-www-form-urlencoded']) | ||
90 | + : type === 'json' | ||
91 | + ? (getRequestBody.content.json = data['json']) | ||
92 | + : type === 'xml' | ||
93 | + ? (getRequestBody.content.xml = data['xml']) | ||
94 | + : ''; | ||
95 | + } finally { | ||
96 | + } | ||
97 | + }); | ||
98 | + }; | ||
99 | + | ||
100 | + //重置数据 | ||
101 | + const resetValue = () => { | ||
102 | + for (let i in getRequestBody.content) Reflect.set(getRequestBody.content, i, ''); | ||
103 | + getRequestBody.content.requestParamsBodyType = 'none'; | ||
104 | + nextTick(() => editCellTableRef?.value?.resetValue()); | ||
62 | }; | 105 | }; |
63 | defineExpose({ | 106 | defineExpose({ |
64 | getValue, | 107 | getValue, |
65 | setValue, | 108 | setValue, |
109 | + resetValue, | ||
66 | }); | 110 | }); |
67 | </script> | 111 | </script> |
src/views/dataview/publicApi/components/SimpleRequest/index.ts
deleted
100644 → 0
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | - <div> | ||
4 | - <Tabs type="card" v-model:activeKey="activeKey"> | ||
5 | - <TabPane forceRender v-for="item in RequestParamsTypeEnum" :key="item" :tab="item" /> | ||
6 | - </Tabs> | ||
7 | - </div> | ||
8 | - <div> | ||
9 | - <div v-if="activeKey === RequestParamsTypeEnum.PARAMS"> | 3 | + <Tabs @change="handleChange" v-model:activeKey="activeKey"> |
4 | + <TabPane class="tab-pane" forceRender key="Params" tab="Params"> | ||
10 | <EditCellTable ref="editCellTableRef" :method="method" /> | 5 | <EditCellTable ref="editCellTableRef" :method="method" /> |
11 | - <TestRequest :method="method" /> | ||
12 | - </div> | ||
13 | - <div v-if="activeKey === RequestParamsTypeEnum.BODY"> | ||
14 | - <Body :method="method" /> | ||
15 | - <TestRequest :method="method" /> | ||
16 | - </div> | ||
17 | - <div v-if="activeKey === RequestParamsTypeEnum.HEADER"> | ||
18 | - <EditCellTable ref="editCellTableRef" :method="method" /> | ||
19 | - <TestRequest :method="method" /> | ||
20 | - </div> | ||
21 | - </div> | 6 | + <TestRequest ref="testParRequestRef" :method="method" :data="dataList" /> |
7 | + </TabPane> | ||
8 | + <TabPane v-if="method !== '2'" class="tab-pane" forceRender key="Body" tab="Body"> | ||
9 | + <Body ref="bodyRef" :method="method" /> | ||
10 | + <TestRequest ref="testBodyRequestRef" :method="method" :data="dataList" /> | ||
11 | + </TabPane> | ||
12 | + <TabPane v-if="method !== '2'" class="tab-pane" forceRender key="Header" tab="Header"> | ||
13 | + <EditCellTable ref="editHeaderCellTableRef" :method="method" /> | ||
14 | + <TestRequest ref="testHeaderRequestRef" :method="method" :data="dataList" /> | ||
15 | + </TabPane> | ||
16 | + </Tabs> | ||
22 | </div> | 17 | </div> |
23 | </template> | 18 | </template> |
24 | <script lang="ts" setup name="simpleRequest"> | 19 | <script lang="ts" setup name="simpleRequest"> |
25 | - import { ref } from 'vue'; | 20 | + import { ref, nextTick } from 'vue'; |
26 | import { Tabs, TabPane } from 'ant-design-vue'; | 21 | import { Tabs, TabPane } from 'ant-design-vue'; |
27 | - import { RequestParamsTypeEnum } from '../../enum'; | ||
28 | import { EditCellTable } from '../EditCellTable'; | 22 | import { EditCellTable } from '../EditCellTable'; |
29 | import Body from './body.vue'; | 23 | import Body from './body.vue'; |
30 | import { TestRequest } from '../TestRequest/index'; | 24 | import { TestRequest } from '../TestRequest/index'; |
31 | 25 | ||
32 | - const props = defineProps({ | 26 | + defineProps({ |
33 | method: { | 27 | method: { |
34 | type: String, | 28 | type: String, |
35 | }, | 29 | }, |
36 | }); | 30 | }); |
37 | 31 | ||
38 | - if (props.method === '2') { | ||
39 | - Reflect.deleteProperty(RequestParamsTypeEnum, 'BODY'); | ||
40 | - Reflect.deleteProperty(RequestParamsTypeEnum, 'HEADER'); | ||
41 | - } else { | ||
42 | - Reflect.set(RequestParamsTypeEnum, 'BODY', 'Body'); | ||
43 | - Reflect.set(RequestParamsTypeEnum, 'HEADER', 'Header'); | ||
44 | - } | 32 | + const emits = defineEmits(['activeKey']); |
45 | 33 | ||
46 | const activeKey = ref('Params'); | 34 | const activeKey = ref('Params'); |
47 | 35 | ||
48 | const editCellTableRef = ref<InstanceType<typeof EditCellTable>>(); | 36 | const editCellTableRef = ref<InstanceType<typeof EditCellTable>>(); |
49 | 37 | ||
38 | + const editHeaderCellTableRef = ref<InstanceType<typeof EditCellTable>>(); | ||
39 | + | ||
40 | + const testParRequestRef = ref<InstanceType<typeof TestRequest>>(); | ||
41 | + | ||
42 | + const testBodyRequestRef = ref<InstanceType<typeof TestRequest>>(); | ||
43 | + | ||
44 | + const testHeaderRequestRef = ref<InstanceType<typeof TestRequest>>(); | ||
45 | + | ||
46 | + const dataList = ref({}); | ||
47 | + | ||
48 | + const bodyRef = ref<InstanceType<typeof Body>>(); | ||
49 | + | ||
50 | + const handleChange = () => { | ||
51 | + testParRequestRef.value?.setValue(); | ||
52 | + testHeaderRequestRef.value?.setValue(); | ||
53 | + testBodyRequestRef.value?.setValue(); | ||
54 | + }; | ||
55 | + | ||
50 | //获取数据 | 56 | //获取数据 |
51 | const getValue = () => { | 57 | const getValue = () => { |
52 | - return editCellTableRef?.value?.getValue(); | 58 | + const type = activeKey.value; |
59 | + const Body = bodyRef.value?.getValue(); | ||
60 | + const Params = editCellTableRef.value?.getValue(); | ||
61 | + const Header = editHeaderCellTableRef.value?.getValue(); | ||
62 | + emits('activeKey', type); | ||
63 | + return type === 'Params' ? Params : type === 'Body' ? Body : Header; | ||
53 | }; | 64 | }; |
54 | 65 | ||
55 | //设置数据 | 66 | //设置数据 |
56 | const setValue = (data) => { | 67 | const setValue = (data) => { |
57 | - editCellTableRef?.value?.setValue(data); | 68 | + dataList.value = data; |
69 | + const Objects = JSON.parse(data?.requestParams); | ||
70 | + nextTick(() => { | ||
71 | + if (!Objects) return; | ||
72 | + activeKey.value = Objects?.type; | ||
73 | + if (activeKey.value === 'Params') { | ||
74 | + editCellTableRef.value?.setValue(Objects?.Params); | ||
75 | + testParRequestRef.value?.setValue(); | ||
76 | + } else if (activeKey.value === 'Body') { | ||
77 | + bodyRef.value?.setValue(Objects?.Body); | ||
78 | + testBodyRequestRef.value?.setValue(); | ||
79 | + } else if (activeKey.value === 'Header') { | ||
80 | + editHeaderCellTableRef.value?.setValue(Objects?.Header); | ||
81 | + testHeaderRequestRef.value?.setValue(); | ||
82 | + } else { | ||
83 | + } | ||
84 | + }); | ||
85 | + }; | ||
86 | + | ||
87 | + //重置数据 | ||
88 | + const resetValue = () => { | ||
89 | + activeKey.value = 'Params'; | ||
90 | + nextTick(() => { | ||
91 | + editCellTableRef.value?.resetValue(); | ||
92 | + editHeaderCellTableRef.value?.resetValue(); | ||
93 | + bodyRef.value?.resetValue(); | ||
94 | + }); | ||
58 | }; | 95 | }; |
59 | 96 | ||
60 | defineExpose({ | 97 | defineExpose({ |
61 | getValue, | 98 | getValue, |
62 | setValue, | 99 | setValue, |
100 | + resetValue, | ||
63 | }); | 101 | }); |
64 | </script> | 102 | </script> |
103 | + | ||
104 | +<style lang="less" scoped> | ||
105 | + .tab-pane { | ||
106 | + display: flex; | ||
107 | + justify-content: flex-start; | ||
108 | + flex-direction: column; | ||
109 | + align-items: flex-start; | ||
110 | + } | ||
111 | +</style> |
@@ -264,12 +264,7 @@ | @@ -264,12 +264,7 @@ | ||
264 | 264 | ||
265 | //获取数据 | 265 | //获取数据 |
266 | const getValue = () => { | 266 | const getValue = () => { |
267 | - const params = {}; | ||
268 | - tableArray.content?.map((item: any) => { | ||
269 | - if (item?.key !== 'scope') params[item?.key] = item.value; | ||
270 | - params[`${(item?.key + item?.id).slice(0, 10)}`] = item.value; | ||
271 | - }); | ||
272 | - return params; | 267 | + return tableArray.content; |
273 | }; | 268 | }; |
274 | defineExpose({ | 269 | defineExpose({ |
275 | getValue, | 270 | getValue, |
1 | <template> | 1 | <template> |
2 | - <div class="mt-8"> | ||
3 | - <div> | ||
4 | - <Button @click="showTestEditCell = true" type="primary"> 测试一下 </Button> | 2 | + <div> |
3 | + <div class="mt-8"> | ||
4 | + <div> | ||
5 | + <Button @click="showTestEditCell = true" type="primary"> 测试接口 </Button> | ||
6 | + </div> | ||
7 | + <div v-if="showTestEditCell" class="mt-8"> | ||
8 | + <a-row type="flex" justify="center"> | ||
9 | + <a-col :span="3"> 参数设置 </a-col> | ||
10 | + <a-col :span="21"> | ||
11 | + <TestEditCellTable ref="testEditCellTableRef" :method="method" /> | ||
12 | + </a-col> | ||
13 | + </a-row> | ||
14 | + </div> | ||
5 | </div> | 15 | </div> |
6 | <div v-if="showTestEditCell" class="mt-8"> | 16 | <div v-if="showTestEditCell" class="mt-8"> |
7 | - <a-row type="flex" justify="center"> | ||
8 | - <a-col :span="3"> 参数设置 </a-col> | ||
9 | - <a-col :span="21"> | ||
10 | - <TestEditCellTable ref="testEditCellTableRef" :method="method" /> | ||
11 | - </a-col> | ||
12 | - </a-row> | ||
13 | - </div> | ||
14 | - </div> | ||
15 | - <div v-if="showTestEditCell" class="mt-8"> | ||
16 | - <div> | ||
17 | - <Button @click="handleExcute" type="primary"> 执行 </Button> | ||
18 | - </div> | ||
19 | - <div class="mt-8"> | ||
20 | - <a-row type="flex" justify="center"> | ||
21 | - <a-col :span="3"> 测试结果 </a-col> | ||
22 | - <a-col :span="21"> | ||
23 | - <a-textarea v-model:value="testResult" placeholder="测试结果为:" :rows="6" /> | ||
24 | - </a-col> | ||
25 | - </a-row> | 17 | + <div> |
18 | + <Button @click="handleExcute" type="primary"> 执行 </Button> | ||
19 | + </div> | ||
20 | + <div class="mt-8"> | ||
21 | + <a-row type="flex" justify="center"> | ||
22 | + <a-col :span="3"> 测试结果 </a-col> | ||
23 | + <a-col :span="21"> | ||
24 | + <a-textarea | ||
25 | + allow-clear | ||
26 | + show-count | ||
27 | + v-model:value="testResult" | ||
28 | + placeholder="测试结果为:" | ||
29 | + :rows="8" | ||
30 | + /> | ||
31 | + </a-col> | ||
32 | + </a-row> | ||
33 | + </div> | ||
26 | </div> | 34 | </div> |
27 | </div> | 35 | </div> |
28 | </template> | 36 | </template> |
29 | -<script lang="ts" setup name="testSql"> | 37 | +<script lang="ts" setup name="testRequest"> |
30 | import { ref } from 'vue'; | 38 | import { ref } from 'vue'; |
31 | import { Button } from 'ant-design-vue'; | 39 | import { Button } from 'ant-design-vue'; |
32 | import { TestEditCellTable } from '../TestEditCellTable/index'; | 40 | import { TestEditCellTable } from '../TestEditCellTable/index'; |
41 | + import { getAllDeviceByOrg } from '/@/api/dataBoard'; | ||
42 | + import { getDeviceAttributes } from '/@/api/dataBoard'; | ||
33 | 43 | ||
34 | defineProps({ | 44 | defineProps({ |
35 | method: { | 45 | method: { |
36 | type: String, | 46 | type: String, |
37 | }, | 47 | }, |
48 | + data: { | ||
49 | + type: Object, | ||
50 | + }, | ||
38 | }); | 51 | }); |
39 | 52 | ||
40 | const showTestEditCell = ref(false); | 53 | const showTestEditCell = ref(false); |
@@ -43,10 +56,34 @@ | @@ -43,10 +56,34 @@ | ||
43 | 56 | ||
44 | const testResult = ref(''); | 57 | const testResult = ref(''); |
45 | 58 | ||
59 | + // const testNeedKeys = ['organizationId', 'deviceProfileId', 'entityId', 'keys', 'date']; | ||
60 | + | ||
46 | const handleExcute = async () => { | 61 | const handleExcute = async () => { |
47 | const params = testEditCellTableRef.value?.getValue(); | 62 | const params = testEditCellTableRef.value?.getValue(); |
48 | - testResult.value = JSON.stringify(params); | 63 | + const keys = params?.map((m) => ({ key: m.key, value: m.value })); |
64 | + keys?.forEach(async (it: any) => { | ||
65 | + console.log(it); | ||
66 | + if (it.key === 'organizationId') { | ||
67 | + //获取设备 | ||
68 | + const data = await getAllDeviceByOrg(it.value!); | ||
69 | + testResult.value = JSON.stringify(data); | ||
70 | + } | ||
71 | + if (it.key === 'deviceProfileId') { | ||
72 | + //获取属性 | ||
73 | + const data = await getDeviceAttributes({ deviceProfileId: it.value! }); | ||
74 | + testResult.value = JSON.stringify(data); | ||
75 | + } | ||
76 | + }); | ||
49 | }; | 77 | }; |
78 | + | ||
79 | + //设置数据 | ||
80 | + const setValue = () => { | ||
81 | + showTestEditCell.value = false; | ||
82 | + testResult.value = ''; | ||
83 | + }; | ||
84 | + defineExpose({ | ||
85 | + setValue, | ||
86 | + }); | ||
50 | </script> | 87 | </script> |
51 | 88 | ||
52 | <style scoped lang="less"></style> | 89 | <style scoped lang="less"></style> |
1 | <template> | 1 | <template> |
2 | <div class="mt-8"> | 2 | <div class="mt-8"> |
3 | <div> | 3 | <div> |
4 | - <Button @click="handleExcute" type="primary"> 测试一下 </Button> | 4 | + <Button @click="handleExcute" type="primary"> 测试SQL </Button> |
5 | </div> | 5 | </div> |
6 | </div> | 6 | </div> |
7 | <div class="mt-8"> | 7 | <div class="mt-8"> |
@@ -9,7 +9,13 @@ | @@ -9,7 +9,13 @@ | ||
9 | <a-row type="flex" justify="center"> | 9 | <a-row type="flex" justify="center"> |
10 | <a-col :span="3"> 测试结果 </a-col> | 10 | <a-col :span="3"> 测试结果 </a-col> |
11 | <a-col :span="21"> | 11 | <a-col :span="21"> |
12 | - <a-textarea v-model:value="testResult" placeholder="测试结果为:" :rows="6" /> | 12 | + <a-textarea |
13 | + allow-clear | ||
14 | + show-count | ||
15 | + v-model:value="testResult" | ||
16 | + placeholder="测试结果为:" | ||
17 | + :rows="8" | ||
18 | + /> | ||
13 | </a-col> | 19 | </a-col> |
14 | </a-row> | 20 | </a-row> |
15 | </div> | 21 | </div> |
@@ -27,9 +33,15 @@ | @@ -27,9 +33,15 @@ | ||
27 | 33 | ||
28 | const testResult = ref(''); | 34 | const testResult = ref(''); |
29 | 35 | ||
30 | - const handleExcute = () => { | 36 | + const handleExcute = async () => { |
31 | testResult.value = '测试结果为:1234'; | 37 | testResult.value = '测试结果为:1234'; |
32 | }; | 38 | }; |
39 | + | ||
40 | + const resetValue = () => (testResult.value = ''); | ||
41 | + | ||
42 | + defineExpose({ | ||
43 | + resetValue, | ||
44 | + }); | ||
33 | </script> | 45 | </script> |
34 | 46 | ||
35 | <style scoped lang="less"></style> | 47 | <style scoped lang="less"></style> |
@@ -8,53 +8,65 @@ export const columns: BasicColumn[] = [ | @@ -8,53 +8,65 @@ export const columns: BasicColumn[] = [ | ||
8 | { | 8 | { |
9 | title: '接口名称', | 9 | title: '接口名称', |
10 | dataIndex: 'interfaceName', | 10 | dataIndex: 'interfaceName', |
11 | - width: 80, | 11 | + width: 150, |
12 | }, | 12 | }, |
13 | { | 13 | { |
14 | title: '请求方式', | 14 | title: '请求方式', |
15 | dataIndex: 'requestContentType', | 15 | dataIndex: 'requestContentType', |
16 | - width: 120, | 16 | + width: 90, |
17 | format(text) { | 17 | format(text) { |
18 | - return text === '0' ? '普通请求' : text === '1' ? 'SQL请求' : 'websocket请求'; | 18 | + return Number(text) === 0 ? '普通请求' : Number(text) === 1 ? 'SQL请求' : 'websocket请求'; |
19 | }, | 19 | }, |
20 | }, | 20 | }, |
21 | { | 21 | { |
22 | title: '接口内容', | 22 | title: '接口内容', |
23 | dataIndex: 'content', | 23 | dataIndex: 'content', |
24 | - width: 120, | 24 | + width: 80, |
25 | + slots: { customRender: 'content' }, | ||
25 | }, | 26 | }, |
26 | { | 27 | { |
27 | title: '状态', | 28 | title: '状态', |
28 | - dataIndex: 'status', | ||
29 | - width: 120, | 29 | + dataIndex: 'state', |
30 | + width: 80, | ||
30 | customRender: ({ record }) => { | 31 | customRender: ({ record }) => { |
31 | - const status = record.status; | ||
32 | - const color = status == 0 ? 'green' : 'red'; | ||
33 | - const text = status == 0 ? '发布' : '未发布'; | 32 | + const status = record.state; |
33 | + const color = status == 1 ? 'green' : 'red'; | ||
34 | + const text = status == 1 ? '发布' : '未发布'; | ||
34 | return h(Tag, { color: color }, () => text); | 35 | return h(Tag, { color: color }, () => text); |
35 | }, | 36 | }, |
36 | }, | 37 | }, |
37 | ]; | 38 | ]; |
38 | 39 | ||
39 | -//模拟数据 | ||
40 | -export const list = [ | 40 | +// 查询配置 |
41 | +export const searchFormSchema: FormSchema[] = [ | ||
41 | { | 42 | { |
42 | - interfaceName: '传感器趋势图', | ||
43 | - requestContentType: '0', | ||
44 | - content: '/api/sensor', | ||
45 | - status: 0, | ||
46 | - }, | ||
47 | - { | ||
48 | - interfaceName: '2co趋势图', | ||
49 | - requestContentType: '2', | ||
50 | - content: '/api/2co', | ||
51 | - status: 1, | 43 | + field: 'name', |
44 | + label: '接口名称', | ||
45 | + component: 'Input', | ||
46 | + colProps: { span: 8 }, | ||
47 | + componentProps: { | ||
48 | + maxLength: 36, | ||
49 | + placeholder: '请输入接口名称', | ||
50 | + }, | ||
52 | }, | 51 | }, |
53 | { | 52 | { |
54 | - interfaceName: 'temp趋势图', | ||
55 | - requestContentType: '1', | ||
56 | - content: '/api/temp', | ||
57 | - status: 1, | 53 | + field: 'state', |
54 | + label: '发布状态', | ||
55 | + component: 'Select', | ||
56 | + colProps: { span: 8 }, | ||
57 | + componentProps: { | ||
58 | + options: [ | ||
59 | + { | ||
60 | + label: '发布', | ||
61 | + value: 1, | ||
62 | + }, | ||
63 | + { | ||
64 | + label: '未发布', | ||
65 | + value: 0, | ||
66 | + }, | ||
67 | + ], | ||
68 | + placeholder: '请选择发布状态', | ||
69 | + }, | ||
58 | }, | 70 | }, |
59 | ]; | 71 | ]; |
60 | 72 | ||
@@ -149,7 +161,7 @@ export const schemas: FormSchema[] = [ | @@ -149,7 +161,7 @@ export const schemas: FormSchema[] = [ | ||
149 | values['requestContentType'] === '0' || values['requestContentType'] === '1', | 161 | values['requestContentType'] === '0' || values['requestContentType'] === '1', |
150 | }, | 162 | }, |
151 | { | 163 | { |
152 | - field: 'sqlKey', | 164 | + field: 'requestSQLKey', |
153 | label: '键名', | 165 | label: '键名', |
154 | colProps: { span: 12 }, | 166 | colProps: { span: 12 }, |
155 | component: 'Input', | 167 | component: 'Input', |
@@ -160,7 +172,7 @@ export const schemas: FormSchema[] = [ | @@ -160,7 +172,7 @@ export const schemas: FormSchema[] = [ | ||
160 | ifShow: ({ values }) => values['requestContentType'] === '1', | 172 | ifShow: ({ values }) => values['requestContentType'] === '1', |
161 | }, | 173 | }, |
162 | { | 174 | { |
163 | - field: 'sqlValue', | 175 | + field: 'requestSQLContent', |
164 | label: '键值', | 176 | label: '键值', |
165 | colProps: { span: 24 }, | 177 | colProps: { span: 24 }, |
166 | component: 'InputTextArea', | 178 | component: 'InputTextArea', |
@@ -12,16 +12,19 @@ | @@ -12,16 +12,19 @@ | ||
12 | <SimpleRequest | 12 | <SimpleRequest |
13 | ref="simpleRequestRef" | 13 | ref="simpleRequestRef" |
14 | v-if="model['requestContentType'] === '0'" | 14 | v-if="model['requestContentType'] === '0'" |
15 | + @activeKey="handleActiveKey" | ||
15 | :method="model['requestContentType']" | 16 | :method="model['requestContentType']" |
16 | /> | 17 | /> |
17 | <SimpleRequest | 18 | <SimpleRequest |
18 | ref="simpleRequestRef" | 19 | ref="simpleRequestRef" |
19 | - v-if="model['requestContentType'] === '2'" | 20 | + @activeKey="handleActiveKey" |
21 | + v-else-if="model['requestContentType'] === '2'" | ||
20 | :method="model['requestContentType']" | 22 | :method="model['requestContentType']" |
21 | /> | 23 | /> |
22 | </template> | 24 | </template> |
23 | <template #testSql="{ model }"> | 25 | <template #testSql="{ model }"> |
24 | <TestSql | 26 | <TestSql |
27 | + ref="testSqlRef" | ||
25 | v-if="model['requestContentType'] === '1'" | 28 | v-if="model['requestContentType'] === '1'" |
26 | :method="model['requestContentType']" | 29 | :method="model['requestContentType']" |
27 | /> | 30 | /> |
@@ -31,38 +34,110 @@ | @@ -31,38 +34,110 @@ | ||
31 | </div> | 34 | </div> |
32 | </template> | 35 | </template> |
33 | <script lang="ts" setup name="publicApi"> | 36 | <script lang="ts" setup name="publicApi"> |
34 | - import { ref } from 'vue'; | 37 | + import { ref, nextTick } from 'vue'; |
35 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 38 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
36 | import { BasicForm, useForm } from '/@/components/Form'; | 39 | import { BasicForm, useForm } from '/@/components/Form'; |
37 | import { schemas } from './config'; | 40 | import { schemas } from './config'; |
38 | - import { SimpleRequest } from './components/SimpleRequest'; | 41 | + import SimpleRequest from './components/SimpleRequest/index.vue'; |
39 | import { TestSql } from './components/TestSql/index'; | 42 | import { TestSql } from './components/TestSql/index'; |
43 | + import { | ||
44 | + saveDataViewInterface, | ||
45 | + updateDataViewInterface, | ||
46 | + } from '/@/api/bigscreen/center/bigscreenCenter'; | ||
47 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
48 | + | ||
49 | + const emits = defineEmits(['success', 'register']); | ||
50 | + | ||
51 | + const { createMessage } = useMessage(); | ||
52 | + | ||
53 | + const isUpdate = ref(false); | ||
54 | + | ||
55 | + const putId = ref(''); | ||
56 | + | ||
57 | + const activeKey = ref(''); | ||
40 | 58 | ||
41 | const simpleRequestRef = ref<InstanceType<typeof SimpleRequest>>(); | 59 | const simpleRequestRef = ref<InstanceType<typeof SimpleRequest>>(); |
42 | 60 | ||
43 | - const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({ | 61 | + const testSqlRef = ref<InstanceType<typeof TestSql>>(); |
62 | + | ||
63 | + const [registerForm, { resetFields, validate, setFieldsValue, updateSchema }] = useForm({ | ||
44 | labelWidth: 120, | 64 | labelWidth: 120, |
45 | schemas, | 65 | schemas, |
46 | showActionButtonGroup: false, | 66 | showActionButtonGroup: false, |
47 | }); | 67 | }); |
48 | 68 | ||
49 | - const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { | 69 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
70 | + setDrawerProps({ loading: true }); | ||
71 | + await nextTick(); | ||
50 | await resetFields(); | 72 | await resetFields(); |
73 | + nextTick(() => simpleRequestRef.value?.resetValue()); | ||
74 | + nextTick(() => testSqlRef.value?.resetValue()); | ||
51 | const title = `${!data.isUpdate ? '新增' : '修改'}公共接口`; | 75 | const title = `${!data.isUpdate ? '新增' : '修改'}公共接口`; |
52 | setDrawerProps({ title }); | 76 | setDrawerProps({ title }); |
53 | - setFieldsValue({ ...data.record }); | 77 | + isUpdate.value = data.isUpdate; |
78 | + !isUpdate.value ? (putId.value = '') : (putId.value = data.record.id); | ||
79 | + if (isUpdate.value) { | ||
80 | + await setFieldsValue({ | ||
81 | + ...data.record, | ||
82 | + requestContentType: String(data.record?.requestContentType), | ||
83 | + requestSQLContent: JSON.parse(data.record?.requestParams)?.requestSQLContent?.sql, | ||
84 | + }); | ||
85 | + await nextTick(() => | ||
86 | + setTimeout(() => { | ||
87 | + simpleRequestRef.value?.setValue(data.record); | ||
88 | + }, 200) | ||
89 | + ); | ||
90 | + const opt = [ | ||
91 | + { label: 'get', value: 'GET' }, | ||
92 | + { label: 'post', value: 'POST' }, | ||
93 | + { label: 'put', value: 'PUT' }, | ||
94 | + ]; | ||
95 | + if (data.record?.requestContentType === 1) { | ||
96 | + updateSchema({ | ||
97 | + field: 'requestHttpType', | ||
98 | + componentProps: { | ||
99 | + options: opt.slice(-2), | ||
100 | + }, | ||
101 | + }); | ||
102 | + } else { | ||
103 | + updateSchema({ | ||
104 | + field: 'requestHttpType', | ||
105 | + componentProps: { | ||
106 | + options: opt, | ||
107 | + }, | ||
108 | + }); | ||
109 | + } | ||
110 | + } | ||
111 | + setDrawerProps({ loading: false }); | ||
54 | }); | 112 | }); |
55 | 113 | ||
114 | + const handleActiveKey = (v) => (activeKey.value = v); | ||
115 | + | ||
56 | const handleOnSubmit = async () => { | 116 | const handleOnSubmit = async () => { |
57 | - const values = await validate(); | ||
58 | - if (!values) return; | ||
59 | - const params = simpleRequestRef?.value?.getValue(); | ||
60 | - const data = { | ||
61 | - ...values, | ||
62 | - requestParams: { | ||
63 | - params, | ||
64 | - }, | ||
65 | - }; | ||
66 | - console.log('Get form values', data); | 117 | + setDrawerProps({ loading: true }); |
118 | + try { | ||
119 | + const values = await validate(); | ||
120 | + if (!values) return; | ||
121 | + const Objects = simpleRequestRef.value?.getValue(); | ||
122 | + const data = { | ||
123 | + ...values, | ||
124 | + id: !putId.value ? null : putId.value, | ||
125 | + requestParams: JSON.stringify({ | ||
126 | + requestSQLContent: { | ||
127 | + sql: values?.requestSQLContent, | ||
128 | + }, | ||
129 | + type: activeKey.value, | ||
130 | + Params: activeKey.value === 'Params' ? Objects : {}, | ||
131 | + Body: activeKey.value === 'Body' ? Objects : {}, | ||
132 | + Header: activeKey.value === 'Header' ? Objects : {}, | ||
133 | + }), | ||
134 | + }; | ||
135 | + !putId.value ? await saveDataViewInterface(data) : await updateDataViewInterface(data); | ||
136 | + emits('success'); | ||
137 | + closeDrawer(); | ||
138 | + createMessage.success(`${!isUpdate.value ? '新增' : '修改'}成功`); | ||
139 | + } finally { | ||
140 | + setDrawerProps({ loading: false }); | ||
141 | + } | ||
67 | }; | 142 | }; |
68 | </script> | 143 | </script> |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | <BasicTable @register="registerTable"> | 3 | <BasicTable @register="registerTable"> |
4 | + <template #content="{ record }"> | ||
5 | + <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button> | ||
6 | + </template> | ||
4 | <template #toolbar> | 7 | <template #toolbar> |
5 | <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增公共接口 </a-button> | 8 | <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增公共接口 </a-button> |
9 | + <Popconfirm | ||
10 | + title="您确定要批量删除数据" | ||
11 | + ok-text="确定" | ||
12 | + cancel-text="取消" | ||
13 | + @confirm="handleDeleteOrBatchDelete(null)" | ||
14 | + > | ||
15 | + <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button> | ||
16 | + </Popconfirm> | ||
6 | </template> | 17 | </template> |
7 | <template #action="{ record }"> | 18 | <template #action="{ record }"> |
8 | <TableAction | 19 | <TableAction |
9 | :actions="[ | 20 | :actions="[ |
10 | { | 21 | { |
11 | label: '发布', | 22 | label: '发布', |
12 | - icon: 'clarity:note-edit-line', | ||
13 | - onClick: handleCreateOrEdit.bind(null, record), | 23 | + icon: 'ant-design:node-expand-outlined', |
24 | + onClick: handlePublish.bind(null, record), | ||
25 | + ifShow: () => { | ||
26 | + return record.state === 0; | ||
27 | + }, | ||
14 | }, | 28 | }, |
15 | { | 29 | { |
16 | label: '取消发布', | 30 | label: '取消发布', |
17 | - icon: 'clarity:note-edit-line', | ||
18 | - onClick: handleCreateOrEdit.bind(null, record), | 31 | + icon: 'ant-design:node-collapse-outlined', |
32 | + onClick: handleCancelPublish.bind(null, record), | ||
33 | + ifShow: () => { | ||
34 | + return record.state === 1; | ||
35 | + }, | ||
19 | }, | 36 | }, |
20 | { | 37 | { |
21 | label: '修改', | 38 | label: '修改', |
22 | icon: 'clarity:note-edit-line', | 39 | icon: 'clarity:note-edit-line', |
23 | onClick: handleCreateOrEdit.bind(null, record), | 40 | onClick: handleCreateOrEdit.bind(null, record), |
41 | + ifShow: () => { | ||
42 | + return record.state === 0; | ||
43 | + }, | ||
24 | }, | 44 | }, |
25 | { | 45 | { |
26 | label: '删除', | 46 | label: '删除', |
27 | icon: 'ant-design:delete-outlined', | 47 | icon: 'ant-design:delete-outlined', |
28 | color: 'error', | 48 | color: 'error', |
49 | + ifShow: () => { | ||
50 | + return record.state === 0; | ||
51 | + }, | ||
29 | popConfirm: { | 52 | popConfirm: { |
30 | title: '是否确认删除', | 53 | title: '是否确认删除', |
31 | confirm: handleDeleteOrBatchDelete.bind(null, record), | 54 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
@@ -36,24 +59,39 @@ | @@ -36,24 +59,39 @@ | ||
36 | </template> | 59 | </template> |
37 | </BasicTable> | 60 | </BasicTable> |
38 | </div> | 61 | </div> |
39 | - <PublicApiForm @register="registerDrawer" /> | 62 | + <PublicApiForm @register="registerDrawer" @success="handleSuccess" /> |
40 | </template> | 63 | </template> |
41 | <script lang="ts" setup name="list"> | 64 | <script lang="ts" setup name="list"> |
65 | + import { nextTick, h } from 'vue'; | ||
42 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 66 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
43 | import { useDrawer } from '/@/components/Drawer'; | 67 | import { useDrawer } from '/@/components/Drawer'; |
44 | - import { columns, list } from './config'; | 68 | + import { columns, searchFormSchema } from './config'; |
45 | import { PublicApiForm } from './index'; | 69 | import { PublicApiForm } from './index'; |
70 | + import { | ||
71 | + getDataViewInterfacePage, | ||
72 | + deleteBigViewInterface, | ||
73 | + getPublish, | ||
74 | + getCancelPublish, | ||
75 | + } from '/@/api/bigscreen/center/bigscreenCenter'; | ||
76 | + import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | ||
77 | + import { Popconfirm, Modal } from 'ant-design-vue'; | ||
78 | + import { JsonPreview } from '/@/components/CodeEditor'; | ||
79 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
46 | 80 | ||
47 | - const [registerTable] = useTable({ | ||
48 | - // api: exportPage, | ||
49 | - dataSource: list, | 81 | + const [registerTable, { reload, setProps }] = useTable({ |
82 | + api: getDataViewInterfacePage, | ||
50 | columns, | 83 | columns, |
51 | showIndexColumn: false, | 84 | showIndexColumn: false, |
52 | clickToRowSelect: false, | 85 | clickToRowSelect: false, |
53 | showTableSetting: true, | 86 | showTableSetting: true, |
54 | bordered: true, | 87 | bordered: true, |
88 | + formConfig: { | ||
89 | + labelWidth: 120, | ||
90 | + schemas: searchFormSchema, | ||
91 | + }, | ||
92 | + useSearchForm: true, | ||
55 | actionColumn: { | 93 | actionColumn: { |
56 | - width: 200, | 94 | + width: 150, |
57 | title: '操作', | 95 | title: '操作', |
58 | dataIndex: 'action', | 96 | dataIndex: 'action', |
59 | slots: { customRender: 'action' }, | 97 | slots: { customRender: 'action' }, |
@@ -63,9 +101,19 @@ | @@ -63,9 +101,19 @@ | ||
63 | 101 | ||
64 | const [registerDrawer, { openDrawer }] = useDrawer(); | 102 | const [registerDrawer, { openDrawer }] = useDrawer(); |
65 | 103 | ||
66 | - const handleDeleteOrBatchDelete = (record) => { | ||
67 | - console.log(record); | ||
68 | - }; | 104 | + const { createMessage } = useMessage(); |
105 | + | ||
106 | + const handleSuccess = () => reload(); | ||
107 | + | ||
108 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | ||
109 | + deleteBigViewInterface, | ||
110 | + handleSuccess, | ||
111 | + setProps | ||
112 | + ); | ||
113 | + | ||
114 | + nextTick(() => { | ||
115 | + setProps(selectionOptions); | ||
116 | + }); | ||
69 | 117 | ||
70 | const handleCreateOrEdit = (record) => { | 118 | const handleCreateOrEdit = (record) => { |
71 | const isUpdate = record === null ? false : true; | 119 | const isUpdate = record === null ? false : true; |
@@ -75,4 +123,24 @@ | @@ -75,4 +123,24 @@ | ||
75 | record: recordContent, | 123 | record: recordContent, |
76 | }); | 124 | }); |
77 | }; | 125 | }; |
126 | + | ||
127 | + const handleRecordContent = (record) => { | ||
128 | + Modal.info({ | ||
129 | + title: '接口内容', | ||
130 | + width: 600, | ||
131 | + content: h(JsonPreview, { data: JSON.parse(record.requestParams) }), | ||
132 | + }); | ||
133 | + }; | ||
134 | + | ||
135 | + const handlePublish = async (record) => { | ||
136 | + await getPublish(record.id); | ||
137 | + createMessage.success(`发布成功`); | ||
138 | + handleSuccess(); | ||
139 | + }; | ||
140 | + | ||
141 | + const handleCancelPublish = async (record) => { | ||
142 | + await getCancelPublish(record.id); | ||
143 | + createMessage.success(`取消发布成功`); | ||
144 | + handleSuccess(); | ||
145 | + }; | ||
78 | </script> | 146 | </script> |