Commit 8e228715 by tdgiang

update code

parent 9b214793
......@@ -6,3 +6,33 @@ export const listTransReconciliation = async (body) =>
PostData(url.listTransReconciliation, body)
.then((res) => res)
.catch((err) => null)
export const listSheetReconciliation = async (body) =>
PostData(url.listSheetReconciliation, body)
.then((res) => res)
.catch((err) => null)
export const listProviderSetting = async (body) =>
PostData(url.listProviderSetting, body)
.then((res) => res)
.catch((err) => null)
export const detailProviderSetting = async (id, body) =>
GetURL(`${url.detailProviderSetting}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const updateProviderSetting = async (body) =>
PostData(url.updateProviderSetting, body)
.then((res) => res)
.catch((err) => null)
export const detailSheetReconciliation = async (id, body) =>
GetURL(`${url.detailSheetReconciliation}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const updateSheetReconciliation = async (body) =>
PostData(url.updateSheetReconciliation, body)
.then((res) => res)
.catch((err) => null)
......@@ -120,6 +120,12 @@ export default {
//reconciliation
listTransReconciliation: `${root}/paymentpartner/list/trans`,
listSheetReconciliation: `${root}/reconciliation/list`,
detailSheetReconciliation: `${root}/reconciliation`,
updateSheetReconciliation: `${root}/reconciliation/update`,
listProviderSetting: `${root}/provider/paging/setting`,
detailProviderSetting: `${root}/reconciliation/setting`,
updateProviderSetting: `${root}/reconciliation/setting/create`,
//Log
logAuth: `${root}/logging/listLogin`,
......
export const listHour = [
{
name: '00:00',
value: '00:00',
},
{
name: '01:00',
value: '01:00',
},
{
name: '02:00',
value: '02:00',
},
{
name: '03:00',
value: '03:00',
},
{
name: '04:00',
value: '04:00',
},
{
name: '05:00',
value: '05:00',
},
{
name: '06:00',
value: '06:00',
},
{
name: '07:00',
value: '07:00',
},
{
name: '08:00',
value: '08:00',
},
{
name: '09:00',
value: '09:00',
},
{
name: '10:00',
value: '10:00',
},
{
name: '11:00',
value: '11:00',
},
{
name: '12:00',
value: '12:00',
},
{
name: '13:00',
value: '13:00',
},
{
name: '14:00',
value: '14:00',
},
{
name: '15:00',
value: '15:00',
},
{
name: '16:00',
value: '16:00',
},
{
name: '17:00',
value: '17:00',
},
{
name: '18:00',
value: '18:00',
},
{
name: '19:00',
value: '19:00',
},
{
name: '20:00',
value: '20:00',
},
{
name: '21:00',
value: '21:00',
},
{
name: '22:00',
value: '22:00',
},
{
name: '23:00',
value: '23:00',
},
]
export const listWeek = [
{
name: 'Thứ 2',
value: 1,
},
{
name: 'Thứ 3',
value: 2,
},
{
name: 'Thứ 4',
value: 3,
},
{
name: 'Thứ 5',
value: 4,
},
{
name: 'Thứ 6',
value: 5,
},
{
name: 'Thứ 7',
value: 6,
},
{
name: 'Chủ nhật',
value: 7,
},
]
export const listMonth = [
{
name: 'Ngày 1',
value: 1,
},
{
name: 'Ngày 2',
value: 2,
},
{
name: 'Ngày 3',
value: 3,
},
{
name: 'Ngày 4',
value: 4,
},
{
name: 'Ngày 5',
value: 5,
},
{
name: 'Ngày 6',
value: 6,
},
{
name: 'Ngày 7',
value: 7,
},
{
name: 'Ngày 8',
value: 8,
},
{
name: 'Ngày 9',
value: 9,
},
{
name: 'Ngày 10',
value: 10,
},
{
name: 'Ngày 11',
value: 11,
},
{
name: 'Ngày 12',
value: 12,
},
{
name: 'Ngày 13',
value: 13,
},
{
name: 'Ngày 14',
value: 14,
},
{
name: 'Ngày 15',
value: 15,
},
{
name: 'Ngày 16',
value: 16,
},
{
name: 'Ngày 17',
value: 17,
},
{
name: 'Ngày 18',
value: 18,
},
{
name: 'Ngày 19',
value: 19,
},
{
name: 'Ngày 20',
value: 20,
},
{
name: 'Ngày 21',
value: 21,
},
{
name: 'Ngày 22',
value: 22,
},
{
name: 'Ngày 23',
value: 23,
},
{
name: 'Ngày 24',
value: 24,
},
{
name: 'Ngày 25',
value: 25,
},
{
name: 'Ngày 26',
value: 26,
},
{
name: 'Ngày 27',
value: 27,
},
{
name: 'Ngày 28',
value: 28,
},
{
name: 'Ngày 29',
value: 29,
},
{
name: 'Ngày 30',
value: 30,
},
{
name: 'Ngày 31',
value: 31,
},
]
......@@ -354,7 +354,6 @@
"ERROR_NAME_IS_EXISTS":"Tên sản phẩm đã tồn tại",
"ERROR_MERCHAN_STORE_CODE_EXIST":"Mã cây xăng đã tồn tại",
"ERROR_CODE_IS_EXITS":"Mã code đã tồn tại",
"ERROR_NAME_IS_EXITS":"Tên sản phẩm đã tồn tại",
"ERROR_MERCHAN_STORE_CODE":"Mã cây xăng đã tồn tại",
......@@ -364,8 +363,12 @@
"ERROR_NAME_PACKAGE_IS_EXITS":"Tên gói đã tồn tại",
"ERROR_NAME_FUNCTION_IS_EXITS":"Tên chức năng đã tồn tại",
"ERROR_USER_GROUP_EXISTS_DATA":"Nhóm quyền đã có dữ liệu",
"ERROR_DATE_INVALID":"Thời gian không hợp lệ",
"ERROR_DATE_INVALID":"Thời gian không hợp lệ"
"ERROR_NOT_PAYMENTGATE": "chưa truyền code đối tác thanh toán",
"ERROR_FORMAT_HOUR": "Sai định dang giờ",
"ERROR_FORMAT_DAYOFWEEK": "Sai định dang ngày trong tuần",
"ERROR_FORMAT_DATEOFMONTH": "Sai định dang ngày trong tháng"
}
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListSupplier,
deleteSupplier,
changeStatusSupplier,
} from 'app/apis/Functions/supplier'
import { listProviderSetting } from 'app/apis/Functions/reconciliation'
import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key'
import { connect } from 'react-redux'
......@@ -32,19 +28,19 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([])
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusSupplier({ id, status_id })
props.hideLoading()
if (res.data.code == 200) {
getData()
toast.success('Thay đổi trạng thái thành công!', {
theme: 'colored',
})
} else {
toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored',
})
}
// props.showLoading()
// const res = await changeStatusSupplier({ id, status_id })
// props.hideLoading()
// if (res.data.code == 200) {
// getData()
// toast.success('Thay đổi trạng thái thành công!', {
// theme: 'colored',
// })
// } else {
// toast.error('Thay đổi trạng thái thất bại!', {
// theme: 'colored',
// })
// }
}
console.log('user', user)
......@@ -53,20 +49,20 @@ const ToolNotificate = (props) => {
let res
if (isInit) {
setPageIndex(0)
res = await getListSupplier({
res = await listProviderSetting({
provider_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
type: 3,
// type: 3,
})
} else {
res = await getListSupplier({
res = await listProviderSetting({
provider_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
type: 3,
// type: 3,
})
}
......@@ -95,24 +91,24 @@ const ToolNotificate = (props) => {
}, [searchDebount, status, store, group])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteSupplier({ id })
props.hideLoading()
if (res.data.code == 200) {
getData(true)
toast.success('Xoá bản ghi thành công!', {
theme: 'colored',
})
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Xoá bản ghi thất bại!', {
theme: 'colored',
})
}
// props.showLoading()
// const res = await deleteSupplier({ id })
// props.hideLoading()
// if (res.data.code == 200) {
// getData(true)
// toast.success('Xoá bản ghi thành công!', {
// theme: 'colored',
// })
// } else if (res.data.code == 401) {
// localStorage.removeItem(KEY.API_TOKEN)
// setTimeout(() => {
// history.push('/')
// }, 100)
// } else {
// toast.error('Xoá bản ghi thất bại!', {
// theme: 'colored',
// })
// }
}
return (
......
......@@ -39,38 +39,31 @@ const columns = [
},
{
id: 'provider_code',
label: 'Mã nhà cung cấp',
label: 'Đối tác',
align: 'center',
minWidth: 150,
},
{
id: 'provider_name',
label: 'Tên nhà cung cấp',
id: 'type_comission',
label: 'Loại hoa hồng',
align: 'left',
minWidth: 200,
},
{
id: 'phone',
label: 'Số điện thoại',
id: 'type_Name',
label: 'ĐVT',
align: 'left',
minWidth: 'auto',
minWidth: 100,
},
{
id: 'email',
label: 'Email',
id: 'reconciliation_cycle_name',
label: 'Chu ký đối soát',
align: 'left',
minWidth: 'auto',
minWidth: 150,
},
{
id: 'address',
label: 'Địa chỉ',
align: 'left',
minWidth: 'auto',
minWidth: 250,
},
]
function TableList(props) {
......@@ -126,21 +119,11 @@ function TableList(props) {
{column.label}
</TableCell>
))}
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 145,
}}
>
Trạng thái
</TableCell>
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 120,
width: 60,
}}
>
Hành động
......@@ -178,53 +161,10 @@ function TableList(props) {
</TableCell>
)
})}
<TableCell className={classes.border}>
<Select
variant={'outlined'}
labelId="demo-simple-select-placeholder-label-label"
id="demo-simple-select-placeholder-label"
onChange={(e) =>
handeChangeActive(
row.id,
e.target.value
)
}
displayEmpty
defaultValue={row.status}
className={classes.formControl}
>
<MenuItem value={1}>
Hot động
</MenuItem>
<MenuItem value={2}>Khóa</MenuItem>
</Select>
</TableCell>
<TableCell>
{checkRole(user, '/ncc/delete') ? (
<Tooltip title="Xoá">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Xóa NCC thiết bị',
content: `Bạn có muốn xóa NCC thiết bị ${row.provider_name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
) : null}
{checkRole(
user,
'/reconciliation/setting/update'
'/reconciliation/setting'
) ? (
<Tooltip title="Cập nhật">
<IconButton
......@@ -232,7 +172,7 @@ function TableList(props) {
history.push({
pathname:
'/reconciliation/setting/update',
state: row.id,
state: row.provider_code,
})
}}
className={classes.button}
......
......@@ -79,11 +79,12 @@ function CustomerView(props) {
sm={8}
xs={8}
>
<Grid item lg={3} md={3} sm={3} xs={3}>
<Grid item lg={4} md={4} sm={6} xs={6}>
<TextField
variant="outlined"
className="w-full"
label="Nhập từ khoá"
fullWidth
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
......@@ -92,41 +93,6 @@ function CustomerView(props) {
}}
/>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Trng thái
</InputLabel>
<Select
label="Trạng thái"
value={status}
onChange={(e) => setStatus(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{[
{
id: 1,
name: 'Hoạt động',
},
{
id: 2,
name: 'Khoá',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid>
{/* {checkRole(user, '/reconciliation/setting/create') ? (
<Link to="/reconciliation/setting/create">
......
import React, { useState, useEffect } from 'react'
import LogAuth from './View'
import { listTransaction } from 'app/apis/Functions/transaction'
import { listSheetReconciliation } from 'app/apis/Functions/reconciliation'
import { useHistory } from 'react-router-dom'
import { toPriceVnd, convertDate } from 'app/config/Function'
import { connect } from 'react-redux'
......@@ -8,7 +8,7 @@ import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next'
import { dropdownMerchant, dropdownStore } from 'app/apis/Functions/dropdown'
import { dropdownMerchant, dropdownProvider } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
......@@ -22,15 +22,13 @@ const ToolNotificate = (props) => {
const [endDate, setEndDate] = useState()
const { t } = useTranslation()
const [data, setData] = useState([])
const [type, setType] = useState()
const [listType, setListType] = useState([])
const [merchant, setMerchant] = useState()
const [listMerchant, setListMerchant] = useState([])
const [store, setStore] = useState()
const [listStore, setListStore] = useState([])
const [status, setStatus] = useState()
const [listProvide, setListProvide] = useState([])
const [provide, setProvide] = useState()
useEffect(() => {
getDataMerchant()
getDataDropdown()
}, [])
const changeDateRange = (start, end) => {
......@@ -43,32 +41,24 @@ const ToolNotificate = (props) => {
let res
if (init) {
setPageIndex(0)
res = await listTransaction({
res = await listSheetReconciliation({
order_code: searchDebount,
applications,
page_no: 0,
page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null,
type_code: type,
merchant_id: merchant,
store_id: store,
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
date_from: startDate ? convertDate(startDate) : null,
date_to: endDate ? convertDate(endDate) : null,
status: status ? status : 0,
idPaymentPartner: provide ? provide : null,
})
} else {
res = await listTransaction({
res = await listSheetReconciliation({
order_code: searchDebount,
applications,
page_no: pageIndex + 1,
page_size: pageSize,
from_date: startDate ? convertDate(startDate) : null,
to_date: endDate ? convertDate(endDate) : null,
type_code: type,
merchant_id: merchant,
store_id: store,
// gasoline_id: '57dd1a73-d847-4d73-9791-08dc0841e7a9',
status: status ? status : 0,
idPaymentPartner: provide ? provide : null,
})
}
......@@ -96,43 +86,15 @@ const ToolNotificate = (props) => {
useEffect(() => {
getData(true)
}, [searchDebount, startDate, type, merchant, store])
useEffect(() => {
if (merchant) {
getDropdownStore(merchant)
}
setStore()
}, [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)
}, [searchDebount, startDate, status, provide])
const getDataDropdown = async () => {
const res = await dropdownProvider({})
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',
return { ...e, id: e.code }
})
setListProvide(newList)
}
}
......@@ -147,15 +109,11 @@ const ToolNotificate = (props) => {
applications={applications}
startDate={startDate}
changeDateRange={changeDateRange}
type={type}
setType={setType}
listType={listType}
merchant={merchant}
setMerchant={setMerchant}
listMerchant={listMerchant}
store={store}
setStore={setStore}
listStore={listStore}
listProvide={listProvide}
provide={provide}
setProvide={setProvide}
status={status}
setStatus={setStatus}
/>
)
}
......
......@@ -39,49 +39,55 @@ const ToolNotificate = (props) => {
}
const getData = async (init) => {
props.showLoading()
let res
if (init) {
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_to: endDate ? convertDate(endDate) : null,
product_code: null,
payment_gate_code: null,
statusReconciliation: 0,
type_payment: null,
})
}
if (props?.idReconciliation) {
props.showLoading()
let res
if (init) {
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,
idReconciliation: props?.idReconciliation,
is_reconciliation: true,
})
} else {
res = await listTransReconciliation({
page_no: pageIndex + 1,
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,
idReconciliation: props?.idReconciliation,
is_reconciliation: true,
})
}
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(' res.data.data', res.data.data)
const newList = res.data.data?.data?.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(' res.data.data', res.data.data)
const newList = res.data.data?.data?.map((e, i) => {
return { ...e, index: i + 1 + pageIndex * pageSize }
})
setData(newList)
setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
}
......
......@@ -12,13 +12,17 @@ import {
MenuItem,
Tooltip,
Icon,
Typography,
} from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete'
import colors from 'app/assets/Color'
import useStyles from 'app/styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components'
import { toPriceVnd } from 'app/config/Function'
import { checkRole } from 'app/config/Function'
import useAuth from 'app/hooks/useAuth'
import { useHistory } from 'react-router-dom'
const columns = [
{
id: 'index',
......@@ -26,73 +30,44 @@ const columns = [
align: 'center',
minWidth: 80,
},
{
id: 'store_name',
label: 'Cây xăng',
id: 'code',
label: 'Mã phiếu đối soát',
align: 'left',
minWidth: 160,
},
// {
// id: 'application',
// label: 'Mã NV',
// align: 'left',
// minWidth: 140,
// },
{
id: 'order_code',
label: 'Mã hoá đơn',
id: 'idPaymentPartner',
label: 'Đối tác',
align: 'left',
minWidth: 160,
},
{
id: 'created_date',
label: 'Ngày giao dịch',
align: 'left',
minWidth: 110,
minWidth: 80,
},
// {
// id: 'IP',
// label: 'Loại nhiên liệu',
// align: 'left',
// minWidth: 140,
// },
{
id: 'product_name',
label: 'Sản phẩm',
id: 'create_date',
label: 'Ngày tạo phiếu',
align: 'left',
minWidth: 120,
minWidth: 110,
},
{
id: 'unit_price',
label: 'Đơn giá',
id: 'update_date',
label: 'Ngày cập nhật',
align: 'left',
minWidth: 80,
minWidth: 110,
},
{
id: 'quantity',
label: 'Lượng nhiên liệu',
id: 'date_reconciliation',
label: 'Ngày đối soát',
align: 'left',
minWidth: 80,
minWidth: 110,
},
{
id: 'price',
label: 'Thành tiền',
id: 'totalCommission',
label: 'Hoa hồng',
align: 'left',
minWidth: 80,
},
{
id: 'type_payment',
label: 'Phương thức thanh toán',
align: 'left',
minWidth: 100,
},
{
id: 'status_text',
label: 'Trạng thái',
align: 'left',
minWidth: 100,
isMonney: true,
},
]
......@@ -109,14 +84,26 @@ function TableList(props) {
pageIndex,
totalRecords,
} = props
let history = useHistory()
const handleChangePage = (event, newPage) => {
setPageIndex(newPage)
}
const handleChangeRowsPerPage = (event) => {
setPageSize(event.target.value)
}
const renderStatusBg = (status) => {
if (status == 3) return '#ECFDF3'
if (status == 2) return '#FFDC98'
return '#F2F4F7'
}
const renderStatusColor = (status) => {
if (status == 3) return '#027A48'
if (status == 2) return '#F1AA1F'
return '#344054'
}
const { user } = useAuth()
return (
<Paper className={classes.root}>
<TableContainer className={classes.container}>
......@@ -135,6 +122,23 @@ function TableList(props) {
{column.label}
</TableCell>
))}
<TableCell
style={{
width: 110,
backgroundColor: colors.headerTable,
}}
>
Trng thái
</TableCell>
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 60,
}}
>
Hành động
</TableCell>
</TableRow>
</TableHead>
<TableBody className={classes.columnTable}>
......@@ -147,28 +151,71 @@ function TableList(props) {
key={row.id}
>
{columns.map((column) => {
const avatar = row[column.id]
const data = row[column.id]
return (
<TableCell
key={column.id}
align={column.align}
style={{
textAlign:
column.id === 'index'
? 'center'
: typeof data ==
'string'
? 'left'
: 'right',
}}
>
{column.format ? (
<img
src={column.format(
avatar
)}
className={
classes.image
}
/>
) : (
avatar
)}
{column.isMonney
? toPriceVnd(data)
: data}
</TableCell>
)
})}
<TableCell
style={{
textAlign: 'center',
}}
>
<Typography
style={{
padding: 5,
backgroundColor: renderStatusBg(
row?.status
),
color: renderStatusColor(
row?.status
),
borderRadius: 10,
}}
>
{row?.status_name}
</Typography>
</TableCell>
<TableCell>
{checkRole(
user,
'/reconciliation/sheet'
) ? (
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
history.push({
pathname:
'/reconciliation/sheet/update',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
) : null}
</TableCell>
</TableRow>
)
})}
......
......@@ -14,7 +14,7 @@ import {
TextField,
Icon,
} from '@material-ui/core'
import { createFunction } from 'app/apis/Functions/function'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
......@@ -28,27 +28,51 @@ import {
dropdownStore,
} from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage'
import { createSupplier } from 'app/apis/Functions/supplier'
import {
detailSheetReconciliation,
updateSheetReconciliation,
} from 'app/apis/Functions/reconciliation'
import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
import ListTrans from './ListTrans/Index'
const SimpleForm = (props) => {
const location = useLocation()
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const [listAction, setListAction] = useState([])
useEffect(() => {
getDataDefault()
}, [])
const { user } = useAuth()
const { t } = useTranslation()
const history = useHistory()
const getDataDefault = async () => {
props.showLoading()
try {
const res = await detailSheetReconciliation(location.state, {})
if (res.data.data) {
setState({ ...res.data.data })
}
} catch (err) {
toast.error(t(err), {
theme: 'colored',
})
}
props.hideLoading()
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createSupplier({
const res = await updateSheetReconciliation({
...newValue,
type: '3',
status: 1,
......@@ -76,8 +100,8 @@ const SimpleForm = (props) => {
[event.target.name]: event.target.value,
})
}
const { provider_code, provider_name, phone, email, address } = state
console.log('state', state)
const { code, idPaymentPartner, note } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
......@@ -139,8 +163,8 @@ const SimpleForm = (props) => {
onChange={handleChange}
disabled={true}
type="text"
name="provider_code"
value={provider_code || ''}
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
......@@ -155,8 +179,8 @@ const SimpleForm = (props) => {
disabled={true}
onChange={handleChange}
type="text"
name="provider_code"
value={provider_code || ''}
name="idPaymentPartner"
value={idPaymentPartner || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
......@@ -171,8 +195,8 @@ const SimpleForm = (props) => {
label="Ghi chú"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
name="note"
value={note || ''}
/>
</Grid>
......@@ -185,7 +209,10 @@ const SimpleForm = (props) => {
container
spacing={2}
>
<ListTrans isDetail={false} />
<ListTrans
isDetail={false}
idReconciliation={location.state}
/>
</Grid>
</Grid>
</ValidatorForm>
......
......@@ -33,15 +33,12 @@ function CustomerView(props) {
applications,
startDate,
changeDateRange,
type,
setType,
listType,
listMerchant,
setMerchant,
merchant,
store,
setStore,
listStore,
status,
setStatus,
provide,
setProvide,
listProvide,
} = props
const handleChange = (event) => {
......@@ -71,7 +68,7 @@ function CustomerView(props) {
container
spacing={3}
>
<Grid item lg={3} md={3} sm={3} xs={3}>
<Grid item lg={3} md={3} sm={4} xs={4}>
<TextField
variant="outlined"
className="w-full"
......@@ -86,12 +83,12 @@ function CustomerView(props) {
<Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Phương thc thanh toán
Trng thái
</InputLabel>
<Select
label="Phương thức thanh toán"
value={type}
onChange={(e) => setType(e.target.value)}
label="Trạng thái"
value={status}
onChange={(e) => setStatus(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
......@@ -102,16 +99,25 @@ function CustomerView(props) {
</MenuItem>
{[
{
id: 'QR',
name: 'QR',
name: 'Nháp',
value: 1,
id: 1,
},
{
name: 'Chưa đối soát',
value: 2,
id: 2,
},
{
id: 'CASH',
name: 'Tiền mặt',
name: 'Đang đối soát',
value: 3,
id: 3,
},
{
id: 'DEBT',
name: 'Công nợ',
name: 'Đã đối soát',
value: 4,
id: 4,
},
].map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
......@@ -122,35 +128,12 @@ function CustomerView(props) {
<Grid item lg={3} md={3} 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={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Cây xăng
Đối tác
</InputLabel>
<Select
label="Cây xăng"
value={store}
onChange={(e) => setStore(e.target.value)}
label="Đối tác"
value={provide}
onChange={(e) => setProvide(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
......@@ -159,12 +142,13 @@ function CustomerView(props) {
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{listStore.map((e) => (
{listProvide.map((e) => (
<MenuItem value={e.id}>{e.name}</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item lg={3} md={3} sm={3} xs={3}>
<DateRange
date={startDate}
......
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