Blame view

src/pages/crm_new/TargetAndProportion/components/List.tsx 2.31 KB
5dae0393   舒述军   目标和占比设置
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
  import React, { useState } from "react";
  import { Popconfirm, Table, message, Space } from "antd";
  import { history } from 'umi';
  import { SaveParams, fetchOperationApi, fetchDeleteConfigApi, List } from '../api';
  import {useStore} from '../index';
  
  const Column = Table.Column;
  
  export default function Index() {
    const { statusData, setStatusData, data, setLoading } = useStore();
    function handleToEdit(value: List, operationType: number) {
      const state = {id: value.id, operationType};
      history.push({pathname: '/crm/addTragetProportion', state});
    }
  
    function handleToDelete(operationType: number, id?: number) {
      fetchDeleteConfigApi(id)
      .then(res => {
        message.success(res.result);
        setLoading(true);
      })
      .catch(e => {
        message.error(e.message);
      });
    }
  
    function handleToShopDetail(value?: List) {
      setStatusData({...statusData, shop: true, id: value?.id});
    }
  
    function handleToTargetDetail(value: List = {}) {
      setStatusData({...statusData, target: true, id: value?.id});
    }
  
    return (
      <div>
        <Table
          dataSource={data}
          pagination={false}
          loading={false}
          rowKey="id"
        >
          <Column
            title="适用门店"
            align="left"
            dataIndex="shopName"
            render={(_text, record: List) => <span style={{color: "#4189FD"}} onClick={() => handleToShopDetail(record)}>{record.shopName || '--'}</span>}
          />
          <Column
            title="目标占比"
            align="left"
            render={(_text, record: List) => <span style={{color: "#4189FD"}} onClick={() => handleToTargetDetail(record)}>查看</span>}
          />
          <Column
            title="操作"
            align="left"
            render={(_text, record: List) => {
              return (
                <Space>
                  <a style={{color: "#4189FD"}} onClick={() => handleToEdit(record, 2)}>编辑</a>
                  <Popconfirm
                    title="是否删除?"
                    okText="确定"
                    cancelText="取消"
                    onConfirm={() => handleToDelete(0, record.id)}
                  >
                    <span>
                      <a style={{color: "red"}}>删除</a>
                    </span>
                  </Popconfirm>
                </Space>
              );
            }}
          />
        </Table>
      </div>
    );
  }