魏熙美 преди 5 години
родител
ревизия
5b8e01c6dc
променени са 1 файла, в които са добавени 36 реда и са изтрити 3 реда
  1. 36
    3
      src/pages/customer/customerlist/index.jsx

+ 36
- 3
src/pages/customer/customerlist/index.jsx Целия файл

28
 
28
 
29
   // eslint-disable-next-line react-hooks/rules-of-hooks
29
   // eslint-disable-next-line react-hooks/rules-of-hooks
30
   const [dataSource, setDataSource] = useState({ records: [] })
30
   const [dataSource, setDataSource] = useState({ records: [] })
31
+  // eslint-disable-next-line react-hooks/rules-of-hooks
32
+  // const [columns, setColumns] = useState(privateColumns)
31
 
33
 
32
   // 默认私客
34
   // 默认私客
33
   // eslint-disable-next-line react-hooks/rules-of-hooks
35
   // eslint-disable-next-line react-hooks/rules-of-hooks
107
 
109
 
108
     const { value } = e.target
110
     const { value } = e.target
109
     setCustomerType(value)
111
     setCustomerType(value)
112
+    //setColumns(value === 'private' ? privateColumns : publicColumns)
110
     getList({ pageNumber: 1, pageSize: 10, customerType: value })
113
     getList({ pageNumber: 1, pageSize: 10, customerType: value })
111
   }
114
   }
112
 
115
 
168
     link.click()
171
     link.click()
169
   }
172
   }
170
 
173
 
171
-  const columns = [
174
+  const publicColumns = [
175
+    {
176
+      title: '头像',
177
+      dataIndex: 'picture',
178
+      key: 'picture',
179
+      align: 'center',
180
+      width: '15%',
181
+      render: (_, record) => <Avatar shape="square" src={customerType === 'private' ? record.picture : record.avatarurl} size={64} icon="user" />,
182
+    },
183
+    {
184
+      title: '姓名',
185
+      dataIndex: 'name',
186
+      key: 'name',
187
+      align: 'center',
188
+      width: '10%',
189
+      // eslint-disable-next-line no-nested-ternary
190
+      render: (_, record) => <><span>{customerType === 'private' ? record.name : record.nickname}</span></>,
191
+    },
192
+    {
193
+      title: '电话',
194
+      dataIndex: 'phone',
195
+      key: 'phone',
196
+      align: 'center',
197
+      width: '15%',
198
+    },
199
+  ]
200
+
201
+  const privateColumns = [
172
     {
202
     {
173
       title: '头像',
203
       title: '头像',
174
       dataIndex: 'picture',
204
       dataIndex: 'picture',
324
           </Radio.Group>
354
           </Radio.Group>
325
         </AuthButton>
355
         </AuthButton>
326
       </div>
356
       </div>
327
-      <Table dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" />
328
-
357
+      {customerType === 'private' ? 
358
+        <Table dataSource={dataSource.records} columns={privateColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> :
359
+        <Table dataSource={dataSource.records} columns={publicColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> 
360
+      }
361
+      
329
       {/* 调整归属 */}
362
       {/* 调整归属 */}
330
       <Attribution visibleData={gVisibleData} />
363
       <Attribution visibleData={gVisibleData} />
331
 
364