Commit ba6234e7 by tdgiang

udpate code

parent a26d5168
...@@ -89,3 +89,8 @@ export const dropdownFuncitonPackge = async (body) => ...@@ -89,3 +89,8 @@ export const dropdownFuncitonPackge = async (body) =>
GetData(url.dropdownFuncitonPackge, body) GetData(url.dropdownFuncitonPackge, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const dropdownStoreStatus = async (body) =>
GetData(url.dropdownStoreStatus, body)
.then((res) => res)
.catch((err) => null)
...@@ -70,3 +70,8 @@ export const deleteGasField = async (body) => ...@@ -70,3 +70,8 @@ export const deleteGasField = async (body) =>
PostData(url.deleteGasField, body) PostData(url.deleteGasField, body)
.then((res) => res) .then((res) => res)
.catch((err) => null) .catch((err) => null)
export const changeStatusStore = async (body) =>
PostData(url.changeStatusStore, body)
.then((res) => res)
.catch((err) => null)
//const root = 'http://petrolpay.tasvietnam.vn:9985/api' //const root = 'http://petrolpay.tasvietnam.vn:9985/api'
//const root = 'https://apigw.petropos.vn/api' //const root = 'https://apigw.petropos.vn/api'
//const root = 'http://dcvf.tasvietnam.vn:9986/api' //const root = 'http://dcvf.tasvietnam.vn:9986/api'
const root = 'https://apigw-v2.petropos.vn/api' //const root = 'https://apigw-v2.petropos.vn/api'
const root = 'https://apitest.petropos.vn/api'
//v2 //v2
//const root = 'https://apitest-v2.petropos.vn/api' //const root = 'https://apitest-v2.petropos.vn/api'
...@@ -94,6 +94,8 @@ export default { ...@@ -94,6 +94,8 @@ export default {
deleteGasOnline: `${root}/gasoline/delete`, deleteGasOnline: `${root}/gasoline/delete`,
deleteGasField: `${root}/gasfield/delete`, deleteGasField: `${root}/gasfield/delete`,
changeStatusStore: `${root}/merchantstore/changeStatus`,
//Supplier Invoice //Supplier Invoice
urlGetListInvoiceSupp: `${root}/supplierInvoice/list`, urlGetListInvoiceSupp: `${root}/supplierInvoice/list`,
urlCreateInvoiceSupp: `${root}/supplierInvoice/create`, urlCreateInvoiceSupp: `${root}/supplierInvoice/create`,
...@@ -166,4 +168,5 @@ export default { ...@@ -166,4 +168,5 @@ export default {
dropdownTypeEquipment: `${root}/dropdown/getlisttypeatc`, dropdownTypeEquipment: `${root}/dropdown/getlisttypeatc`,
dropdownNcc: `${root}/dropdown/getlistsuppliercontruct`, dropdownNcc: `${root}/dropdown/getlistsuppliercontruct`,
dropdownFuncitonPackge: `${root}/dropdown/getlistfunctionpk`, dropdownFuncitonPackge: `${root}/dropdown/getlistfunctionpk`,
dropdownStoreStatus: `${root}/dropdown/getlistStoreStatus`,
} }
...@@ -2,6 +2,11 @@ import React from 'react' ...@@ -2,6 +2,11 @@ import React from 'react'
const GasStationRoutes = [ const GasStationRoutes = [
{ {
path: '/gas-station/detail',
component: React.lazy(() => import('./detail')),
},
{
path: '/gas-station/create', path: '/gas-station/create',
component: React.lazy(() => import('./Create')), component: React.lazy(() => import('./Create')),
}, },
......
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
getListGasStation, getListGasStation,
deleteGasStation, deleteGasStation,
changeStatusGasStation, changeStatusGasStation,
changeStatusStore,
} from 'app/apis/Functions/merchant' } from 'app/apis/Functions/merchant'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import KEY from 'app/assets/Key' import KEY from 'app/assets/Key'
...@@ -13,6 +14,7 @@ import { toast } from 'react-toastify' ...@@ -13,6 +14,7 @@ import { toast } from 'react-toastify'
import useDebounce from 'app/hooks/useDebounce' import useDebounce from 'app/hooks/useDebounce'
import { dropdownMerchant } from 'app/apis/Functions/dropdown' import { dropdownMerchant } from 'app/apis/Functions/dropdown'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { dropdownStoreStatus } from 'app/apis/Functions/dropdown'
const ToolNotificate = (props) => { const ToolNotificate = (props) => {
const [txtSearch, setTxtSearch] = useState('') const [txtSearch, setTxtSearch] = useState('')
...@@ -26,13 +28,14 @@ const ToolNotificate = (props) => { ...@@ -26,13 +28,14 @@ const ToolNotificate = (props) => {
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
const [listMerchant, setListMerchant] = useState([]) const [listMerchant, setListMerchant] = useState([])
const [merchant, setMerchant] = useState() const [merchant, setMerchant] = useState()
const [listStatus, setListStatus] = useState([])
const history = useHistory() const history = useHistory()
const [data, setData] = useState([]) const [data, setData] = useState([])
const [permissions, setPermissions] = useState([]) const [permissions, setPermissions] = useState([])
useEffect(() => { useEffect(() => {
getDropDownMerchant() getDropDownMerchant()
getDropdownData()
}, []) }, [])
const handeChangeActive = async (id, status_id) => { const handeChangeActive = async (id, status_id) => {
...@@ -95,6 +98,17 @@ const ToolNotificate = (props) => { ...@@ -95,6 +98,17 @@ const ToolNotificate = (props) => {
} }
} }
const getDropdownData = async () => {
const res = await dropdownStoreStatus()
if (res.data.code == 200 && res.data.data) {
setListStatus(res.data.data)
} else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
const getDropDownMerchant = async () => { const getDropDownMerchant = async () => {
try { try {
const res = await dropdownMerchant() const res = await dropdownMerchant()
...@@ -116,13 +130,26 @@ const ToolNotificate = (props) => { ...@@ -116,13 +130,26 @@ const ToolNotificate = (props) => {
getData(true) getData(true)
}, [searchDebount, merchant, status]) }, [searchDebount, merchant, status])
const removeItem = async (id) => { const removeItem = async (item) => {
props.showLoading() props.showLoading()
const res = await deleteGasStation({ idGuid: id }) let res
if (item.status == 1) {
res = await changeStatusStore({
id: item.id,
status_id: 5,
})
} else {
res = await changeStatusStore({
id: item.id,
status_id: 1,
})
}
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData(true) getData(true)
toast.success('Xoá bản ghi thành công!', { toast.success('Cập nhật trạng thái cây xăng thành công!', {
theme: 'colored', theme: 'colored',
}) })
} else if (res.data.code == 401) { } else if (res.data.code == 401) {
...@@ -156,6 +183,7 @@ const ToolNotificate = (props) => { ...@@ -156,6 +183,7 @@ const ToolNotificate = (props) => {
setMerchant={setMerchant} setMerchant={setMerchant}
status={status} status={status}
setStatus={setStatus} setStatus={setStatus}
listStatus={listStatus}
/> />
) )
} }
......
...@@ -82,6 +82,12 @@ const columns = [ ...@@ -82,6 +82,12 @@ const columns = [
align: 'left', align: 'left',
minWidth: 'auto', minWidth: 'auto',
}, },
{
id: 'status_text',
label: 'Trạng thái',
align: 'left',
minWidth: 'auto',
},
] ]
function TableList(props) { function TableList(props) {
...@@ -135,7 +141,7 @@ function TableList(props) { ...@@ -135,7 +141,7 @@ function TableList(props) {
{column.label} {column.label}
</TableCell> </TableCell>
))} ))}
{checkRole(user, '/gas-station/changeStatus') && ( {/* {checkRole(user, '/gas-station/changeStatus') && (
<TableCell <TableCell
style={{ style={{
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
...@@ -144,13 +150,13 @@ function TableList(props) { ...@@ -144,13 +150,13 @@ function TableList(props) {
> >
Trạng thái Trạng thái
</TableCell> </TableCell>
)} )} */}
<TableCell <TableCell
style={{ style={{
textAlign: 'center', textAlign: 'center',
backgroundColor: colors.headerTable, backgroundColor: colors.headerTable,
width: 120, width: 160,
}} }}
> >
Hành động Hành động
...@@ -188,7 +194,7 @@ function TableList(props) { ...@@ -188,7 +194,7 @@ function TableList(props) {
</TableCell> </TableCell>
) )
})} })}
{/*
{checkRole( {checkRole(
user, user,
'/gas-station/changeStatus' '/gas-station/changeStatus'
...@@ -216,9 +222,9 @@ function TableList(props) { ...@@ -216,9 +222,9 @@ function TableList(props) {
</MenuItem> </MenuItem>
</Select> </Select>
</TableCell> </TableCell>
)} )} */}
<TableCell> <TableCell>
{checkRole( {/* {checkRole(
user, user,
'/gas-station/delete' '/gas-station/delete'
) ? ( ) ? (
...@@ -262,7 +268,70 @@ function TableList(props) { ...@@ -262,7 +268,70 @@ function TableList(props) {
</Icon> </Icon>
</IconButton> </IconButton>
</Tooltip> </Tooltip>
) : null} ) : null} */}
{row.status == 1 && (
<Tooltip title="Ngừng hoạt động">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Ngừng hoạt động cây xăng',
content: `Bạn có muốn ngừng hoạt động cây xăng ${row.store_name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon color="error">
stop_circle
</Icon>
</IconButton>
</Tooltip>
)}
{row.status == 5 && (
<Tooltip title="Hoạt động">
<IconButton
onClick={() => {
setSelected({
...row,
title: 'Cho phép hoạt động cây xăng',
content: `Bạn có muốn cho phép hoạt động cây xăng ${row.store_name} hay không?`,
})
setOpen(true)
}}
className={classes.button}
aria-label="Delete"
>
<Icon
style={{
color: '#00C65B',
}}
>
not_started
</Icon>
</IconButton>
</Tooltip>
)}
<Tooltip title="Chi tiết">
<IconButton
onClick={() => {
history.push({
pathname:
'/gas-station/detail',
state: row.id,
})
}}
className={classes.button}
aria-label="edit"
>
<Icon color="primary">
visibility
</Icon>
</IconButton>
</Tooltip>
</TableCell> </TableCell>
</TableRow> </TableRow>
) )
...@@ -275,7 +344,7 @@ function TableList(props) { ...@@ -275,7 +344,7 @@ function TableList(props) {
open={open} open={open}
handleClose={handleClose} handleClose={handleClose}
onAgree={() => { onAgree={() => {
removeItem(selected.id) removeItem(selected)
handleClose() handleClose()
}} }}
/> />
......
...@@ -36,6 +36,7 @@ function CustomerView(props) { ...@@ -36,6 +36,7 @@ function CustomerView(props) {
listMerchant, listMerchant,
status, status,
setStatus, setStatus,
listStatus,
} = props } = props
const [age, setAge] = React.useState('') const [age, setAge] = React.useState('')
const { user } = useAuth() const { user } = useAuth()
...@@ -135,16 +136,7 @@ function CustomerView(props) { ...@@ -135,16 +136,7 @@ function CustomerView(props) {
<MenuItem value=""> <MenuItem value="">
<em>Tt c</em> <em>Tt c</em>
</MenuItem> </MenuItem>
{[ {listStatus.map((e) => (
{
id: 1,
name: 'Hoạt động',
},
{
id: 2,
name: 'Khoá',
},
].map((e) => (
<MenuItem value={e.id}> <MenuItem value={e.id}>
{e.name} {e.name}
</MenuItem> </MenuItem>
...@@ -153,7 +145,7 @@ function CustomerView(props) { ...@@ -153,7 +145,7 @@ function CustomerView(props) {
</FormControl> </FormControl>
</Grid> </Grid>
</Grid> </Grid>
{checkRole(user, '/gas-station/create') ? ( {/* {checkRole(user, '/gas-station/create') ? (
<Link to="/gas-station/create"> <Link to="/gas-station/create">
<Button <Button
variant="contained" variant="contained"
...@@ -162,7 +154,7 @@ function CustomerView(props) { ...@@ -162,7 +154,7 @@ function CustomerView(props) {
<span className={'text-primary'}>Thêm mới</span> <span className={'text-primary'}>Thêm mới</span>
</Button> </Button>
</Link> </Link>
) : null} ) : null} */}
</Grid> </Grid>
<Table <Table
......
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