Commit b5144226 by tdgiang

update code

parent 0ee66d2b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<!-- <link rel="shortcut icon" href="%PUBLIC_URL%/logo.png" /> --> <link rel="shortcut icon" href="%PUBLIC_URL%/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<!-- <!--
......
...@@ -17,6 +17,7 @@ import MerchantRoutes from './views/Merchant/MerchantRoutes' ...@@ -17,6 +17,7 @@ import MerchantRoutes from './views/Merchant/MerchantRoutes'
import GasStationRoutes from './views/GasStation/GasStationRoutes' import GasStationRoutes from './views/GasStation/GasStationRoutes'
import ListRequestRoutes from './views/ListRequest/routes' import ListRequestRoutes from './views/ListRequest/routes'
import SignUp from './views/SignUp/routes' import SignUp from './views/SignUp/routes'
import InvoiceSupplier from './views/InvoiceSupplier/routes'
const redirectRoute = [ const redirectRoute = [
{ {
...@@ -33,6 +34,7 @@ const errorRoute = [ ...@@ -33,6 +34,7 @@ const errorRoute = [
] ]
const routes = [ const routes = [
...InvoiceSupplier,
...SignUp, ...SignUp,
...ListRequestRoutes, ...ListRequestRoutes,
...GasStationRoutes, ...GasStationRoutes,
......
/* eslint-disable handle-callback-err */
import { PostData, GetURL } from '../helpers'
import url from '../url'
export const getListInvoiceSupp = async (body) =>
PostData(url.urlGetListInvoiceSupp, body)
.then((res) => res)
.catch((err) => null)
export const createInvoiceSupp = async (body) =>
PostData(url.urlCreateInvoiceSupp, body)
.then((res) => res)
.catch((err) => null)
export const updateInvoiceSupp = async (body) =>
PostData(url.urlUpdateInvoiceSupp, body)
.then((res) => res)
.catch((err) => null)
export const detailInvoiceSupp = async (id, body) =>
GetURL(`${url.urlDetailInvoiceSupp}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const deleteInvoiceSupp = async (body) =>
PostData(url.urlDeleteInvoiceSupp, body)
.then((res) => res)
.catch((err) => null)
export const changeStatusInvoiceSupp = async (body) =>
PostData(url.changeStatusInvoiceSupp, body)
.then((res) => res)
.catch((err) => null)
...@@ -84,6 +84,14 @@ export default { ...@@ -84,6 +84,14 @@ export default {
deleteGasOnline: `${root}/gasoline/delete`, deleteGasOnline: `${root}/gasoline/delete`,
deleteGasField: `${root}/gasfield/delete`, deleteGasField: `${root}/gasfield/delete`,
//Supplier Invoice
urlGetListInvoiceSupp: `${root}/supplierInvoice/list`,
urlCreateInvoiceSupp: `${root}/supplierInvoice/create`,
urlUpdateInvoiceSupp: `${root}/supplierInvoice/update`,
urlDeleteInvoiceSupp: `${root}/supplierInvoice/delete`,
urlDetailInvoiceSupp: `${root}/supplierInvoice`,
changeStatusInvoiceSupp: `${root}/supplierInvoice/changeStatus`,
//Log //Log
logAuth: `${root}/logging/listLogin`, logAuth: `${root}/logging/listLogin`,
logApi: `${root}/logging/listCallApi`, logApi: `${root}/logging/listCallApi`,
......
...@@ -352,6 +352,7 @@ ...@@ -352,6 +352,7 @@
"ERROR_CODE_IS_EXISTS":"Mã code đã tồn tại", "ERROR_CODE_IS_EXISTS":"Mã code đã tồn tại",
"ERROR_NAME_IS_EXISTS":"Tên sản phẩm đã tồn tại", "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_CODE_IS_EXITS":"Mã code đã tồn tại",
......
...@@ -3,20 +3,43 @@ import { Avatar, Typography, Badge } from '@material-ui/core' ...@@ -3,20 +3,43 @@ import { Avatar, Typography, Badge } from '@material-ui/core'
import PhotoCamera from '@material-ui/icons/PhotoCamera' import PhotoCamera from '@material-ui/icons/PhotoCamera'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { apiUploadFile } from 'app/apis/Functions/Upload.js' import { apiUploadFile } from 'app/apis/Functions/Upload.js'
const supportedExtensions = ['jpeg', 'jpg', 'png']
const validateImg = (string) => {
const path = string.name.split('.')
const extension = `${path[path.length - 1]}`
if (supportedExtensions.includes(extension)) {
return true
// TODO: upload
} else {
// TODO: show "invalid file type" message to user
// reset value
return false
}
}
function UploadButtons(props) { function UploadButtons(props) {
const { image, onFileChange } = props const { image, onFileChange } = props
const upLoadImage = async (event) => { const upLoadImage = async (event) => {
const res = await apiUploadFile( if (validateImg(event.target.files[0])) {
createFormData(event.target.files[0], {}) const res = await apiUploadFile(
) createFormData(event.target.files[0], {})
if (res.data.status == 200 && res.data.data) { )
onFileChange(res.data.data[0].url) if (res.data.status == 200 && res.data.data) {
toast.success('Upload ảnh thành công!', { onFileChange(res.data.data[0].url)
theme: 'colored', toast.success('Upload ảnh thành công!', {
}) theme: 'colored',
})
} else {
toast.success('Upload ảnh thất bại!', {
theme: 'colored',
})
}
} else { } else {
toast.success('Upload ảnh thất bại!', { toast.warn('File không đúng định dạng!', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -7,22 +7,46 @@ import { apiUploadFile } from 'app/apis/Functions/Upload.js' ...@@ -7,22 +7,46 @@ import { apiUploadFile } from 'app/apis/Functions/Upload.js'
import { CKEditor } from '@ckeditor/ckeditor5-react' import { CKEditor } from '@ckeditor/ckeditor5-react'
const supportedExtensions = ['jpeg', 'jpg', 'png']
const validateImg = (string) => {
const path = string.name.split('.')
const extension = `${path[path.length - 1]}`
if (supportedExtensions.includes(extension)) {
return true
// TODO: upload
} else {
// TODO: show "invalid file type" message to user
// reset value
return false
}
}
function UploadButtons(props) { function UploadButtons(props) {
const { images, onFileChange, title } = props const { images, onFileChange, title } = props
const upLoadImage = async (event) => { const upLoadImage = async (event) => {
const res = await apiUploadFile( if (validateImg(event.target.files[0])) {
createFormData(event.target.files[0], {}) const res = await apiUploadFile(
) createFormData(event.target.files[0], {})
console.log('res image', res) )
if (res.data.status == 200 && res.data.data) { console.log('res image', res)
console.log(res.data.data[0].url) if (res.data.status == 200 && res.data.data) {
onFileChange(res.data.data[0].url) console.log(res.data.data[0].url)
toast.success('Upload ảnh thành công!', { onFileChange(res.data.data[0].url)
theme: 'colored', toast.success('Upload ảnh thành công!', {
}) theme: 'colored',
})
} else {
toast.success('Upload ảnh thất bại!', {
theme: 'colored',
})
}
} else { } else {
toast.success('Upload ảnh thất bại!', { toast.warn('File không đúng định dạng!', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -241,6 +241,14 @@ export const navigationsAdmin = [ ...@@ -241,6 +241,14 @@ export const navigationsAdmin = [
}, },
{ {
name: 'NCC hoá đơn',
iconText: 'IV',
path: '/invoice-supplier',
hide: false,
id: 'INVOICE_SUPPLIER',
},
{
name: 'Log login,logout', name: 'Log login,logout',
iconText: 'NO', iconText: 'NO',
path: '/system/log-auth', path: '/system/log-auth',
......
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Icon,
Grid,
Radio,
RadioGroup,
FormControlLabel,
Checkbox,
TextField,
Typography,
MenuItem,
Select,
InputLabel,
} from '@material-ui/core'
import { Breadcrumb, SimpleCard } from 'app/components'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { toast } from 'react-toastify'
import { trimObject, toPriceVndInput } from 'app/config/Function'
import { connect } from 'react-redux'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { createInvoiceSupp } from 'app/apis/Functions/supplierInvoice'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const history = useHistory()
const { t } = useTranslation()
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await createInvoiceSupp({
...newValue,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/invoice-supplier')
if (res.data.code == 200) {
toast.success('Tạo đơn vị cung cấp hoá đơn thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
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({
...state,
[event.target.name]: event.target.value,
})
}
const handleDateChange = (date) => {
setState({ ...state, date })
}
const {
supplier_name,
supplier_code,
address,
email,
phone,
representative,
} = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'NCC hoá đơn',
path: '/invoice-supplier',
},
{ name: 'Thêm mới NCC hoá đơn' },
]}
/>
</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="Tên đơn vị hoá đơn*"
onChange={handleChange}
type="text"
name="supplier_name"
value={supplier_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="Mã đơn vị *"
onChange={handleChange}
type="text"
name="supplier_code"
value={supplier_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="Địa chỉ *"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
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="Người đại diện *"
onChange={handleChange}
type="text"
name="representative"
value={representative || ''}
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="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="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>
<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 {
getListInvoiceSupp,
changeStatusInvoiceSupp,
deleteInvoiceSupp,
} from 'app/apis/Functions/supplierInvoice'
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 { useTranslation } from 'react-i18next'
import { dropdownProductType } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('')
const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1)
const searchDebount = useDebounce(txtSearch, 1000)
const [status, setStatus] = useState()
const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0)
const [type, setType] = useState()
const [listType, setListType] = useState([])
const history = useHistory()
const { t } = useTranslation()
const [data, setData] = useState([])
const [permissions, setPermissions] = useState([])
useEffect(() => {}, [])
const handeChangeActive = async (id, status_id) => {
props.showLoading()
const res = await changeStatusInvoiceSupp({ 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(t(res.data.error), {
theme: 'colored',
})
}
}
const getData = async (init) => {
props.showLoading()
let res
if (init) {
setPageIndex(0)
res = await getListInvoiceSupp({
supplier_code: searchDebount,
page_no: 0,
page_size: pageSize,
status,
type_id: type,
})
} else {
res = await getListInvoiceSupp({
supplier_code: searchDebount,
page_no: pageIndex + 1,
page_size: pageSize,
status,
type_id: type,
})
}
props.hideLoading()
console.log(res.data)
if (res.data.code == 200 && res.data.data) {
console.log(res.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 {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
useEffect(() => {
getData(false)
}, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, status, type])
const removeItem = async (id) => {
props.showLoading()
const res = await deleteInvoiceSupp({ id })
props.hideLoading()
if (res.data.code == 200) {
getData()
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(t(res.data.error), {
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}
permissions={permissions}
status={status}
setStatus={setStatus}
listType={listType}
type={type}
setType={setType}
/>
)
}
const mapStateToProps = (state) => {
return {}
}
export default connect(mapStateToProps, { showLoading, hideLoading })(
ToolNotificate
)
import React, { useState } from 'react'
import {
Paper,
Table,
TableBody,
TableCell,
TableHead,
TableContainer,
TablePagination,
TableRow,
IconButton,
MenuItem,
Select,
Modal,
Fade,
Grid,
Backdrop,
Link,
Button,
Tooltip,
Icon,
} 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 DialogTransition from 'app/components/dialog/DialogTransition'
import { useHistory } from 'react-router-dom'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
const columns = [
{
id: 'index',
label: 'STT',
align: 'center',
minWidth: 50,
},
{
id: 'supplier_name',
label: 'Tên NCC hoá đơn',
align: 'left',
minWidth: 'auto',
},
{
id: 'supplier_code',
label: 'Mã đơn vị',
align: 'left',
minWidth: 'auto',
},
{
id: 'address',
label: 'Địa chỉ',
align: 'left',
minWidth: 'auto',
},
{
id: 'email',
label: 'Email',
align: 'left',
minWidth: 'auto',
},
{
id: 'phone',
label: 'Người đại diện',
align: 'left',
minWidth: 'auto',
},
{
id: 'phone',
label: 'Số điện thoại',
align: 'left',
minWidth: 'auto',
},
]
function TableList(props) {
const {
data,
handeChangeActive,
removeItem,
changeActive,
setChangeActive,
setPageIndex,
setPageSize,
pageIndex,
totalRecords,
permissions,
} = props
const classes = useStyles()
let history = useHistory()
const [selected, setSelected] = useState({
name: '',
id: '',
title: '',
content: '',
})
const [open, setOpen] = React.useState(false)
const handleChangePage = (event, newPage) => {
setPageIndex(newPage)
}
const handleChangeRowsPerPage = (event) => {
setPageSize(event.target.value)
}
const handleClose = () => {
setOpen(false)
}
const { user } = useAuth()
return (
<Paper className={classes.root}>
<TableContainer className={classes.container}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{columns.map((column) => (
<TableCell
key={column.id}
align={'center'}
style={{
width: column.minWidth,
backgroundColor: colors.headerTable,
}}
>
{column.label}
</TableCell>
))}
{checkRole(user, '/product/changeStatus') && (
<TableCell
style={{
backgroundColor: colors.headerTable,
width: 125,
}}
>
Trạng thái
</TableCell>
)}
<TableCell
style={{
textAlign: 'center',
backgroundColor: colors.headerTable,
width: 120,
}}
>
Hành động
</TableCell>
</TableRow>
</TableHead>
<TableBody className={classes.columnTable}>
{data.map((row) => {
return (
<TableRow
hover
role="checkbox"
tabIndex={-1}
key={row.id}
>
{columns.map((column) => {
const imageUrl = row[column.id]
return (
<TableCell
key={column.id}
align={column.align}
>
{column.format ? (
<img
src={column.format(
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell>
)
})}
{checkRole(
user,
'/invoice-supplier/changeStatus'
) && (
<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,
'/invoice-supplier/delete'
) ? (
<Tooltip title="Xoá">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Xóa NCC hoá đơn',
content: `Bạn có muốn xóa NCC hoá đơn ${row.supplier_name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
) : null}
{checkRole(
user,
'/invoice-supplier/update'
) ? (
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
history.push({
pathname:
'/invoice-supplier/update',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
) : null}
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
</TableContainer>
<DialogTransition
data={selected}
open={open}
handleClose={handleClose}
onAgree={() => {
removeItem(selected.id)
handleClose()
}}
/>
<TablePagination
component="div"
page={pageIndex}
count={totalRecords}
rowsPerPage={10}
rowsPerPageOptions={[]}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Paper>
)
}
export default TableList
import React, { useState, useEffect } from 'react'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import { Button, Grid, MenuItem } from '@material-ui/core'
import {
detailInvoiceSupp,
updateInvoiceSupp,
} from 'app/apis/Functions/supplierInvoice'
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, toPriceVndInput } from 'app/config/Function'
import { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const [listDrop, setListDrop] = useState([])
const history = useHistory()
const { t } = useTranslation()
const location = useLocation()
useEffect(() => {
getData()
}, [])
const getData = async () => {
props.showLoading()
const res = await detailInvoiceSupp(location.state, {})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(res.data.data)
setState(res.data.data)
} else if (res.data.code == 401) {
localStorageService.removeToken()
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
props.showLoading()
const res = await updateInvoiceSupp({
...newValue,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/invoice-supplier')
if (res.data.code == 200) {
toast.success('Cập nhật đơn vị cung cấp hoá đơn thành công!', {
theme: 'colored',
})
}
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
}
}
const handleChange = (event) => {
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({
...state,
[event.target.name]: event.target.value,
})
}
const {
supplier_name,
supplier_code,
address,
email,
phone,
representative,
} = state
return (
<div className="m-sm-30">
<div className="mb-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'NCC hoá đơn',
path: '/invoice-supplier',
},
{ name: 'Cập nhật NCC hoá đơn' },
]}
/>
</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="Tên đơn vị hoá đơn*"
onChange={handleChange}
type="text"
name="supplier_name"
value={supplier_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="Mã đơn vị *"
onChange={handleChange}
type="text"
name="supplier_code"
value={supplier_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="Địa chỉ *"
onChange={handleChange}
type="text"
name="address"
value={address || ''}
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="Người đại diện *"
onChange={handleChange}
type="text"
name="representative"
value={representative || ''}
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="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="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>
<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">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,
permissions,
status,
setStatus,
listType,
type,
setType,
} = props
const { user } = useAuth()
const handleChange = (event) => {
setAge(event.target.value)
}
return (
<Fragment>
<div className="m-sm-30">
<div className="mb-sm-30">
<Breadcrumb
routeSegments={[
{
name: 'NCC hoá đơn',
path: '/invoice-supplier',
},
]}
/>
</div>
<Grid
style={{
padding: 10,
marginBottom: 20,
}}
justify={'space-between'}
alignItems={'center'}
container
spacing={3}
>
<Grid
container
spacing={3}
item
lg={8}
md={8}
sm={8}
xs={8}
>
<Grid item lg={4} md={4} sm={4} xs={4}>
<TextField
variant="outlined"
className="w-full"
label="Tìm kiếm"
onChange={(e) => {
const text = e.target.value
setTimeout(() => {
setTxtSearch(text)
}, 1000)
}}
/>
</Grid>
<Grid item lg={4} md={4} sm={4} xs={4}>
<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, '/invoice-supplier/create') ? (
<Link to="/invoice-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}
permissions={permissions}
/>
</div>
</Fragment>
)
}
export default CustomerView
import React from 'react'
const routes = [
{
path: '/invoice-supplier/update',
component: React.lazy(() => import('./Update')),
},
{
path: '/invoice-supplier/create',
component: React.lazy(() => import('./Create')),
},
{
path: '/invoice-supplier',
component: React.lazy(() => import('./Index')),
},
]
export default routes
...@@ -31,7 +31,7 @@ const columns = [ ...@@ -31,7 +31,7 @@ const columns = [
id: 'store_name', id: 'store_name',
label: 'Cây xăng', label: 'Cây xăng',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 160,
}, },
// { // {
// id: 'application', // id: 'application',
...@@ -43,13 +43,13 @@ const columns = [ ...@@ -43,13 +43,13 @@ const columns = [
id: 'order_code', id: 'order_code',
label: 'Mã hoá đơn', label: 'Mã hoá đơn',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 160,
}, },
{ {
id: 'created_date', id: 'created_date',
label: 'Ngày giao dịch', label: 'Ngày giao dịch',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 110,
}, },
// { // {
...@@ -62,25 +62,25 @@ const columns = [ ...@@ -62,25 +62,25 @@ const columns = [
id: 'product_name', id: 'product_name',
label: 'Sản phẩm', label: 'Sản phẩm',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 120,
}, },
{ {
id: 'unit_price', id: 'unit_price',
label: 'Đơn giá', label: 'Đơn giá',
align: 'left', align: 'left',
minWidth: 100, minWidth: 80,
}, },
{ {
id: 'quantity', id: 'quantity',
label: 'Lượng nhiên liệu', label: 'Lượng nhiên liệu',
align: 'left', align: 'left',
minWidth: 100, minWidth: 80,
}, },
{ {
id: 'price', id: 'price',
label: 'Thành tiền', label: 'Thành tiền',
align: 'left', align: 'left',
minWidth: 100, minWidth: 80,
}, },
{ {
id: 'type_payment', id: 'type_payment',
......
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