Sanakey
6 天以前 cb165187ddcf5d9cfd8aad97a2868d0343b14bd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
import dayjs from 'dayjs';
import type {Dayjs} from 'dayjs';
import {treeOptionsListApi} from "@/api/demo/tree";
import {ApiSelect, FormSchema} from '@/components/Form';
import { SearchOutlined,CloseOutlined,PlusCircleOutlined } from '@ant-design/icons-vue';
import {h} from 'vue';
import {PlusOutlined, MinusOutlined} from '@ant-design/icons-vue';
import {
  FormItem,
  FormItemRest,
  Input,
  Select,
  RadioGroup,
  RadioButton,
  Avatar,
  Image,
  message
} from "ant-design-vue";
import {BasicModal,useModal,useModalInner} from '@/components/Modal';
import PersonnelModal from "@/components/NewSchedule/src/PersonnelModal.vue";
import {optionsListApi} from "@/api/demo/select";
import {uploadApi} from "@/api/sys/upload";
 
const [registerPersonnelModal, { openModal: openPersonnelModal,setModalProps }] = useModal();
 
 
 
type RangeValue = [Dayjs, Dayjs];
 
 
export const schemas: FormSchema[] = [
  {
    field: 'scheduleContent',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入日程内容',
    },
    label: '',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'color',
    component: 'RadioButtonGroup',
    defaultValue: 1,
    // componentProps: () => {
    //   return {
    //     onChange: (val) => {
    //       console.log(val);
    //     }
    //   }
    // },
    renderColContent({model, field}, {disabled}) {
      let colors = [
        {
        "type_id": 1,
        "color": "#ff3333",
        "name": "红"
        },
        {
          "type_id": 2,
          "color": "#ff9933",
          "name": "橙"
        },
        {
          "type_id": 3,
          "color": "#f5f109",
          "name": "黄"
        },
        {
          "type_id": 4,
          "color": "#6ee86a",
          "name": "绿"
        },
        {
          "type_id": 5,
          "color": "#00ccee",
          "name": "蓝"
        },
        {
          "type_id": 6,
          "color": "#cc9933",
          "name": "褐"
        },
        {
          "type_id": 7,
          "color": "#9999ff",
          "name": "紫"
        }]
      const onChange = (val) => {
        // console.log(val);
        Logger.log('model',model);
      }
      return (
        <FormItem
          name="color"
          label=""
        >
          <RadioGroup v-model:value={model[field]} button-style="solid" size="small" name="color">
            {
              colors.map((item) => {
                return <RadioButton class="mr-5px" value={item.type_id} onChange={onChange}
                                    style={{backgroundColor: item.color,borderColor:item.color}}>
                  <span class={'c-white' + (model[field] === item.type_id ?'':' select-none op0')}>✓</span>
                </RadioButton>;
              })
            }
          </RadioGroup>
        </FormItem>
      );
    },
    label: '',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'isAllDayEvent',
    component: 'Checkbox',
    // suffix:'全天事件',
    subLabel: '',
    colProps: {
      span: 6,
    },
    renderComponentContent: '全天事件',
    componentProps: ({formActionType}) => {
      return {
        onChange: (e: any) => {
          const checked = e?.target?.checked || false;
          Logger.log('是否全天事件:', checked);
          formActionType.updateSchema([
            {
              field: '[startDate, endDate]',
              componentProps: {
                format: 'YYYY-MM-DD' + (!checked ? ' HH:mm:ss' : ''),
                showTime: (!checked ? {format: 'HH:mm:ss'} : false),
              }
            },
          ]);
        },
      };
    },
  },
  {
    field: '[startDate, endDate]',
    label: '起止时间',
    component: 'RangePicker',
    componentProps: {
      style: {width: '100%'},
      format: 'YYYY-MM-DD HH:mm:ss',
      placeholder: ['开始日期、时间', '结束日期、时间'],
      showTime: {format: 'HH:mm:ss'},
    },
    // componentProps: ({ schema, formModel}) => {
    //   console.log('RangePicker form:', schema);
    //   console.log('RangePicker formModel:', formModel);
    //   return {
    //     format: 'YYYY-MM-DD',
    //     placeholder: ['开始日期', '结束日期'],
    //     showTime: { format: 'HH:mm:ss' },
    //   };
    // },
    colProps: {span: 24},
  },
  {
    component: 'Select',
    label: '设置为周期性日期',
    field: 'recurringDates',
    colProps: {span: 13},
    componentProps: {
      options: [
        {
          label: '不设置',
          value: '1',
        },
        {
          label: '每天',
          value: '2',
        },
        {
          label: '每周',
          value: '3',
        },
        {
          label: '每月',
          value: '4',
        },
        {
          label: '自定义',
          value: '5',
        },
      ],
    },
    defaultValue: '1'
  },
  {
    field: 'recurringDatesUntil',
    component: 'DatePicker',
    label: '直到',
    colProps: {
      span: 10,
      offset: 1,
    },
    componentProps: {
      style: {width: '100%'},
      disabledDate: (currentDate) => {
        // Logger.log('currentDate',currentDate)
        // 禁用今天之前的天数
        return currentDate && currentDate < dayjs().subtract(1, 'day');
      }
    },
    dynamicRules: ({values}) => {
      return [
        {
          // required: true,
          validator: (_, value) => {
            if (['2', '3', '4'].includes(values.recurringDates)) {
              if (!value) {
                return Promise.reject('不能为空');
              }
            }
 
            return Promise.resolve();
          },
        },
      ];
    },
    ifShow: ({values}) => {
      // Logger.log('vvv',values)
      return ['2', '3', '4'].includes(values.recurringDates);
    },
  },
  {
    field: 'recurringDatesRepeatCycle',
    component: 'InputNumber',
    label: '重复周期',
    colProps: {
      span: 12,
    },
    componentProps: {
      style: {width: '100%'},
      min: 1
    },
    defaultValue: 1,
    dynamicRules: ({values}) => {
      return [
        {
          // required: true,
          validator: (_, value) => {
            if (values.recurringDates === '5') {
              if (!value) {
                return Promise.reject('重复周期不能为空');
              }
            }
 
            return Promise.resolve();
          },
        },
      ];
    },
    ifShow: ({values}) => {
      // Logger.log('vvv',values)
      return values.recurringDates === '5';
    },
  },
  {
    field: 'recurringDatesRepeatCycleUnit',
    component: 'Select',
    label: '提示:每1日重复一次日程',
    colProps: {
      span: 10,
      offset: 1,
    },
    componentProps: ({formActionType}) => {
      return {
        options: [
          {
            label: '日',
            value: '1',
          },
          {
            label: '周',
            value: '2',
          },
          {
            label: '月',
            value: '3',
          },
        ],
        onChange: (e: any, v) => {
          Logger.log(e, v);
          formActionType.updateSchema([
            {
              field: 'recurringDatesRepeatCycleUnit',
              label: '提示:每' + v.label + '重复一次日程',
            },
          ]);
        },
      };
    },
    // componentProps: {
    //
    // },
    defaultValue: '1',
    dynamicRules: ({values}) => {
      return [
        {
          // required: true,
          validator: (_, value) => {
            if (values.recurringDates === '5') {
              if (!value) {
                return Promise.reject('重复周期不能为空');
              }
            }
 
            return Promise.resolve();
          },
        },
      ];
    },
    ifShow: ({values}) => {
      // Logger.log('vvv',values)
      return values.recurringDates === '5';
    },
  },
  {
    field: 'endDateTime',
    component: 'DatePicker',
    label: '结束时间',
    colProps: {
      span: 24,
    },
    componentProps: {
      showTime: true,
      style: {width: '100%'},
      disabledDate: (currentDate) => {
        // 禁用今天之前的天数
        return currentDate && currentDate < dayjs().subtract(1, 'day');
      }
    },
    dynamicRules: ({values}) => {
      return [
        {
          // required: true,
          validator: (_, value) => {
            if (values.recurringDates === '5') {
              if (!value) {
                return Promise.reject('重复周期不能为空');
              }
            }
 
            return Promise.resolve();
          },
        },
      ];
    },
    ifShow: ({values}) => {
      // Logger.log('vvv',values)
      return values.recurringDates === '5';
    },
  },
  {
    field: 'Divider',
    component: 'Divider',
    // componentProps: {
    //   style: {lineHeight: '0'},
    // },
    // label: 'renderColContent渲染',
    /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
    renderColContent({model, field}, {disabled}) {
      return (
        <br />
      );
    },
    colProps: {
      span: 24,
      style: {
        lineHeight: '0',
      },
    },
    // show: ({values}) => {
    //   // Logger.log('vvv',values)
    //   return false;
    // },
  },
  {
    field: 'remindTime',
    component: 'Select',
    label: '提醒时间',
    colProps: {
      span: 20,
    },
    componentProps: ({formActionType}) => {
      return {
        options: [
          {
            label: '不提醒',
            value: '1',
          },
          {
            label: '当天开始(上午9:00)',
            value: '2',
          },
          {
            label: '1天前(上午9:00)',
            value: '3',
          },
          {
            label: '2天前(上午9:00)',
            value: '4',
          },
          {
            label: '1周前(上午9:00)',
            value: '5',
          },
          {
            label: '自定义',
            value: '6',
          },
        ],
        onChange: (e: any, v) => {
          // Logger.log(e);
          Logger.log(e,v);
          let span = 20;
          if(e==6) { span = 8 }
          formActionType.updateSchema([
            {
              field: 'remindTime',
              colProps: {
                span:span,
              },
            },
          ]);
        },
      };
    },
    defaultValue: '1'
  },
  {
    field: 'remindTime2',
    component: 'DatePicker',
    label: ' ',
    colProps: {
      span: 11,
      offset: 1,
    },
    componentProps: {
      style: {width: '100%'},
      // disabledDate:(currentDate)=>{
      //   // Logger.log('currentDate',currentDate)
      //   // 禁用今天之前的天数
      //   return currentDate && currentDate < dayjs().subtract(1, 'day');
      // }
    },
    dynamicRules: ({values}) => {
      return [
        {
          // required: true,
          validator: (_, value) => {
            if (values.remindTime === '6') {
              if (!value) {
                return Promise.reject('不能为空');
              }
            }
 
            return Promise.resolve();
          },
        },
      ];
    },
    show: ({values}) => {
      // Logger.log('vvv',values)
      return values.remindTime === '6';
    },
  },
  {
    field: 'btnGroup_0',
    label: ' ',
    // component: 'Input',
    slot: 'btnGroup',
    // label: 'renderColContent渲染',
    /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
    // render({model, field}, {disabled}) {
    //   return (
    //     <div class="flex flex-justify-between">
    //       <a-button size="small" style={{background: '#9C9C9C', color: '#FFFFFF'}} shape="circle"
    //                 icon={h(MinusOutlined)}/>
    //       <a-button size="small" style={{background: '#9C9C9C', color: '#FFFFFF'}} shape="circle"
    //                 icon={h(PlusOutlined)}/>
    //     </div>
    //   );
    // },
    colProps: {
      span: 3,
      offset: 1,
    },
  },
  {
    field: 'relatedObjects',
    fields: ['relatedObjectsSearch'],
    component: 'Input',
    defaultValue: '0',
    // label: 'renderColContent渲染',
    /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
    renderColContent({model, field}, {disabled}) {
      return (
        <FormItem
          name="relatedObjects"
          label="关联对象"
          // rules={[{ trigger: 'blur',required: true, }]}
          // rules={custom_typeKey2typeValueRules(model)}
        >
          <Input.Group compact>
            <Select
              disabled={disabled}
              style="width: 120px"
              v-model:value={model[field]}
            >
              <Select.Option value="0">客户</Select.Option>
              <Select.Option value="1">商机</Select.Option>
              <Select.Option value="2">线索</Select.Option>
              <Select.Option value="3">销售订单</Select.Option>
              <Select.Option value="4">报价单</Select.Option>
            </Select>
            <FormItemRest>
              <ApiSelect
                style="width: calc(100% - 120px); margin-left: -1px;border-inline-end-width: 0px;"
                v-model:api={optionsListApi}
                showSearch
                v-model:value={model['relatedObjectsSearch']}
                placeholder="请输入关键词"
                optionFilterProp="label"
                resultField="list"
                labelField="name"
                valueField="id"
                mode="multiple"
                disabled={disabled}
                suffixIcon={<SearchOutlined />}
                // rules={[{ trigger: 'blur',required: true, }]}
              >
 
                {/*<SearchOutlined v-slot='suffixIcon' />*/}
                {/*<template v-slot={suffixIcon}><SearchOutlined /></template>*/}
              </ApiSelect>
            </FormItemRest>
          </Input.Group>
        </FormItem>
      );
    },
    colProps: {
      span: 24,
    },
    dynamicDisabled: ({values}) => {
      return !!values.field_disabled;
    },
  },
  {
    field: 'participants',
    component: 'Input',
    defaultValue: [],
    // componentProps: {
    //   style: {lineHeight: '0'},
    // },
    // label: 'renderColContent渲染',
    /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
    renderColContent({model, field}, {disabled}) {
      let participants = model[field];
 
      return (
        <FormItem
          name="participants"
          label="参与人员"
          // rules={[{ trigger: 'blur',required: true, }]}
      >
          <ul class="flex">
            {participants.map((item,index) => {
              return (
                <li class="flex flex-col flex-items-center mr-10px ">
                  {/*<Image class="rd-50%" src={item.src} width={60}*/}
                  {/*       preview={{maskClassName:'rd-50%',getContainer:'.splitpanes__pane'}}*/}
                  {/*/>*/}
                  <div class="relative">
                    <Avatar src={item.avatar} size={64}>
                    </Avatar>
                    <div class="ant-avatar-mask">
                      <CloseOutlined onClick={()=>{
                        participants.splice(index,1);
                        // model['participants'] = participants;
                        Logger.log(model[field]);
                      }} />
                    </div>
                  </div>
 
                  <span class="mt-10px">{item.title}</span>
                </li>
              );
            })}
            <li class="flex flex-col flex-items-center">
              <PlusCircleOutlined onClick={
                ()=>{
                  setModalProps({
                    zIndex: 1001,
                  });
                  openPersonnelModal(true, {
                    data: participants,
                  });
                }
              } class="cursor-pointer" style={{fontSize: '64px', color: '#B4B3B3'}} />
            </li>
          </ul>
          <PersonnelModal onRegister={registerPersonnelModal} onSubmitOk={(v)=> {
            console.log('vvv', v);
            model[field] = v
          }} />
        </FormItem>
      );
    },
    colProps: {
      span: 24,
    },
  },
  {
    field: 'Divider_remark',
    component: 'Divider',
    label: '备注',
    colProps: {
      span: 24,
      // style: {
      //   lineHeight: '0',
      // },
    },
  },
  {
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入备注',
    },
    label: '',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'remark_image',
    component: 'ImageUpload',
    label: '备注图片',
    subLabel: '(单张图片最大3M,最多上传5张图片)',
    // required: true,
    defaultValue: [
      'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
    ],
    componentProps: {
      api: uploadApi,
      accept: ['png', 'jpeg', 'jpg'],
      helpText: '单张图片最大3M,最多上传5张图片',
      maxSize: 3, //单个文件最大体积,单位 M
      maxNumber: 5,
    },
    // rules: [
    //   {
    //     required: true,
    //     trigger: 'change',
    //     validator(_, value) {
    //       if (isArray(value) && value.length > 0) {
    //         return Promise.resolve();
    //       } else {
    //         return Promise.reject('请选择上传图片');
    //       }
    //     },
    //   },
    // ],
  },
  {
    field: 'remark_file',
    component: 'Upload',
    label: '备注附件',
    colProps: {
      span: 24,
    },
    rules: [{ message: '请选择上传文件' }],
    componentProps: {
      api: uploadApi,
    },
  },
  // {
  //   field: 'field33',
  //   component: 'ApiTreeSelect',
  //   label: '远程下拉树',
  //   helpMessage: ['ApiTreeSelect组件', '使用接口提供的数据生成选项'],
  //   required: true,
  //   componentProps: {
  //     api: treeOptionsListApi,
  //     treeCheckable: true,
  //     resultField: 'list',
  //     onChange: (e, v) => {
  //       console.log('ApiTreeSelect====>:', e, v);
  //     },
  //   },
  //   colProps: {
  //     span: 14,
  //   },
  // },
];