Commit 5acc8772 by tdgiang

update code

parent e108ebbb
......@@ -60,3 +60,13 @@ export const changeStatusGasStation = async (body) =>
PostData(url.changeStatusGasStation, body)
.then((res) => res)
.catch((err) => null)
export const deleteGasOnline = async (body) =>
PostData(url.deleteGasOnline, body)
.then((res) => res)
.catch((err) => null)
export const deleteGasField = async (body) =>
PostData(url.deleteGasField, body)
.then((res) => res)
.catch((err) => null)
......@@ -80,6 +80,9 @@ export default {
urlDetailGasStation: `${root}/merchantstore`,
changeStatusGasStation: `${root}/merchantstore/changeStatus`,
deleteGasOnline: `${root}/gasoline/delete`,
deleteGasField: `${root}/gasfield/delete`,
//Log
logAuth: `${root}/logging/listLogin`,
logApi: `${root}/logging/listCallApi`,
......
......@@ -99,10 +99,21 @@ export default function FormDialog({ onCreate }) {
}
const handleSubmit = async (value) => {
console.log('state', state)
let index=listProduct.findIndex(e=>e.id==state.product_id)
if(index!=-1){
console.log(listProduct[index])
console.log("listProduct",listProduct)
console.log('state', state)
onCreate({...state,type,type_name:listProduct[index].type_name, product_name: listProduct[index].product_name})
setOpen(false)
setState({})
setType()
}
onCreate({...state,type})
}
const handleChange = (event) => {
......@@ -134,15 +145,15 @@ export default function FormDialog({ onCreate }) {
<DialogContent>
<Grid container spacing={2}>
<Grid item lg={12} md={12} sm={12} xs={12}>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Tên vòi xăng *"
label=" vòi xăng *"
onChange={handleChange}
variant="outlined"
type="text"
name="name"
value={name || ''}
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
......@@ -152,18 +163,19 @@ export default function FormDialog({ onCreate }) {
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label=" vòi xăng *"
label="Tên vòi xăng *"
onChange={handleChange}
variant="outlined"
type="text"
name="code"
value={code || ''}
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<SelectValidator
......
import React, { useState, useEffect } from 'react'
import {
Button,
FormControl,
Grid,
InputLabel,
Select,
TextField,
Typography,
Radio,
FormControlLabel,
DialogActions,
Dialog,
DialogContent,
DialogContentText,
DialogTitle,
IconButton,
Icon,
Tooltip,
RadioGroup,
MenuItem,
} from '@material-ui/core'
import { toast } from 'react-toastify'
import { useTranslation } from 'react-i18next'
import { KeyboardDatePicker } from '@material-ui/pickers'
import {
convertDate,
toPriceVndInput,
convertViToEn,
} from 'app/config/Function'
import {
TextValidator,
ValidatorForm,
SelectValidator,
} from 'react-material-ui-form-validator'
import {dropdownProductType,dropdownProcutByType} from 'app/apis/Functions/dropdown'
export default function FormDialog( props) {
const { t } = useTranslation()
const { open, handleClose, data, onAgree } = props
const [state, setState] = useState({})
const [listType, setListType] = useState([])
const [listProduct, setListProduct] = useState([])
const [product,setProduct]=useState()
const [type, setType] = useState()
useEffect(()=>{
if(data){
setState({...data})
setType(data.type)
setProduct(data.product_id)
}
},[data])
useEffect(()=>{
setState({...state})
if(type){
getDropdownProduct(type)
}
},[type])
useEffect(() => {
getData()
}, [])
const getData = async () => {
const res = await dropdownProductType({})
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { ...e,name: e.type_name, value: e.id}
})
setListType(newList)
}
else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
const getDropdownProduct= async (type) => {
const res = await dropdownProcutByType(type)
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { ...e,name: e.product_name, value: e.id}
})
setListProduct(newList)
}
else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
const handleSubmit = async (value) => {
let index=listProduct.findIndex(e=>e.id==state.product_id)
if(index!=-1){
console.log(listProduct[index])
console.log("listProduct",listProduct)
console.log('state', state)
onAgree({...state,type,type_name:listProduct[index].type_name, product_name: listProduct[index].product_name})}
}
const handleChange = (event) => {
event.persist()
setState({
...state,
[event.target.name]: event.target.value,
})
}
const { product_id, name, code } = state
console.log("product_id",product_id)
return (
<Dialog
open={open}
onClose={handleClose}
aria-labelledby="form-dialog-title"
>
<DialogTitle id="form-dialog-title">
Thêm vòi xăng
</DialogTitle>
<DialogContent>
<Grid container spacing={2}>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
defaultValue={true}
label="Mã vòi xăng *"
onChange={handleChange}
variant="outlined"
disabled={true}
type="text"
name="code"
value={code || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={12} md={12} sm={12} xs={12}>
<TextValidator
className="mb-4 w-full"
label="Tên vòi xăng *"
onChange={handleChange}
variant="outlined"
type="text"
name="name"
value={name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
{type && <Grid item lg={12} md={12} sm={12} xs={12}>
<SelectValidator
variant={'outlined'}
label={'Loại nguyên liệu *'}
className="mb-4 w-full"
value={type || ''}
displayEmpty
name="merchan_id"
onChange={(event) => {
setType(event.target.value)
}}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{listType.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>}
{product_id && <Grid item lg={12} md={12} sm={12} xs={12}>
<SelectValidator
variant={'outlined'}
label={'Loại xăng *'}
className="mb-4 w-full"
value={product_id || ''}
displayEmpty
name="product_id"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{listProduct.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>}
</Grid>
</DialogContent>
<DialogActions>
<Button color="secondary" onClick={handleClose}>
Thoát
</Button>
<Button onClick={handleSubmit} color="primary">
Đồng ý
</Button>
</DialogActions>
</Dialog>
)
}
......@@ -14,7 +14,7 @@ import {
Tooltip,
} from '@material-ui/core'
import _ from 'lodash'
import { createFunction } from 'app/apis/Functions/function'
import { createGasStation } from 'app/apis/Functions/merchant'
import { showLoading, hideLoading } from 'app/redux/actions/loadingAction'
import { toast } from 'react-toastify'
import { Breadcrumb, SimpleCard } from 'app/components'
......@@ -31,6 +31,7 @@ import TableRow from '@material-ui/core/TableRow'
import Paper from '@material-ui/core/Paper'
import CreateField from 'app/components/dialog/CreateField'
import CreateFountain from 'app/components/dialog/CreateFountain'
import UpdateFountain from 'app/components/dialog/UpdateFountain'
const SimpleForm = (props) => {
const [state, setState] = useState({})
......@@ -38,6 +39,8 @@ const SimpleForm = (props) => {
const [listDrop, setListDrop] = useState([])
const [openCreate, setOpenCreate] = useState(false)
const [listField, setListField] = useState([])
const [fountainSelected, setFountainSelected] = useState()
const [openUpdate, setOpenUpdate] = useState()
useEffect(() => {
getData()
......@@ -65,22 +68,25 @@ const SimpleForm = (props) => {
const handleSubmit = async (event) => {
const newValue = trimObject(state)
console.log('newValue', newValue)
console.log('listField', listField)
props.showLoading()
const res = await createFunction({
const res = await createGasStation({
...newValue,
status: 1,
is_default: true,
gas_fields: listField,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/gas-station')
if (res.data.code == 200) {
toast.success('Tạo hành động thành công!', {
toast.success('Tạo cây xăng thành công!', {
theme: 'colored',
})
}
} else {
toast.error('Tạo hành động thất bại!', {
toast.error('Tạo cây xăng thất bại!', {
theme: 'colored',
})
}
......@@ -140,13 +146,29 @@ const SimpleForm = (props) => {
let newList = arr.map((e, i) => {
if (i == index) {
if (e.gas_olines) {
return {
...e,
gas_olines: [
{
...data,
},
].concat(e.gas_olines),
console.log('data', data)
console.log('e.gas_olines', e.gas_olines)
if (
e.gas_olines.findIndex((e) => e.name == data.name) ==
-1 &&
e.gas_olines.findIndex((e) => e.code == data.code) == -1
) {
return {
...e,
gas_olines: [
{
...data,
},
].concat(e.gas_olines),
}
} else {
toast.warning('Tên vòi xăng đã tồn tại', {
theme: 'colored',
})
return {
...e,
gas_olines: e.gas_olines,
}
}
} else {
return {
......@@ -164,14 +186,85 @@ const SimpleForm = (props) => {
console.log('newList', newList)
setListField(newList)
}
const deleteFountain = (item, index) => {
console.log('item', item)
let arr = [...listField]
console.log('index', index)
let newList = arr.map((e, i) => {
if (item?.field_name == e?.field_name) {
let temp = [...e?.gas_olines]
console.log('temp', temp)
console.log('index', index)
temp.splice(index, 1)
console.log('temp', temp)
return {
...e,
gas_olines: temp,
}
} else return { ...e }
})
console.log('newList', newList)
setListField(newList)
toast.success('Xoá vòi thành công!', {
theme: 'colored',
})
}
const handleCloseCreate = () => {
setOpenCreate(false)
}
const { store_name, address, merchan_id } = state
const handleCloseUpdate = () => {
setOpenUpdate(false)
}
const onUpdateField = (data) => {
console.log('hehe', data)
console.log('fountainSelected', fountainSelected)
let arr = [...listField]
console.log('listField', listField)
let newList = arr.map((e, i) => {
if (i == fountainSelected.index) {
console.log('data', data)
console.log('e.gas_olines', e.gas_olines)
if (e.gas_olines.findIndex((e) => e.code == data.code) != -1) {
const temp = e.gas_olines.map((item) => {
if (item.code == data.code) return { ...data }
return { ...item }
})
return {
...e,
gas_olines: temp,
}
} else {
return {
...e,
gas_olines: e.gas_olines,
}
}
} else return { ...e }
})
setListField(newList)
setOpenUpdate(false)
}
const countFountain = () => {
let temp = 0
listField.map((e) => {
if (e.gas_olines) {
temp += e.gas_olines.length
}
})
return temp
}
const { store_name, address, merchan_id } = state
return (
<div className="m-sm-30">
......@@ -294,7 +387,7 @@ const SimpleForm = (props) => {
{listField.length}
</Typography>
<Typography variant="subtitle1">
S lượng tr:3
S lượng tr: {countFountain()}
</Typography>
</div>
<Button
......@@ -503,9 +596,24 @@ const SimpleForm = (props) => {
</TableCell> */}
<TableCell>
<Tooltip title="Xoá">
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {}}
onClick={() => {
setOpenUpdate(
true
)
setFountainSelected(
{
...row,
index,
}
)
console.log(
'heelo',
index
)
}}
//className={classes.button}
aria-label="Delete"
>
......@@ -516,7 +624,16 @@ const SimpleForm = (props) => {
</Tooltip>
<Tooltip title="Xoá">
<IconButton
onClick={() => {}}
onClick={() => {
deleteFountain(
item,
index
)
console.log(
'heelo',
index
)
}}
//className={classes.button}
aria-label="Delete"
>
......@@ -574,6 +691,12 @@ const SimpleForm = (props) => {
handleClose={handleCloseCreate}
onAgree={onCreateField}
/>
<UpdateFountain
open={openUpdate}
handleClose={handleCloseUpdate}
onAgree={onUpdateField}
data={fountainSelected}
/>
</ValidatorForm>
</SimpleCard>
</div>
......
......@@ -92,7 +92,7 @@ const ToolNotificate = (props) => {
const removeItem = async (id) => {
props.showLoading()
const res = await deleteGasStation({ id })
const res = await deleteGasStation({ idGuid: id })
props.hideLoading()
if (res.data.code == 200) {
getData()
......
......@@ -211,7 +211,7 @@ function TableList(props) {
setSelected({
...row,
title: 'Xóa cây xăng',
content: `Bạn có muốn xóa cây xăng ${row.name} hay không?`,
content: `Bạn có muốn xóa cây xăng ${row.store_name} hay không?`,
})
setOpen(true)
}}
......
import React, { useState, useEffect } from 'react'
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator'
import { Button, Grid } from '@material-ui/core'
import { detailFunction, updateFunction } from 'app/apis/Functions/function'
import {
ValidatorForm,
TextValidator,
SelectValidator,
} from 'react-material-ui-form-validator'
import {
Button,
Grid,
MenuItem,
Typography,
IconButton,
Icon,
Tooltip,
} from '@material-ui/core'
import _ from 'lodash'
import {
createGasStation,
detailGasStation,
deleteGasField,
deleteGasOnline,
} from 'app/apis/Functions/merchant'
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 { connect } from 'react-redux'
import localStorageService from 'app/services/localStorageService'
import { dropdownMerchant } from 'app/apis/Functions/dropdown'
import Table from '@material-ui/core/Table'
import TableBody from '@material-ui/core/TableBody'
import TableCell from '@material-ui/core/TableCell'
import TableContainer from '@material-ui/core/TableContainer'
import TableHead from '@material-ui/core/TableHead'
import TableRow from '@material-ui/core/TableRow'
import Paper from '@material-ui/core/Paper'
import CreateField from 'app/components/dialog/CreateField'
import CreateFountain from 'app/components/dialog/CreateFountain'
import UpdateFountain from 'app/components/dialog/UpdateFountain'
import { useTranslation } from 'react-i18next'
const SimpleForm = (props) => {
const [state, setState] = useState({})
const history = useHistory()
const [listDrop, setListDrop] = useState([])
const [openCreate, setOpenCreate] = useState(false)
const [listField, setListField] = useState([])
const [fountainSelected, setFountainSelected] = useState()
const [openUpdate, setOpenUpdate] = useState()
const location = useLocation()
const { t } = useTranslation()
useEffect(() => {
getDateDetail()
getData()
}, [])
const getData = async () => {
const getDateDetail = async () => {
props.showLoading()
const res = await detailFunction(location.state, {})
const res = await detailGasStation(location.state, {})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
console.log(res.data.data.gas_fields)
if (res.data.data.gas_fields) {
setListField(res.data.data?.gas_fields)
}
setState(res.data.data)
} else if (res.data.code == 401) {
localStorageService.removeToken()
setTimeout(() => {
history.push('/')
}, 100)
......@@ -37,24 +76,51 @@ const SimpleForm = (props) => {
}
}
const getData = async () => {
props.showLoading()
const res = await dropdownMerchant({})
props.hideLoading()
if (res.data.code == 200 && res.data.data) {
const newList = res.data.data.map((e) => {
return { ...e, name: e.merchant_name }
})
setListDrop(newList)
} else if (res.data.code == 401) {
setTimeout(() => {
history.push('/')
}, 100)
} else {
toast.error('Lấy giữ liệu thất bại !', {
theme: 'colored',
})
}
}
const handleSubmit = async (event) => {
const newValue = trimObject(state)
console.log('newValue', newValue)
console.log('listField', listField)
props.showLoading()
const res = await updateFunction({
...newValue,
status: 1,
is_default: true,
const res = await createGasStation({
id: newValue?.id,
merchant_id: newValue?.merchant_id,
store_name: newValue?.store_name,
address: newValue?.address,
gas_fields: listField,
})
props.hideLoading()
if (res.data.code == 200) {
history.push('/gas-station')
if (res.data.code == 200) {
toast.success('Cập nhật hành động thành công!', {
toast.success('Cập nhật cây xăng thành công!', {
theme: 'colored',
})
}
} else {
toast.error('Cập nhật hành động thất bại!', {
toast.error('Cập nhật cây xăng thất bại!', {
theme: 'colored',
})
}
......@@ -72,7 +138,184 @@ const SimpleForm = (props) => {
setState({ ...state, date })
}
const { description, name, code, url } = state
const onCreateField = (value) => {
if (value) {
console.log('value', value)
if (listField.findIndex((e) => e.field_name == value) == -1) {
setListField(
[
{
field_name: value,
gas_olines: [],
},
].concat(listField)
)
setOpenCreate(false)
toast.success('Thêm trụ thành công!', {
theme: 'colored',
})
} else {
toast.warning('Tên trụ xăng đã tồn tại', {
theme: 'colored',
})
}
} else {
toast.warning('Bạn chưa nhập đầy đủ thông tin', {
theme: 'colored',
})
}
}
const deletePillar = (index) => {
let arr = [...listField]
arr.splice(index, 1)
setListField(arr)
toast.success('Xoá trụ thành công!', {
theme: 'colored',
})
}
const createFountain = (data, index) => {
let arr = [...listField]
let newList = arr.map((e, i) => {
if (i == index) {
if (e.gas_olines) {
console.log('data', data)
console.log('e.gas_olines', e.gas_olines)
if (
e.gas_olines.findIndex((e) => e.name == data.name) ==
-1 &&
e.gas_olines.findIndex((e) => e.code == data.code) == -1
) {
return {
...e,
gas_olines: [
{
...data,
},
].concat(e.gas_olines),
}
} else {
toast.warning('Tên vòi xăng đã tồn tại', {
theme: 'colored',
})
return {
...e,
gas_olines: e.gas_olines,
}
}
} else {
return {
...e,
gas_olines: [
{
...data,
},
],
}
}
} else return { ...e }
})
console.log('newList', newList)
setListField(newList)
}
const deleteFountain = (item, index) => {
console.log('item', item)
let arr = [...listField]
console.log('index', index)
let newList = arr.map((e, i) => {
if (item?.field_name == e?.field_name) {
let temp = [...e?.gas_olines]
console.log('temp', temp)
console.log('index', index)
if (temp[index].id) {
callApiDeleteFountain(temp[index].id)
}
temp.splice(index, 1)
console.log('temp', temp)
return {
...e,
gas_olines: temp,
}
} else return { ...e }
})
console.log('newList', newList)
setListField(newList)
toast.success('Xoá vòi thành công!', {
theme: 'colored',
})
}
const handleCloseCreate = () => {
setOpenCreate(false)
}
const handleCloseUpdate = () => {
setOpenUpdate(false)
}
const onUpdateField = (data) => {
console.log('hehe', data)
console.log('fountainSelected', fountainSelected)
let arr = [...listField]
let newList = arr.map((e, i) => {
if (i == fountainSelected.index) {
console.log('data', data)
console.log('e.gas_olines', e.gas_olines)
if (e.gas_olines.findIndex((e) => e.code == data.code) != -1) {
const temp = e.gas_olines.map((item) => {
if (item.code == data.code) return { ...data }
return { ...item }
})
return {
...e,
gas_olines: temp,
}
} else {
return {
...e,
gas_olines: e.gas_olines,
}
}
} else return { ...e }
})
setListField(newList)
setOpenUpdate(false)
}
const countFountain = () => {
let temp = 0
listField.map((e) => {
if (e.gas_olines) {
temp += e.gas_olines.length
}
})
return temp
}
const callApiDeleteFountain = async (id) => {
props.showLoading()
const res = await deleteGasOnline({ idGuid: id })
props.hideLoading()
if (res.data.code == 200) {
return true
} else {
toast.error(t(res.data.error), {
theme: 'colored',
})
return false
}
}
const { store_name, address, merchant_id } = state
return (
<div className="m-sm-30">
......@@ -89,8 +332,37 @@ const SimpleForm = (props) => {
/>
</div>
<SimpleCard>
<ValidatorForm onSubmit={handleSubmit} onError={() => null}>
<ValidatorForm
id="form-create"
onSubmit={handleSubmit}
onError={() => null}
>
<Grid container spacing={3}>
{merchant_id && (
<Grid xs={6} sm={6} item>
<SelectValidator
variant={'outlined'}
label={'Thuộc pháp nhân *'}
disabled={true}
className="mb-4 w-full"
value={merchant_id || ''}
displayEmpty
name="merchant_id"
onChange={handleChange}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
>
{listDrop.map((e) => (
<MenuItem value={e.id}>
{e.name}
</MenuItem>
))}
</SelectValidator>
</Grid>
)}
<Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
......@@ -98,8 +370,8 @@ const SimpleForm = (props) => {
label="Tên cây xăng *"
onChange={handleChange}
type="text"
name="name"
value={name || ''}
name="store_name"
value={store_name || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
......@@ -110,50 +382,346 @@ const SimpleForm = (props) => {
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Mã code *"
label="Địa chỉ *"
onChange={handleChange}
type="text"
name="code"
value={code || ''}
name="address"
value={address || ''}
validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
{/* <Grid item lg={6} md={6} sm={12} xs={12}>
<TextValidator
variant="outlined"
className="mb-4 w-full"
label="Đường dẫn *"
label="Tên cây xăng *"
onChange={handleChange}
type="text"
name="url"
value={url || ''}
name="store_name"
value={store_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ả "
onChange={handleChange}
type="text"
name="description"
value={description || ''}
//validators={['required']}
errorMessages={[
'Không được để trống trường này',
]}
/>
</Grid> */}
<Grid
item
container
lg={12}
md={12}
sm={12}
xs={12}
justify="space-between"
style={{
padding: 10,
borderRadius: 5,
}}
>
<Typography variant="h6">
Thông tin tr xăng
</Typography>
<Grid
item
container
lg={12}
md={12}
sm={12}
xs={12}
justify="space-between"
>
<div>
<Typography variant="subtitle1">
S lượng vòi mi tr:{' '}
{listField.length}
</Typography>
<Typography variant="subtitle1">
S lượng tr: {countFountain()}
</Typography>
</div>
<Button
style={{
width: 140,
}}
onClick={() => {
setOpenCreate(true)
}}
variant="contained"
className={'bg-light-primary'}
>
<span className={'text-primary'}>
Thêm mi tr
</span>
</Button>
</Grid>
{listField.map((item, index) => (
<Grid
style={{
border: '1px solid #B9B9B9',
borderRadius: 5,
padding: 10,
marginTop: 20,
}}
lg={12}
md={12}
sm={12}
xs={12}
>
<Grid lg={12} md={12} sm={12} xs={12}>
<div
style={{
alignItems: 'center',
justifyContent:
'space-between',
display: 'flex',
marginBottom: 10,
}}
>
<Typography variant="h6">
{item.field_name}
</Typography>
<Button
onClick={() => {
deletePillar(index)
}}
variant="contained"
style={{
backgroundColor:
'#FC2B05',
color: 'white',
}}
>
<span>Xoá tr</span>
</Button>
</div>
<TableContainer component={Paper}>
<Table aria-label="simple table">
<TableHead>
<TableRow
style={{
backgroundColor:
'#F3F3F3',
}}
>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
width: 100,
}}
align="center"
>
STT
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Mã vòi
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Vòi
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Loi nhiên liu
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
Sn phm
</TableCell>
{/* <TableCell align="center">
Trạng thái hoạt
động
</TableCell> */}
<TableCell
style={{
textAlign:
'center',
width: 120,
}}
align="center"
>
Hành động
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{item?.gas_olines.map(
(row, index) => (
<TableRow
key={
row.name
}
>
<TableCell
component="th"
scope="row"
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="center"
>
{index +
1}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.code
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.name
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.type_name
}
</TableCell>
<TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.product_name
}
</TableCell>
{/* <TableCell
style={{
borderRight:
'0.05px solid #e0e0e0',
}}
align="right"
>
{
row?.status
}
</TableCell> */}
<TableCell>
<Tooltip title="Cập nhật">
<IconButton
onClick={() => {
setOpenUpdate(
true
)
setFountainSelected(
{
...row,
index,
}
)
console.log(
'heelo',
index
)
}}
//className={classes.button}
aria-label="Delete"
>
<Icon color="primary">
edit
</Icon>
</IconButton>
</Tooltip>
<Tooltip title="Xoá">
<IconButton
onClick={() => {
deleteFountain(
item,
index
)
console.log(
'heelo',
index
)
}}
//className={classes.button}
aria-label="Delete"
>
<Icon color="error">
delete
</Icon>
</IconButton>
</Tooltip>
</TableCell>
</TableRow>
)
)}
</TableBody>
</Table>
</TableContainer>
<CreateFountain
onCreate={(data) => {
createFountain(data, index)
}}
/>
</Grid>
</Grid>
))}
</Grid>
</Grid>
<Grid container justify={'flex-end'}>
<Grid
style={{
marginTop: 40,
}}
container
justify={'flex-end'}
>
<Link to="gas-station">
<Button
style={{
......@@ -174,6 +742,17 @@ const SimpleForm = (props) => {
<span className="capitalize">Cp nht</span>
</Button>
</Grid>
<CreateField
open={openCreate}
handleClose={handleCloseCreate}
onAgree={onCreateField}
/>
<UpdateFountain
open={openUpdate}
handleClose={handleCloseUpdate}
onAgree={onUpdateField}
data={fountainSelected}
/>
</ValidatorForm>
</SimpleCard>
</div>
......
......@@ -60,7 +60,6 @@ const SimpleForm = (props) => {
props.showLoading()
const res = await createProduct({
...newValue,
type_id: 2,
})
props.hideLoading()
if (res.data.code == 200) {
......
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