Sanakey
3 天以前 b5c1614fe473330ceca8b7cff0f1802e19bd5039
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
// import {FormSchema} from '@/components/Table';
import {treeOptionsListApi} from "@/api/demo/tree";
import {areaRecord} from "@/api/demo/cascader";
import dayjs from "dayjs";
import {optionsListApi} from "@/api/demo/select";
import {Input, FormItem, FormItemRest, Select} from "ant-design-vue";
import { ApiSelect, FormSchema } from '@/components/Form';
 
import companyType from './drawer-form/companyType';
import annualPurchaseAmount from './drawer-form/annualPurchaseAmount';
import timeZone from './drawer-form/timeZone';
import {uploadApi} from "@/api/sys/upload";
 
const custom_typeKey2typeValueRules = (model) => {
  return [
    {
      // required: true,
      // trigger: 'blur',
      validator: async () => {
        Logger.log('custom_typeKey2typeValueRules', model);
        if (!model.telephoneAreaCode) return Promise.reject('请选择电话区号');
        if (!model.telephoneNumber) return Promise.reject('请输入电话号码');
        Promise.resolve();
      },
    },
  ];
};
 
const add = (model) => {
  console.log('add-',model);
  Logger.log('add=', model);
};
 
export const schemas: FormSchema[] = [
  {
    field: 'contactName',
    component: 'Input',
    label: '联系人名称',
    colProps: {
      span: 24,
    },
    rules: [{required: true, trigger: 'blur'}],
  },
  {
    field: 'email',
    component: 'Input',
    label: '邮箱',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'socialPlatform',
    fields: ['socialAccount','socialCount'],
    component: 'Input',
    // label: 'renderColContent渲染',
    /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
    renderColContent({model, field}, {disabled}) {
      return (
        <FormItem
          name="social"
          label="社交平台"
          // rules={[{ trigger: 'blur',required: true, }]}
          // rules={custom_typeKey2typeValueRules(model)}
        >
          <Input.Group compact>
            {/*<Select*/}
            {/*  allowClear*/}
            {/*  disabled={disabled}*/}
            {/*  style="width: 120px"*/}
            {/*  v-model:value={model[field]}*/}
            {/*>*/}
            {/*  <Select.Option value="公司名称">公司名称</Select.Option>*/}
            {/*  <Select.Option value="产品名称">产品名称</Select.Option>*/}
            {/*</Select>*/}
            <ApiSelect
              style="width: 120px"
              v-model:api={optionsListApi}
              placeholder="社交平台"
              showSearch
              v-model:value={model['socialPlatform']}
              optionFilterProp="label"
              resultField="list"
              labelField="name"
              valueField="id"
            />
            <FormItemRest>
              <Input
                style="width: calc(100% - 120px); margin-left: -1px;"
                placeholder="社交账号"
                v-model:value={model['socialAccount']}
                disabled={disabled}
                // rules={[{ type: 'number',trigger: 'blur',required: true, }]}
                // rules={custom_typeKey2typeValueRules(model)}
              />
            </FormItemRest>
            {/*<div>*/}
            {/*  <a-button shape="circle" onClick={add(model)}>+</a-button>*/}
            {/*  /!*<a-button shape="circle" v-if={Number(model['socialCount']) > 0}>-</a-button>*!/*/}
            {/*  /!*<a-button shape="circle" v-if={Number(model['socialCount']) === 0} onClick={add}>+</a-button>*!/*/}
            {/*  /!*<a-button shape="circle" v-if={Number(model['socialCount']) > 0} onClick={() => del(field)}>-</a-button>*!/*/}
            {/*</div>*/}
          </Input.Group>
 
        </FormItem>
      );
    },
    colProps: {
      span: 18,
    },
    dynamicDisabled: ({values}) => {
      return !!values.field_disabled;
    },
  },
  {
    field: '0',
    label: ' ',
    component: 'Input',
    render({model, field}, {disabled}) {
      return (
        <div>
          <a-button shape="circle" onClick={add(model)}>+</a-button>
          {/*<a-button shape="circle" v-if={Number(model['socialCount']) > 0}>-</a-button>*/}
          {/*<a-button shape="circle" v-if={Number(model['socialCount']) === 0} onClick={add}>+</a-button>*/}
          {/*<a-button shape="circle" v-if={Number(model['socialCount']) > 0} onClick={() => del(field)}>-</a-button>*/}
        </div>
      );
    },
    colProps: {
      span: 6,
    },
  },
  {
    field: 'telephoneAreaCode',
    fields: ['telephoneNumber'],
    component: 'Input',
    // label: 'renderColContent渲染',
    /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
    renderColContent({model, field}, {disabled}) {
      return (
        <FormItem
          name="telephone"
          label="联系电话"
          // rules={[{ trigger: 'blur',required: true, }]}
          // rules={custom_typeKey2typeValueRules(model)}
        >
          <Input.Group compact>
 
            <ApiSelect
              style="width: 120px"
              v-model:api={optionsListApi}
              placeholder="电话区号"
              showSearch
              v-model:value={model['telephoneAreaCode']}
              optionFilterProp="label"
              resultField="list"
              labelField="name"
              valueField="id"
              // rules={[{ trigger: 'blur',required: true, }]}
            />
            <FormItemRest>
              <Input
                style="width: calc(100% - 120px); margin-left: -1px;"
                placeholder="电话号码"
                v-model:value={model['telephoneNumber']}
                disabled={disabled}
                // rules={[{ trigger: 'blur',required: true, }]}
                // rules={custom_typeKey2typeValueRules(model)}
              />
            </FormItemRest>
          </Input.Group>
        </FormItem>
      );
    },
    colProps: {
      span: 16,
    },
    dynamicDisabled: ({values}) => {
      return !!values.field_disabled;
    },
  },
  // {
  //   field: 'typeKey2',
  //   fields: ['typeValue2'],
  //   component: 'Input',
  //   label: '复合',
  //   /**!!!renderColContent 没有FormItem 包裹, 若想要 Form 提交需要带上数据须 <FormItem name={}></FormItem> 包裹: 示例如下*/
  //   render({ model, field }, { disabled }) {
  //     return (
  //       <Input.Group>
  //         <Select
  //           disabled={disabled}
  //           style="width: 120px"
  //           allowClear
  //           v-model:value={model[field]}
  //         >
  //           <Select.Option value="测试类型">测试类型</Select.Option>
  //           <Select.Option value="测试名称">测试名称</Select.Option>
  //         </Select>
  //         <FormItem name="typeValue2"  rules={[{ required: true }]}>
  //           <FormItemRest>
  //             <Input
  //               placeholder="请输入"
  //               v-model:value={model['typeValue2']}
  //               disabled={disabled}
  //             />
  //           </FormItemRest>
  //         </FormItem>
  //       </Input.Group>
  //     );
  //   },
  //   colProps: {
  //     span: 12,
  //   },
  //   dynamicDisabled: ({values}) => {
  //     return !!values.field_disabled;
  //   },
  // },
  {
    field: 'position',
    component: 'Input',
    label: '职位',
    colProps: {
      span: 16,
    },
  },
  {
    field: 'remark',
    component: 'InputTextArea',
    label: '备注',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'gender',
    component: 'RadioGroup',
    defaultValue: '0',
    label: '性别',
    componentProps: {
      options: [
        {label: '不设置', value: '0'},
        {label: '男', value: '1'},
        {label: '女', value: '1'},
      ],
    },
    colProps: {
      span: 24,
    },
  },
  {
    field: '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: 'birthday',
    label: '生日',
    component: 'DatePicker',
    componentProps: {
      style: 'width: 100%;',
      format: 'YYYY-MM-DD',
    },
    colProps: {span: 16},
  },
  {
    component: 'Select',
    label: '职级',
    field: 'rank',
    colProps: {span: 24},
    componentProps: {
      options: [
        {
          label: '普通职员',
          value: '1',
        },
        {
          label: '中层管理者',
          value: '2',
        },
        {
          label: '高层管理者',
          value: '3',
        },
      ],
    },
  },
  // {
  //   field: 'remindTime2',
  //   component: 'DatePicker',
  //   label: '',
  //   colProps: {
  //     span: 6,
  //     offset: 2,
  //   },
  //   componentProps: {
  //     // 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';
  //   },
  // },
];