Commit 9d88a399 by tdgiang

update build

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