Commit 9d88a399 by tdgiang

update build

parent beaf9b04
...@@ -75,8 +75,8 @@ export const dropdownTypeCaculator = async (body) => ...@@ -75,8 +75,8 @@ export const dropdownTypeCaculator = async (body) =>
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const dropdownEquipment = async (body) => export const dropdownTypeEquipment = async (body) =>
GetData(url.dropdownEquipment, body) GetData(url.dropdownTypeEquipment, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
......
...@@ -88,3 +88,18 @@ export const changeStatusPackage = async (body) => ...@@ -88,3 +88,18 @@ export const changeStatusPackage = async (body) =>
PostData(url.changeStatusPackage, body) PostData(url.changeStatusPackage, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const getListtPaymentCost = async (body) =>
PostData(url.urlGetListPaymentCost, body)
.then((res) => res)
.catch((err) => null)
export const detailPaymentCost = async (id, body) =>
GetURL(`${url.urlDetailPaymentCost}/${id}`, body)
.then((res) => res)
.catch((err) => null)
export const acceptPaymentCost = async (id, body) =>
PostData(`${url.acceptPaymentCost}/${id}`, body)
.then((res) => res)
.catch((err) => null)
...@@ -124,6 +124,10 @@ export default { ...@@ -124,6 +124,10 @@ export default {
urlDetailPackage: `${root}/package`, urlDetailPackage: `${root}/package`,
changeStatusPackage: `${root}/package/changeStatus`, changeStatusPackage: `${root}/package/changeStatus`,
urlGetListPaymentCost: `${root}/paymentcosts/paging`,
urlDetailPaymentCost: `${root}/paymentcosts`,
acceptPaymentCost: `${root}/paymentcosts/paymentConfirm`,
urlGetListPackageFunction: `${root}/functionpk/paging`, urlGetListPackageFunction: `${root}/functionpk/paging`,
urlCreatePackageFunction: `${root}/functionpk/create`, urlCreatePackageFunction: `${root}/functionpk/create`,
urlUpdatePackageFunction: `${root}/functionpk/update`, urlUpdatePackageFunction: `${root}/functionpk/update`,
...@@ -152,7 +156,7 @@ export default { ...@@ -152,7 +156,7 @@ export default {
dropdownProcutByType: `${root}/dropdown/productListByType`, dropdownProcutByType: `${root}/dropdown/productListByType`,
dropdownListSupplier: `${root}/dropdown/listSupplier`, dropdownListSupplier: `${root}/dropdown/listSupplier`,
dropdownTypeCaculator: `${root}/dropdown/getlisttypecaculator`, dropdownTypeCaculator: `${root}/dropdown/getlisttypecaculator`,
dropdownEquipment: `${root}/dropdown/getlisttypeatc`, dropdownTypeEquipment: `${root}/dropdown/getlisttypeatc`,
dropdownNcc: `${root}/dropdown/getlistsuppliercontruct`, dropdownNcc: `${root}/dropdown/getlistsuppliercontruct`,
dropdownFuncitonPackge: `${root}/dropdown/getlistfunctionpk`, dropdownFuncitonPackge: `${root}/dropdown/getlistfunctionpk`,
} }
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react' ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator' import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid, FormControlLabel, Checkbox } from '@material-ui/core' import { Button, Grid, FormControlLabel, Checkbox } from '@material-ui/core'
import { createPackageFunction } from 'app/apis/Functions/landingpage' import { createPackage } from 'app/apis/Functions/landingpage'
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 { Breadcrumb, SimpleCard } from 'app/components' import { Breadcrumb, SimpleCard } from 'app/components'
...@@ -15,21 +15,38 @@ import { ...@@ -15,21 +15,38 @@ import {
isNumeric, isNumeric,
toPriceVnd, toPriceVnd,
} from 'app/config/Function' } from 'app/config/Function'
import { dropdownFuncitonPackge } from 'app/apis/Functions/dropdown'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [outstanding, setOutstanding] = useState(false) const [listFunc, setListFunc] = useState([])
const [listChecked, setListChecked] = useState([])
const { t } = useTranslation() const { t } = useTranslation()
const history = useHistory() const history = useHistory()
useEffect(() => {
getDataDropdown()
}, [])
const getDataDropdown = async () => {
const res = await dropdownFuncitonPackge({})
if (res.data.code == 200 && res.data.data) {
setListFunc(res.data.data)
}
}
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() props.showLoading()
const res = await createPackageFunction({ const res = await createPackage({
...newValue, ...newValue,
status: 1, status: 1,
outstand: 1,
func_id_add: listChecked,
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/package-function') history.push('/package')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Tạo chức năng gói thành công!', { toast.success('Tạo chức năng gói thành công!', {
theme: 'colored', theme: 'colored',
...@@ -61,8 +78,20 @@ const SimpleForm = (props) => { ...@@ -61,8 +78,20 @@ const SimpleForm = (props) => {
const handleDateChange = (date) => { const handleDateChange = (date) => {
setState({ ...state, date }) setState({ ...state, date })
} }
const onPicker = (value) => {
if (value.target.checked) {
const newList = listChecked.concat(value.target.name)
setListChecked(newList)
} else {
const newList = listChecked.filter((e) => {
return e != value.target.name
})
setListChecked(newList)
}
}
const { pack_name, price } = state
const { description, func_name, price } = state console.log('listChecked', listChecked)
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -88,8 +117,8 @@ const SimpleForm = (props) => { ...@@ -88,8 +117,8 @@ const SimpleForm = (props) => {
label="Tên gói*" label="Tên gói*"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="func_name" name="pack_name"
value={func_name || ''} value={pack_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',
...@@ -104,33 +133,32 @@ const SimpleForm = (props) => { ...@@ -104,33 +133,32 @@ const SimpleForm = (props) => {
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="price" name="price"
value={toPriceVndInput(price) || ''} value={toPriceVnd(price) || ''}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
]} ]}
/> />
</Grid> </Grid>
<Grid lg={12} md={12} sm={12} xs={12} item> <Grid row container item xs={12} sm={12}>
<FormControlLabel {listFunc.map((e) => (
className="min-w-288" <Grid item xs={4}>
control={ <FormControlLabel
<Checkbox label={e.func_name}
size="small" control={
color="primary" <Checkbox
onChange={(event) => { size="small"
console.log( color="primary"
event.target.checked onChange={onPicker}
) name={e.id}
setOutstanding( checked={listChecked.includes(
event.target.checked e.id
) )}
}} />
value={outstanding} }
/> />
} </Grid>
label="Nổi bật" ))}
/>
</Grid> </Grid>
</Grid> </Grid>
<Grid container justify={'flex-end'}> <Grid container justify={'flex-end'}>
......
...@@ -130,7 +130,7 @@ function TableList(props) { ...@@ -130,7 +130,7 @@ function TableList(props) {
</TableCell> </TableCell>
)} )}
<TableCell {/* <TableCell
align={'center'} align={'center'}
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -138,7 +138,7 @@ function TableList(props) { ...@@ -138,7 +138,7 @@ function TableList(props) {
}} }}
> >
Nổi bật Nổi bật
</TableCell> </TableCell> */}
<TableCell <TableCell
style={{ style={{
...@@ -202,7 +202,7 @@ function TableList(props) { ...@@ -202,7 +202,7 @@ function TableList(props) {
</Select> </Select>
</TableCell> </TableCell>
)} )}
<TableCell className={classes.border}> {/* <TableCell className={classes.border}>
<Switch <Switch
size="medium" size="medium"
checked={ checked={
...@@ -225,29 +225,7 @@ function TableList(props) { ...@@ -225,29 +225,7 @@ function TableList(props) {
'primary checkbox', 'primary checkbox',
}} }}
/> />
</TableCell> */}
{/* <Select
variant={'outlined'}
labelId="demo-simple-select-placeholder-label-label"
id="demo-simple-select-placeholder-label"
onChange={(e) =>
handeChangeActiveOutstanding(
row.id,
e.target.value
)
}
displayEmpty
defaultValue={row.outstand}
className={classes.formControl}
>
<MenuItem value={1}>
Nổi bật
</MenuItem>
<MenuItem value={2}>
Thường
</MenuItem>
</Select> */}
</TableCell>
<TableCell> <TableCell>
{checkRole(user, '/package/delete') ? ( {checkRole(user, '/package/delete') ? (
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator' import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid } from '@material-ui/core' import { Button, Grid, Checkbox, FormControlLabel } from '@material-ui/core'
import { import { detailPackage, updatePackage } from 'app/apis/Functions/landingpage'
detailPackageFunction,
updatePackageFunction,
} from 'app/apis/Functions/landingpage'
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 { Breadcrumb, SimpleCard } from 'app/components' import { Breadcrumb, SimpleCard } from 'app/components'
import { Link, useHistory, useLocation } from 'react-router-dom' import { Link, useHistory, useLocation } from 'react-router-dom'
import { trimObject } from 'app/config/Function' import {
trimObject,
toPriceVndInput,
isNumeric,
toPriceVnd,
} from 'app/config/Function'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService' import localStorageService from 'app/services/localStorageService'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { dropdownFuncitonPackge } from 'app/apis/Functions/dropdown'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listFunc, setListFunc] = useState([])
const [listChecked, setListChecked] = useState([])
const history = useHistory() const history = useHistory()
const location = useLocation() const location = useLocation()
const { t } = useTranslation() const { t } = useTranslation()
...@@ -23,13 +29,24 @@ const SimpleForm = (props) => { ...@@ -23,13 +29,24 @@ const SimpleForm = (props) => {
useEffect(() => { useEffect(() => {
getData() getData()
}, []) }, [])
useEffect(() => {
getDataDropdown()
}, [])
const getDataDropdown = async () => {
const res = await dropdownFuncitonPackge({})
if (res.data.code == 200 && res.data.data) {
setListFunc(res.data.data)
}
}
const getData = async () => { const getData = async () => {
props.showLoading() props.showLoading()
const res = await detailPackageFunction(location.state, {}) const res = await detailPackage(location.state, {})
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setState(res.data.data) setState(res.data.data)
const newList = res.data.data?.fuctionPk.map((e) => e?.id)
setListChecked(newList)
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
localStorageService.removeToken() localStorageService.removeToken()
setTimeout(() => { setTimeout(() => {
...@@ -45,12 +62,13 @@ const SimpleForm = (props) => { ...@@ -45,12 +62,13 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
const newValue = trimObject(state) const newValue = trimObject(state)
props.showLoading() props.showLoading()
const res = await updatePackageFunction({ const res = await updatePackage({
...newValue, ...newValue,
func_id_add: listChecked,
}) })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/package-function') history.push('/package')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Cập nhật chức năng thành công!', { toast.success('Cập nhật chức năng thành công!', {
theme: 'colored', theme: 'colored',
...@@ -65,17 +83,37 @@ const SimpleForm = (props) => { ...@@ -65,17 +83,37 @@ const SimpleForm = (props) => {
const handleChange = (event) => { const handleChange = (event) => {
event.persist() event.persist()
setState({ console.log('event.target.name', event.target.name)
...state, if (event.target.name === 'price') {
[event.target.name]: event.target.value, 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) => { const handleDateChange = (date) => {
setState({ ...state, date }) setState({ ...state, date })
} }
const { description, func_name } = state const onPicker = (value) => {
if (value.target.checked) {
const newList = listChecked.concat(value.target.name)
setListChecked(newList)
} else {
const newList = listChecked.filter((e) => {
return e != value.target.name
})
setListChecked(newList)
}
}
const { pack_name, price } = state
console.log('listChecked', listChecked)
return ( return (
<div className="m-sm-30"> <div className="m-sm-30">
...@@ -98,29 +136,52 @@ const SimpleForm = (props) => { ...@@ -98,29 +136,52 @@ const SimpleForm = (props) => {
<TextValidator <TextValidator
variant="outlined" variant="outlined"
className="mb-4 w-full" className="mb-4 w-full"
label="Tên chức năng *" label="Tên gói*"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="func_name" name="pack_name"
value={func_name || ''} value={pack_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',
]} ]}
/> />
</Grid> </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"
className="mb-4 w-full" className="mb-4 w-full"
label="Mô tả " label="Đơn giá *"
onChange={handleChange} onChange={handleChange}
type="text" type="text"
name="description" name="price"
value={description || ''} value={toPriceVnd(price) || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/> />
</Grid> </Grid>
<Grid row container item xs={12} sm={12}>
{listFunc.map((e) => (
<Grid item xs={4}>
<FormControlLabel
label={e.func_name}
control={
<Checkbox
size="small"
color="primary"
onChange={onPicker}
name={e.id}
checked={listChecked.includes(
e.id
)}
/>
}
/>
</Grid>
))}
</Grid>
</Grid> </Grid>
<Grid container justify={'flex-end'}> <Grid container justify={'flex-end'}>
<Button <Button
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
} from 'react-material-ui-form-validator' } from 'react-material-ui-form-validator'
import { Button, Grid, MenuItem } from '@material-ui/core' import { Button, Grid, MenuItem } from '@material-ui/core'
import { createPackageFunction } from 'app/apis/Functions/landingpage' import { createPriceProduct } from 'app/apis/Functions/landingpage'
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 { Breadcrumb, SimpleCard } from 'app/components' import { Breadcrumb, SimpleCard } from 'app/components'
...@@ -19,15 +19,46 @@ import { ...@@ -19,15 +19,46 @@ import {
isNumeric, isNumeric,
toPriceVnd, toPriceVnd,
} from 'app/config/Function' } from 'app/config/Function'
import {
dropdownTypeEquipment,
dropdownTypeCaculator,
dropdownNcc,
} from 'app/apis/Functions/dropdown'
const SimpleForm = (props) => { const SimpleForm = (props) => {
const [state, setState] = useState({}) const [state, setState] = useState({})
const [listTypeEquipment, setListEquipment] = useState([])
const [listTypeCaculator, setListCaculator] = useState([])
const [listNcc, setListNcc] = useState([])
useEffect(() => {
getDataDropdown()
}, [])
const getDataDropdown = async () => {
const resTypeEquipment = await dropdownTypeEquipment({})
if (resTypeEquipment.data.code == 200 && resTypeEquipment.data.data) {
setListEquipment(resTypeEquipment.data.data)
}
const resTypeCaculator = await dropdownTypeCaculator({})
if (resTypeCaculator.data.code == 200 && resTypeCaculator.data.data) {
setListCaculator(resTypeCaculator.data.data)
}
const resNcc = await dropdownNcc({})
if (resNcc.data.code == 200 && resNcc.data.data) {
const newList = resNcc.data.data.map((e) => {
return { ...e, name: e?.supp_name }
})
setListNcc(newList)
}
}
const { t } = useTranslation() const { t } = useTranslation()
const history = useHistory() 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 createPackageFunction({ const res = await createPriceProduct({
...newValue, ...newValue,
status: 1, status: 1,
}) })
...@@ -35,7 +66,7 @@ const SimpleForm = (props) => { ...@@ -35,7 +66,7 @@ const SimpleForm = (props) => {
if (res.data.code == 200) { if (res.data.code == 200) {
history.push('/price-product') history.push('/price-product')
if (res.data.code == 200) { if (res.data.code == 200) {
toast.success('Tạo chức năng gói thành công!', { toast.success('Tạo sản phẩm thành công!', {
theme: 'colored', theme: 'colored',
}) })
} }
...@@ -129,6 +160,7 @@ const SimpleForm = (props) => { ...@@ -129,6 +160,7 @@ const SimpleForm = (props) => {
className="mb-4 w-full" className="mb-4 w-full"
label="Đơn giá *" label="Đơn giá *"
onChange={handleChange} onChange={handleChange}
name="price"
type="text" type="text"
value={toPriceVndInput(price) || ''} value={toPriceVndInput(price) || ''}
validators={['required']} validators={['required']}
...@@ -151,8 +183,8 @@ const SimpleForm = (props) => { ...@@ -151,8 +183,8 @@ const SimpleForm = (props) => {
'Không được để trống trường này', 'Không được để trống trường này',
]} ]}
> >
{[].map((e) => ( {listTypeCaculator.map((e) => (
<MenuItem value={e.id}> <MenuItem value={e.code}>
{e.name} {e.name}
</MenuItem> </MenuItem>
))} ))}
...@@ -163,17 +195,17 @@ const SimpleForm = (props) => { ...@@ -163,17 +195,17 @@ const SimpleForm = (props) => {
variant={'outlined'} variant={'outlined'}
label={'Loại sản phẩm *'} label={'Loại sản phẩm *'}
className="mb-4 w-full" className="mb-4 w-full"
value={type_caculator || ''} value={type || ''}
displayEmpty displayEmpty
name="type_caculator" name="type"
onChange={handleChange} onChange={handleChange}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
]} ]}
> >
{[].map((e) => ( {listTypeEquipment.map((e) => (
<MenuItem value={e.id}> <MenuItem value={e.code}>
{e.name} {e.name}
</MenuItem> </MenuItem>
))} ))}
...@@ -184,16 +216,16 @@ const SimpleForm = (props) => { ...@@ -184,16 +216,16 @@ const SimpleForm = (props) => {
variant={'outlined'} variant={'outlined'}
label={'Nhà cung cấp *'} label={'Nhà cung cấp *'}
className="mb-4 w-full" className="mb-4 w-full"
value={type_caculator || ''} value={suppconstruction_id || ''}
displayEmpty displayEmpty
name="type_caculator" name="suppconstruction_id"
onChange={handleChange} onChange={handleChange}
validators={['required']} validators={['required']}
errorMessages={[ errorMessages={[
'Không được để trống trường này', 'Không được để trống trường này',
]} ]}
> >
{[].map((e) => ( {listNcc.map((e) => (
<MenuItem value={e.id}> <MenuItem value={e.id}>
{e.name} {e.name}
</MenuItem> </MenuItem>
......
...@@ -28,7 +28,7 @@ import { Breadcrumb, SimpleCard } from 'app/components' ...@@ -28,7 +28,7 @@ import { Breadcrumb, SimpleCard } from 'app/components'
import DialogTransition from 'app/components/dialog/DialogTransition' 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, toPriceVnd } from 'app/config/Function'
const columns = [ const columns = [
{ {
...@@ -51,22 +51,23 @@ const columns = [ ...@@ -51,22 +51,23 @@ const columns = [
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'type_caculator', id: 'name_type_caculator',
label: 'Cách tính', label: 'Cách tính',
align: 'center', align: 'center',
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'number_pack', id: 'supplier_name',
label: 'Nhà cung cấp', label: 'Nhà cung cấp',
align: 'center', align: 'center',
minWidth: 'auto', minWidth: 'auto',
}, },
{ {
id: 'price', id: 'price',
label: VT', label: ơn giá',
align: 'center', align: 'center',
minWidth: 'auto', minWidth: 'auto',
isMonney: true,
}, },
{ {
id: 'date_created', id: 'date_created',
...@@ -76,8 +77,8 @@ const columns = [ ...@@ -76,8 +77,8 @@ const columns = [
}, },
{ {
id: 'price', id: 'type_name',
label: 'ĐVT', label: 'Loại sản phẩm',
align: 'center', align: 'center',
minWidth: 'auto', minWidth: 'auto',
}, },
...@@ -166,24 +167,15 @@ function TableList(props) { ...@@ -166,24 +167,15 @@ function TableList(props) {
key={row.id} key={row.id}
> >
{columns.map((column) => { {columns.map((column) => {
const imageUrl = row[column.id] const data = row[column.id]
return ( return (
<TableCell <TableCell
key={column.id} key={column.id}
align={column.align} align={column.align}
> >
{column.format ? ( {column.isMonney
<img ? toPriceVnd(data)
src={column.format( : data}
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell> </TableCell>
) )
})} })}
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import ToolUserView from './View' import ToolUserView from './View'
import { import {
getListPackageFunction, getListtPaymentCost,
deletePackageFunction, acceptPaymentCost,
changeStatusPackageFunction,
} from 'app/apis/Functions/landingpage' } from 'app/apis/Functions/landingpage'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import KEY from '../../../assets/Key' import KEY from '../../../assets/Key'
...@@ -42,21 +41,7 @@ const ToolNotificate = (props) => { ...@@ -42,21 +41,7 @@ const ToolNotificate = (props) => {
// } // }
// }; // };
const handeChangeActive = async (id, status_id) => { const handeChangeActive = async (id, status_id) => {}
props.showLoading()
const res = await changeStatusPackageFunction({ idGuid: 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 (isInit) => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
...@@ -65,14 +50,14 @@ const ToolNotificate = (props) => { ...@@ -65,14 +50,14 @@ const ToolNotificate = (props) => {
if (isInit) { if (isInit) {
setPageIndex(0) setPageIndex(0)
res = await getListPackageFunction({ res = await getListtPaymentCost({
func_name: searchDebount, gas_name: searchDebount,
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
}) })
} else { } else {
res = await getListPackageFunction({ res = await getListtPaymentCost({
func_name: searchDebount, gas_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
...@@ -83,7 +68,12 @@ const ToolNotificate = (props) => { ...@@ -83,7 +68,12 @@ const ToolNotificate = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(res.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,
status_name:
e.status == 1 ? 'Đã thanh toán' : 'Chưa thanh toán',
}
}) })
setData(newList) setData(newList)
...@@ -110,18 +100,13 @@ const ToolNotificate = (props) => { ...@@ -110,18 +100,13 @@ const ToolNotificate = (props) => {
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
const res = await deletePackageFunction({ idGuid: id }) const res = await acceptPaymentCost(id)
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData()
toast.success('Xoá bản ghi thành công!', { toast.success('Xác nhận thanh toán thành công!', {
theme: 'colored', theme: 'colored',
}) })
} else if (res.data.code == 401) {
localStorage.removeItem(KEY.API_TOKEN)
setTimeout(() => {
history.push('/')
}, 100)
} else { } else {
toast.error(t(res.data.error), { toast.error(t(res.data.error), {
theme: 'colored', theme: 'colored',
......
...@@ -28,7 +28,7 @@ import { Breadcrumb, SimpleCard } from 'app/components' ...@@ -28,7 +28,7 @@ import { Breadcrumb, SimpleCard } from 'app/components'
import DialogTransition from 'app/components/dialog/DialogTransition' 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, toPriceVnd } from 'app/config/Function'
const columns = [ const columns = [
{ {
...@@ -39,22 +39,75 @@ const columns = [ ...@@ -39,22 +39,75 @@ const columns = [
}, },
{ {
id: 'func_name', id: 'gas_name',
label: 'Tên chức năng', label: 'Tên',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 200,
}, },
{
id: 'phone',
label: 'SĐT',
align: 'left',
minWidth: 120,
},
{
id: 'address',
label: 'Địa chỉ',
align: 'left',
minWidth: 200,
},
{
id: 'email',
label: 'Email',
align: 'left',
minWidth: 200,
},
{
id: 'suppcontruction_name',
label: 'Đơn vị cung cấp ATC',
align: 'left',
minWidth: 160,
},
{ {
id: 'number_pack', id: 'num_fuel',
label: 'Số lượng gói đang áp dụng', label: 'Số trụ',
align: 'center', align: 'center',
minWidth: 'auto', minWidth: 80,
},
{
id: 'num_gas',
label: 'Số vòi',
align: 'center',
minWidth: 80,
},
{
id: 'package_name',
label: 'Gói đăng ký',
align: 'left',
minWidth: 120,
},
{
id: 'money',
label: 'Tổng tiền ước tính',
align: 'left',
minWidth: 160,
isMonney: true,
},
{
id: 'status_name',
label: 'Trạng thái',
align: 'left',
minWidth: 120,
}, },
{ {
id: 'date_created', id: 'date_created',
label: 'Ngày tạo', label: 'Ngày đăng ký',
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 180,
}, },
] ]
...@@ -109,7 +162,7 @@ function TableList(props) { ...@@ -109,7 +162,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole( {/* {checkRole(
user, user,
'/package-function/changeStatus' '/package-function/changeStatus'
) && ( ) && (
...@@ -121,7 +174,7 @@ function TableList(props) { ...@@ -121,7 +174,7 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)} )} */}
<TableCell <TableCell
style={{ style={{
...@@ -144,29 +197,19 @@ function TableList(props) { ...@@ -144,29 +197,19 @@ function TableList(props) {
key={row.id} key={row.id}
> >
{columns.map((column) => { {columns.map((column) => {
const imageUrl = row[column.id] const data = row[column.id]
return ( return (
<TableCell <TableCell
key={column.id} key={column.id}
align={column.align} align={column.align}
> >
{column.format ? ( {column.isMonney
<img ? toPriceVnd(data)
src={column.format( : data}
imageUrl
)}
className={
classes.image
}
/>
) : (
imageUrl
)}
</TableCell> </TableCell>
) )
})} })}
{/* {checkRole(
{checkRole(
user, user,
'/package-function/changeStatus' '/package-function/changeStatus'
) && ( ) && (
...@@ -193,49 +236,51 @@ function TableList(props) { ...@@ -193,49 +236,51 @@ function TableList(props) {
</MenuItem> </MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)} )} */}
<TableCell> <TableCell>
{checkRole( {checkRole(
user, user,
'/package-function/delete' '/package-register/detail'
) ? ( ) ? (
<Tooltip title="Xoá"> <Tooltip title="Chi tiết">
<IconButton <IconButton
onClick={() => { onClick={() => {
setSelected({ history.push({
...row, pathname:
title: 'Xóa chức năng', '/package-register/detail',
content: `Bạn có muốn xóa chức năng ${row.func_name} hay không?`, state: row.id,
}) })
setOpen(true)
}} }}
className={classes.button} className={classes.button}
aria-label="Delete" aria-label="edit"
> >
<Icon color="error"> <Icon color="primary">
delete visibility
</Icon> </Icon>
</IconButton> </IconButton>
</Tooltip> </Tooltip>
) : null} ) : null}
{checkRole(
user, {row.status != 1 ? (
'/package-function/update' <Tooltip title="Thanh toán">
) ? (
<Tooltip title="Cập nhật">
<IconButton <IconButton
onClick={() => { onClick={() => {
history.push({ setSelected({
pathname: ...row,
'/package-function/update', title: 'Xác nhận thanh toán',
state: row.id, content: `Bạn có muốn xác nhận thanh toán ${row.gas_name} hay không?`,
}) })
setOpen(true)
}} }}
className={classes.button} className={classes.button}
aria-label="edit" aria-label="Delete"
> >
<Icon color="primary"> <Icon
edit style={{
color: '#07BA00',
}}
>
paid
</Icon> </Icon>
</IconButton> </IconButton>
</Tooltip> </Tooltip>
......
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