Skip to content

Commit 89f35bf

Browse files
committed
大屏编辑发布
1 parent 127d544 commit 89f35bf

File tree

4 files changed

+419
-131
lines changed

4 files changed

+419
-131
lines changed

public/resource/img/no-data.svg

Lines changed: 1 addition & 0 deletions
Loading

src/views/screen/visual/form.vue

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
<template>
2-
<BasicModal v-bind="$attrs" :showFooter="true" @register="registerModal" @ok="handleSubmit" width="40%"
3-
:show-ok-btn="hasPermission(Authority.TENANT_ADMIN)">
4-
<template #title>
5-
<Icon :icon="getTitle.icon" class="pr-1 m-1" />
6-
<span> {{ getTitle.value }} </span>
7-
</template>
8-
<BasicForm @register="registerForm">
9-
10-
</BasicForm>
11-
</BasicModal>
12-
</template>
13-
<script lang="ts" setup name="ViewsScreenVisualForm">
2+
<BasicModal
3+
v-bind="$attrs"
4+
:showFooter="true"
5+
@register="registerModal"
6+
@ok="handleSubmit"
7+
width="40%"
8+
:show-ok-btn="hasPermission(Authority.TENANT_ADMIN)"
9+
>
10+
<template #title>
11+
<Icon :icon="getTitle.icon" class="pr-1 m-1" />
12+
<span> {{ getTitle.value }} </span>
13+
</template>
14+
<BasicForm @register="registerForm"> </BasicForm>
15+
</BasicModal>
16+
</template>
17+
<script lang="ts" setup name="ViewsScreenVisualForm">
1418
import { ref, unref, computed } from 'vue';
1519
import { useI18n } from '/@/hooks/web/useI18n';
1620
import { useMessage } from '/@/hooks/web/useMessage';
1721
import { router } from '/@/router';
1822
import { Icon } from '/@/components/Icon';
19-
23+
2024
import { BasicForm, FormSchema, useForm } from '/@/components/Form';
2125
import { BasicModal, useModalInner } from '/@/components/Modal';
2226
import { useUserStore } from '/@/store/modules/user';
23-
import { getTbVisualInfoById, createTbVisual, saveTbVisual, TbVisualInfo } from '/@/api/screen/visual';
27+
import {
28+
getTbVisualInfoById,
29+
createTbVisual,
30+
saveTbVisual,
31+
TbVisualInfo,
32+
} from '/@/api/screen/visual';
2433
import { EntityType } from '/@/enums/entityTypeEnum';
2534
import { usePermission } from '/@/hooks/web/usePermission';
2635
import { Authority } from '/@/enums/authorityEnum';
27-
36+
2837
const emit = defineEmits(['success', 'register']);
29-
38+
3039
const { t } = useI18n('tb');
3140
const { hasPermission } = usePermission();
3241
const userStore = useUserStore();
@@ -37,23 +46,40 @@
3746
icon: meta.icon || 'ant-design:book-outlined',
3847
value: record.value.id?.id ? t('编辑数据大屏') : t('新增数据大屏'),
3948
}));
40-
41-
42-
43-
49+
4450
const inputFormSchemas: FormSchema[] = [
45-
{ field: 'tenantId', component: 'Input', defaultValue: userStore.getUserInfo.tenantId, show: false },
51+
{
52+
field: 'tenantId',
53+
component: 'Input',
54+
defaultValue: userStore.getUserInfo.tenantId,
55+
show: false,
56+
},
4657
{
4758
label: t('大屏名称'),
4859
field: 'title',
4960
component: 'Input',
5061
componentProps: {
5162
maxlength: 100,
52-
placeholder: '请输大屏名称'
63+
placeholder: '请输大屏名称',
5364
},
5465
required: true,
5566
},
56-
67+
{
68+
label: t('访问密钥'),
69+
field: 'credentials',
70+
component: 'Input',
71+
ifShow: () => !!record.value.id?.id,
72+
componentProps: {
73+
maxlength: 100,
74+
placeholder: '请输大屏访问密钥',
75+
},
76+
rules: [
77+
{ required: false },
78+
{ max: 10, message: t('请输入长度在 10 个字符之内') },
79+
{ pattern: /^[a-zA-Z0-9]*$/, message: t('请输入字母和数字') },
80+
],
81+
},
82+
5783
{
5884
label: t('描述信息'),
5985
field: 'additionalInfo.description',
@@ -62,15 +88,14 @@
6288
maxlength: 500,
6389
},
6490
},
65-
6691
];
67-
92+
6893
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({
6994
labelWidth: 120,
7095
schemas: inputFormSchemas,
7196
baseColProps: { lg: 24, md: 24 },
7297
});
73-
98+
7499
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
75100
setModalProps({ loading: true });
76101
await resetFields();
@@ -82,16 +107,16 @@
82107
setFieldsValue(record.value);
83108
setModalProps({ loading: false });
84109
});
85-
110+
86111
async function handleSubmit() {
87112
try {
88113
const data = await validate();
89114
setModalProps({ confirmLoading: true });
90115
// console.log('submit', params, data, record);
91-
116+
92117
if (record.value?.id?.id) {
93118
const res = await saveTbVisual({ ...record.value, ...data, id: record.value.id });
94-
}else{
119+
} else {
95120
const res = await createTbVisual({ ...data });
96121
}
97122
showMessage(`${record.value.id?.id ? '编辑' : '新增'}设备大屏成功!`);
@@ -106,9 +131,4 @@
106131
setModalProps({ confirmLoading: false });
107132
}
108133
}
109-
110-
111-
112-
113-
</script>
114-
134+
</script>

0 commit comments

Comments
 (0)