Commit 2c5d250a by tdgiang

update build

parent 691ab984
...@@ -21,6 +21,7 @@ import InvoiceSupplier from './views/InvoiceSupplier/routes' ...@@ -21,6 +21,7 @@ import InvoiceSupplier from './views/InvoiceSupplier/routes'
import Package from './views/package/routers' import Package from './views/package/routers'
import NccRouter from './views/Ncc/router' import NccRouter from './views/Ncc/router'
import LandingpageRouter from './views/landingpage/router' import LandingpageRouter from './views/landingpage/router'
import PaymentSupplier from './views/PaymentSupplier/routes'
const redirectRoute = [ const redirectRoute = [
{ {
...@@ -37,6 +38,7 @@ const errorRoute = [ ...@@ -37,6 +38,7 @@ const errorRoute = [
] ]
const routes = [ const routes = [
...PaymentSupplier,
...LandingpageRouter, ...LandingpageRouter,
...NccRouter, ...NccRouter,
// ...Package, // ...Package,
......
...@@ -243,6 +243,35 @@ export const navigationsAdmin = [ ...@@ -243,6 +243,35 @@ export const navigationsAdmin = [
}, },
{ {
name: 'Nhà cung cấp',
icon: 'wb_iridescent',
hide: false,
children: [
{
name: 'NCC thiết bị',
iconText: 'IV',
path: '/ncc',
hide: false,
id: 'INVOICE',
},
{
name: 'NCC hoá đơn',
iconText: 'IV',
path: '/invoice-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
{
name: 'Đối tác thanh toán',
iconText: 'IV',
path: '/payment-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
],
},
{
name: 'Quản lý hệ thống', name: 'Quản lý hệ thống',
icon: 'wb_iridescent', icon: 'wb_iridescent',
hide: false, hide: false,
...@@ -276,21 +305,6 @@ export const navigationsAdmin = [ ...@@ -276,21 +305,6 @@ export const navigationsAdmin = [
hide: false, hide: false,
id: 'GROUP_ROLE', id: 'GROUP_ROLE',
}, },
{
name: 'NCC thiết bị',
iconText: 'IV',
path: '/ncc',
hide: false,
id: 'INVOICE',
},
{
name: 'NCC hoá đơn',
iconText: 'IV',
path: '/invoice-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
{ {
name: 'Log login,logout', name: 'Log login,logout',
......
...@@ -6,45 +6,55 @@ import { ...@@ -6,45 +6,55 @@ import {
} from 'react-material-ui-form-validator' } from 'react-material-ui-form-validator'
import { import {
Button, Button,
Icon,
Grid, Grid,
Radio, MenuItem,
RadioGroup,
FormControlLabel, FormControlLabel,
Checkbox, Checkbox,
TextField,
Typography, Typography,
MenuItem,
Select,
InputLabel,
} from '@material-ui/core' } 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' import { Breadcrumb, SimpleCard } from 'app/components'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
import { Link, useHistory, useLocation } from 'react-router-dom' import { Link, useHistory, useLocation } from 'react-router-dom'
import { toast } from 'react-toastify' import { trimObject, encryString, convertDate } from 'app/config/Function'
import { trimObject, toPriceVndInput } from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { KeyboardDatePicker } from '@material-ui/pickers'
import { createInvoiceSupp } from 'app/apis/Functions/supplierInvoice' import {
dropdownDepartment,
dropdownUserGroup,
dropdownStore,
} from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage'
import { createSupplier } from 'app/apis/Functions/supplier'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([]) const [listDrop, setListDrop] = useState([])
const history = useHistory() const [listAction, setListAction] = useState([])
const { user } = useAuth()
const { t } = useTranslation() const { t } = useTranslation()
const history = useHistory()
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() props.showLoading()
const res = await createInvoiceSupp({ const res = await createSupplier({
...newValue, ...newValue,
type: '1',
status: 1,
}) })
console.log(res)
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/invoice-supplier') history.push('/invoice-supplier')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Tạo đơn vị cung cấp hoá đơn thành công!', { toast.success('Tạo nhà cung cấp hoá đơn thành công!', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -57,33 +67,13 @@ const SimpleForm = (props) => { ...@@ -57,33 +67,13 @@ const SimpleForm = (props) => {
const handleChange = (event) => { const handleChange = (event) => {
event.persist() event.persist()
if (event.target.name === 'price_default') {
if (event.target.value !== null)
setState({
...state,
[event.target.name]: event.target.value.split('.').join(''),
})
} else
setState({ setState({
...state, ...state,
[event.target.name]: event.target.value, [event.target.name]: event.target.value,
}) })
} }
const handleDateChange = (date) => { const { provider_code, provider_name, phone, email, address } = state
setState({ ...state, date })
}
const {
supplier_name,
supplier_code,
address,
email,
phone,
representative,
} = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
<div className="mb-sm-30"> <div className="mb-sm-30">
...@@ -91,10 +81,10 @@ const SimpleForm = (props) => { ...@@ -91,10 +81,10 @@ const SimpleForm = (props) => {
<Breadcrumb <Breadcrumb
routeSegments={[ routeSegments={[
{ {
name: 'NCC hoá đơn', name: 'Danh sách nhà cung cấp hoá đơn',
path: '/invoice-supplier', path: '/invoice-supplier',
}, },
{ name: 'Thêm mới NCC hoá đơn' }, { name: 'Thêm mới' },
]} ]}
/> />
</div> </div>
...@@ -105,11 +95,11 @@ const SimpleForm = (props) => { ...@@ -105,11 +95,11 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Tên đơn vị hoá đơn*" label="Mã nhà cung cấp *"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="supplier_name" name="provider_code"
value={supplier_name || ''} value={provider_code || ''}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
...@@ -120,11 +110,11 @@ const SimpleForm = (props) => { ...@@ -120,11 +110,11 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Mã đơn vị *" label="Tên nhà cung cấp *"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="supplier_code" name="provider_name"
value={supplier_code || ''} value={provider_name || ''}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
...@@ -135,29 +125,22 @@ const SimpleForm = (props) => { ...@@ -135,29 +125,22 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Địa chỉ *" label="Số điện thoại *"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="address" name="phone"
value={address || ''} value={phone || ''}
validators={['required']} validators={[
errorMessages={[ 'required',
'Không được để trống trường này', 'isNumber',
'minStringLength:10',
'maxStringLength:15',
]} ]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Người đại diện *"
onChange={handleChange}
type="text"
name="representative"
value={representative || ''}
validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]} ]}
/> />
</Grid> </Grid>
...@@ -182,23 +165,11 @@ const SimpleForm = (props) => { ...@@ -182,23 +165,11 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Số điện thoại *" label="Địa chỉ"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="phone" name="address"
value={phone || ''} value={address || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
/> />
</Grid> </Grid>
</Grid> </Grid>
...@@ -229,6 +200,7 @@ const SimpleForm = (props) => { ...@@ -229,6 +200,7 @@ const SimpleForm = (props) => {
</div> </div>
) )
} }
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return {} return {}
} }
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import ToolUserView from './View' import ToolUserView from './View'
import { import {
getListInvoiceSupp, getListSupplier,
changeStatusInvoiceSupp, deleteSupplier,
deleteInvoiceSupp, changeStatusSupplier,
} from 'app/apis/Functions/supplierInvoice' } from 'app/apis/Functions/supplier'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key' import KEY from 'app/assets/Key'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction' import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { useTranslation } from 'react-i18next' import useAuth from 'app/hooks/useAuth'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000) const searchDebount = useDebounce(txtSearch, 1000)
const [status, setStatus] = useState()
const [pageIndex, setPageIndex] = useState(0) const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10) const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
const [type, setType] = useState() const [status, setStatus] = useState()
const [listType, setListType] = useState([]) const [listDrop, setListDrop] = useState([])
const [store, setStore] = useState()
const history = useHistory() const history = useHistory()
const { t } = useTranslation() const [listGroup, setListGroup] = useState([])
const [data, setData] = useState([]) const [group, setGroup] = useState()
const [permissions, setPermissions] = useState([]) const { user } = useAuth()
useEffect(() => {}, []) const [data, setData] = useState([])
const handeChangeActive = async (id, status_id) => { const handeChangeActive = async (id, status_id) => {
props.showLoading() props.showLoading()
const res = await changeStatusInvoiceSupp({ id, status_id }) const res = await changeStatusSupplier({ id, status_id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData()
...@@ -42,41 +41,39 @@ const ToolNotificate = (props) => { ...@@ -42,41 +41,39 @@ const ToolNotificate = (props) => {
theme: 'colored', theme: 'colored',
}) })
} else { } else {
toast.error(t(res.data.error), { toast.error('Thay đổi trạng thái thất bại!', {
theme: 'colored', theme: 'colored',
}) })
} }
} }
const getData = async (init) => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
let res let res
if (init) { if (isInit) {
setPageIndex(0) setPageIndex(0)
res = await getListInvoiceSupp({ res = await getListSupplier({
supplier_code: searchDebount, provider_name: searchDebount,
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
status, status,
type_id: type, type: 1,
}) })
} else { } else {
res = await getListInvoiceSupp({ res = await getListSupplier({
supplier_code: searchDebount, provider_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
status, status,
type_id: type, type: 1,
}) })
} }
props.hideLoading() props.hideLoading()
console.log(res.data)
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(res.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 }
}) })
setData(newList) setData(newList)
setTotalRecord(res.data.data.total_elements) setTotalRecord(res.data.data.total_elements)
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
...@@ -85,26 +82,23 @@ const ToolNotificate = (props) => { ...@@ -85,26 +82,23 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error(t(res.data.error), { // enqueueSnackbar('Error!', { variant: 'error' })
theme: 'colored',
})
} }
} }
useEffect(() => { useEffect(() => {
getData(false) getData(false)
}, [pageIndex]) }, [pageIndex])
useEffect(() => { useEffect(() => {
getData(true) getData(true)
}, [searchDebount, status, type]) }, [searchDebount, status, store, group])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
const res = await deleteInvoiceSupp({ id }) const res = await deleteSupplier({ id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData(true)
toast.success('Xoá bản ghi thành công!', { toast.success('Xoá bản ghi thành công!', {
theme: 'colored', theme: 'colored',
}) })
...@@ -114,7 +108,7 @@ const ToolNotificate = (props) => { ...@@ -114,7 +108,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error(t(res.data.error), { toast.error('Xoá bản ghi thất bại!', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -133,12 +127,14 @@ const ToolNotificate = (props) => { ...@@ -133,12 +127,14 @@ const ToolNotificate = (props) => {
activeSelected={activeSelected} activeSelected={activeSelected}
handeChangeActive={handeChangeActive} handeChangeActive={handeChangeActive}
totalRecords={totalRecords} totalRecords={totalRecords}
permissions={permissions}
status={status} status={status}
setStatus={setStatus} setStatus={setStatus}
listType={listType} listDrop={listDrop}
type={type} store={store}
setType={setType} setStore={setStore}
listGroup={listGroup}
group={group}
setGroup={setGroup}
/> />
) )
} }
......
...@@ -29,6 +29,7 @@ import DialogTransition from 'app/components/dialog/DialogTransition' ...@@ -29,6 +29,7 @@ import DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth' import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function' import { checkRole } from 'app/config/Function'
const columns = [ const columns = [
{ {
id: 'index', id: 'index',
...@@ -36,42 +37,39 @@ const columns = [ ...@@ -36,42 +37,39 @@ const columns = [
align: 'center', align: 'center',
minWidth: 50, minWidth: 50,
}, },
{ {
id: 'supplier_name', id: 'provider_code',
label: 'Tên NCC hoá đơn', label: 'Mã nhà cung cấp',
align: 'left', align: 'center',
minWidth: 'auto', minWidth: 150,
}, },
{ {
id: 'supplier_code', id: 'provider_name',
label: 'Mã đơn vị', label: 'Tên nhà cung cấp',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 200,
}, },
{ {
id: 'address', id: 'phone',
label: 'Địa chỉ', label: 'Số điện thoại',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
minWidth: 100,
}, },
{ {
id: 'email', id: 'email',
label: 'Email', label: 'Email',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
minWidth: 150,
}, },
{ {
id: 'representative', id: 'address',
label: 'Người đại diện', label: 'Địa chỉ',
align: 'left',
minWidth: 'auto',
},
{
id: 'phone',
label: 'Số điện thoại',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
minWidth: 250,
}, },
] ]
...@@ -107,6 +105,7 @@ function TableList(props) { ...@@ -107,6 +105,7 @@ function TableList(props) {
const handleClose = () => { const handleClose = () => {
setOpen(false) setOpen(false)
} }
const { user } = useAuth() const { user } = useAuth()
return ( return (
...@@ -127,16 +126,15 @@ function TableList(props) { ...@@ -127,16 +126,15 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/product/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 125, width: 145,
}} }}
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)}
<TableCell <TableCell
style={{ style={{
...@@ -180,10 +178,7 @@ function TableList(props) { ...@@ -180,10 +178,7 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{checkRole(
user,
'/invoice-supplier/changeStatus'
) && (
<TableCell className={classes.border}> <TableCell className={classes.border}>
<Select <Select
variant={'outlined'} variant={'outlined'}
...@@ -202,12 +197,9 @@ function TableList(props) { ...@@ -202,12 +197,9 @@ function TableList(props) {
<MenuItem value={1}> <MenuItem value={1}>
Hot động Hot động
</MenuItem> </MenuItem>
<MenuItem value={2}> <MenuItem value={2}>Khóa</MenuItem>
Khóa
</MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
...@@ -219,7 +211,7 @@ function TableList(props) { ...@@ -219,7 +211,7 @@ function TableList(props) {
setSelected({ setSelected({
...row, ...row,
title: 'Xóa NCC hoá đơn', title: 'Xóa NCC hoá đơn',
content: `Bạn có muốn xóa NCC hoá đơn ${row.supplier_name} hay không?`, content: `Bạn có muốn xóa NCC hoá đơn ${row.provider_name} hay không?`,
}) })
setOpen(true) setOpen(true)
}} }}
...@@ -232,6 +224,7 @@ function TableList(props) { ...@@ -232,6 +224,7 @@ function TableList(props) {
</IconButton> </IconButton>
</Tooltip> </Tooltip>
) : null} ) : null}
{checkRole( {checkRole(
user, user,
'/invoice-supplier/update' '/invoice-supplier/update'
......
...@@ -31,17 +31,21 @@ function CustomerView(props) { ...@@ -31,17 +31,21 @@ function CustomerView(props) {
setPageIndex, setPageIndex,
pageIndex, pageIndex,
totalRecords, totalRecords,
permissions,
status, status,
setStatus, setStatus,
listType, store,
type, setStore,
setType, listDrop,
listGroup,
group,
setGroup,
} = props } = props
const { user } = useAuth()
const handleChange = (event) => { const handleChange = (event) => {
setAge(event.target.value) setAge(event.target.value)
} }
const { user } = useAuth()
return ( return (
<Fragment> <Fragment>
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -49,7 +53,7 @@ function CustomerView(props) { ...@@ -49,7 +53,7 @@ function CustomerView(props) {
<Breadcrumb <Breadcrumb
routeSegments={[ routeSegments={[
{ {
name: 'NCC hoá đơn', name: 'Danh sách nhà cung cấp hoá đơn',
path: '/invoice-supplier', path: '/invoice-supplier',
}, },
]} ]}
...@@ -67,19 +71,19 @@ function CustomerView(props) { ...@@ -67,19 +71,19 @@ function CustomerView(props) {
spacing={3} spacing={3}
> >
<Grid <Grid
container
spacing={3} spacing={3}
container
item item
lg={8} lg={8}
md={8} md={8}
sm={8} sm={8}
xs={8} xs={8}
> >
<Grid item lg={4} md={4} sm={4} xs={4}> <Grid item lg={3} md={3} sm={3} xs={3}>
<TextField <TextField
variant="outlined" variant="outlined"
className="w-full" className="w-full"
label="Tìm kiếm" label="Nhập từ khoá"
onChange={(e) => { onChange={(e) => {
const text = e.target.value const text = e.target.value
setTimeout(() => { setTimeout(() => {
...@@ -89,7 +93,7 @@ function CustomerView(props) { ...@@ -89,7 +93,7 @@ function CustomerView(props) {
/> />
</Grid> </Grid>
<Grid item lg={4} md={4} sm={4} xs={4}> <Grid item lg={3} md={3} sm={3} xs={3}>
<FormControl variant="outlined" fullWidth> <FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple"> <InputLabel htmlFor="outlined-age-native-simple">
Trng thái Trng thái
...@@ -124,7 +128,6 @@ function CustomerView(props) { ...@@ -124,7 +128,6 @@ function CustomerView(props) {
</FormControl> </FormControl>
</Grid> </Grid>
</Grid> </Grid>
{checkRole(user, '/invoice-supplier/create') ? ( {checkRole(user, '/invoice-supplier/create') ? (
<Link to="/invoice-supplier/create"> <Link to="/invoice-supplier/create">
<Button <Button
...@@ -147,7 +150,6 @@ function CustomerView(props) { ...@@ -147,7 +150,6 @@ function CustomerView(props) {
pageIndex={pageIndex} pageIndex={pageIndex}
setPageIndex={setPageIndex} setPageIndex={setPageIndex}
totalRecords={totalRecords} totalRecords={totalRecords}
permissions={permissions}
/> />
</div> </div>
</Fragment> </Fragment>
......
...@@ -46,15 +46,15 @@ const SimpleForm = (props) => { ...@@ -46,15 +46,15 @@ const SimpleForm = (props) => {
props.showLoading() props.showLoading()
const res = await createSupplier({ const res = await createSupplier({
...newValue, ...newValue,
type: parseInt(newValue?.type), type: '3',
status: 1, status: 1,
}) })
console.log(res)
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/ncc') history.push('/ncc')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Tạo nhân viên thành công!', { toast.success('Tạo nhà cung cấp thiết bị thành công!', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -73,7 +73,7 @@ const SimpleForm = (props) => { ...@@ -73,7 +73,7 @@ const SimpleForm = (props) => {
}) })
} }
const { provider_code, provider_name, phone, email, address, type } = state const { provider_code, provider_name, phone, email, address } = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
<div className="mb-sm-30"> <div className="mb-sm-30">
...@@ -91,45 +91,6 @@ const SimpleForm = (props) => { ...@@ -91,45 +91,6 @@ const SimpleForm = (props) => {
<SimpleCard> <SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}> <ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}> <Grid container spacing={3}>
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Loại nhà cung cấp *'}
className="mb-4 w-full"
value={type || ''}
displayEmpty
name="type"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{[
{
id: '0',
name: 'Cổng thanh toán',
},
{
id: '1',
name: 'Hoá đơn',
},
{
id: '2',
name: 'Nhiên liệu',
},
{
id: '3',
name: 'Thiết bị',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}> <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
......
...@@ -54,17 +54,19 @@ const ToolNotificate = (props) => { ...@@ -54,17 +54,19 @@ const ToolNotificate = (props) => {
if (isInit) { if (isInit) {
setPageIndex(0) setPageIndex(0)
res = await getListSupplier({ res = await getListSupplier({
supp_name: searchDebount, provider_name: searchDebount,
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
status, status,
type: 3,
}) })
} else { } else {
res = await getListSupplier({ res = await getListSupplier({
supp_name: searchDebount, provider_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
status, status,
type: 3,
}) })
} }
......
...@@ -207,7 +207,7 @@ function TableList(props) { ...@@ -207,7 +207,7 @@ function TableList(props) {
onClick={() => { onClick={() => {
setSelected({ setSelected({
...row, ...row,
title: 'Xóa NCC', 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?`, content: `Bạn có muốn xóa NCC thiết bị ${row.provider_name} hay không?`,
}) })
setOpen(true) setOpen(true)
......
...@@ -45,7 +45,7 @@ const SimpleForm = (props) => { ...@@ -45,7 +45,7 @@ const SimpleForm = (props) => {
props.showLoading() props.showLoading()
try { try {
const res = await detailSupplier(location.state, {}) const res = await detailSupplier(location.state, {})
setState({ ...res.data.data, type: `${res.data.data.type}` }) setState({ ...res.data.data })
} catch (err) { } catch (err) {
toast.error(t(err), { toast.error(t(err), {
theme: 'colored', theme: 'colored',
...@@ -60,14 +60,12 @@ const SimpleForm = (props) => { ...@@ -60,14 +60,12 @@ const SimpleForm = (props) => {
props.showLoading() props.showLoading()
const res = await updateSupplier({ const res = await updateSupplier({
...newValue, ...newValue,
type: parseInt(newValue?.type),
}) })
console.log(res)
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/ncc') history.push('/ncc')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Cập nhật nhân viên thành công!', { toast.success('Cập nhật nhà cung cấp thiết bị thành công!', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -86,7 +84,7 @@ const SimpleForm = (props) => { ...@@ -86,7 +84,7 @@ const SimpleForm = (props) => {
}) })
} }
const { provider_code, provider_name, phone, email, address, type } = state const { provider_code, provider_name, phone, email, address } = state
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
<div className="mb-sm-30"> <div className="mb-sm-30">
...@@ -104,45 +102,6 @@ const SimpleForm = (props) => { ...@@ -104,45 +102,6 @@ const SimpleForm = (props) => {
<SimpleCard> <SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}> <ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}> <Grid container spacing={3}>
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Loại nhà cung cấp *'}
className="mb-4 w-full"
value={type || ''}
displayEmpty
name="type"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{[
{
id: '0',
name: 'Cổng thanh toán',
},
{
id: '1',
name: 'Hoá đơn',
},
{
id: '2',
name: 'Nhiên liệu',
},
{
id: '3',
name: 'Thiết bị',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}> <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator <TextValidator
variant="outlined" variant="outlined"
......
...@@ -52,7 +52,10 @@ function CustomerView(props) { ...@@ -52,7 +52,10 @@ function CustomerView(props) {
<div className="mb-sm-30"> <div className="mb-sm-30">
<Breadcrumb <Breadcrumb
routeSegments={[ routeSegments={[
{ name: 'Danh sách nhà cung cấp', path: '/ncc' }, {
name: 'Danh sách nhà cung cấp thiết bị',
path: '/ncc',
},
]} ]}
/> />
</div> </div>
......
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Grid,
MenuItem,
FormControlLabel,
Checkbox,
Typography,
} 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'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject, encryString, convertDate } from 'app/config/Function'
import { connect } from 'react-redux'
import { KeyboardDatePicker } from '@material-ui/pickers'
import {
dropdownDepartment,
dropdownUserGroup,
dropdownStore,
} from 'app/apis/Functions/dropdown'
import PickerImage from 'app/components/Input/PickerImage'
import { createSupplier } from 'app/apis/Functions/supplier'
import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const [listAction, setListAction] = useState([])
const { user } = useAuth()
const { t } = useTranslation()
const history = useHistory()
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createSupplier({
...newValue,
type: 0,
status: 1,
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/payment-supplier')
if (res.data.code == 200) {
toast.success('Tạo nhà đối tác thanh toán thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Đối tác thanh toán',
path: '/payment-supplier',
},
{ name: 'Thêm mới' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã đối tác *"
onChange={handleChange}
type="text"
name="provider_code"
value={provider_code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đối tác *"
onChange={handleChange}
type="text"
name="provider_name"
value={provider_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Số điện thoại *"
onChange={handleChange}
type="text"
name="phone"
value={phone || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Email *"
onChange={handleChange}
type="text"
name="email"
value={email || ''}
validators={['required', 'isEmail']}
errorMessages={[
'Không được để trống trường này',
'Email không hợp lệ',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Địa chỉ"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
/>
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Link to="/invoice-supplier">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Thêm mi</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { useState, useEffect } from 'react'
import ToolUserView from './View'
import {
getListSupplier,
deleteSupplier,
changeStatusSupplier,
} from 'app/apis/Functions/supplier'
import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce'
import useAuth from 'app/hooks/useAuth'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000)
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const [status, setStatus] = useState()
const [listDrop, setListDrop] = useState([])
const [store, setStore] = useState()
const history = useHistory()
const [listGroup, setListGroup] = useState([])
const [group, setGroup] = useState()
const { user } = useAuth()
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',
})
}
}
const getData = async (isInit) => {
props.showLoading()
let res
if (isInit) {
setPageIndex(0)
res = await getListSupplier({
provider_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
type: 0,
})
} else {
res = await getListSupplier({
provider_name: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
type: 0,
})
}
props.hideLoading()
if (res.data.code == 200 && 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) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else {
// enqueueSnackbar('Error!', { variant: 'error' })
}
}
useEffect(() => {
getData(false)
}, [pageIndex])
useEffect(() => {
getData(true)
}, [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',
})
}
}
return (
<ToolUserView
data={data}
removeItem={removeItem}
setTxtSearch={setTxtSearch}
setActiveSeleted={setActiveSeleted}
pageIndex={pageIndex}
changeActive={changeActive}
setChangeActive={setChangeActive}
setPageIndex={setPageIndex}
activeSelected={activeSelected}
handeChangeActive={handeChangeActive}
totalRecords={totalRecords}
status={status}
setStatus={setStatus}
listDrop={listDrop}
store={store}
setStore={setStore}
listGroup={listGroup}
group={group}
setGroup={setGroup}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Grid,
MenuItem,
FormControlLabel,
Checkbox,
Typography,
} from '@material-ui/core'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom'
import {
trimObject,
encryString,
convertDate,
convertTimeApi,
} from 'app/config/Function'
import { connect } from 'react-redux'
import { detailSupplier, updateSupplier } from 'app/apis/Functions/supplier'
import { useTranslation } from 'react-i18next'
import useAuth from 'app/hooks/useAuth'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const location = useLocation()
const [image, setImage] = useState()
const { user } = useAuth()
const [date, setDate] = useState(null)
const { t } = useTranslation()
useEffect(() => {
getDataDefault()
}, [])
const history = useHistory()
const getDataDefault = async () => {
props.showLoading()
try {
const res = await detailSupplier(location.state, {})
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 updateSupplier({
...newValue,
})
console.log(res)
props.hideLoading()
if (res.data.code == 200) {
history.push('/payment-supplier')
if (res.data.code == 200) {
toast.success('Cập nhật đối tác thanh toán thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const { provider_code, provider_name, phone, email, address } = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Đối tác thanh toán',
path: '/payment-supplier',
},
{ name: 'Cập nhật' },
]}
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<Grid container spacing={3}>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã đối tác *"
onChange={handleChange}
type="text"
name="provider_code"
disabled={true}
value={provider_code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Tên đối tác *"
onChange={handleChange}
type="text"
name="provider_name"
value={provider_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Số điện thoại *"
onChange={handleChange}
type="text"
name="phone"
value={phone || ''}
validators={[
'required',
'isNumber',
'minStringLength:10',
'maxStringLength:15',
]}
errorMessages={[
'Không được để trống trường này',
'Trường này phải nhập số ',
'Số điện thoại phải có ít nhất 10 chữ số',
'Số điện thoại nhiều nhất chỉ có 15 chữ số',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Email *"
onChange={handleChange}
type="text"
name="email"
value={email || ''}
validators={['required', 'isEmail']}
errorMessages={[
'Không được để trống trường này',
'Email không hợp lệ',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Địa chỉ"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
/>
</Grid>
</Grid>
<Grid
style={{ marginTop: 20 }}
container
justify={'flex-end'}
>
<Link to="/invoice-supplier">
<Button
style={{
marginRight: 20,
}}
color="inherit"
variant="contained"
onClick={() => {}}
>
<span className="capitalize">Quay li</span>
</Button>
</Link>
<Button
color="primary"
variant="contained"
type="submit"
>
<span className="capitalize">Cp nht</span>
</Button>
</Grid>
</ValidatorForm>
</SimpleCard>
</div>
</div>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
SimpleForm
)
import React, { Fragment, useState, useEffect } from 'react'
import {
TextField,
Icon,
Button,
StepLabel,
Step,
Stepper,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
const [age, setAge] = React.useState('')
const {
data,
updateItem,
removeItem,
setTxtSearch,
changeActive,
setChangeActive,
handeChangeActive,
setPageIndex,
pageIndex,
totalRecords,
status,
setStatus,
store,
setStore,
listDrop,
listGroup,
group,
setGroup,
} = props
const handleChange = (event) => {
setAge(event.target.value)
}
const { user } = useAuth()
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'Đối tác thanh toán',
path: '/payment-supplier',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid
spacing={3}
container
item
lg={8}
md={8}
sm={8}
xs={8}
>
<Grid item lg={3} md={3} sm={3} xs={3}>
<TextField
variant="outlined"
className="w-full"
label="Nhập từ khoá"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</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, '/payment-supplier/create') ? (
<Link to="/payment-supplier/create">
<Button
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>Thêm mi</span>
</Button>
</Link>
) : null}
</Grid>
<Table
data={data}
changeActive={changeActive}
setChangeActive={setChangeActive}
handeChangeActive={handeChangeActive}
updateItem={updateItem}
removeItem={removeItem}
pageIndex={pageIndex}
setPageIndex={setPageIndex}
totalRecords={totalRecords}
/>
</div>
</Fragment>
)
}
export default CustomerView
import React from 'react'
const routes = [
{
path: '/payment-supplier/update',
component: React.lazy(() => import('./Update')),
},
{
path: '/payment-supplier/create',
component: React.lazy(() => import('./Create')),
},
{
path: '/payment-supplier',
component: React.lazy(() => import('./Index')),
},
]
export default routes
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