Commit 762f38be8ae2b3df4f78b67f1039ae920fcd8fd1

Authored by fengwotao
1 parent bda264ea

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

@@ -19,31 +19,35 @@ export const step1Schemas: FormSchema[] = [ @@ -19,31 +19,35 @@ export const step1Schemas: FormSchema[] = [
19 component: 'Input', 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 field: 'alias', 22 field: 'alias',
34 label: '别名 ', 23 label: '别名 ',
35 component: 'Input', 24 component: 'Input',
36 - labelWidth: 60,  
37 - colProps: { span: 10 },  
38 componentProps: { 25 componentProps: {
39 maxLength: 255, 26 maxLength: 255,
40 }, 27 },
41 }, 28 },
42 { 29 {
43 - field: 'sn',  
44 - label: 'SN码', 30 + field: 'name',
  31 + label: '设备名称/SN码',
45 component: 'Input', 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 slot: 'snCode', 51 slot: 'snCode',
48 }, 52 },
49 { 53 {
@@ -5,6 +5,7 @@ import { DeviceTypeEnum, DeviceState, DeviceRecord } from '/@/api/device/model/d @@ -5,6 +5,7 @@ import { DeviceTypeEnum, DeviceState, DeviceRecord } from '/@/api/device/model/d
5 import { deviceProfile } from '/@/api/device/deviceManager'; 5 import { deviceProfile } from '/@/api/device/deviceManager';
6 import { h } from 'vue'; 6 import { h } from 'vue';
7 import { Tag } from 'ant-design-vue'; 7 import { Tag } from 'ant-design-vue';
  8 +import { handeleCopy } from '../../profiles/step/topic';
8 9
9 // 表格列数据 10 // 表格列数据
10 export const columns: BasicColumn[] = [ 11 export const columns: BasicColumn[] = [
@@ -24,9 +25,19 @@ export const columns: BasicColumn[] = [ @@ -24,9 +25,19 @@ export const columns: BasicColumn[] = [
24 dataIndex: 'name', 25 dataIndex: 'name',
25 title: '设备名称/设备SN', 26 title: '设备名称/设备SN',
26 width: 200, 27 width: 200,
27 - align: 'left',  
28 slots: { customRender: 'name', title: 'deviceTitle' }, 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 title: '设备类型', 43 title: '设备类型',
@@ -140,8 +140,8 @@ @@ -140,8 +140,8 @@
140 confirmLoading: true, 140 confirmLoading: true,
141 }); 141 });
142 if (unref(isUpdate)) { 142 if (unref(isUpdate)) {
143 - console.log(currentDeviceData);  
144 const editData = { 143 const editData = {
  144 + sn: 'XXXX',
145 ...unref(stepState), 145 ...unref(stepState),
146 customerId: currentDeviceData.customerId, 146 customerId: currentDeviceData.customerId,
147 deviceInfo: { 147 deviceInfo: {
@@ -152,6 +152,7 @@ @@ -152,6 +152,7 @@
152 await createOrEditDevice(editData); 152 await createOrEditDevice(editData);
153 } else { 153 } else {
154 const createData = { 154 const createData = {
  155 + sn: 'XXXX',
155 ...unref(stepState), 156 ...unref(stepState),
156 deviceInfo: { 157 deviceInfo: {
157 avatar: DeviceStep1Ref.value?.devicePic, 158 avatar: DeviceStep1Ref.value?.devicePic,
@@ -363,7 +363,7 @@ @@ -363,7 +363,7 @@
363 const generateSN = async () => { 363 const generateSN = async () => {
364 const data = await generateSNCode(); 364 const data = await generateSNCode();
365 setFieldsValue({ 365 setFieldsValue({
366 - sn: data, 366 + name: data,
367 }); 367 });
368 }; 368 };
369 369
@@ -62,18 +62,6 @@ @@ -62,18 +62,6 @@
62 </Popover> 62 </Popover>
63 </div> 63 </div>
64 </template> 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 <template #deviceProfile="{ record }"> 65 <template #deviceProfile="{ record }">
78 <Tag.CheckableTag 66 <Tag.CheckableTag
79 @click="goDeviceProfile(record.deviceProfile.name)" 67 @click="goDeviceProfile(record.deviceProfile.name)"
@@ -201,7 +189,7 @@ @@ -201,7 +189,7 @@
201 } from '/@/api/device/model/deviceModel'; 189 } from '/@/api/device/model/deviceModel';
202 import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table'; 190 import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table';
203 import { columns, searchFormSchema } from './config/device.data'; 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 import { 193 import {
206 deleteDevice, 194 deleteDevice,
207 devicePage, 195 devicePage,
@@ -244,7 +232,6 @@ @@ -244,7 +232,6 @@
244 DeviceDetailDrawer, 232 DeviceDetailDrawer,
245 CustomerModal, 233 CustomerModal,
246 TableImg, 234 TableImg,
247 - Tooltip,  
248 QuestionCircleOutlined, 235 QuestionCircleOutlined,
249 Popover, 236 Popover,
250 Authority, 237 Authority,
@@ -4,7 +4,7 @@ import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; @@ -4,7 +4,7 @@ import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
4 import { useMessage } from '/@/hooks/web/useMessage'; 4 import { useMessage } from '/@/hooks/web/useMessage';
5 const { createMessage } = useMessage(); 5 const { createMessage } = useMessage();
6 6
7 -const handeleCopy = (e) => { 7 +export const handeleCopy = (e) => {
8 const { isSuccessRef } = useCopyToClipboard(JSON.parse(JSON.stringify(unref(e), null, 2))); 8 const { isSuccessRef } = useCopyToClipboard(JSON.parse(JSON.stringify(unref(e), null, 2)));
9 unref(isSuccessRef); 9 unref(isSuccessRef);
10 createMessage.success('复制成功!'); 10 createMessage.success('复制成功!');