Commit 1f6e62c9 by tdgiang

updtae code

parent d7db34b4
...@@ -346,10 +346,11 @@ ...@@ -346,10 +346,11 @@
"ERROR_UPDATE_FAIL_ERROR_PHONE_EXIST" :"Số điện thoại đã tồn tại", "ERROR_UPDATE_FAIL_ERROR_PHONE_EXIST" :"Số điện thoại đã tồn tại",
"ERROR_UPDATE_FAIL_ERROR_EMAIL_EXIST" :"Email đã tồn tại", "ERROR_UPDATE_FAIL_ERROR_EMAIL_EXIST" :"Email đã tồn tại",
"ERROR_UPDATE_FAIL_ERROR_USERNAME_EXIST" :"Tài khoản đã tồn tại.", "ERROR_UPDATE_FAIL_ERROR_USERNAME_EXIST" :"Tài khoản đã tồn tại.",
"ERROR_USERNAME_MISSING" :"Thiếu tài khoản" "ERROR_USERNAME_MISSING" :"Thiếu tài khoản",
"ERROR_PERMISSION_IS_EXIST":"Nhóm quyền đã tồn tại",
"ERROR_CODE_IS_EXISTS":"Mã code đã tồn tại",
"ERROR_NAME_IS_EXISTS":"Tên sản phẩm đã tồn tại"
} }
...@@ -128,7 +128,7 @@ export default function FormDialog({ onCreate }) { ...@@ -128,7 +128,7 @@ export default function FormDialog({ onCreate }) {
return ( return (
<> <>
<Tooltip title="Chuyển tiền đáo hạn"> <Tooltip title="Thêm mới vòi xăng">
<IconButton onClick={handleClickOpen}> <IconButton onClick={handleClickOpen}>
<Icon style={{ color: '#4caf50' }}>add_circle</Icon> <Icon style={{ color: '#4caf50' }}>add_circle</Icon>
</IconButton> </IconButton>
......
...@@ -53,16 +53,29 @@ const ToolNotificate = (props) => { ...@@ -53,16 +53,29 @@ const ToolNotificate = (props) => {
} }
} }
const getData = async () => { const getData = async (isInit) => {
try { try {
props.showLoading() props.showLoading()
const res = await getListEmployees({ let res
if (isInit) {
setPageIndex(0)
res = await getListEmployees({
full_name: searchDebount,
page_no: 0,
page_size: pageSize,
status,
user_group_id: role,
})
} else {
res = await getListEmployees({
full_name: searchDebount, full_name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
status, status,
user_group_id: role, user_group_id: role,
}) })
}
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.data.map((e, i) => { const newList = res.data.data.data.map((e, i) => {
...@@ -84,15 +97,18 @@ const ToolNotificate = (props) => { ...@@ -84,15 +97,18 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(true)
}, [searchDebount, pageIndex, status, role]) }, [searchDebount, status, role])
useEffect(() => {
getData(false)
}, [pageIndex])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
const res = await deleteEmployee({ id }) const res = await deleteEmployee({ id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData(true)
toast.success('Xoá bản ghi thành công!', { toast.success('Xoá bản ghi thành công!', {
theme: 'colored', theme: 'colored',
}) })
......
...@@ -58,13 +58,25 @@ const ToolNotificate = (props) => { ...@@ -58,13 +58,25 @@ const ToolNotificate = (props) => {
} }
} }
const getData = async () => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
const res = await getListFunction({
let res
if (isInit) {
setPageIndex(0)
res = await getListFunction({
name: searchDebount,
page_no: 0,
page_size: pageSize,
})
} else {
res = await getListFunction({
name: searchDebount, name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
}
props.hideLoading() props.hideLoading()
...@@ -89,8 +101,12 @@ const ToolNotificate = (props) => { ...@@ -89,8 +101,12 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(true)
}, [searchDebount, pageIndex]) }, [searchDebount])
useEffect(() => {
getData(false)
}, [pageIndex])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
......
...@@ -42,13 +42,23 @@ const ToolNotificate = (props) => { ...@@ -42,13 +42,23 @@ const ToolNotificate = (props) => {
} }
} }
const getData = async () => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
const res = await getListGroups({ let res
if (isInit) {
setPageIndex(0)
res = await getListGroups({
name: searchDebount,
page_no: 0,
page_size: pageSize,
})
} else {
res = await getListGroups({
name: searchDebount, name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
}
props.hideLoading() props.hideLoading()
...@@ -73,15 +83,19 @@ const ToolNotificate = (props) => { ...@@ -73,15 +83,19 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(false)
}, [searchDebount, pageIndex]) }, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
const res = await deleteGroup({ id }) const res = await deleteGroup({ id })
props.hideLoading() props.hideLoading()
if (res.data.code == 200) { if (res.data.code == 200) {
getData() getData(true)
toast.success('Xoá bản ghi thành công!', { toast.success('Xoá bản ghi thành công!', {
theme: 'colored', theme: 'colored',
}) })
......
...@@ -51,14 +51,26 @@ const ToolNotificate = (props) => { ...@@ -51,14 +51,26 @@ const ToolNotificate = (props) => {
} }
} }
const getData = async () => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
const res = await getListActions({
let res
if (isInit) {
setPageIndex(0)
res = await getListActions({
name: searchDebount,
page_no: 0,
page_size: pageSize,
function_id,
})
} else {
res = await getListActions({
name: searchDebount, name: searchDebount,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
function_id, function_id,
}) })
}
props.hideLoading() props.hideLoading()
...@@ -83,8 +95,12 @@ const ToolNotificate = (props) => { ...@@ -83,8 +95,12 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(false)
}, [searchDebount, pageIndex, function_id]) }, [pageIndex])
useEffect(() => {
getData(true)
}, [searchDebount, function_id])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
...@@ -101,7 +117,7 @@ const ToolNotificate = (props) => { ...@@ -101,7 +117,7 @@ const ToolNotificate = (props) => {
history.push('/') history.push('/')
}, 100) }, 100)
} else { } else {
toast.error(t(res.data.error), { toast.error('Bản ghi đã sử dụng, xoá hành động thất bại', {
theme: 'colored', theme: 'colored',
}) })
} }
......
...@@ -20,7 +20,7 @@ const ToolNotificate = (props) => { ...@@ -20,7 +20,7 @@ const ToolNotificate = (props) => {
const { t } = useTranslation() const { t } = useTranslation()
const [activeSelected, setActiveSeleted] = useState(null) const [activeSelected, setActiveSeleted] = useState(null)
const [changeActive, setChangeActive] = useState(1) const [changeActive, setChangeActive] = useState(1)
const [status, setStatus] = useState()
const [pageIndex, setPageIndex] = useState(0) const [pageIndex, setPageIndex] = useState(0)
const [pageSize] = useState(10) const [pageSize] = useState(10)
const [totalRecords, setTotalRecord] = useState(0) const [totalRecords, setTotalRecord] = useState(0)
...@@ -61,6 +61,7 @@ const ToolNotificate = (props) => { ...@@ -61,6 +61,7 @@ const ToolNotificate = (props) => {
page_no: 0, page_no: 0,
page_size: pageSize, page_size: pageSize,
merchant_id: merchant, merchant_id: merchant,
status,
}) })
} else { } else {
res = await getListGasStation({ res = await getListGasStation({
...@@ -68,6 +69,7 @@ const ToolNotificate = (props) => { ...@@ -68,6 +69,7 @@ const ToolNotificate = (props) => {
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
merchant_id: merchant, merchant_id: merchant,
status,
}) })
} }
...@@ -112,7 +114,7 @@ const ToolNotificate = (props) => { ...@@ -112,7 +114,7 @@ const ToolNotificate = (props) => {
useEffect(() => { useEffect(() => {
getData(true) getData(true)
}, [searchDebount, merchant]) }, [searchDebount, merchant, status])
const removeItem = async (id) => { const removeItem = async (id) => {
props.showLoading() props.showLoading()
...@@ -152,6 +154,8 @@ const ToolNotificate = (props) => { ...@@ -152,6 +154,8 @@ const ToolNotificate = (props) => {
listMerchant={listMerchant} listMerchant={listMerchant}
merchant={merchant} merchant={merchant}
setMerchant={setMerchant} setMerchant={setMerchant}
status={status}
setStatus={setStatus}
/> />
) )
} }
......
...@@ -37,6 +37,12 @@ const columns = [ ...@@ -37,6 +37,12 @@ const columns = [
align: 'center', align: 'center',
minWidth: 50, minWidth: 50,
}, },
// {
// id: 'id',
// label: 'id',
// align: 'center',
// minWidth: 50,
// },
{ {
id: 'store_name', id: 'store_name',
......
...@@ -34,6 +34,8 @@ function CustomerView(props) { ...@@ -34,6 +34,8 @@ function CustomerView(props) {
merchant, merchant,
setMerchant, setMerchant,
listMerchant, listMerchant,
status,
setStatus,
} = props } = props
const [age, setAge] = React.useState('') const [age, setAge] = React.useState('')
const { user } = useAuth() const { user } = useAuth()
...@@ -87,6 +89,7 @@ function CustomerView(props) { ...@@ -87,6 +89,7 @@ function CustomerView(props) {
}} }}
/> />
</Grid> </Grid>
<Grid item lg={4} md={4} sm={6} xs={6}> <Grid item lg={4} md={4} sm={6} xs={6}>
<FormControl variant="outlined" fullWidth> <FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple"> <InputLabel htmlFor="outlined-age-native-simple">
...@@ -114,6 +117,41 @@ function CustomerView(props) { ...@@ -114,6 +117,41 @@ function CustomerView(props) {
</Select> </Select>
</FormControl> </FormControl>
</Grid> </Grid>
<Grid item lg={4} md={4} sm={6} xs={6}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-age-native-simple">
Trng thái
</InputLabel>
<Select
label="Trạng thái"
value={status}
onChange={(e) => setStatus(e.target.value)}
inputProps={{
name: 'age',
id: 'outlined-age-native-simple',
}}
>
<MenuItem value="">
<em>Tt c</em>
</MenuItem>
{[
{
id: 1,
name: 'Hoạt động',
},
{
id: 2,
name: 'Khoá',
},
].map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid> </Grid>
{checkRole(user, '/gas-station/create') ? ( {checkRole(user, '/gas-station/create') ? (
<Link to="/gas-station/create"> <Link to="/gas-station/create">
......
...@@ -18,15 +18,28 @@ const ToolNotificate = (props) => { ...@@ -18,15 +18,28 @@ const ToolNotificate = (props) => {
const history = useHistory() const history = useHistory()
const [data, setData] = useState([]) const [data, setData] = useState([])
const getData = async () => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
const res = await getLogAction({ let res
if (isInit) {
setPageIndex(0)
res = await getLogAction({
search: txtSearch,
results,
functions,
page_no: 0,
page_size: pageSize,
})
} else {
res = await getLogAction({
search: txtSearch, search: txtSearch,
results, results,
functions, functions,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
}
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
...@@ -47,8 +60,11 @@ const ToolNotificate = (props) => { ...@@ -47,8 +60,11 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(true)
}, [txtSearch, pageIndex, functions, results]) }, [txtSearch, functions, results])
useEffect(() => {
getData(false)
}, [pageIndex])
return ( return (
<LogAuth <LogAuth
......
...@@ -17,14 +17,27 @@ const ToolNotificate = (props) => { ...@@ -17,14 +17,27 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
const getData = async () => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
const res = await getLogApi({
let res
if (isInit) {
setPageIndex(0)
res = await getLogApi({
search: txtSearch,
applications,
page_no: 0,
page_size: pageSize,
})
} else {
res = await getLogApi({
search: txtSearch, search: txtSearch,
applications, applications,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
}
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.data.map((e, i) => { const newList = res.data.data.data.map((e, i) => {
...@@ -44,8 +57,12 @@ const ToolNotificate = (props) => { ...@@ -44,8 +57,12 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(true)
}, [txtSearch, pageIndex, applications]) }, [txtSearch, applications])
useEffect(() => {
getData(false)
}, [pageIndex])
return ( return (
<LogAuth <LogAuth
......
...@@ -17,14 +17,27 @@ const ToolNotificate = (props) => { ...@@ -17,14 +17,27 @@ const ToolNotificate = (props) => {
const [data, setData] = useState([]) const [data, setData] = useState([])
const getData = async () => { const getData = async (isInit) => {
props.showLoading() props.showLoading()
const res = await getLogAuth({
let res
if (isInit) {
setPageIndex(0)
res = await getLogAuth({
search: txtSearch,
applications,
page_no: 0,
page_size: pageSize,
})
} else {
res = await getLogAuth({
search: txtSearch, search: txtSearch,
applications, applications,
page_no: pageIndex + 1, page_no: pageIndex + 1,
page_size: pageSize, page_size: pageSize,
}) })
}
props.hideLoading() props.hideLoading()
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
...@@ -45,8 +58,12 @@ const ToolNotificate = (props) => { ...@@ -45,8 +58,12 @@ const ToolNotificate = (props) => {
} }
useEffect(() => { useEffect(() => {
getData() getData(true)
}, [txtSearch, pageIndex, applications]) }, [txtSearch, applications])
useEffect(() => {
getData(false)
}, [pageIndex])
return ( return (
<LogAuth <LogAuth
......
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