Commit 762f38be8ae2b3df4f78b67f1039ae920fcd8fd1

Authored by fengwotao
1 parent bda264ea

pref: 调整设备列表第一页表单的设备名称和SN

... ... @@ -19,31 +19,35 @@ export const step1Schemas: FormSchema[] = [
19 19 component: 'Input',
20 20 },
21 21 {
22   - field: 'name',
23   - label: '设备名称',
24   - required: true,
25   - component: 'Input',
26   - colProps: { span: 14 },
27   - componentProps: {
28   - placeholder: '设备名称',
29   - maxLength: 36,
30   - },
31   - },
32   - {
33 22 field: 'alias',
34 23 label: '别名 ',
35 24 component: 'Input',
36   - labelWidth: 60,
37   - colProps: { span: 10 },
38 25 componentProps: {
39 26 maxLength: 255,
40 27 },
41 28 },
42 29 {
43   - field: 'sn',
44   - label: 'SN码',
  30 + field: 'name',
  31 + label: '设备名称/SN码',
45 32 component: 'Input',
46   - required: true,
  33 + dynamicRules: () => {
  34 + return [
  35 + {
  36 + required: true,
  37 + validator: (_, value) => {
  38 + // 支持英文字母、数字、下划线(_)、中划线(-)、点号(.)、半角冒号(:)和特殊字符@,长度限制为4~32个字符
  39 + const reg = /^[A-Za-z0-9_\( \)\-\@\:\.]+$/;
  40 + const strLength = String(value).length as number;
  41 + if (!reg.test(value) || strLength > 32 || strLength < 4) {
  42 + return Promise.reject(
  43 + '请输入支持英文字母、数字、下划线(_)、中划线(-)、点号(.)、半角冒号(:)和特殊字符@,长度限制为4~32个字符'
  44 + );
  45 + }
  46 + return Promise.resolve();
  47 + },
  48 + },
  49 + ];
  50 + },
47 51 slot: 'snCode',
48 52 },
49 53 {
... ...
... ... @@ -5,6 +5,7 @@ import { DeviceTypeEnum, DeviceState, DeviceRecord } from '/@/api/device/model/d
5 5 import { deviceProfile } from '/@/api/device/deviceManager';
6 6 import { h } from 'vue';
7 7 import { Tag } from 'ant-design-vue';
  8 +import { handeleCopy } from '../../profiles/step/topic';
8 9
9 10 // 表格列数据
10 11 export const columns: BasicColumn[] = [
... ... @@ -24,9 +25,19 @@ export const columns: BasicColumn[] = [
24 25 dataIndex: 'name',
25 26 title: '设备名称/设备SN',
26 27 width: 200,
27   - align: 'left',
28 28 slots: { customRender: 'name', title: 'deviceTitle' },
29   - ellipsis: true,
  29 + customRender: ({ record }) => {
  30 + return h(
  31 + 'span',
  32 + {
  33 + style: { cursor: 'pointer', color: '#377dff' },
  34 + onClick: () => {
  35 + handeleCopy(record.name || record.alias);
  36 + },
  37 + },
  38 + record.name || record.alias
  39 + );
  40 + },
30 41 },
31 42 {
32 43 title: '设备类型',
... ...
... ... @@ -140,8 +140,8 @@
140 140 confirmLoading: true,
141 141 });
142 142 if (unref(isUpdate)) {
143   - console.log(currentDeviceData);
144 143 const editData = {
  144 + sn: 'XXXX',
145 145 ...unref(stepState),
146 146 customerId: currentDeviceData.customerId,
147 147 deviceInfo: {
... ... @@ -152,6 +152,7 @@
152 152 await createOrEditDevice(editData);
153 153 } else {
154 154 const createData = {
  155 + sn: 'XXXX',
155 156 ...unref(stepState),
156 157 deviceInfo: {
157 158 avatar: DeviceStep1Ref.value?.devicePic,
... ...
... ... @@ -363,7 +363,7 @@
363 363 const generateSN = async () => {
364 364 const data = await generateSNCode();
365 365 setFieldsValue({
366   - sn: data,
  366 + name: data,
367 367 });
368 368 };
369 369
... ...
... ... @@ -62,18 +62,6 @@
62 62 </Popover>
63 63 </div>
64 64 </template>
65   - <template #name="{ record }">
66   - <div>
67   - <Tooltip :title="record.alias || record.name" placement="topRight">
68   - {{ record.alias || record.name.slice(0, 13) }}
69   - </Tooltip>
70   - </div>
71   - <Tooltip title="设备SN码" placement="topRight">
72   - <a-button type="link" @click="copySN(record.sn)" style="padding: 0">
73   - {{ record.sn }}
74   - </a-button>
75   - </Tooltip>
76   - </template>
77 65 <template #deviceProfile="{ record }">
78 66 <Tag.CheckableTag
79 67 @click="goDeviceProfile(record.deviceProfile.name)"
... ... @@ -201,7 +189,7 @@
201 189 } from '/@/api/device/model/deviceModel';
202 190 import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table';
203 191 import { columns, searchFormSchema } from './config/device.data';
204   - import { Tag, Tooltip, Popover, Popconfirm, Button } from 'ant-design-vue';
  192 + import { Tag, Popover, Popconfirm, Button } from 'ant-design-vue';
205 193 import {
206 194 deleteDevice,
207 195 devicePage,
... ... @@ -244,7 +232,6 @@
244 232 DeviceDetailDrawer,
245 233 CustomerModal,
246 234 TableImg,
247   - Tooltip,
248 235 QuestionCircleOutlined,
249 236 Popover,
250 237 Authority,
... ...
... ... @@ -4,7 +4,7 @@ import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
4 4 import { useMessage } from '/@/hooks/web/useMessage';
5 5 const { createMessage } = useMessage();
6 6
7   -const handeleCopy = (e) => {
  7 +export const handeleCopy = (e) => {
8 8 const { isSuccessRef } = useCopyToClipboard(JSON.parse(JSON.stringify(unref(e), null, 2)));
9 9 unref(isSuccessRef);
10 10 createMessage.success('复制成功!');
... ...