indexNew.jsx 10.4 KB
Newer Older
1 2 3
import React, { useState, useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import { Tabs, Table, Form, Input, Button, Tooltip, Tag, Space, Popconfirm, message } from 'antd';
邓超's avatar
邓超 committed
4 5 6 7 8 9 10
import {
  FundViewOutlined,
  EditTwoTone,
  DeleteOutlined,
  CheckOutlined,
  CloseOutlined,
} from '@ant-design/icons';
邓超's avatar
邓超 committed
11
import SchemeTest from './schemeDetails/schemeTest';
邓超's avatar
邓超 committed
12
import PushTest from './schemeDetails/components/PushTest/PushTest';
邓超's avatar
邓超 committed
13 14 15 16 17
import {
  GetMessageConfigs,
  DelMessageConfigs,
  GetThirdpartyTemplates,
} from '@/services/messagemanage/messagemanage';
18 19 20 21 22 23 24 25 26
import styles from './index.less';

const { TabPane } = Tabs;
const { Search } = Input;

const HostManager = () => {
  const history = useHistory();
  const [dataList, setDataList] = useState([]);
  const [loading, setLoading] = useState(false);
邓超's avatar
邓超 committed
27
  const [visible, setVisible] = useState({ configPage: false, personPage: false });
邓超's avatar
邓超 committed
28
  const [schemeMsg, setSchemeMsg] = useState({});
29
  const searchValue = useRef();
邓超's avatar
邓超 committed
30
  const [msgTemplate, setMsgTemplate] = useState();
邓超's avatar
邓超 committed
31
  const [testPersons, setTestPersons] = useState();
32 33
  const [form] = Form.useForm();
  useEffect(() => {
邓超's avatar
邓超 committed
34 35 36 37 38 39 40
    GetThirdpartyTemplates().then(res => {
      if (res.code === 0) {
        setMsgTemplate(res.data);
      } else {
        message.error(res.msg);
      }
    });
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    getData();
  }, []);
  const getData = query => {
    setLoading(true);
    GetMessageConfigs({ keyword: query }).then(res => {
      setLoading(false);
      if (res.code === 0) {
        setDataList(res.data);
      } else {
        message.error(res.msg);
      }
    });
  };
  const onChage = value => {
    searchValue.current = value.target.value;
  };
  const onSearch = value => {
    getData(value);
  };
  const changeDesc = value => {
    history.push({
      pathname: `/platform/SchemeDetailNew`,
邓超's avatar
邓超 committed
63
      state: { schemeMsg: value, msgTemplate },
64 65 66
    });
  };
  // 消息发送测试
邓超's avatar
邓超 committed
67 68
  const TestDesc = val => {
    setSchemeMsg(val);
邓超's avatar
邓超 committed
69
    setVisible({ ...visible, personPage: true });
邓超's avatar
邓超 committed
70
  };
71 72 73 74 75 76 77 78 79 80 81
  // 删除消息
  const DeleteProject = val => {
    DelMessageConfigs({ Id: val.Id }).then(res => {
      if (res.code === 0) {
        message.success('删除成功');
        getData(searchValue.current);
      } else {
        message.error(res.msg);
      }
    });
  };
邓超's avatar
邓超 committed
82 83 84 85 86
  const savePersonTest = value => {
    console.log(value, 'aaaaa');
    setTestPersons(value);
    setVisible({ personPage: false, configPage: true });
  };
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  const columns = [
    {
      title: '序号',
      dataIndex: 'ID',
      align: 'center',
      key: 'ID',
      width: 60,
      render: (text, record, index) => <span>{index + 1}</span>,
    },
    {
      title: '方案名称',
      dataIndex: 'SchemeName',
      align: 'center',
      key: 'SchemeName',
      render: (text, record) => <div>{text === null || !text ? '-' : text}</div>,
    },

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    // {
    //   title: '推送组',
    //   dataIndex: 'TimeJobGroup',
    //   key: 'TimeJobGroup',
    //   align: 'center',
    //   ellipsis: true,
    //   width: 500,
    //   render: (text, record) => (
    //     <span>
    //       <Tooltip placement="topLeft" title={text.map(item => item.name).join(',')}>
    //         {text.map(item => item.name).join(',') || '--'}
    //       </Tooltip>
    //     </span>
    //   ),
    // },
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    {
      title: '消息平台',
      dataIndex: 'Platform',
      align: 'center',
      key: 'Platform',
      width: '100px',

      render: record => {
        if (record.PlatformStatus === 1) {
          return <Tag color="success"></Tag>;
        }
        return <Tag color="processing"></Tag>;
      },
    },
    {
      title: '短信推送',
      dataIndex: 'SMS',
      align: 'center',
      key: 'SMS',
      width: '100px',

      render: record => {
邓超's avatar
邓超 committed
141
        if (record.SMSStatus === 1) {
142 143 144 145 146 147 148 149 150 151 152 153
          return <Tag color="success"></Tag>;
        }
        return <Tag color="processing"></Tag>;
      },
    },
    {
      title: '公众号推送',
      dataIndex: 'Wechat',
      align: 'center',
      key: 'Wechat',
      width: '100px',
      render: record => {
邓超's avatar
邓超 committed
154
        if (record.WechatStatus === 1) {
155 156 157 158 159 160 161 162 163 164 165 166
          return <Tag color="success"></Tag>;
        }
        return <Tag color="processing"></Tag>;
      },
    },
    {
      title: '企业微信推送',
      dataIndex: 'WorkWechat',
      align: 'center',
      key: 'WorkWechat',
      width: '110px',
      render: record => {
邓超's avatar
邓超 committed
167
        if (record.WorkWechatStatus === 1) {
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
          return <Tag color="success"></Tag>;
        }
        return <Tag color="processing"></Tag>;
      },
    },

    {
      title: '是否启用',
      dataIndex: 'IsEnable',
      align: 'center',
      key: 'IsEnable',
      width: '100px',

      render: record => {
        if (record === 1) {
          return <Tag color="success"></Tag>;
        }
        return <Tag color="processing"></Tag>;
      },
    },
    {
      title: '操作',
      width: 250,
      align: 'center',
      ellipsis: true,
      render: (text, record) => (
        <Space>
邓超's avatar
邓超 committed
195
          <Tooltip title="测试">
196 197 198 199 200 201
            <FundViewOutlined
              style={{ fontSize: '16px', color: '#1890FF' }}
              onClick={() => {
                TestDesc(record);
              }}
            />
邓超's avatar
邓超 committed
202
          </Tooltip>
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
          <Tooltip title="编辑">
            <EditTwoTone
              style={{ fontSize: '16px', color: '#e86060' }}
              onClick={() => {
                changeDesc(record);
              }}
            />
          </Tooltip>

          <Popconfirm
            title="是否删除方案?"
            okText="确认"
            cancelText="取消"
            onConfirm={() => {
              DeleteProject(record);
            }}
          >
            <DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
          </Popconfirm>
        </Space>
      ),
    },
  ];
  return (
    <div className={styles.pageContent}>
      <div className={styles.header}>
        <Form name={form} layout="inline">
          <Form.Item>
            <Search
              placeholder="请输入方案名称"
              onChange={onChage}
              onSearch={onSearch}
              enterButton
              allowClear
            />
          </Form.Item>
          <Form.Item>
            <Button
              onClick={() => {
                history.push({
                  pathname: `/platform/schemeDetailNew`,
邓超's avatar
邓超 committed
244
                  state: { schemeMsg: null, msgTemplate },
245 246 247 248 249 250 251 252 253
                });
              }}
            >
              新增
            </Button>
          </Form.Item>
        </Form>
      </div>
      <div className={styles.content}>
邓超's avatar
邓超 committed
254
        {/* <Table
255 256 257 258 259 260 261
          loading={loading}
          bordered
          columns={columns}
          dataSource={dataList}
          pagination={false}
          rowKey="Id"
          scroll={{ y: 'calc(100% - 55px)' }}
邓超's avatar
邓超 committed
262 263 264 265 266 267 268 269 270 271 272
        /> */}
        {dataList.map(item => (
          <div className={styles.cardBox}>
            <div className={styles.header}>{item.SchemeName}</div>
            <div className={styles.cardContent}>
              <div className={styles.stadusBox}>
                <div className={styles.label}>消息平台</div>
                <div className={styles.value}>
                  {item.Platform.PlatformStatus ? (
                    <CheckOutlined style={{ color: '#1890FF' }} />
                  ) : (
邓超's avatar
邓超 committed
273 274
                    ''
                    // <CloseOutlined style={{ color: '#e86060' }} />
邓超's avatar
邓超 committed
275 276 277 278 279 280 281 282 283
                  )}
                </div>
              </div>
              <div className={styles.stadusBox}>
                <div className={styles.label}>短信推送</div>
                <div className={styles.value}>
                  {item.SMS.SMSStatus ? (
                    <CheckOutlined style={{ color: '#1890FF' }} />
                  ) : (
邓超's avatar
邓超 committed
284 285
                    ''
                    // <CloseOutlined style={{ color: '#e86060' }} />
邓超's avatar
邓超 committed
286 287 288 289 290 291 292 293 294
                  )}
                </div>
              </div>
              <div className={styles.stadusBox}>
                <div className={styles.label}>公众号推送</div>
                <div className={styles.value}>
                  {item.Wechat.WechatStatus ? (
                    <CheckOutlined style={{ color: '#1890FF' }} />
                  ) : (
邓超's avatar
邓超 committed
295 296
                    ''
                    // <CloseOutlined style={{ color: '#e86060' }} />
邓超's avatar
邓超 committed
297 298 299 300 301 302 303 304 305
                  )}
                </div>
              </div>
              <div className={styles.stadusBox}>
                <div className={styles.label}>企业微信推送</div>
                <div className={styles.value}>
                  {item.WorkWechat.WorkWechatStatus ? (
                    <CheckOutlined style={{ color: '#1890FF' }} />
                  ) : (
邓超's avatar
邓超 committed
306 307
                    ''
                    // <CloseOutlined style={{ color: '#e86060' }} />
邓超's avatar
邓超 committed
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
                  )}
                </div>
              </div>
            </div>
            <div className={styles.footer}>
              <div className={styles.operateBox}>
                <Tooltip title="测试">
                  <FundViewOutlined
                    style={{ fontSize: '16px', color: '#1890FF' }}
                    onClick={() => {
                      TestDesc(item);
                    }}
                  />
                </Tooltip>
              </div>
              <div className={styles.operateBox}>
                <Tooltip title="编辑">
                  <EditTwoTone
                    style={{ fontSize: '16px', color: '#1890FF' }}
                    onClick={() => {
                      changeDesc(item);
                    }}
                  />
                </Tooltip>
              </div>
              <div className={styles.operateBox}>
                <Popconfirm
                  title="是否删除方案?"
                  okText="确认"
                  cancelText="取消"
                  onConfirm={() => {
                    DeleteProject(item);
                  }}
                >
                  <DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
                </Popconfirm>
              </div>
            </div>
          </div>
        ))}
348
      </div>
邓超's avatar
邓超 committed
349
      <SchemeTest
邓超's avatar
邓超 committed
350
        visible={visible.configPage}
邓超's avatar
邓超 committed
351
        schemeMsg={schemeMsg}
邓超's avatar
邓超 committed
352 353
        testPersons={testPersons}
        onCancel={() => setVisible({ ...visible, configPage: false })}
邓超's avatar
邓超 committed
354 355
        onOk={() => {}}
      />
邓超's avatar
邓超 committed
356 357 358 359 360
      <PushTest
        onOk={savePersonTest}
        visible={visible.personPage}
        onCancel={() => setVisible({ ...visible, personPage: false })}
      />
361 362 363 364
    </div>
  );
};
export default HostManager;