Blame view

src/pages/backlog/TaskConfig/components/CreateModal.tsx 13.3 KB
30e68723   王强   修改 待办配置表单页,添加 是否使...
1
2
3
4
5
  import React, { useEffect, useState } from "react";
  import { Modal, Form, Input, Radio, message, Select } from "antd";
  import { ListVO, saveTaskApi } from "../api";
  import { NotifyTypeEnum, TodoTypeEnum } from "../entity";
  import PageParams, { ValueVO } from "./PageParams";
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
6
  import { systemListApi } from "@/pages/admin/Privilege/api";
30e68723   王强   修改 待办配置表单页,添加 是否使...
7
  import usePagination from "@/hooks/usePagination";
fda8a7e0   王强   修复 编辑待办项问题;
8
  import { checkNull } from "@/utils/validate";
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
9
10
11
12
  
  const { TextArea } = Input;
  
  interface Props {
30e68723   王强   修改 待办配置表单页,添加 是否使...
13
14
15
16
    visible: boolean;
    onCancel: () => void;
    onRefreshing: () => void;
    item: ListVO;
c4a486ae   赵凤   待办配置add工作类型字段
17
18
19
20
    /** 系统列表 */
    systemList: any[];
    /** 工作类型列表 */
    workTyoeList: any[];
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
21
    /** 角色列表 */
d2a4028d   赵凤   待办时效配置
22
    // roleList: CommonApi.RoleCodeVO[],
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
23
  }
30e68723   王强   修改 待办配置表单页,添加 是否使...
24
25
26
27
28
  export default function CreateModal({
    visible,
    onCancel,
    item,
    onRefreshing,
c4a486ae   赵凤   待办配置add工作类型字段
29
30
    systemList,
    workTyoeList,
30e68723   王强   修改 待办配置表单页,添加 是否使...
31
  }: Props) {
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
32
33
    const [form] = Form.useForm();
    const [saveLoading, setSaveLoading] = useState(false);
88e539b9   赵凤   待办配置保存路径参数
34
    const [value, setValue] = useState<ValueVO[]>([]);
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
35
36
  
    useEffect(() => {
c4a486ae   赵凤   待办配置add工作类型字段
37
38
      /** 编辑时,表单数据回显 */
      // if (visible && item.id) {
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
39
      if (visible) {
30e68723   王强   修改 待办配置表单页,添加 是否使...
40
41
42
        const prePageParam: { [key: string]: any } = JSON.parse(
          item.pageParam || "{}"
        );
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
43
44
45
46
        let pageParam: ValueVO[] = [{ key: "", value: "" }];
        for (let [key, value] of Object.entries(prePageParam)) {
          pageParam.unshift({ key, value });
        }
88e539b9   赵凤   待办配置保存路径参数
47
        setValue(pageParam);
30e68723   王强   修改 待办配置表单页,添加 是否使...
48
  
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
49
        form.setFieldsValue({
9fa495c3   赵凤   修复功能页面路径不回显bug
50
51
          ...item,
          funcPage: item.funcPage,
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
52
          itemName: item.itemName,
30e68723   王强   修改 待办配置表单页,添加 是否使...
53
54
55
          dock: item.dock,
          exShow: item.exShow,
          assess: item.assess,
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
56
57
58
          itemType: item.itemType || TodoTypeEnum["业务性"],
          listPage: item.listPage,
          detailPage: item.detailPage,
c3d771f5   赵凤   待办时效修改延长失效配置样式
59
          dynamicTemp: item.dynamicTemp,
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
60
          notifyType: item.notifyType || 1,
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
61
62
          pageParam,
          applySysId: item.applySysId,
c4a486ae   赵凤   待办配置add工作类型字段
63
          workType: item.workType,
30e68723   王强   修改 待办配置表单页,添加 是否使...
64
65
          customTemp: item.customTemp,
          customTempPath: item.customTempPath,
f1c6e767   王强   修改 待办配置,添加 是否关单站岗...
66
          closeStand: checkNull(item.closeStand) ? true : item.closeStand,
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
67
68
        });
      }
c03a7a5b   赵凤   待办系统
69
70
71
      if (!visible) {
        setSaveLoading(false);
      }
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
72
73
74
    }, [visible]);
  
    function handleSave(feildValue: any) {
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
75
76
      setSaveLoading(true);
      const pageParam = {};
88e539b9   赵凤   待办配置保存路径参数
77
      (feildValue.pageParam || value || []).forEach((obj: ValueVO) => {
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
78
        if (obj.key) {
bd0ae2eb   赵凤   待办调整接口
79
          pageParam[obj.key.trim()] = (obj.value || "").trim();
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
80
81
        }
      });
729ef4ec   赵凤   add是否展示切换入口
82
83
84
      const dock = feildValue.dock;
      const assess = feildValue.assess;
      const exShow = feildValue.exShow;
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
85
86
87
      const params = {
        ...feildValue,
        itemName: (feildValue.itemName || "").trim(),
729ef4ec   赵凤   add是否展示切换入口
88
        listPage: (feildValue.listPage || item.listPage || "").trim(),
c03a7a5b   赵凤   待办系统
89
        funcPage: (feildValue.funcPage || "").trim(),
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
90
        detailPage: (feildValue.detailPage || "").trim(),
729ef4ec   赵凤   add是否展示切换入口
91
        pageParam: JSON.stringify(pageParam),
c03a7a5b   赵凤   待办系统
92
        dock: JSON.parse(dock),
4dd26c2d   赵凤   add待办时效考核
93
        assess: JSON.parse(assess),
729ef4ec   赵凤   add是否展示切换入口
94
        exShow: JSON.parse(exShow),
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
95
96
97
98
        itemCode: item.itemCode,
        id: item.id,
        applySysId: feildValue.applySysId,
      };
30e68723   王强   修改 待办配置表单页,添加 是否使...
99
100
101
102
103
104
105
106
107
108
109
      saveTaskApi(params)
        .then((res) => {
          message.success("操作成功!");
          onRefreshing && onRefreshing();
          setSaveLoading(false);
          onCancel && onCancel();
        })
        .catch((e) => {
          message.error(e.message);
          setSaveLoading(false);
        });
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
110
111
112
    }
  
    return (
30e68723   王强   修改 待办配置表单页,添加 是否使...
113
114
115
116
117
118
      <Modal
        visible={visible}
        onCancel={onCancel}
        onOk={form.submit}
        title={item.itemCode ? "编辑待办项" : "新增待办项"}
        confirmLoading={saveLoading}
bd792cdf   王强   fix
119
        maskClosable={false}
c4a486ae   赵凤   待办配置add工作类型字段
120
        // afterClose={() => form.resetFields()}
30e68723   王强   修改 待办配置表单页,添加 是否使...
121
122
123
124
125
126
127
128
129
130
131
132
      >
        <Form
          form={form}
          onFinish={handleSave}
          wrapperCol={{ span: 18 }}
          labelCol={{ span: 6 }}
        >
          <Form.Item
            label="待办名称"
            name="itemName"
            rules={[{ required: true }]}
          >
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
133
134
            <Input placeholder="请输入" />
          </Form.Item>
30e68723   王强   修改 待办配置表单页,添加 是否使...
135
          <Form.Item
f1c6e767   王强   修改 待办配置,添加 是否关单站岗...
136
137
138
139
140
            label="关单站岗"
            name="closeStand"
            rules={[{ required: true, message: "请选择是否关单站岗" }]}
          >
            <Radio.Group>
fda8a7e0   王强   修复 编辑待办项问题;
141
              <Radio value>是</Radio>
f1c6e767   王强   修改 待办配置,添加 是否关单站岗...
142
143
144
145
              <Radio value={false}>否</Radio>
            </Radio.Group>
          </Form.Item>
          <Form.Item
30e68723   王强   修改 待办配置表单页,添加 是否使...
146
147
148
149
            label="对接新待办"
            name="dock"
            rules={[{ required: true, message: "请选择是否对接新待办" }]}
          >
bd0ae2eb   赵凤   待办调整接口
150
            <Radio.Group>
fda8a7e0   王强   修复 编辑待办项问题;
151
              <Radio value>是</Radio>
30e68723   王强   修改 待办配置表单页,添加 是否使...
152
              <Radio value={false}>否</Radio>
bd0ae2eb   赵凤   待办调整接口
153
154
            </Radio.Group>
          </Form.Item>
729ef4ec   赵凤   add是否展示切换入口
155
          {/* 是否显示切换入口 */}
30e68723   王强   修改 待办配置表单页,添加 是否使...
156
157
158
159
160
          <Form.Item
            label="显示切换入口"
            name="exShow"
            rules={[{ required: true, message: "请选择是否显示切换入口" }]}
          >
729ef4ec   赵凤   add是否展示切换入口
161
            <Radio.Group>
fda8a7e0   王强   修复 编辑待办项问题;
162
              <Radio value>是</Radio>
30e68723   王强   修改 待办配置表单页,添加 是否使...
163
              <Radio value={false}>否</Radio>
729ef4ec   赵凤   add是否展示切换入口
164
165
            </Radio.Group>
          </Form.Item>
30e68723   王强   修改 待办配置表单页,添加 是否使...
166
167
168
169
170
          <Form.Item
            label="待办时效考核"
            name="assess"
            rules={[{ required: true, message: "请选择是否对接待办时效考核" }]}
          >
4dd26c2d   赵凤   add待办时效考核
171
            <Radio.Group>
fda8a7e0   王强   修复 编辑待办项问题;
172
              <Radio value>是</Radio>
30e68723   王强   修改 待办配置表单页,添加 是否使...
173
              <Radio value={false}>否</Radio>
4dd26c2d   赵凤   add待办时效考核
174
175
            </Radio.Group>
          </Form.Item>
30e68723   王强   修改 待办配置表单页,添加 是否使...
176
177
178
179
180
          <Form.Item
            label="待办类型"
            name="itemType"
            rules={[{ required: true, message: "请选择待办类型" }]}
          >
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
181
            <Radio.Group>
bd0ae2eb   赵凤   待办调整接口
182
183
184
185
              {[1, 2].map((it) => (
                <Radio value={it} key={it}>
                  {TodoTypeEnum[it]}
                </Radio>
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
186
187
188
              ))}
            </Radio.Group>
          </Form.Item>
30e68723   王强   修改 待办配置表单页,添加 是否使...
189
190
191
  
          <Form.Item
            noStyle
c4a486ae   赵凤   待办配置add工作类型字段
192
193
194
            shouldUpdate={(pre, cur) =>
              pre.dock !== cur.dock || pre.itemType !== cur.itemType
            }
30e68723   王强   修改 待办配置表单页,添加 是否使...
195
196
197
          >
            {({ getFieldValue }) => {
              const dock = getFieldValue("dock");
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
198
              const itemType = getFieldValue("itemType");
30e68723   王强   修改 待办配置表单页,添加 是否使...
199
              if (dock && itemType === TodoTypeEnum["业务性"]) {
c03a7a5b   赵凤   待办系统
200
                return (
30e68723   王强   修改 待办配置表单页,添加 是否使...
201
202
203
204
205
206
207
208
                  <Form.Item
                    label="使用自定义模板"
                    name="customTemp"
                    rules={[
                      { required: true, message: "请选择是否使用自定义模板" },
                    ]}
                  >
                    <Radio.Group>
fda8a7e0   王强   修复 编辑待办项问题;
209
                      <Radio value>是</Radio>
30e68723   王强   修改 待办配置表单页,添加 是否使...
210
211
                      <Radio value={false}>否</Radio>
                    </Radio.Group>
c03a7a5b   赵凤   待办系统
212
213
                  </Form.Item>
                );
30e68723   王强   修改 待办配置表单页,添加 是否使...
214
215
216
217
218
219
220
              }
              return null;
            }}
          </Form.Item>
  
          <Form.Item
            noStyle
c4a486ae   赵凤   待办配置add工作类型字段
221
222
            shouldUpdate={(pre, cur) =>
              pre.customTemp !== cur.customTemp ||
fda8a7e0   王强   修复 编辑待办项问题;
223
              pre.dock !== cur.dock ||
c4a486ae   赵凤   待办配置add工作类型字段
224
225
              pre.itemType !== cur.itemType
            }
30e68723   王强   修改 待办配置表单页,添加 是否使...
226
227
          >
            {({ getFieldValue }) => {
fda8a7e0   王强   修复 编辑待办项问题;
228
229
              const dock = getFieldValue("dock");
              const itemType = getFieldValue("itemType");
30e68723   王强   修改 待办配置表单页,添加 是否使...
230
              const customTemp = getFieldValue("customTemp");
fda8a7e0   王强   修复 编辑待办项问题;
231
              if (dock && itemType === TodoTypeEnum["业务性"] && customTemp) {
30e68723   王强   修改 待办配置表单页,添加 是否使...
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
                return (
                  <>
                    <Form.Item
                      label="自定义模板路径"
                      name="customTempPath"
                      rules={[{ required: true }]}
                    >
                      <Input allowClear placeholder="请输入自定义模板路径" />
                    </Form.Item>
                    <Form.Item
                      label="详情页面路径"
                      name="detailPage"
                      extra="用于待办报表跳转详情页"
                      rules={[{ required: true }]}
                    >
                      <Input placeholder="请输入" />
                    </Form.Item>
                  </>
                );
              }
              return null;
            }}
          </Form.Item>
  
          <Form.Item
            noStyle
c4a486ae   赵凤   待办配置add工作类型字段
258
259
            shouldUpdate={(pre, cur) =>
              pre.dock !== cur.dock ||
30e68723   王强   修改 待办配置表单页,添加 是否使...
260
              pre.itemType !== cur.itemType ||
c4a486ae   赵凤   待办配置add工作类型字段
261
262
              pre.customTemp !== cur.customTemp
            }
30e68723   王强   修改 待办配置表单页,添加 是否使...
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
          >
            {({ getFieldValue }) => {
              const dock = getFieldValue("dock");
              const itemType = getFieldValue("itemType");
              const customTemp = getFieldValue("customTemp");
  
              if (itemType === TodoTypeEnum["业务性"]) {
                // 业务性待办
                if (dock) {
                  // 新待办
                  if (!customTemp) {
                    // 不使用自定义模板
                    return (
                      <div>
                        <Form.Item
                          label="功能页面路径"
                          name="funcPage"
                          rules={[{ required: true }]}
                        >
                          <Input placeholder="请输入功能页面路径" />
                        </Form.Item>
                        <Form.Item
                          label="详情页面路径"
                          name="detailPage"
                          extra="用于待办报表跳转详情页"
                          rules={[{ required: true }]}
                        >
                          <Input placeholder="请输入详情页面路径" />
                        </Form.Item>
                        <Form.Item
                          label="通用模版"
                          name="dynamicTemp"
                          rules={[{ required: true }]}
                          extra={
                            <span>
                              {
                                "换行使用“\n”,动态内容用“${}”包含,如:您的验证码是“${}”(其中code是变量)"
                              }
                            </span>
                          }
                        >
                          <TextArea
                            placeholder={`动态内容用“\${}”包含,如:您的验证码是“\${}”(其中code是变量)"`}
                            allowClear
                            autoSize={{ minRows: 4 }}
                          />
                        </Form.Item>
                      </div>
                    );
                  }
                } else {
                  // 旧待办
c03a7a5b   赵凤   待办系统
315
316
                  return (
                    <div>
30e68723   王强   修改 待办配置表单页,添加 是否使...
317
318
319
320
321
322
                      <Form.Item
                        label="待办路径"
                        name="listPage"
                        rules={[{ required: true }]}
                      >
                        <Input placeholder="请输入待办路径" />
c03a7a5b   赵凤   待办系统
323
                      </Form.Item>
d2a4028d   赵凤   待办时效配置
324
                      <Form.Item label="详情页面路径" name="detailPage">
30e68723   王强   修改 待办配置表单页,添加 是否使...
325
                        <Input placeholder="请输入详情页面路径" />
c03a7a5b   赵凤   待办系统
326
327
328
329
330
331
332
                      </Form.Item>
                      <Form.Item label="路径参数" name="pageParam">
                        <PageParams />
                      </Form.Item>
                    </div>
                  );
                }
c03a7a5b   赵凤   待办系统
333
              }
30e68723   王强   修改 待办配置表单页,添加 是否使...
334
              return null;
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
335
336
            }}
          </Form.Item>
30e68723   王强   修改 待办配置表单页,添加 是否使...
337
338
339
  
          <Form.Item
            noStyle
c4a486ae   赵凤   待办配置add工作类型字段
340
341
342
            shouldUpdate={(pre, cur) =>
              pre.itemType !== cur.itemType || pre.customTemp !== cur.customTemp
            }
30e68723   王强   修改 待办配置表单页,添加 是否使...
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
          >
            {({ getFieldValue }) => {
              const itemType = getFieldValue("itemType");
              const customTemp = getFieldValue("customTemp");
  
              if (itemType === TodoTypeEnum["提示性"]) {
                // 业务性待办
                if (!customTemp) {
                  // 不使用自定义模板
                  return (
                    <Form.Item
                      label="待办模版"
                      name="dynamicTemp"
                      rules={[{ required: true, message: "必填项" }]}
                      extra={
                        <span>
                          {
                            "换行使用“\n”,动态内容用“${}”包含,如:您的验证码是“${}”(其中code是变量)"
                          }
                        </span>
                      }
                    >
                      <TextArea
                        placeholder="请输入"
                        allowClear
                        autoSize={{ minRows: 4 }}
                      />
                    </Form.Item>
                  );
                }
              }
              return null;
            }}
          </Form.Item>
  
          <Form.Item
            name="applySysId"
            label="适用系统"
            rules={[{ required: true, message: "适用系统不能为空" }]}
          >
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
383
            <Select placeholder="请选择">
c4a486ae   赵凤   待办配置add工作类型字段
384
              {systemList.map((item) => (
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
385
386
387
388
389
390
                <Select.Option value={item.id} key={item.id}>
                  {item.sysName}
                </Select.Option>
              ))}
            </Select>
          </Form.Item>
30e68723   王强   修改 待办配置表单页,添加 是否使...
391
392
393
394
395
          <Form.Item
            label="通知方式"
            name="notifyType"
            rules={[{ required: true, message: "必选项" }]}
          >
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
396
            <Radio.Group>
bd0ae2eb   赵凤   待办调整接口
397
398
399
400
              {[1, 2, 9].map((it) => (
                <Radio value={it} key={it}>
                  {NotifyTypeEnum[it]}
                </Radio>
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
401
402
403
              ))}
            </Radio.Group>
          </Form.Item>
c4a486ae   赵凤   待办配置add工作类型字段
404
405
406
407
408
409
410
411
412
413
414
415
416
          <Form.Item
            name="workType"
            label="工作类型"
            rules={[{ required: true, message: "工作类型不能为空" }]}
          >
            <Select placeholder="请选择">
              {workTyoeList.map((item) => (
                <Select.Option value={item.id} key={item.id}>
                  {item.name}
                </Select.Option>
              ))}
            </Select>
          </Form.Item>
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
417
418
419
420
        </Form>
      </Modal>
    );
  }