|
@@ -11,14 +11,7 @@ import { formatValues } from '@/components/LazyCascader'
|
|
|
import { apiChangeCustomer } from '@/services/customer'
|
|
import { apiChangeCustomer } from '@/services/customer'
|
|
|
import { useModal } from '@/components/ModalStore'
|
|
import { useModal } from '@/components/ModalStore'
|
|
|
|
|
|
|
|
-const ConnectCompany = ({
|
|
|
|
|
- onCancel,
|
|
|
|
|
- dataId,
|
|
|
|
|
- onSelect,
|
|
|
|
|
- preUrl = 'Client',
|
|
|
|
|
- defaultAddibleValue,
|
|
|
|
|
- ...resetModalProps
|
|
|
|
|
-}) => {
|
|
|
|
|
|
|
+const ConnectCompany = ({ onCancel, dataId, onSelect, preUrl = 'Client', defaultAddibleValue, ...resetModalProps }) => {
|
|
|
const hasAddPerm = useAccess()?.validatePermByType('company_add')
|
|
const hasAddPerm = useAccess()?.validatePermByType('company_add')
|
|
|
const dispatchModal = useModal()
|
|
const dispatchModal = useModal()
|
|
|
const scrollRef = useRef()
|
|
const scrollRef = useRef()
|
|
@@ -28,12 +21,14 @@ const ConnectCompany = ({
|
|
|
noMore: false,
|
|
noMore: false,
|
|
|
searchVal: '',
|
|
searchVal: '',
|
|
|
current: 1,
|
|
current: 1,
|
|
|
- pageSize: 10,
|
|
|
|
|
|
|
+ pageSize: 25,
|
|
|
total: 0
|
|
total: 0
|
|
|
})
|
|
})
|
|
|
const initData = async params => {
|
|
const initData = async params => {
|
|
|
- const { data: { customer, total } = { customer: [], total: 0 }, code = -1 } =
|
|
|
|
|
- await queryCustomers({ ...params, waiver: true })
|
|
|
|
|
|
|
+ const { data: { customer, total } = { customer: [], total: 0 }, code = -1 } = await queryCustomers({
|
|
|
|
|
+ ...params,
|
|
|
|
|
+ waiver: true
|
|
|
|
|
+ })
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
if (params?.current === 1) {
|
|
if (params?.current === 1) {
|
|
|
scrollRef.current?.scrollTo({ top: 0 })
|
|
scrollRef.current?.scrollTo({ top: 0 })
|
|
@@ -53,7 +48,7 @@ const ConnectCompany = ({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- initData({ current: 1, pageSize: 10 })
|
|
|
|
|
|
|
+ initData({ current: 1, pageSize: 25 })
|
|
|
}, [])
|
|
}, [])
|
|
|
const onChange = e => {
|
|
const onChange = e => {
|
|
|
const { value = '' } = e.target || e.currentTarget
|
|
const { value = '' } = e.target || e.currentTarget
|
|
@@ -88,13 +83,10 @@ const ConnectCompany = ({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const handleListScroll = () => {
|
|
|
|
|
|
|
+ const handleListScroll = e => {
|
|
|
if (!scrollRef.current) return
|
|
if (!scrollRef.current) return
|
|
|
// 未滚动到底部
|
|
// 未滚动到底部
|
|
|
- if (
|
|
|
|
|
- scrollRef.current.scrollHeight - scrollRef.current.clientHeight <=
|
|
|
|
|
- scrollRef.current.scrollTop
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (scrollRef.current.scrollHeight - scrollRef.current.clientHeight <= scrollRef.current.scrollTop) {
|
|
|
// 已到底部
|
|
// 已到底部
|
|
|
if (state.current * state.pageSize > state.total) {
|
|
if (state.current * state.pageSize > state.total) {
|
|
|
setState({ ...state, noMore: true })
|
|
setState({ ...state, noMore: true })
|
|
@@ -134,31 +126,29 @@ const ConnectCompany = ({
|
|
|
</Button>
|
|
</Button>
|
|
|
)
|
|
)
|
|
|
}>
|
|
}>
|
|
|
- <div
|
|
|
|
|
- className={styles.modalContent}
|
|
|
|
|
- ref={scrollRef}
|
|
|
|
|
- onScroll={handleListScroll}
|
|
|
|
|
- style={{ paddingBottom: 0 }}>
|
|
|
|
|
- <Spin spinning={state.laoding}>
|
|
|
|
|
- {state.customer.map(item => (
|
|
|
|
|
- <div key={item.id} className={styles.card}>
|
|
|
|
|
- <div className="flex flex-1">{item.companyName}</div>
|
|
|
|
|
- <div className="flex flex-1 justify-between">
|
|
|
|
|
- <span>{item.districtName}</span>
|
|
|
|
|
- <Popconfirm
|
|
|
|
|
- title="确认关联ta"
|
|
|
|
|
- onConfirm={() => connectCustomer(item.id)}
|
|
|
|
|
- okText="确认"
|
|
|
|
|
- cancelText="取消">
|
|
|
|
|
- <Button type="primary" size="small">
|
|
|
|
|
- 关联
|
|
|
|
|
- </Button>
|
|
|
|
|
- </Popconfirm>
|
|
|
|
|
|
|
+ <div className={styles.modalContainer}>
|
|
|
|
|
+ <div className={styles.modalContent} ref={scrollRef} onScroll={handleListScroll}>
|
|
|
|
|
+ <Spin spinning={state.laoding}>
|
|
|
|
|
+ {state.customer.map(item => (
|
|
|
|
|
+ <div key={item.id} className={styles.card}>
|
|
|
|
|
+ <div className="flex flex-1">{item.companyName}</div>
|
|
|
|
|
+ <div className="flex flex-1 justify-between">
|
|
|
|
|
+ <span>{item.districtName}</span>
|
|
|
|
|
+ <Popconfirm
|
|
|
|
|
+ title="确认关联ta"
|
|
|
|
|
+ onConfirm={() => connectCustomer(item.id)}
|
|
|
|
|
+ okText="确认"
|
|
|
|
|
+ cancelText="取消">
|
|
|
|
|
+ <Button type="primary" size="small">
|
|
|
|
|
+ 关联
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Popconfirm>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
- ))}
|
|
|
|
|
- </Spin>
|
|
|
|
|
- {state.noMore && <div className="text-center text-gray-400 my-4">已到底部</div>}
|
|
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </Spin>
|
|
|
|
|
+ {state.noMore && <div className="text-center text-gray-400 my-4">已到底部</div>}
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</Modal>
|
|
</Modal>
|
|
|
)
|
|
)
|