pyt
2025-03-17 956d1d6e32b3c7a8c40101a42a2855fb5c22bc63
management/src/pages/party/manage/index.jsx
@@ -1,17 +1,18 @@
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { buildProTableDataSource, sendRequest, showDelConfirm } from '@/utils/antdUtils';
import { buildProTableDataSource, sendRequest, showDelConfirm, showDelConfirm1 } from '@/utils/antdUtils';
import { Button, message, Space, Cascader } from 'antd';
import { useRef, useState } from 'react';
import { useRef, useState, useEffect } from 'react';
import { Access, history, useAccess } from 'umi';
import AddAndEdit from './components/index';
import ImportExcell from './components/export';
import { getList, updateStatus, deleteBanner, add, Edit } from './service'
import { getList, deleteBanner, freeze, regionTree, enterList } from './service'
import { exportExcell } from '@/utils/utils'
const Banner = () => {
  const actionRef = useRef();
  const access = useAccess();
  const addViewRef = useRef();
  const modalExportRef = useRef();
  const [modalVisible, handleModalVisible] = useState(false);
  const [items, setItems] = useState([]);
  const [excelParams, setExcelParams] = useState({});
@@ -26,38 +27,51 @@
    {
      title: '性别',
      hideInSearch: true,
      dataIndex: 'name'
      dataIndex: 'gender',
      valueEnum: {
        1: { text: '男' },
        0: { text: '女' },
      }
    },
    {
      title: '所在社区',
      dataIndex: 'name',
      dataIndex: 'community',
      renderFormItem: () => {
        return (
          <Cascader
            options={items}
            fieldNames={{ value: 'key', label: 'name' }}
            fieldNames={{ value: 'id', label: 'name' }}
            placeholder="请选择"
            displayRender={(label) => label[label.length - 1]}
            changeOnSelect={true}
          // changeOnSelect={true}
          />
        );
      },
      render: (text, record) => {
        return record.community
      }
    },
    {
      title: '服务对象',
      dataIndex: 'name'
      dataIndex: 'serviceTarget',
      render: (text, record) => {
        return record.serviceTarget
      }
    },
    {
      title: '所在党组织',
      dataIndex: 'name'
      dataIndex: 'partyOrganization',
      render: (text, record) => {
        return record.partyOrganization
      }
    },
    {
      title: '状态',
      dataIndex: 'status',
      dataIndex: 'freezeStatus',
      valueEnum: {
        0: { text: '全部' },
        1: { text: '正常中' },
        2: { text: '已冻结' },
        // 'all': { text: '全部' },
        '1': { text: '已冻结' },
        '0': { text: '正常中' },
      }
    },
    {
@@ -66,7 +80,7 @@
      render: (text, record) => {
        return (
          <Space>
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/edit']}> */}
            <Access accessible={access['/party_member/edit']}>
            <Button
              type="link"
              onClick={() => {
@@ -75,23 +89,23 @@
            >
              编辑
            </Button>
            {/* </Access> */}
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
            </Access>
            <Access accessible={access['/party_member/del']}>
            <Button
              type="link"
              onClick={() => {
                showDelConfirm(async () => {
                  // let status = await sendRequest(deleteBanner, record.id)
                  // if (status) {
                  //   actionRef.current.reload();
                  // }
                  let status = await sendRequest(deleteBanner, {id:record.id})
                  if (status) {
                    actionRef.current.reload();
                  }
                }, '确认删除所选信息吗?');
              }}
            >
              删除
            </Button>
            {/* </Access> */}
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
            </Access>
            <Access accessible={access['/party_member/detail']}>
            <Button
              type="link"
              onClick={() => {
@@ -100,42 +114,53 @@
            >
              查看详情
            </Button>
            {/* </Access> */}
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
            <Button
              type="link"
              onClick={() => {
                showDelConfirm(async () => {
                  // let status = await sendRequest(deleteBanner, record.id)
                  // if (status) {
                  //   actionRef.current.reload();
                  // }
                }, '确认冻结该党员信息吗?');
              }}
            >
              冻结
            </Button>
            {/* </Access> */}
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
            <Button
              type="link"
              onClick={() => {
                showDelConfirm(async () => {
                  // let status = await sendRequest(deleteBanner, record.id)
                  // if (status) {
                  //   actionRef.current.reload();
                  // }
                }, '确认解冻该党员信息吗?');
              }}
            >
              解冻
            </Button>
            {/* </Access> */}
            </Access>
            <Access accessible={access['/party_member/freeze']}>
            {record.freezeStatus == 0 && (
              <Button
                type="link"
                onClick={() => {
                  showDelConfirm1(async () => {
                    let status = await sendRequest(freeze, { id: record.id })
                    if (status) {
                      actionRef.current.reload();
                    }
                  }, '确认冻结该党员信息吗?', '冻结', '', '确认冻结该党员信息吗?');
                }}
              >
                冻结
              </Button>
            )}
            </Access>
            <Access accessible={access['/party_member/freeze']}>
            {record.freezeStatus == 1 && (
              <Button
                type="link"
                onClick={() => {
                  showDelConfirm1(async () => {
                    let status = await sendRequest(freeze, { id: record.id })
                    if (status) {
                      actionRef.current.reload();
                    }
                  }, '确认解冻该党员信息吗?', '解冻', '', '确认解冻该党员信息吗?');
                }}
              >
                解冻
              </Button>
            )}
            </Access>
          </Space >
        );
      },
    },
  ]
  useEffect(() => {
    regionTree({}).then(res => {
      setItems(() => res.data)
    })
  }, [])
  return <div>
    <PageContainer title='党员管理' header={{
@@ -151,13 +176,14 @@
          defaultPageSize: 10,
        }}
        request={(params) => {
          params.status = (params.status && params.status != 0) ? params.status : '';
          params.communityId = params.community ? params.community[params.community.length - 1] : ''
          params.auditStatus = 1
          setExcelParams(() => params)
          return buildProTableDataSource(getList, params)
        }}
        toolBarRender={(action, selectRows) => [
          <Space>
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/add']}> */}
            <Access accessible={access['/party_member/add']}>
            <Button
              type="primary"
              onClick={() => {
@@ -166,67 +192,63 @@
            >
              添加
            </Button>
            {/* </Access> */}
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/add']}> */}
            </Access>
            <Access accessible={access['/party_member/export']}>
            <Button
              type="primary"
              onClick={() => {
                // exportExcell('党员列表', excelParams, '/promotion/mgt/coupon/receive-detail/export')
                exportExcell('党员列表', excelParams, '/api/huacheng-sangeshenbian/party-member/export')
              }}
            >
              导出
            </Button>
            {/* </Access> */}
            {/* <Access accessible={access['/work_order_transaction_management/banner_management/add']}> */}
            </Access>
            <Access accessible={access['/party_member/import']}>
            <Button
              type="primary"
              onClick={() => {
                // history.push('/party/manage/add?type=add')
                handleModalExport(true)
                modalExportRef.current.clean()
              }}
            >
              导入
            </Button>
            {/* </Access> */}
            </Access>
          </Space>
        ]}
      />
      {/* 导入失败弹窗 */}
      <AddAndEdit
        ref={addViewRef}
        visible={modalVisible}
        onCancel={() => handleModalVisible(false)}
        onSave={async (fileds) => {
          // const success = await sendRequest(add, fileds);
          // if (success) {
            handleModalVisible(false);
          //   actionRef.current.reload();
          // }
          handleModalVisible(false);
        }}
        onUpdate={async (fileds) => {
          // const success = await sendRequest(Edit, fileds);
          // if (success) {
            handleModalVisible(false);
          //   actionRef.current.reload();
          // }
          handleModalVisible(false);
        }}
      />
      <ImportExcell
        ref={modalExportRef}
        visible={modalExport}
        onSave={async (fileds) => {
          console.log('上传文件数据', fileds);
          handleModalExport(false);
          handleModalVisible(true)
          // const success = await sendRequest(enable, fileds);
          // if (success) {
          //   handleModalExport(false);
          //   // actionRef.current.reload();
          //   // listCheck({ checkType: checktype, }).then(res => {
          //   //   console.log('一键导入数据', res)
          //   // })
          // }
          enterList(fileds).then(res => {
            if (res.code == 200) {
              if (res.data.length > 0) {
                message.error('导入失败')
                handleModalExport(false);
                handleModalVisible(true)
                actionRef.current.reload()
                addViewRef.current.refreshData(res.data)
              } else {
                message.success('导入成功')
                handleModalExport(false);
                actionRef.current.reload()
              }
            }
          })
        }}
        onCancel={() => handleModalExport(false)}
      />