Commit dc2a6642708c1fc45e2b67c236b13865740366f3

Authored by ww
1 parent 15fdc350

perf: DEFECT-1101 优化组织下拉选择器

1 import { BasicColumn, FormSchema } from '/@/components/Table'; 1 import { BasicColumn, FormSchema } from '/@/components/Table';
2 -import { getOrganizationList } from '/@/api/system/system';  
3 -import { copyTransFun } from '/@/utils/fnUtils';  
4 import { findDictItemByCode } from '/@/api/system/dict'; 2 import { findDictItemByCode } from '/@/api/system/dict';
5 - 3 +import { useComponentRegister } from '/@/components/Form';
  4 +import { OrgTreeSelect } from '../../common/OrgTreeSelect';
  5 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
6 // 表格列数据 6 // 表格列数据
7 export const columns: BasicColumn[] = [ 7 export const columns: BasicColumn[] = [
8 { 8 {
@@ -98,19 +98,8 @@ export const formSchema: FormSchema[] = [ @@ -98,19 +98,8 @@ export const formSchema: FormSchema[] = [
98 { 98 {
99 field: 'organizationId', 99 field: 'organizationId',
100 label: '所属组织', 100 label: '所属组织',
101 - component: 'ApiTreeSelect', 101 + component: 'OrgTreeSelect',
102 required: true, 102 required: true,
103 - componentProps: () => {  
104 - return {  
105 - maxLength: 250,  
106 - placeholder: '请选择所属组织',  
107 - api: async () => {  
108 - const data = await getOrganizationList();  
109 - copyTransFun(data as any as any[]);  
110 - return data;  
111 - },  
112 - };  
113 - },  
114 }, 103 },
115 { 104 {
116 field: 'alarmContactId', 105 field: 'alarmContactId',
1 import { BasicColumn, FormSchema } from '/@/components/Table'; 1 import { BasicColumn, FormSchema } from '/@/components/Table';
2 -import { getOrganizationList } from '/@/api/system/system';  
3 -import { copyTransFun } from '/@/utils/fnUtils';  
4 import { emailRule, phoneRule } from '/@/utils/rules'; 2 import { emailRule, phoneRule } from '/@/utils/rules';
5 - 3 +import { useComponentRegister } from '/@/components/Form';
  4 +import { OrgTreeSelect } from '../../common/OrgTreeSelect';
  5 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
6 // 表格列数据 6 // 表格列数据
7 export const columns: BasicColumn[] = [ 7 export const columns: BasicColumn[] = [
8 { 8 {
@@ -78,14 +78,7 @@ export const formSchema: FormSchema[] = [ @@ -78,14 +78,7 @@ export const formSchema: FormSchema[] = [
78 field: 'organizationId', 78 field: 'organizationId',
79 label: '所属组织', 79 label: '所属组织',
80 required: true, 80 required: true,
81 - component: 'ApiTreeSelect',  
82 - componentProps: {  
83 - api: async () => {  
84 - const data = await getOrganizationList();  
85 - copyTransFun(data as any as any[]);  
86 - return data;  
87 - },  
88 - }, 81 + component: 'OrgTreeSelect',
89 }, 82 },
90 { 83 {
91 field: 'phone', 84 field: 'phone',
1 -import { BasicColumn, FormSchema } from '/@/components/Table';  
2 -import { getOrganizationList } from '/@/api/system/system';  
3 -import { copyTransFun } from '/@/utils/fnUtils';  
4 -import type { FormSchema as QFormSchema } from '/@/components/Form/index';  
5 -  
6 -import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules';  
7 -import { h } from 'vue';  
8 -import SnHelpMessage from './SnHelpMessage.vue';  
9 -  
10 -export enum CameraPermission {  
11 - PREVIEW = 'api:yt:video:get',  
12 - CREATE = 'api:yt:video:post',  
13 - UPDATE = 'api:yt:video:update',  
14 - DELETE = 'api:yt:video:delete',  
15 -}  
16 -  
17 -export enum AccessMode {  
18 - ManuallyEnter = 0,  
19 - Streaming = 1,  
20 -}  
21 -  
22 -export enum PlayProtocol {  
23 - HTTP = 0,  
24 - HTTPS = 1,  
25 -}  
26 -  
27 -export enum StreamType {  
28 - MASTER = 0,  
29 - CHILD = 1,  
30 - THIRD = 2,  
31 -}  
32 -  
33 -export enum PageMode {  
34 - SPLIT_SCREEN_MODE = 'splitScreen',  
35 - LIST_MODE = 'listMode',  
36 - FULL_SCREEN_MODE = 'fullScreenMode',  
37 -}  
38 -  
39 -export enum MediaType {  
40 - MP4 = 'mp4',  
41 - M3U8 = 'm3u8',  
42 -}  
43 -  
44 -// 表格列数据  
45 -export const columns: BasicColumn[] = [  
46 - {  
47 - title: '封面',  
48 - dataIndex: 'avatar',  
49 - width: 80,  
50 - slots: { customRender: 'img' },  
51 - },  
52 - {  
53 - title: '名字',  
54 - dataIndex: 'name',  
55 - width: 120,  
56 - },  
57 - {  
58 - title: '摄像头编号/监控点编号',  
59 - dataIndex: 'sn',  
60 - width: 220,  
61 - },  
62 - {  
63 - title: '视频流',  
64 - dataIndex: 'videoUrl',  
65 - width: 120,  
66 - },  
67 - {  
68 - title: '所属组织',  
69 - dataIndex: 'organizationName',  
70 - width: 160,  
71 - },  
72 - {  
73 - title: '获取方式',  
74 - dataIndex: 'accessMode',  
75 - width: 100,  
76 - slots: { customRender: 'accessMode' },  
77 - },  
78 - {  
79 - title: '创建时间',  
80 - dataIndex: 'createTime',  
81 - width: 140,  
82 - },  
83 -];  
84 -  
85 -// 查询字段  
86 -export const searchFormSchema: FormSchema[] = [  
87 - {  
88 - field: 'name',  
89 - label: '摄像头名字',  
90 - component: 'Input',  
91 - colProps: { span: 8 },  
92 - componentProps: {  
93 - maxLength: 36,  
94 - placeholder: '请输入摄像头名字',  
95 - },  
96 - },  
97 -];  
98 -  
99 -// 弹框配置项  
100 -export const formSchema: QFormSchema[] = [  
101 - {  
102 - field: 'avatar',  
103 - label: '视频封面',  
104 - slot: 'iconSelect',  
105 - component: 'Input',  
106 - },  
107 - {  
108 - field: 'name',  
109 - label: '视频名字',  
110 - required: true,  
111 - component: 'Input',  
112 - componentProps: {  
113 - placeholder: '请输入视频名字',  
114 - maxLength: 30,  
115 - },  
116 - rules: [...CameraMaxLength, { required: true, message: '视频名是必填项' }],  
117 - },  
118 - {  
119 - field: 'organizationId',  
120 - label: '所属组织',  
121 - required: true,  
122 - component: 'ApiTreeSelect',  
123 - componentProps: {  
124 - api: async () => {  
125 - const data = await getOrganizationList();  
126 - copyTransFun(data as any as any[]);  
127 - return data;  
128 - },  
129 - },  
130 - },  
131 - {  
132 - label: '视频流获取方式',  
133 - field: 'accessMode',  
134 - component: 'RadioGroup',  
135 - rules: [{ required: true, message: '视频流获取方式为必选项', type: 'number' }],  
136 - defaultValue: AccessMode.ManuallyEnter,  
137 - componentProps({ formActionType }) {  
138 - return {  
139 - defaultValue: AccessMode.ManuallyEnter,  
140 - placeholder: '请选择视频流获取方式',  
141 - options: [  
142 - { label: '手动输入', value: AccessMode.ManuallyEnter },  
143 - { label: '流媒体获取', value: AccessMode.Streaming },  
144 - ],  
145 - onChange() {  
146 - formActionType.setFieldsValue({  
147 - brand: null,  
148 - sn: null,  
149 - videoUrl: null,  
150 - videoPlatformId: null,  
151 - });  
152 - },  
153 - };  
154 - },  
155 - },  
156 - {  
157 - field: 'brand',  
158 - label: '视频厂家',  
159 - component: 'Input',  
160 - ifShow({ values }) {  
161 - return values.accessMode === AccessMode.ManuallyEnter;  
162 - },  
163 - componentProps: {  
164 - maxLength: 36,  
165 - placeholder: '请输入视频厂家',  
166 - },  
167 - },  
168 - {  
169 - field: 'sn',  
170 - label: '摄像头编号',  
171 - required: true,  
172 - component: 'Input',  
173 - rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],  
174 - ifShow({ values }) {  
175 - return values.accessMode === AccessMode.ManuallyEnter;  
176 - },  
177 - componentProps: {  
178 - maxLength: 36,  
179 - placeholder: '请输入摄像头编号',  
180 - },  
181 - },  
182 - {  
183 - field: 'videoUrl',  
184 - label: '视频流',  
185 - component: 'Input',  
186 - required: true,  
187 - ifShow({ values }) {  
188 - return values.accessMode === AccessMode.ManuallyEnter;  
189 - },  
190 - componentProps: {  
191 - placeholder: '请输入视频流',  
192 - maxLength: 255,  
193 - },  
194 - rules: [{ required: true, message: '视频流是必填项' }, ...CameraVideoUrl],  
195 - },  
196 -  
197 - {  
198 - field: 'videoPlatformId',  
199 - label: '流媒体配置',  
200 - component: 'Select',  
201 - ifShow({ values }) {  
202 - return values.accessMode === AccessMode.Streaming;  
203 - },  
204 - slot: 'videoPlatformIdSlot',  
205 - componentProps: {  
206 - placeholder: '请选择流媒体配置',  
207 - },  
208 - },  
209 - {  
210 - field: 'streamType',  
211 - label: '码流',  
212 - component: 'RadioGroup',  
213 - defaultValue: StreamType.MASTER,  
214 - ifShow({ values }) {  
215 - return values.accessMode === AccessMode.Streaming;  
216 - },  
217 - componentProps: {  
218 - placeholder: '请选择码流',  
219 - defaultValue: StreamType.MASTER,  
220 - options: [  
221 - { label: '主码流', value: StreamType.MASTER },  
222 - { label: '子码流', value: StreamType.CHILD },  
223 - { label: '第三码流', value: StreamType.THIRD },  
224 - ],  
225 - },  
226 - },  
227 - {  
228 - field: 'playProtocol',  
229 - label: '播放协议',  
230 - component: 'RadioGroup',  
231 - defaultValue: PlayProtocol.HTTP,  
232 - ifShow({ values }) {  
233 - return values.accessMode === AccessMode.Streaming;  
234 - },  
235 - helpMessage: ['平台使用https的hls协议,需联系海康开放平台专家支持。'],  
236 - componentProps: {  
237 - placeholder: '请选择播放协议',  
238 - defaultValue: PlayProtocol.HTTP,  
239 - options: [  
240 - { label: 'http', value: PlayProtocol.HTTP },  
241 - { label: 'https', value: PlayProtocol.HTTPS },  
242 - ],  
243 - },  
244 - },  
245 - {  
246 - field: 'sn',  
247 - label: h(SnHelpMessage) as any,  
248 - component: 'Input',  
249 - rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],  
250 - ifShow({ values }) {  
251 - return values.accessMode === AccessMode.Streaming;  
252 - },  
253 - componentProps: {  
254 - placeholder: '请输入监控点编号',  
255 - },  
256 - },  
257 -]; 1 +import { BasicColumn, FormSchema } from '/@/components/Table';
  2 +import { FormSchema as QFormSchema, useComponentRegister } from '/@/components/Form/index';
  3 +
  4 +import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules';
  5 +import { h } from 'vue';
  6 +import SnHelpMessage from './SnHelpMessage.vue';
  7 +import { OrgTreeSelect } from '../../common/OrgTreeSelect';
  8 +
  9 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
  10 +
  11 +export enum CameraPermission {
  12 + PREVIEW = 'api:yt:video:get',
  13 + CREATE = 'api:yt:video:post',
  14 + UPDATE = 'api:yt:video:update',
  15 + DELETE = 'api:yt:video:delete',
  16 +}
  17 +
  18 +export enum AccessMode {
  19 + ManuallyEnter = 0,
  20 + Streaming = 1,
  21 +}
  22 +
  23 +export enum PlayProtocol {
  24 + HTTP = 0,
  25 + HTTPS = 1,
  26 +}
  27 +
  28 +export enum StreamType {
  29 + MASTER = 0,
  30 + CHILD = 1,
  31 + THIRD = 2,
  32 +}
  33 +
  34 +export enum PageMode {
  35 + SPLIT_SCREEN_MODE = 'splitScreen',
  36 + LIST_MODE = 'listMode',
  37 + FULL_SCREEN_MODE = 'fullScreenMode',
  38 +}
  39 +
  40 +export enum MediaType {
  41 + MP4 = 'mp4',
  42 + M3U8 = 'm3u8',
  43 +}
  44 +
  45 +// 表格列数据
  46 +export const columns: BasicColumn[] = [
  47 + {
  48 + title: '封面',
  49 + dataIndex: 'avatar',
  50 + width: 80,
  51 + slots: { customRender: 'img' },
  52 + },
  53 + {
  54 + title: '名字',
  55 + dataIndex: 'name',
  56 + width: 120,
  57 + },
  58 + {
  59 + title: '摄像头编号/监控点编号',
  60 + dataIndex: 'sn',
  61 + width: 220,
  62 + },
  63 + {
  64 + title: '视频流',
  65 + dataIndex: 'videoUrl',
  66 + width: 120,
  67 + },
  68 + {
  69 + title: '所属组织',
  70 + dataIndex: 'organizationName',
  71 + width: 160,
  72 + },
  73 + {
  74 + title: '获取方式',
  75 + dataIndex: 'accessMode',
  76 + width: 100,
  77 + slots: { customRender: 'accessMode' },
  78 + },
  79 + {
  80 + title: '创建时间',
  81 + dataIndex: 'createTime',
  82 + width: 140,
  83 + },
  84 +];
  85 +
  86 +// 查询字段
  87 +export const searchFormSchema: FormSchema[] = [
  88 + {
  89 + field: 'name',
  90 + label: '摄像头名字',
  91 + component: 'Input',
  92 + colProps: { span: 8 },
  93 + componentProps: {
  94 + maxLength: 36,
  95 + placeholder: '请输入摄像头名字',
  96 + },
  97 + },
  98 +];
  99 +
  100 +// 弹框配置项
  101 +export const formSchema: QFormSchema[] = [
  102 + {
  103 + field: 'avatar',
  104 + label: '视频封面',
  105 + slot: 'iconSelect',
  106 + component: 'Input',
  107 + },
  108 + {
  109 + field: 'name',
  110 + label: '视频名字',
  111 + required: true,
  112 + component: 'Input',
  113 + componentProps: {
  114 + placeholder: '请输入视频名字',
  115 + maxLength: 30,
  116 + },
  117 + rules: [...CameraMaxLength, { required: true, message: '视频名是必填项' }],
  118 + },
  119 + {
  120 + field: 'organizationId',
  121 + label: '所属组织',
  122 + required: true,
  123 + component: 'OrgTreeSelect',
  124 + },
  125 + {
  126 + label: '视频流获取方式',
  127 + field: 'accessMode',
  128 + component: 'RadioGroup',
  129 + rules: [{ required: true, message: '视频流获取方式为必选项', type: 'number' }],
  130 + defaultValue: AccessMode.ManuallyEnter,
  131 + componentProps({ formActionType }) {
  132 + return {
  133 + defaultValue: AccessMode.ManuallyEnter,
  134 + placeholder: '请选择视频流获取方式',
  135 + options: [
  136 + { label: '手动输入', value: AccessMode.ManuallyEnter },
  137 + { label: '流媒体获取', value: AccessMode.Streaming },
  138 + ],
  139 + onChange() {
  140 + formActionType.setFieldsValue({
  141 + brand: null,
  142 + sn: null,
  143 + videoUrl: null,
  144 + videoPlatformId: null,
  145 + });
  146 + },
  147 + };
  148 + },
  149 + },
  150 + {
  151 + field: 'brand',
  152 + label: '视频厂家',
  153 + component: 'Input',
  154 + ifShow({ values }) {
  155 + return values.accessMode === AccessMode.ManuallyEnter;
  156 + },
  157 + componentProps: {
  158 + maxLength: 36,
  159 + placeholder: '请输入视频厂家',
  160 + },
  161 + },
  162 + {
  163 + field: 'sn',
  164 + label: '摄像头编号',
  165 + required: true,
  166 + component: 'Input',
  167 + rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
  168 + ifShow({ values }) {
  169 + return values.accessMode === AccessMode.ManuallyEnter;
  170 + },
  171 + componentProps: {
  172 + maxLength: 36,
  173 + placeholder: '请输入摄像头编号',
  174 + },
  175 + },
  176 + {
  177 + field: 'videoUrl',
  178 + label: '视频流',
  179 + component: 'Input',
  180 + required: true,
  181 + ifShow({ values }) {
  182 + return values.accessMode === AccessMode.ManuallyEnter;
  183 + },
  184 + componentProps: {
  185 + placeholder: '请输入视频流',
  186 + maxLength: 255,
  187 + },
  188 + rules: [{ required: true, message: '视频流是必填项' }, ...CameraVideoUrl],
  189 + },
  190 +
  191 + {
  192 + field: 'videoPlatformId',
  193 + label: '流媒体配置',
  194 + component: 'Select',
  195 + ifShow({ values }) {
  196 + return values.accessMode === AccessMode.Streaming;
  197 + },
  198 + slot: 'videoPlatformIdSlot',
  199 + componentProps: {
  200 + placeholder: '请选择流媒体配置',
  201 + },
  202 + },
  203 + {
  204 + field: 'streamType',
  205 + label: '码流',
  206 + component: 'RadioGroup',
  207 + defaultValue: StreamType.MASTER,
  208 + ifShow({ values }) {
  209 + return values.accessMode === AccessMode.Streaming;
  210 + },
  211 + componentProps: {
  212 + placeholder: '请选择码流',
  213 + defaultValue: StreamType.MASTER,
  214 + options: [
  215 + { label: '主码流', value: StreamType.MASTER },
  216 + { label: '子码流', value: StreamType.CHILD },
  217 + { label: '第三码流', value: StreamType.THIRD },
  218 + ],
  219 + },
  220 + },
  221 + {
  222 + field: 'playProtocol',
  223 + label: '播放协议',
  224 + component: 'RadioGroup',
  225 + defaultValue: PlayProtocol.HTTP,
  226 + ifShow({ values }) {
  227 + return values.accessMode === AccessMode.Streaming;
  228 + },
  229 + helpMessage: ['平台使用https的hls协议,需联系海康开放平台专家支持。'],
  230 + componentProps: {
  231 + placeholder: '请选择播放协议',
  232 + defaultValue: PlayProtocol.HTTP,
  233 + options: [
  234 + { label: 'http', value: PlayProtocol.HTTP },
  235 + { label: 'https', value: PlayProtocol.HTTPS },
  236 + ],
  237 + },
  238 + },
  239 + {
  240 + field: 'sn',
  241 + label: h(SnHelpMessage) as any,
  242 + component: 'Input',
  243 + rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
  244 + ifShow({ values }) {
  245 + return values.accessMode === AccessMode.Streaming;
  246 + },
  247 + componentProps: {
  248 + placeholder: '请输入监控点编号',
  249 + },
  250 + },
  251 +];
1 import { BasicColumn, FormSchema } from '/@/components/Table'; 1 import { BasicColumn, FormSchema } from '/@/components/Table';
2 -import { getOrganizationList } from '/@/api/system/system';  
3 -import { copyTransFun } from '/@/utils/fnUtils';  
4 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; 2 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
5 import { createImgPreview } from '/@/components/Preview'; 3 import { createImgPreview } from '/@/components/Preview';
6 import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; 4 import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter';
  5 +import { useComponentRegister } from '/@/components/Form';
  6 +import { OrgTreeSelect } from '../../common/OrgTreeSelect';
  7 +
  8 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
7 export enum Platform { 9 export enum Platform {
8 PHONE = 'phone', 10 PHONE = 'phone',
9 PC = 'pc', 11 PC = 'pc',
@@ -126,14 +128,7 @@ export const formSchema: FormSchema[] = [ @@ -126,14 +128,7 @@ export const formSchema: FormSchema[] = [
126 field: 'organizationId', 128 field: 'organizationId',
127 label: '所属组织', 129 label: '所属组织',
128 required: true, 130 required: true,
129 - component: 'ApiTreeSelect',  
130 - componentProps: {  
131 - api: async () => {  
132 - const data = await getOrganizationList();  
133 - copyTransFun(data as any as any[]);  
134 - return data;  
135 - },  
136 - }, 131 + component: 'OrgTreeSelect',
137 }, 132 },
138 { 133 {
139 field: 'platform', 134 field: 'platform',
1 import { FormSchema } from '/@/components/Table'; 1 import { FormSchema } from '/@/components/Table';
2 -import { getOrganizationList } from '/@/api/system/system';  
3 -import { copyTransFun } from '/@/utils/fnUtils';  
4 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; 2 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
5 import { createImgPreview } from '/@/components/Preview'; 3 import { createImgPreview } from '/@/components/Preview';
6 import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; 4 import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter';
  5 +import { useComponentRegister } from '/@/components/Form';
  6 +import { OrgTreeSelect } from '../common/OrgTreeSelect';
  7 +
  8 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
  9 +
7 export enum Platform { 10 export enum Platform {
8 PHONE = 0, 11 PHONE = 0,
9 PC = 1, 12 PC = 1,
@@ -80,29 +83,8 @@ export const formSchema: FormSchema[] = [ @@ -80,29 +83,8 @@ export const formSchema: FormSchema[] = [
80 field: 'organizationId', 83 field: 'organizationId',
81 label: '所属组织', 84 label: '所属组织',
82 required: true, 85 required: true,
83 - component: 'ApiTreeSelect',  
84 - componentProps: {  
85 - api: async () => {  
86 - const data = await getOrganizationList();  
87 - copyTransFun(data as any as any[]);  
88 - return data;  
89 - },  
90 - }, 86 + component: 'OrgTreeSelect',
91 }, 87 },
92 - // {  
93 - // field: 'state',  
94 - // label: '发布状态',  
95 - // required: true,  
96 - // component: 'RadioGroup',  
97 - // defaultValue: Platform.PC,  
98 - // componentProps: {  
99 - // defaultValue: Platform.PC,  
100 - // options: [  
101 - // { label: '未发布', value: Platform.PC },  
102 - // { label: '已发布', value: Platform.PHONE },  
103 - // ],  
104 - // },  
105 - // },  
106 { 88 {
107 field: 'remark', 89 field: 'remark',
108 label: '备注', 90 label: '备注',
1 -import { ref } from 'vue';  
2 -import { BasicColumn, FormSchema } from '/@/components/Table';  
3 -import type { FormSchema as QFormSchema } from '/@/components/Form/index';  
4 -import { getOrganizationList } from '/@/api/system/system';  
5 -import { copyTransFun } from '/@/utils/fnUtils';  
6 -import { findDictItemByCode } from '/@/api/system/dict';  
7 -import { isTiming, isWeek, isMonth, isFixedTime } from './timeConfig';  
8 -import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';  
9 -import {  
10 - getPacketIntervalByRange,  
11 - getPacketIntervalByValue,  
12 - intervalOption,  
13 -} from '../../device/localtion/cpns/TimePeriodForm/helper';  
14 -import moment, { Moment } from 'moment';  
15 -  
16 -export enum QueryWay {  
17 - LATEST = 'latest',  
18 - TIME_PERIOD = 'timePeriod',  
19 -}  
20 -export enum SchemaFiled {  
21 - WAY = 'queryMode',  
22 - TIME_PERIOD = 'timePeriod',  
23 - KEYS = 'keys',  
24 - DATE_RANGE = 'dataRange',  
25 - START_TS = 'startTs',  
26 - END_TS = 'endTs',  
27 - INTERVAL = 'interval',  
28 - LIMIT = 'limit',  
29 - AGG = 'agg',  
30 - ORDER_BY = 'orderBy',  
31 -}  
32 -export const organizationId = ref('');  
33 -  
34 -// 表格配置  
35 -export const columns: BasicColumn[] = [  
36 - {  
37 - title: '配置名称',  
38 - dataIndex: 'name',  
39 - width: 120,  
40 - },  
41 - {  
42 - title: '所属组织',  
43 - dataIndex: 'organizationDTO.name',  
44 - width: 120,  
45 - },  
46 - {  
47 - title: '数据类型',  
48 - dataIndex: 'dataType',  
49 - width: 120,  
50 - format: (_text: string, record: Recordable) => {  
51 - return record.dataType === 0 ? '原始数据' : '聚合数据';  
52 - },  
53 - },  
54 - {  
55 - title: '配置状态',  
56 - dataIndex: 'status',  
57 - width: 120,  
58 - slots: { customRender: 'configStatus' },  
59 - },  
60 - {  
61 - title: '执行方式',  
62 - dataIndex: 'executeWay',  
63 - width: 160,  
64 - format: (_text: string, record: Recordable) => {  
65 - return record.executeWay === 0 ? '立即执行' : '定时执行';  
66 - },  
67 - },  
68 - {  
69 - title: '执行设备',  
70 - dataIndex: 'devices',  
71 - width: 160,  
72 - slots: { customRender: 'doDeviceSlot' },  
73 - },  
74 - {  
75 - title: '创建人',  
76 - dataIndex: 'createUserName',  
77 - width: 180,  
78 - },  
79 - {  
80 - title: '创建时间',  
81 - dataIndex: 'createTime',  
82 - width: 180,  
83 - },  
84 -];  
85 -export const viewDeviceColumn: BasicColumn[] = [  
86 - {  
87 - title: '设备',  
88 - dataIndex: 'device',  
89 - width: 80,  
90 - },  
91 - {  
92 - title: '属性',  
93 - dataIndex: 'attribute',  
94 - width: 120,  
95 - },  
96 -];  
97 -  
98 -// 查询配置  
99 -export const searchFormSchema: FormSchema[] = [  
100 - {  
101 - field: 'name',  
102 - label: '配置名称',  
103 - component: 'Input',  
104 - colProps: { span: 6 },  
105 - componentProps: {  
106 - maxLength: 36,  
107 - placeholder: '请输入配置名称',  
108 - },  
109 - },  
110 - {  
111 - field: 'status',  
112 - label: '配置状态',  
113 - component: 'Select',  
114 - colProps: { span: 6 },  
115 - componentProps: {  
116 - options: [  
117 - {  
118 - label: '启用',  
119 - value: 1,  
120 - },  
121 - {  
122 - label: '禁用',  
123 - value: 0,  
124 - },  
125 - ],  
126 - placeholder: '请选择配置状态',  
127 - },  
128 - },  
129 - {  
130 - field: 'sendTime',  
131 - label: '创建时间',  
132 - component: 'RangePicker',  
133 - componentProps: {  
134 - showTime: {  
135 - defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],  
136 - },  
137 - },  
138 - colProps: { span: 6 },  
139 - },  
140 -];  
141 -  
142 -// 新增编辑配置  
143 -export const formSchema: QFormSchema[] = [  
144 - {  
145 - field: 'name',  
146 - label: '报表名称',  
147 - colProps: { span: 24 },  
148 - required: true,  
149 - component: 'Input',  
150 - componentProps: {  
151 - maxLength: 64,  
152 - placeholder: '请输入报表名称',  
153 - },  
154 - },  
155 - {  
156 - field: 'organizationId',  
157 - label: '所属组织',  
158 - colProps: { span: 24 },  
159 - component: 'ApiTreeSelect',  
160 - required: true,  
161 - componentProps: () => {  
162 - return {  
163 - maxLength: 250,  
164 - placeholder: '请选择所属组织',  
165 - api: async () => {  
166 - const data = await getOrganizationList();  
167 - copyTransFun(data as any as any[]);  
168 - return data;  
169 - },  
170 - async onChange(e) {  
171 - organizationId.value = e;  
172 - },  
173 - };  
174 - },  
175 - },  
176 - {  
177 - field: 'remark',  
178 - label: '描述',  
179 - colProps: { span: 24 },  
180 - component: 'InputTextArea',  
181 - componentProps: {  
182 - maxLength: 255,  
183 - placeholder: '请输入描述',  
184 - },  
185 - },  
186 - {  
187 - field: 'executeWay',  
188 - component: 'RadioGroup',  
189 - helpMessage: [  
190 - `立即执行,在创建完报表配置后,启用配置即执行。  
191 - 定时执行,用户定义执行时间,启用后,  
192 - 在满足执行时间条件后,自动执行。`,  
193 - ],  
194 - label: '执行方式',  
195 - colProps: {  
196 - span: 24,  
197 - },  
198 - defaultValue: 0,  
199 - componentProps: ({ formActionType }) => {  
200 - const { updateSchema, setFieldsValue } = formActionType;  
201 - const options = [  
202 - {  
203 - label: '立即执行',  
204 - value: 0,  
205 - },  
206 - {  
207 - label: '定时执行',  
208 - value: 1,  
209 - },  
210 - ];  
211 - return {  
212 - options,  
213 - placeholder: '请选择执行方式',  
214 - onChange(e) {  
215 - let dataCompareOpions: any = [];  
216 - setFieldsValue({  
217 - startTs: 1000,  
218 - interval: 1000,  
219 - });  
220 - if (e.target.value == 0) {  
221 - setFieldsValue({ queryMode: QueryWay.LATEST });  
222 - dataCompareOpions = [  
223 - { label: '固定周期', value: QueryWay.LATEST },  
224 - { label: '自定义周期', value: QueryWay.TIME_PERIOD },  
225 - ];  
226 - updateSchema({  
227 - field: SchemaFiled.WAY,  
228 - componentProps: {  
229 - options: dataCompareOpions,  
230 - },  
231 - });  
232 - } else {  
233 - setFieldsValue({ queryMode: QueryWay.LATEST });  
234 - setFieldsValue({ startTs: 5000 });  
235 - setFieldsValue({ interval: 1000 });  
236 - dataCompareOpions = [{ label: '固定周期', value: QueryWay.LATEST }];  
237 - updateSchema({  
238 - defaultValue: QueryWay.LATEST,  
239 - field: SchemaFiled.WAY,  
240 - componentProps: {  
241 - options: dataCompareOpions,  
242 - },  
243 - });  
244 - }  
245 - },  
246 - maxLength: 250,  
247 - };  
248 - },  
249 - },  
250 - {  
251 - field: 'cycleType',  
252 - component: 'Select',  
253 - label: '周期',  
254 - required: true,  
255 - colProps: { span: 24 },  
256 - defaultValue: 0,  
257 - componentProps: {  
258 - placeholder: '请选择周期',  
259 - options: [  
260 - { label: '每日', value: 0 },  
261 - { label: '每周', value: 1 },  
262 - { label: '每月', value: 2 },  
263 - ],  
264 - },  
265 - ifShow: ({ values }) => isTiming(values.executeWay),  
266 - },  
267 - {  
268 - field: 'currentCycle',  
269 - component: 'ApiSelect',  
270 - label: '每周',  
271 - required: true,  
272 - colProps: { span: 24 },  
273 - defaultValue: '0 0 0 ? * MON',  
274 - componentProps: {  
275 - placeholder: '请选择周期',  
276 - api: findDictItemByCode,  
277 - params: {  
278 - dictCode: 'every_week',  
279 - },  
280 - labelField: 'itemText',  
281 - valueField: 'itemValue',  
282 - },  
283 - ifShow: ({ values }) => isWeek(values.cycleType),  
284 - },  
285 - {  
286 - field: 'cycleTime',  
287 - component: 'ApiSelect',  
288 - label: '每月',  
289 - required: true,  
290 - colProps: { span: 24 },  
291 - defaultValue: '0 0 0 1 * ? *',  
292 - componentProps: {  
293 - placeholder: '请选择月份',  
294 - api: findDictItemByCode,  
295 - params: {  
296 - dictCode: 'every_month',  
297 - },  
298 - labelField: 'itemText',  
299 - valueField: 'itemValue',  
300 - },  
301 - ifShow: ({ values }) => isMonth(values.cycleType),  
302 - },  
303 - {  
304 - field: 'cronTime',  
305 - component: 'ApiSelect',  
306 - label: '时间',  
307 - required: true,  
308 - colProps: { span: 24 },  
309 - defaultValue: '0 0 0 * * ?',  
310 - componentProps: {  
311 - placeholder: '请选择时间',  
312 - api: findDictItemByCode,  
313 - params: {  
314 - dictCode: 'every_day',  
315 - },  
316 - labelField: 'itemText',  
317 - valueField: 'itemValue',  
318 - },  
319 - ifShow: ({ values }) => isTiming(values.executeWay),  
320 - },  
321 - {  
322 - field: 'devices',  
323 - label: '设备',  
324 - component: 'Select',  
325 - slot: 'devices',  
326 - colProps: { span: 24 },  
327 - },  
328 - {  
329 - field: 'dataType',  
330 - label: '数据类型',  
331 - required: true,  
332 - component: 'Select',  
333 - componentProps: ({ formActionType }) => {  
334 - const { updateSchema, setFieldsValue } = formActionType;  
335 - const options = [  
336 - { label: '原始数据', value: 0 },  
337 - { label: '聚合数据', value: 1 },  
338 - ];  
339 - return {  
340 - options,  
341 - onSelect(e) {  
342 - let dataCompareOpions: any = [];  
343 - if (e == 0) {  
344 - setFieldsValue({ agg: 'NONE' });  
345 - dataCompareOpions = [{ label: '空', value: AggregateDataEnum.NONE }];  
346 - updateSchema({  
347 - field: SchemaFiled.AGG,  
348 - componentProps: {  
349 - options: dataCompareOpions,  
350 - },  
351 - });  
352 - } else {  
353 - setFieldsValue({ agg: '' });  
354 - dataCompareOpions = [  
355 - { label: '最小值', value: AggregateDataEnum.MIN },  
356 - { label: '最大值', value: AggregateDataEnum.MAX },  
357 - { label: '平均值', value: AggregateDataEnum.AVG },  
358 - { label: '求和', value: AggregateDataEnum.SUM },  
359 - { label: '计数', value: AggregateDataEnum.COUNT },  
360 - ];  
361 - updateSchema({  
362 - field: SchemaFiled.AGG,  
363 - componentProps: {  
364 - options: dataCompareOpions,  
365 - },  
366 - });  
367 - }  
368 - },  
369 - maxLength: 250,  
370 - placeholder: '请选择属性性质',  
371 - };  
372 - },  
373 - colProps: { span: 24 },  
374 - },  
375 - {  
376 - field: SchemaFiled.AGG,  
377 - label: '聚合条件',  
378 - component: 'Select',  
379 - required: true,  
380 - componentProps: {  
381 - placeholder: '请选择聚合条件',  
382 - getPopupContainer: () => document.body,  
383 - },  
384 - },  
385 - {  
386 - field: 'limit',  
387 - required: true,  
388 - label: '最大条数',  
389 - component: 'InputNumber',  
390 - defaultValue: 100,  
391 - ifShow({ values }) {  
392 - return values[SchemaFiled.AGG] === AggregateDataEnum.NONE;  
393 - },  
394 - colProps: { span: 12 },  
395 - componentProps: {  
396 - placeholder: '请输入最大条数',  
397 - min: 7,  
398 - max: 50000,  
399 - },  
400 - },  
401 - {  
402 - field: SchemaFiled.WAY,  
403 - label: '查询周期',  
404 - component: 'RadioGroup',  
405 - defaultValue: QueryWay.LATEST,  
406 - required: true,  
407 - componentProps({ formActionType }) {  
408 - const { setFieldsValue } = formActionType;  
409 - return {  
410 - placeholder: '请选择查询周期',  
411 - options: [  
412 - { label: '固定周期', value: QueryWay.LATEST },  
413 - { label: '自定义周期', value: QueryWay.TIME_PERIOD },  
414 - ],  
415 - onChange(value) {  
416 - console.log(value);  
417 - value === QueryWay.LATEST  
418 - ? setFieldsValue({  
419 - [SchemaFiled.DATE_RANGE]: [],  
420 - [SchemaFiled.START_TS]: null,  
421 - [SchemaFiled.END_TS]: null,  
422 - })  
423 - : setFieldsValue({ [SchemaFiled.START_TS]: null });  
424 - },  
425 - };  
426 - },  
427 - },  
428 - {  
429 - field: SchemaFiled.DATE_RANGE,  
430 - label: '时间段',  
431 - component: 'RangePicker',  
432 - required: true,  
433 - ifShow({ values }) {  
434 - return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);  
435 - },  
436 - // componentProps: {  
437 - // showTime: {  
438 - // defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],  
439 - // },  
440 - // },  
441 - componentProps({ formActionType }) {  
442 - const { setFieldsValue } = formActionType;  
443 - let dates: Moment[] = [];  
444 - return {  
445 - showTime: {  
446 - defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],  
447 - },  
448 - onCalendarChange(value: Moment[]) {  
449 - dates = value;  
450 - },  
451 - disabledDate(current: Moment) {  
452 - if (!dates || dates.length === 0 || !current) {  
453 - return false;  
454 - }  
455 - const diffDate = current.diff(dates[0], 'years', true);  
456 - return Math.abs(diffDate) > 1;  
457 - },  
458 - onChange() {  
459 - dates = [];  
460 - setFieldsValue({ dateGroupGap: null });  
461 - },  
462 - getPopupContainer: () => document.body,  
463 - };  
464 - },  
465 - colProps: {  
466 - span: 10,  
467 - },  
468 - },  
469 - {  
470 - field: 'dateGroupGap',  
471 - label: '分组间隔',  
472 - component: 'Select',  
473 - dynamicRules: ({ model }) => {  
474 - return [  
475 - {  
476 - required: model[SchemaFiled.AGG] !== AggregateDataEnum.NONE,  
477 - message: '分组间隔为必填项',  
478 - type: 'number',  
479 - },  
480 - ];  
481 - },  
482 - ifShow({ values }) {  
483 - return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);  
484 - },  
485 - componentProps({ formModel, formActionType }) {  
486 - const options =  
487 - formModel[SchemaFiled.WAY] === QueryWay.LATEST  
488 - ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])  
489 - : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);  
490 - if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {  
491 - formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });  
492 - }  
493 - return {  
494 - options,  
495 - getPopupContainer: () => document.body,  
496 - };  
497 - },  
498 - },  
499 - {  
500 - field: SchemaFiled.START_TS,  
501 - label: '最近时间',  
502 - component: 'Select',  
503 - required: true,  
504 - ifShow({ values }) {  
505 - return values[SchemaFiled.WAY] == QueryWay.LATEST;  
506 - },  
507 - componentProps({ formActionType }) {  
508 - const { setFieldsValue } = formActionType;  
509 - return {  
510 - defaultValue: 1000,  
511 - placeholder: '请选择近期时间',  
512 - options: intervalOption,  
513 - onChange() {  
514 - setFieldsValue({ [SchemaFiled.INTERVAL]: null });  
515 - },  
516 - };  
517 - },  
518 - },  
519 - {  
520 - field: SchemaFiled.INTERVAL,  
521 - label: '间隔时间',  
522 - component: 'Select',  
523 - required: true,  
524 - ifShow({ values }) {  
525 - return values[SchemaFiled.WAY] == QueryWay.LATEST;  
526 - },  
527 - componentProps({ formModel, formActionType }) {  
528 - const options =  
529 - formModel[SchemaFiled.WAY] === QueryWay.LATEST  
530 - ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])  
531 - : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);  
532 - if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {  
533 - formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });  
534 - }  
535 - return {  
536 - placeholder: '请选择间隔时间',  
537 - options,  
538 - };  
539 - },  
540 - },  
541 -]; 1 +import { ref } from 'vue';
  2 +import { BasicColumn, FormSchema } from '/@/components/Table';
  3 +import { FormSchema as QFormSchema, useComponentRegister } from '/@/components/Form/index';
  4 +import { findDictItemByCode } from '/@/api/system/dict';
  5 +import { isTiming, isWeek, isMonth, isFixedTime } from './timeConfig';
  6 +import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
  7 +import {
  8 + getPacketIntervalByRange,
  9 + getPacketIntervalByValue,
  10 + intervalOption,
  11 +} from '../../device/localtion/cpns/TimePeriodForm/helper';
  12 +import moment, { Moment } from 'moment';
  13 +import { OrgTreeSelect } from '../../common/OrgTreeSelect';
  14 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
  15 +export enum QueryWay {
  16 + LATEST = 'latest',
  17 + TIME_PERIOD = 'timePeriod',
  18 +}
  19 +export enum SchemaFiled {
  20 + WAY = 'queryMode',
  21 + TIME_PERIOD = 'timePeriod',
  22 + KEYS = 'keys',
  23 + DATE_RANGE = 'dataRange',
  24 + START_TS = 'startTs',
  25 + END_TS = 'endTs',
  26 + INTERVAL = 'interval',
  27 + LIMIT = 'limit',
  28 + AGG = 'agg',
  29 + ORDER_BY = 'orderBy',
  30 +}
  31 +export const organizationId = ref('');
  32 +
  33 +// 表格配置
  34 +export const columns: BasicColumn[] = [
  35 + {
  36 + title: '配置名称',
  37 + dataIndex: 'name',
  38 + width: 120,
  39 + },
  40 + {
  41 + title: '所属组织',
  42 + dataIndex: 'organizationDTO.name',
  43 + width: 120,
  44 + },
  45 + {
  46 + title: '数据类型',
  47 + dataIndex: 'dataType',
  48 + width: 120,
  49 + format: (_text: string, record: Recordable) => {
  50 + return record.dataType === 0 ? '原始数据' : '聚合数据';
  51 + },
  52 + },
  53 + {
  54 + title: '配置状态',
  55 + dataIndex: 'status',
  56 + width: 120,
  57 + slots: { customRender: 'configStatus' },
  58 + },
  59 + {
  60 + title: '执行方式',
  61 + dataIndex: 'executeWay',
  62 + width: 160,
  63 + format: (_text: string, record: Recordable) => {
  64 + return record.executeWay === 0 ? '立即执行' : '定时执行';
  65 + },
  66 + },
  67 + {
  68 + title: '执行设备',
  69 + dataIndex: 'devices',
  70 + width: 160,
  71 + slots: { customRender: 'doDeviceSlot' },
  72 + },
  73 + {
  74 + title: '创建人',
  75 + dataIndex: 'createUserName',
  76 + width: 180,
  77 + },
  78 + {
  79 + title: '创建时间',
  80 + dataIndex: 'createTime',
  81 + width: 180,
  82 + },
  83 +];
  84 +export const viewDeviceColumn: BasicColumn[] = [
  85 + {
  86 + title: '设备',
  87 + dataIndex: 'device',
  88 + width: 80,
  89 + },
  90 + {
  91 + title: '属性',
  92 + dataIndex: 'attribute',
  93 + width: 120,
  94 + },
  95 +];
  96 +
  97 +// 查询配置
  98 +export const searchFormSchema: FormSchema[] = [
  99 + {
  100 + field: 'name',
  101 + label: '配置名称',
  102 + component: 'Input',
  103 + colProps: { span: 6 },
  104 + componentProps: {
  105 + maxLength: 36,
  106 + placeholder: '请输入配置名称',
  107 + },
  108 + },
  109 + {
  110 + field: 'status',
  111 + label: '配置状态',
  112 + component: 'Select',
  113 + colProps: { span: 6 },
  114 + componentProps: {
  115 + options: [
  116 + {
  117 + label: '启用',
  118 + value: 1,
  119 + },
  120 + {
  121 + label: '禁用',
  122 + value: 0,
  123 + },
  124 + ],
  125 + placeholder: '请选择配置状态',
  126 + },
  127 + },
  128 + {
  129 + field: 'sendTime',
  130 + label: '创建时间',
  131 + component: 'RangePicker',
  132 + componentProps: {
  133 + showTime: {
  134 + defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
  135 + },
  136 + },
  137 + colProps: { span: 6 },
  138 + },
  139 +];
  140 +
  141 +// 新增编辑配置
  142 +export const formSchema: QFormSchema[] = [
  143 + {
  144 + field: 'name',
  145 + label: '报表名称',
  146 + colProps: { span: 24 },
  147 + required: true,
  148 + component: 'Input',
  149 + componentProps: {
  150 + maxLength: 64,
  151 + placeholder: '请输入报表名称',
  152 + },
  153 + },
  154 + {
  155 + field: 'organizationId',
  156 + label: '所属组织',
  157 + colProps: { span: 24 },
  158 + component: 'OrgTreeSelect',
  159 + required: true,
  160 + componentProps: () => {
  161 + return {
  162 + async onChange(e) {
  163 + organizationId.value = e;
  164 + },
  165 + };
  166 + },
  167 + },
  168 + {
  169 + field: 'remark',
  170 + label: '描述',
  171 + colProps: { span: 24 },
  172 + component: 'InputTextArea',
  173 + componentProps: {
  174 + maxLength: 255,
  175 + placeholder: '请输入描述',
  176 + },
  177 + },
  178 + {
  179 + field: 'executeWay',
  180 + component: 'RadioGroup',
  181 + helpMessage: [
  182 + `立即执行,在创建完报表配置后,启用配置即执行。
  183 + 定时执行,用户定义执行时间,启用后,
  184 + 在满足执行时间条件后,自动执行。`,
  185 + ],
  186 + label: '执行方式',
  187 + colProps: {
  188 + span: 24,
  189 + },
  190 + defaultValue: 0,
  191 + componentProps: ({ formActionType }) => {
  192 + const { updateSchema, setFieldsValue } = formActionType;
  193 + const options = [
  194 + {
  195 + label: '立即执行',
  196 + value: 0,
  197 + },
  198 + {
  199 + label: '定时执行',
  200 + value: 1,
  201 + },
  202 + ];
  203 + return {
  204 + options,
  205 + placeholder: '请选择执行方式',
  206 + onChange(e) {
  207 + let dataCompareOpions: any = [];
  208 + setFieldsValue({
  209 + startTs: 1000,
  210 + interval: 1000,
  211 + });
  212 + if (e.target.value == 0) {
  213 + setFieldsValue({ queryMode: QueryWay.LATEST });
  214 + dataCompareOpions = [
  215 + { label: '固定周期', value: QueryWay.LATEST },
  216 + { label: '自定义周期', value: QueryWay.TIME_PERIOD },
  217 + ];
  218 + updateSchema({
  219 + field: SchemaFiled.WAY,
  220 + componentProps: {
  221 + options: dataCompareOpions,
  222 + },
  223 + });
  224 + } else {
  225 + setFieldsValue({ queryMode: QueryWay.LATEST });
  226 + setFieldsValue({ startTs: 5000 });
  227 + setFieldsValue({ interval: 1000 });
  228 + dataCompareOpions = [{ label: '固定周期', value: QueryWay.LATEST }];
  229 + updateSchema({
  230 + defaultValue: QueryWay.LATEST,
  231 + field: SchemaFiled.WAY,
  232 + componentProps: {
  233 + options: dataCompareOpions,
  234 + },
  235 + });
  236 + }
  237 + },
  238 + maxLength: 250,
  239 + };
  240 + },
  241 + },
  242 + {
  243 + field: 'cycleType',
  244 + component: 'Select',
  245 + label: '周期',
  246 + required: true,
  247 + colProps: { span: 24 },
  248 + defaultValue: 0,
  249 + componentProps: {
  250 + placeholder: '请选择周期',
  251 + options: [
  252 + { label: '每日', value: 0 },
  253 + { label: '每周', value: 1 },
  254 + { label: '每月', value: 2 },
  255 + ],
  256 + },
  257 + ifShow: ({ values }) => isTiming(values.executeWay),
  258 + },
  259 + {
  260 + field: 'currentCycle',
  261 + component: 'ApiSelect',
  262 + label: '每周',
  263 + required: true,
  264 + colProps: { span: 24 },
  265 + defaultValue: '0 0 0 ? * MON',
  266 + componentProps: {
  267 + placeholder: '请选择周期',
  268 + api: findDictItemByCode,
  269 + params: {
  270 + dictCode: 'every_week',
  271 + },
  272 + labelField: 'itemText',
  273 + valueField: 'itemValue',
  274 + },
  275 + ifShow: ({ values }) => isWeek(values.cycleType),
  276 + },
  277 + {
  278 + field: 'cycleTime',
  279 + component: 'ApiSelect',
  280 + label: '每月',
  281 + required: true,
  282 + colProps: { span: 24 },
  283 + defaultValue: '0 0 0 1 * ? *',
  284 + componentProps: {
  285 + placeholder: '请选择月份',
  286 + api: findDictItemByCode,
  287 + params: {
  288 + dictCode: 'every_month',
  289 + },
  290 + labelField: 'itemText',
  291 + valueField: 'itemValue',
  292 + },
  293 + ifShow: ({ values }) => isMonth(values.cycleType),
  294 + },
  295 + {
  296 + field: 'cronTime',
  297 + component: 'ApiSelect',
  298 + label: '时间',
  299 + required: true,
  300 + colProps: { span: 24 },
  301 + defaultValue: '0 0 0 * * ?',
  302 + componentProps: {
  303 + placeholder: '请选择时间',
  304 + api: findDictItemByCode,
  305 + params: {
  306 + dictCode: 'every_day',
  307 + },
  308 + labelField: 'itemText',
  309 + valueField: 'itemValue',
  310 + },
  311 + ifShow: ({ values }) => isTiming(values.executeWay),
  312 + },
  313 + {
  314 + field: 'devices',
  315 + label: '设备',
  316 + component: 'Select',
  317 + slot: 'devices',
  318 + colProps: { span: 24 },
  319 + },
  320 + {
  321 + field: 'dataType',
  322 + label: '数据类型',
  323 + required: true,
  324 + component: 'Select',
  325 + componentProps: ({ formActionType }) => {
  326 + const { updateSchema, setFieldsValue } = formActionType;
  327 + const options = [
  328 + { label: '原始数据', value: 0 },
  329 + { label: '聚合数据', value: 1 },
  330 + ];
  331 + return {
  332 + options,
  333 + onSelect(e) {
  334 + let dataCompareOpions: any = [];
  335 + if (e == 0) {
  336 + setFieldsValue({ agg: 'NONE' });
  337 + dataCompareOpions = [{ label: '空', value: AggregateDataEnum.NONE }];
  338 + updateSchema({
  339 + field: SchemaFiled.AGG,
  340 + componentProps: {
  341 + options: dataCompareOpions,
  342 + },
  343 + });
  344 + } else {
  345 + setFieldsValue({ agg: '' });
  346 + dataCompareOpions = [
  347 + { label: '最小值', value: AggregateDataEnum.MIN },
  348 + { label: '最大值', value: AggregateDataEnum.MAX },
  349 + { label: '平均值', value: AggregateDataEnum.AVG },
  350 + { label: '求和', value: AggregateDataEnum.SUM },
  351 + { label: '计数', value: AggregateDataEnum.COUNT },
  352 + ];
  353 + updateSchema({
  354 + field: SchemaFiled.AGG,
  355 + componentProps: {
  356 + options: dataCompareOpions,
  357 + },
  358 + });
  359 + }
  360 + },
  361 + maxLength: 250,
  362 + placeholder: '请选择属性性质',
  363 + };
  364 + },
  365 + colProps: { span: 24 },
  366 + },
  367 + {
  368 + field: SchemaFiled.AGG,
  369 + label: '聚合条件',
  370 + component: 'Select',
  371 + required: true,
  372 + componentProps: {
  373 + placeholder: '请选择聚合条件',
  374 + getPopupContainer: () => document.body,
  375 + },
  376 + },
  377 + {
  378 + field: 'limit',
  379 + required: true,
  380 + label: '最大条数',
  381 + component: 'InputNumber',
  382 + defaultValue: 100,
  383 + ifShow({ values }) {
  384 + return values[SchemaFiled.AGG] === AggregateDataEnum.NONE;
  385 + },
  386 + colProps: { span: 12 },
  387 + componentProps: {
  388 + placeholder: '请输入最大条数',
  389 + min: 7,
  390 + max: 50000,
  391 + },
  392 + },
  393 + {
  394 + field: SchemaFiled.WAY,
  395 + label: '查询周期',
  396 + component: 'RadioGroup',
  397 + defaultValue: QueryWay.LATEST,
  398 + required: true,
  399 + componentProps({ formActionType }) {
  400 + const { setFieldsValue } = formActionType;
  401 + return {
  402 + placeholder: '请选择查询周期',
  403 + options: [
  404 + { label: '固定周期', value: QueryWay.LATEST },
  405 + { label: '自定义周期', value: QueryWay.TIME_PERIOD },
  406 + ],
  407 + onChange(value) {
  408 + console.log(value);
  409 + value === QueryWay.LATEST
  410 + ? setFieldsValue({
  411 + [SchemaFiled.DATE_RANGE]: [],
  412 + [SchemaFiled.START_TS]: null,
  413 + [SchemaFiled.END_TS]: null,
  414 + })
  415 + : setFieldsValue({ [SchemaFiled.START_TS]: null });
  416 + },
  417 + };
  418 + },
  419 + },
  420 + {
  421 + field: SchemaFiled.DATE_RANGE,
  422 + label: '时间段',
  423 + component: 'RangePicker',
  424 + required: true,
  425 + ifShow({ values }) {
  426 + return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
  427 + },
  428 + // componentProps: {
  429 + // showTime: {
  430 + // defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
  431 + // },
  432 + // },
  433 + componentProps({ formActionType }) {
  434 + const { setFieldsValue } = formActionType;
  435 + let dates: Moment[] = [];
  436 + return {
  437 + showTime: {
  438 + defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
  439 + },
  440 + onCalendarChange(value: Moment[]) {
  441 + dates = value;
  442 + },
  443 + disabledDate(current: Moment) {
  444 + if (!dates || dates.length === 0 || !current) {
  445 + return false;
  446 + }
  447 + const diffDate = current.diff(dates[0], 'years', true);
  448 + return Math.abs(diffDate) > 1;
  449 + },
  450 + onChange() {
  451 + dates = [];
  452 + setFieldsValue({ dateGroupGap: null });
  453 + },
  454 + getPopupContainer: () => document.body,
  455 + };
  456 + },
  457 + colProps: {
  458 + span: 10,
  459 + },
  460 + },
  461 + {
  462 + field: 'dateGroupGap',
  463 + label: '分组间隔',
  464 + component: 'Select',
  465 + dynamicRules: ({ model }) => {
  466 + return [
  467 + {
  468 + required: model[SchemaFiled.AGG] !== AggregateDataEnum.NONE,
  469 + message: '分组间隔为必填项',
  470 + type: 'number',
  471 + },
  472 + ];
  473 + },
  474 + ifShow({ values }) {
  475 + return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
  476 + },
  477 + componentProps({ formModel, formActionType }) {
  478 + const options =
  479 + formModel[SchemaFiled.WAY] === QueryWay.LATEST
  480 + ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])
  481 + : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);
  482 + if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {
  483 + formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
  484 + }
  485 + return {
  486 + options,
  487 + getPopupContainer: () => document.body,
  488 + };
  489 + },
  490 + },
  491 + {
  492 + field: SchemaFiled.START_TS,
  493 + label: '最近时间',
  494 + component: 'Select',
  495 + required: true,
  496 + ifShow({ values }) {
  497 + return values[SchemaFiled.WAY] == QueryWay.LATEST;
  498 + },
  499 + componentProps({ formActionType }) {
  500 + const { setFieldsValue } = formActionType;
  501 + return {
  502 + defaultValue: 1000,
  503 + placeholder: '请选择近期时间',
  504 + options: intervalOption,
  505 + onChange() {
  506 + setFieldsValue({ [SchemaFiled.INTERVAL]: null });
  507 + },
  508 + };
  509 + },
  510 + },
  511 + {
  512 + field: SchemaFiled.INTERVAL,
  513 + label: '间隔时间',
  514 + component: 'Select',
  515 + required: true,
  516 + ifShow({ values }) {
  517 + return values[SchemaFiled.WAY] == QueryWay.LATEST;
  518 + },
  519 + componentProps({ formModel, formActionType }) {
  520 + const options =
  521 + formModel[SchemaFiled.WAY] === QueryWay.LATEST
  522 + ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS])
  523 + : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]);
  524 + if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) {
  525 + formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
  526 + }
  527 + return {
  528 + placeholder: '请选择间隔时间',
  529 + options,
  530 + };
  531 + },
  532 + },
  533 +];
@@ -15,6 +15,10 @@ import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; @@ -15,6 +15,10 @@ import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
15 import useCommonFun from '../hooks/useCommonFun'; 15 import useCommonFun from '../hooks/useCommonFun';
16 import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; 16 import { DeviceProfileModel } from '/@/api/device/model/deviceModel';
17 import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; 17 import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const';
  18 +import { useComponentRegister } from '/@/components/Form';
  19 +import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect';
  20 +
  21 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
18 22
19 const { useByProductGetAttribute } = useCommonFun(); 23 const { useByProductGetAttribute } = useCommonFun();
20 export type TOption = { 24 export type TOption = {
@@ -109,13 +113,8 @@ export const formSchema: FormSchema[] = [ @@ -109,13 +113,8 @@ export const formSchema: FormSchema[] = [
109 field: 'organizationId', 113 field: 'organizationId',
110 label: '所属组织', 114 label: '所属组织',
111 colProps: { span: 24 }, 115 colProps: { span: 24 },
112 - component: 'ApiTreeSelect', 116 + component: 'OrgTreeSelect',
113 componentProps: { 117 componentProps: {
114 - api: async () => {  
115 - const data = await screenLinkOrganizationGetApi();  
116 - copyTransFun(data as any as any[]);  
117 - return data;  
118 - },  
119 onChange(value) { 118 onChange(value) {
120 organizationId.value = value; 119 organizationId.value = value;
121 }, 120 },
1 -import { getOrganizationList } from '/@/api/system/system';  
2 -import { FormSchema } from '/@/components/Form';  
3 -import { copyTransFun } from '/@/utils/fnUtils'; 1 +import { FormSchema, useComponentRegister } from '/@/components/Form';
  2 +import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect';
4 export enum ViewType { 3 export enum ViewType {
5 PRIVATE_VIEW = 'PRIVATE_VIEW', 4 PRIVATE_VIEW = 'PRIVATE_VIEW',
6 PUBLIC_VIEW = 'PUBLIC_VIEW', 5 PUBLIC_VIEW = 'PUBLIC_VIEW',
7 } 6 }
  7 +useComponentRegister('OrgTreeSelect', OrgTreeSelect);
8 8
9 export const formSchema: FormSchema[] = [ 9 export const formSchema: FormSchema[] = [
10 { 10 {
@@ -19,20 +19,9 @@ export const formSchema: FormSchema[] = [ @@ -19,20 +19,9 @@ export const formSchema: FormSchema[] = [
19 }, 19 },
20 { 20 {
21 field: 'organizationId', 21 field: 'organizationId',
22 - component: 'ApiTreeSelect', 22 + component: 'OrgTreeSelect',
23 label: '组织', 23 label: '组织',
24 rules: [{ required: true, message: '组织为必填项' }], 24 rules: [{ required: true, message: '组织为必填项' }],
25 - componentProps() {  
26 - return {  
27 - placeholder: '请选择组织',  
28 - api: async () => {  
29 - const data = await getOrganizationList();  
30 - copyTransFun(data as any as any[]);  
31 - return data;  
32 - },  
33 - getPopupContainer: () => document.body,  
34 - };  
35 - },  
36 }, 25 },
37 { 26 {
38 field: 'remark', 27 field: 'remark',