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 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