Commit 8ab6c443 by tdgiang

update code

parent 8e228715
...@@ -55,7 +55,7 @@ const DialogActions = withStyles((theme) => ({ ...@@ -55,7 +55,7 @@ const DialogActions = withStyles((theme) => ({
}))(MuiDialogActions) }))(MuiDialogActions)
const CustomizedDialogs = (props) => { const CustomizedDialogs = (props) => {
const { onSelectCustomer, cusomterSelect } = props const { onSelectCustomer, cusomterSelect, idPaymentPartner } = props
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const handleClickOpen = () => { const handleClickOpen = () => {
...@@ -70,6 +70,7 @@ const CustomizedDialogs = (props) => { ...@@ -70,6 +70,7 @@ const CustomizedDialogs = (props) => {
onSelectCustomer(item) onSelectCustomer(item)
setOpen(false) setOpen(false)
} }
console.log('idPaymentPartner dialog', idPaymentPartner)
return ( return (
<div style={{ marginRight: 10 }}> <div style={{ marginRight: 10 }}>
...@@ -102,6 +103,8 @@ const CustomizedDialogs = (props) => { ...@@ -102,6 +103,8 @@ const CustomizedDialogs = (props) => {
<CustomerList <CustomerList
customSelect={customSelect} customSelect={customSelect}
handleClose={handleClose} handleClose={handleClose}
idPaymentPartner={idPaymentPartner}
open={open}
/> />
</DialogContent> </DialogContent>
</Dialog> </Dialog>
......
...@@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next' ...@@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next'
import { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown' import { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const { customSelect, handleClose } = props const { customSelect, handleClose, idPaymentPartner } = props
const [listSelected, setListSelected] = useState([]) const [listSelected, setListSelected] = useState([])
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [applications, setApplications] = useState('') const [applications, setApplications] = useState('')
...@@ -26,51 +26,32 @@ const ToolNotificate = (props) => { ...@@ -26,51 +26,32 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
const [type, setType] = useState() const [type, setType] = useState()
const [listType, setListType] = useState([]) const [listType, setListType] = useState([])
const [merchant, setMerchant] = useState()
const [listMerchant, setListMerchant] = useState([])
const [store, setStore] = useState()
const [listStore, setListStore] = useState([])
useEffect(() => {
getDataMerchant()
}, [])
const changeDateRange = (start, end) => { const changeDateRange = (start, end) => {
setStartDate(start) setStartDate(start)
setEndDate(end) setEndDate(end)
} }
console.log('idPaymentPartner index', idPaymentPartner)
const getData = async (init) => { const getData = async (init) => {
if (props?.idPaymentPartner) {
console.log('props?.idPaymentPartner', props?.idPaymentPartner)
props.showLoading() props.showLoading()
let res
if (init) { const res = await listTransReconciliation({
setPageIndex(0)
res = await listTransReconciliation({
page_no: 0,
page_size: pageSize,
date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null,
product_code: null,
payment_gate_code: null,
statusReconciliation: 0,
type_payment: null,
})
} else {
res = await listTransReconciliation({
page_no: pageIndex + 1,
page_size: pageSize,
date_from: startDate ? convertDate(startDate) : null, date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null, date_to: endDate ? convertDate(endDate) : null,
product_code: null, statusReconciliation: 1,
payment_gate_code: null, payment_gate_code: props?.idPaymentPartner,
statusReconciliation: 0, order_code: searchDebount,
type_payment: null, type_payment: type || type,
}) })
}
console.log('res.data', res.data)
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(' res.data.data', res.data.data) console.log('idPaymentPartner', res.data.data)
const newList = res.data.data?.data?.map((e, i) => { const newList = res.data.data?.data?.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize } return { ...e, index: i + 1 + pageIndex * pageSize }
}) })
...@@ -86,52 +67,17 @@ const ToolNotificate = (props) => { ...@@ -86,52 +67,17 @@ const ToolNotificate = (props) => {
}) })
} }
} }
}
useEffect(() => { useEffect(() => {
getData(false) console.log('props?.open', props?.open)
}, [pageIndex]) console.log('props?.open', props?.idPaymentPartner)
if (props?.open) {
useEffect(() => { console.log('run')
getData(true) getData(true)
}, [searchDebount, startDate, type, merchant, store])
useEffect(() => {
if (merchant) {
getDropdownStore(merchant)
} }
setStore() }, [searchDebount, startDate, type, props])
}, [merchant])
const getDataMerchant = async () => {
const res = await dropdownMerchant({})
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { ...e, name: e.merchant_name }
})
setListMerchant(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const getDropdownStore = async (id) => {
const res = await dropdownStore(id)
if (res.data.code == 200 && res.data.data) {
console.log('res.data.data', res.data.data)
const newList = res.data.data.map((e) => {
return { ...e, name: e.store_name }
})
setListStore(newList)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const onAdd = () => { const onAdd = () => {
console.log('listSelected', listSelected) console.log('listSelected', listSelected)
} }
...@@ -150,12 +96,6 @@ const ToolNotificate = (props) => { ...@@ -150,12 +96,6 @@ const ToolNotificate = (props) => {
type={type} type={type}
setType={setType} setType={setType}
listType={listType} listType={listType}
merchant={merchant}
setMerchant={setMerchant}
listMerchant={listMerchant}
store={store}
setStore={setStore}
listStore={listStore}
customSelect={customSelect} customSelect={customSelect}
handleClose={handleClose} handleClose={handleClose}
listSelected={listSelected} listSelected={listSelected}
......
...@@ -69,7 +69,7 @@ function CustomerView(props) { ...@@ -69,7 +69,7 @@ function CustomerView(props) {
<TextField <TextField
variant="outlined" variant="outlined"
className="w-full" className="w-full"
label="Tìm kiếm" label="Nhập mã giao dịch"
onChange={(e) => { onChange={(e) => {
const text = e.target.value const text = e.target.value
setTxtSearch(text) setTxtSearch(text)
...@@ -113,52 +113,7 @@ function CustomerView(props) { ...@@ -113,52 +113,7 @@ function CustomerView(props) {
</Select> </Select>
</FormControl> </FormControl>
</Grid> </Grid>
<Grid item lg={2} md={2} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Pháp nhân
</InputLabel>
<Select
label="Pháp nhân"
value={merchant}
onChange={(e) => setMerchant(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listMerchant.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={2} md={2} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Cây xăng
</InputLabel>
<Select
label="Cây xăng"
value={store}
onChange={(e) => setStore(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listStore.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={2} md={2} sm={3} xs={3}> <Grid item lg={2} md={2} sm={3} xs={3}>
<DateRange <DateRange
date={startDate} date={startDate}
......
...@@ -38,6 +38,8 @@ const ToolNotificate = (props) => { ...@@ -38,6 +38,8 @@ const ToolNotificate = (props) => {
setEndDate(end) setEndDate(end)
} }
console.log('props?.idReconciliation', props?.idReconciliation)
const getData = async (init) => { const getData = async (init) => {
if (props?.idReconciliation) { if (props?.idReconciliation) {
props.showLoading() props.showLoading()
...@@ -158,6 +160,7 @@ const ToolNotificate = (props) => { ...@@ -158,6 +160,7 @@ const ToolNotificate = (props) => {
setStore={setStore} setStore={setStore}
listStore={listStore} listStore={listStore}
isDetail={props.isDetail} isDetail={props.isDetail}
idPaymentPartner={props?.idPaymentPartner}
/> />
) )
} }
......
...@@ -45,6 +45,7 @@ function CustomerView(props) { ...@@ -45,6 +45,7 @@ function CustomerView(props) {
setStore, setStore,
listStore, listStore,
isDetail, isDetail,
idPaymentPartner,
} = props } = props
const handleChange = (event) => { const handleChange = (event) => {
...@@ -93,7 +94,7 @@ function CustomerView(props) { ...@@ -93,7 +94,7 @@ function CustomerView(props) {
Chọn giao dịch Chọn giao dịch
</Button> */} </Button> */}
<DialogTrans /> <DialogTrans idPaymentPartner={idPaymentPartner} />
</Grid> </Grid>
) : null} ) : null}
......
...@@ -203,7 +203,7 @@ function TableList(props) { ...@@ -203,7 +203,7 @@ function TableList(props) {
history.push({ history.push({
pathname: pathname:
'/reconciliation/sheet/update', '/reconciliation/sheet/update',
state: row.id, state: { ...row },
}) })
}} }}
className={classes.button} className={classes.button}
......
...@@ -57,7 +57,7 @@ const SimpleForm = (props) => { ...@@ -57,7 +57,7 @@ const SimpleForm = (props) => {
const getDataDefault = async () => { const getDataDefault = async () => {
props.showLoading() props.showLoading()
try { try {
const res = await detailSheetReconciliation(location.state, {}) const res = await detailSheetReconciliation(location.state?.id, {})
if (res.data.data) { if (res.data.data) {
setState({ ...res.data.data }) setState({ ...res.data.data })
} }
...@@ -102,6 +102,10 @@ const SimpleForm = (props) => { ...@@ -102,6 +102,10 @@ const SimpleForm = (props) => {
} }
console.log('state', state) console.log('state', state)
const { code, idPaymentPartner, note } = state const { code, idPaymentPartner, note } = state
console.log(
'location.state?.idPaymentPartner',
location.state?.idPaymentPartner
)
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
<div className="mb-sm-30"> <div className="mb-sm-30">
...@@ -211,7 +215,10 @@ const SimpleForm = (props) => { ...@@ -211,7 +215,10 @@ const SimpleForm = (props) => {
> >
<ListTrans <ListTrans
isDetail={false} isDetail={false}
idReconciliation={location.state} idReconciliation={location.state?.id}
idPaymentPartner={
location.state?.idPaymentPartner
}
/> />
</Grid> </Grid>
</Grid> </Grid>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment