forked from gzzfw/frontEnd/gzDyh

zhangyongtian
2024-08-27 33440bb15f8d7f07b68e34760129d3300cab5e88
feat:编辑当事人逻辑
4 files modified
86 ■■■■ changed files
gz-customerSystem/src/components/personCard/index.jsx 4 ●●●● patch | view | raw | blame | history
gz-customerSystem/src/views/register/visit/component/agentDialog.jsx 30 ●●●● patch | view | raw | blame | history
gz-customerSystem/src/views/register/visit/component/applyDialog.jsx 19 ●●●●● patch | view | raw | blame | history
gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx 33 ●●●●● patch | view | raw | blame | history
gz-customerSystem/src/components/personCard/index.jsx
@@ -18,7 +18,7 @@
 * handleCheckParty, // 点击查看详情
 * handleDeleteParty, // 删除当事人
 */
const PersonCard = ({ isCheck, data, handleCheckParty, handleDeleteParty, handleAdd }) => {
const PersonCard = ({ isCheck, data, handleCheckParty, handleDeleteParty, handleAdd, handleEdit }) => {
    let isAgent = false
    let isAgentFor = false
    const typeList = data.map(item => {
@@ -53,7 +53,7 @@
                                <Text style={{ maxWidth: '80%', paddingRight: '8px' }} ellipsis={{ tooltip: x.trueName }}>
                                    {x.trueName}
                                </Text>
                                <Text ellipsis={{ tooltip: x.perClassName }} className={`public-personCard-tag public-personCard-tag-${(x.partyType === 0 || x.partyType === 2) ? 'blue' : 'orange'}`}>
                                <Text onClick={() => { handleEdit(x) }} ellipsis={{ tooltip: x.perClassName }} className={`public-personCard-tag public-personCard-tag-${(x.partyType === 0 || x.partyType === 2) ? 'blue' : 'orange'}`}>
                                    {x.perClassName}
                                </Text>
                            </div>
gz-customerSystem/src/views/register/visit/component/agentDialog.jsx
@@ -17,27 +17,48 @@
  const [visitList, setVisitList] = useState([])
  useEffect(() => {
    if (props.editData) {
      //编辑
      formRef.current.setFieldsValue({
        ...props.editData
      })
    //过滤代理人
    setVisitList(props.fakeData.filter(item => {
      console.log(item,props.dialogType);
        if (props.editData.dialogType === 2) {
          return item.partyType === 0
        } else {
          return item.partyType === 1
        }
      }))
    } else {
      //过滤代理人
      setVisitList(props.fakeData.filter(item => {
      if (props.dialogType === 2) {
        return item.partyType === 0
      } else {
        return item.partyType === 1
      }
    }))
  }, [props.fakeData])
    }
  }, [])
  //保存信息
  const handleSave = () => {
    if (formRef.current) {
      formRef.current.validate(undefined, (errors, values) => {
        if (!errors) {
          if (props.editData) {
            props.handleAddParty({
              ...props.editData,
              ...values,
            })
          } else {
          props.handleAddParty({
            ...values,
            partyType: props.dialogType,
            perClassName: props.dialogType === 2 ? '申请方代理人' : '被申请方代理人',
          })
          }
          props.onClose()
        }
      });
@@ -55,6 +76,7 @@
              requiredSymbol={false}
              initialValues={{
              }}//默认值
              scrollToFirstError
            >
              <Row gutter={[32, 0]} style={{ margin: '0 -10px' }}>
                <Col span={24}>
@@ -227,7 +249,7 @@
                <Col span={12}>
                  <FormItem
                    label={(<div style={{ display: 'flex' }}>代理对象<div className="must">必填</div></div>)}
                    rules={[{ required: true }]}
                    rules={[{ required: true, message: '请选择代理对象' }]}
                    field='dailimap'
                  >
                    <CheckboxGroup
@@ -256,7 +278,7 @@
          className="dialogPrimary"
          onClick={handleSave}
        >
          保存信息
          保存
        </Button>
        <Button className="dialogBack">
          重置
gz-customerSystem/src/views/register/visit/component/applyDialog.jsx
@@ -29,6 +29,15 @@
  const [perClass, setPerClass] = useState('09_01001-1');
  const [visible, setVisible] = useState(false);
  useEffect(() => {
    if (props.editData) {
      //编辑
      formRef.current.setFieldsValue({
        ...props.editData
      })
    }
  }, [])
  const personIconType = (v) => {
    switch (v) {
@@ -271,12 +280,19 @@
    if (formRef.current) {
      formRef.current.validate(undefined, (errors, values) => {
        if (!errors) {
          if (props.editData) {
            props.handleAddParty({
              ...props.editData,
              ...values
            })
          } else {
          props.handleAddParty({
            ...values,
            partyType: props.dialogType,
            perClass: perClass,
            perClassName: props.dialogType === 0 ? '申请方当事人' : '被申请方当事人'
          })
          }
          props.onClose()
        }
      });
@@ -319,6 +335,7 @@
              requiredSymbol={false}
              initialValues={{
              }}//默认值
              scrollToFirstError
            >
              <Row gutter={[32, 0]} style={{ margin: '0 -10px' }}>{formType(perClass)}</Row>
            </Form>
@@ -336,7 +353,7 @@
          className="dialogPrimary"
          onClick={handleSave}
        >
          保存信息
          保存
        </Button>
        <Button className="dialogBack">
          重置
gz-customerSystem/src/views/register/visit/component/visitorRegister.jsx
@@ -46,9 +46,10 @@
  const [fileTip, setFileTip] = useState('0');
  const [detailVisabled, setDetailVisabled] = useState(false);//查看信息弹窗控制
  const [mapView, setMapView] = useState(false);
  const [flagId, setFlagId] = useState(0);//赋予当事人唯一id,用于删除
  const [flagId, setFlagId] = useState(1);//赋予当事人唯一id,用于删除
  const [visible, setVisible] = useState(false);
  const [apply, setApply] = useState(false);
  const [editData, setEditData] = useState(null);
  const addressOptions = [
    { label: '地址1', value: 'address1' },
@@ -369,12 +370,24 @@
  //添加当事人
  const handleAddParty = (value) => {
    console.log(value);
    if (value.id) {
      //编辑
      const newList = fakeData.map(item => {
        if (item.id === value.id) {
          return value
        } else {
          return item
        }
      })
      setFakeData(newList)
      setEditData(null)
    } else {
    setFakeData([...fakeData, {
      ...value,
      id: flagId
    }])
    setFlagId(flagId + 1)
    }
  }
  //删除当事人
@@ -382,6 +395,19 @@
    event.stopPropagation();
    const filterData = fakeData.filter(item => item.id !== value.id)
    setFakeData(filterData)
  }
  //编辑
  const handleEdit = (value) => {
    console.log(value);
    if (value.partyType === 0 || value.partyType === 1) {
      //当事人
      setAddVisabled(true)
    } else {
      //代理人
      setAgentVisible(true)
    }
    setEditData(value)
  }
@@ -401,6 +427,7 @@
          handleCheckParty={handleCheckParty}
          handleAdd={handleAdd}
          handleDeleteParty={handleDeleteParty}
          handleEdit={handleEdit}
        />
      </div>
      <Col span={24} style={{ display: 'flex', alignItems: 'center', marginBottom: '8px' }}>
@@ -726,6 +753,7 @@
          dialogType={dialogType}
          onClose={() => setAddVisabled(false)}
          handleAddParty={handleAddParty}
          editData={editData}
        />
      </Modal>
      <Modal
@@ -744,6 +772,7 @@
          onClose={() => setAgentVisible(false)}
          fakeData={fakeData}
          dialogType={dialogType}
          editData={editData}
        />
      </Modal>
      <Modal