sua lai
This commit is contained in:
parent
4a36e76620
commit
eb1b39b9fe
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/app/node_modules
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
|
||||||
|
|
795
app/package-lock.json
generated
795
app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -75,6 +75,7 @@ export default function ListItem() {
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: 'Thành công',
|
title: 'Thành công',
|
||||||
text: 'Xoá thành công',
|
text: 'Xoá thành công',
|
||||||
|
timer: 1500,
|
||||||
buttons: false,
|
buttons: false,
|
||||||
})
|
})
|
||||||
getData(activePage)
|
getData(activePage)
|
||||||
|
@ -84,6 +85,7 @@ export default function ListItem() {
|
||||||
swal("Thất bại", "Xoá thất bại!", "error");
|
swal("Thất bại", "Xoá thất bại!", "error");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
setLoading(false)
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +141,7 @@ export default function ListItem() {
|
||||||
|
|
||||||
var listImg
|
var listImg
|
||||||
if (value.sample_images.length > 0) {
|
if (value.sample_images.length > 0) {
|
||||||
listImg = <img key={index} style={{ width: "80px", height: "80px" }} alt={value.sample_images.length > 0 ? value.sample_images[0] : ""} src={`${value.sample_images.length > 0 && value.image_host + value.sample_images[0]}`} />
|
listImg = <img key={index} style={{ width: "80px", height: "80px" }} alt="" src={`${value.sample_images.length > 0 && value.image_host + value.sample_images[0]}`} />
|
||||||
} else {
|
} else {
|
||||||
listImg = <Avatar shape="square" size={80} icon={<UserOutlined />} />
|
listImg = <Avatar shape="square" size={80} icon={<UserOutlined />} />
|
||||||
}
|
}
|
||||||
|
@ -166,7 +168,7 @@ export default function ListItem() {
|
||||||
// title: "Are you sure?",
|
// title: "Are you sure?",
|
||||||
text: "Bạn có chắc muốn xoá " + value.name,
|
text: "Bạn có chắc muốn xoá " + value.name,
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
buttons: true,
|
buttons: ["Huỷ", "Xoá"],
|
||||||
dangerMode: true,
|
dangerMode: true,
|
||||||
})
|
})
|
||||||
.then(willDelete => {
|
.then(willDelete => {
|
||||||
|
@ -187,15 +189,14 @@ export default function ListItem() {
|
||||||
|
|
||||||
const onCloseModal = () => {
|
const onCloseModal = () => {
|
||||||
setShowModal(false)
|
setShowModal(false)
|
||||||
|
setActivePage(activePage)
|
||||||
getData(1)
|
getData(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
setDataSearch("")
|
|
||||||
getData(1)
|
getData(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) return <></>
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{showModal && <Modaledit data={dataEdit} onHide={onCloseModal} show={showModal} />}
|
{showModal && <Modaledit data={dataEdit} onHide={onCloseModal} show={showModal} />}
|
||||||
|
@ -239,6 +240,8 @@ export default function ListItem() {
|
||||||
<div className="pl-3">
|
<div className="pl-3">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setActivePage(1)
|
||||||
|
setDataSearch("")
|
||||||
reset()
|
reset()
|
||||||
}}
|
}}
|
||||||
className="btn btn-secondary m-btn m-btn--icon" id="m_reset">
|
className="btn btn-secondary m-btn m-btn--icon" id="m_reset">
|
||||||
|
@ -283,7 +286,7 @@ export default function ListItem() {
|
||||||
<th>Thao tác</th>
|
<th>Thao tác</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>{tableRows(data)}</tbody>
|
<tbody>{data && tableRows(data)}</tbody>
|
||||||
</table>
|
</table>
|
||||||
<PulseLoader
|
<PulseLoader
|
||||||
// css={override}
|
// css={override}
|
||||||
|
|
|
@ -18,7 +18,6 @@ const Modaledit = (props) => {
|
||||||
|
|
||||||
const [form] = Form.useForm()
|
const [form] = Form.useForm()
|
||||||
|
|
||||||
const fileInput = useRef(null);
|
|
||||||
|
|
||||||
const [birthday, setBirthday] = useState(moment())
|
const [birthday, setBirthday] = useState(moment())
|
||||||
const [crrData, setCrrData] = useState(null);
|
const [crrData, setCrrData] = useState(null);
|
||||||
|
@ -29,13 +28,14 @@ const Modaledit = (props) => {
|
||||||
|
|
||||||
const [disableBtn, setDisableBtn] = useState(true);
|
const [disableBtn, setDisableBtn] = useState(true);
|
||||||
|
|
||||||
const [listImgUpload, setListImgUpload] = useState([]);
|
const [hostImg, setHostImg] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCrrData(data);
|
setCrrData(data);
|
||||||
setCrrImages(data.sample_images)
|
setCrrImages(data.sample_images)
|
||||||
setBirthday(data.birthday !== "" ? moment(data.birthday) : null)
|
setBirthday(data.birthday !== "" ? moment(data.birthday) : null)
|
||||||
setDisableBtn(data._id ? false : true)
|
setDisableBtn(data._id ? false : true)
|
||||||
|
setHostImg(data.image_host)
|
||||||
return () => {
|
return () => {
|
||||||
setCrrData(null);
|
setCrrData(null);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ const Modaledit = (props) => {
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: 'Thành công',
|
title: 'Thành công',
|
||||||
text: 'Sửa thông tin thành công',
|
text: 'Sửa thông tin thành công',
|
||||||
|
timer: 1500,
|
||||||
buttons: false,
|
buttons: false,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,8 +88,10 @@ const Modaledit = (props) => {
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: 'Thành công',
|
title: 'Thành công',
|
||||||
text: 'Thêm mới thành công',
|
text: 'Thêm mới thành công',
|
||||||
|
timer: 1500,
|
||||||
buttons: false,
|
buttons: false,
|
||||||
})
|
})
|
||||||
|
setCrrData({...crrData, _id: result.data.data})
|
||||||
setDisableBtn(false)
|
setDisableBtn(false)
|
||||||
}
|
}
|
||||||
} else if (result.data.status === 10004) {
|
} else if (result.data.status === 10004) {
|
||||||
|
@ -100,7 +103,7 @@ const Modaledit = (props) => {
|
||||||
|
|
||||||
|
|
||||||
const bulletedImg = crrImages.map((value, index) => {
|
const bulletedImg = crrImages.map((value, index) => {
|
||||||
let renderImg = value.includes("data:image") ? value : data.image_host + value
|
let renderImg = value.includes("data:image") ? value : hostImg + value
|
||||||
return (
|
return (
|
||||||
<div className="img-res col-md-4 pl-0 mb-3" key={index + 1}>
|
<div className="img-res col-md-4 pl-0 mb-3" key={index + 1}>
|
||||||
<div style={{ 'height': 80 }}>
|
<div style={{ 'height': 80 }}>
|
||||||
|
@ -125,58 +128,13 @@ const Modaledit = (props) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const onChangeFile = async (event) => {
|
|
||||||
const file = event.target.files[0]
|
|
||||||
const base64 = await convertBase64(file)
|
|
||||||
let imgUplpad = [...crrImages]
|
|
||||||
imgUplpad.push(base64)
|
|
||||||
setCrrImages(imgUplpad)
|
|
||||||
setCheckDeleteMulti(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onClickUpload = () => {
|
|
||||||
if (crrImages.length >= 3) {
|
|
||||||
swal("Cảnh báo", "Số lượng ảnh tải lên tối đa là 3", "warning")
|
|
||||||
} else {
|
|
||||||
fileInput.current.click()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleChange = (event) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const onUpload = async (file) => {
|
|
||||||
console.log(file)
|
|
||||||
const base64 = await convertBase64(file)
|
|
||||||
|
|
||||||
let dataUploadImg = {
|
|
||||||
obj_id: crrData._id ? crrData._id : "",
|
|
||||||
base64_image_list: [base64.split(',')[1]]
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch(`${HOST}/api/face_images/famous_person`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
// 'Authorization': token
|
|
||||||
},
|
|
||||||
body: JSON.stringify(dataUploadImg)
|
|
||||||
})
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(data => {
|
|
||||||
console.log(data)
|
|
||||||
if (data.status === 10000) {
|
|
||||||
let listImg = [...crrImages]
|
|
||||||
listImg.unshift(data.data.toString())
|
|
||||||
setCrrImages(listImg)
|
|
||||||
setCheckDeleteMulti(false)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const uploadImage = async (options) => {
|
const uploadImage = async (options) => {
|
||||||
|
if (crrImages.length >= 3) {
|
||||||
|
swal("Cảnh báo", "Bạn chỉ được tải lên tối đa 3 ảnh!", "warning");
|
||||||
|
return
|
||||||
|
} else {
|
||||||
const { file } = options;
|
const { file } = options;
|
||||||
const base64 = await convertBase64(file)
|
const base64 = await convertBase64(file)
|
||||||
|
|
||||||
|
@ -197,13 +155,15 @@ const Modaledit = (props) => {
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.status === 10000) {
|
if (data.status === 10000) {
|
||||||
|
setHostImg(data.image_host)
|
||||||
let listImg = [...crrImages]
|
let listImg = [...crrImages]
|
||||||
listImg.unshift(data.data.toString())
|
listImg.unshift(data.data.toString())
|
||||||
setCrrImages(listImg)
|
setCrrImages(listImg)
|
||||||
setCheckDeleteMulti(false)
|
setCheckDeleteMulti(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,7 +236,7 @@ const Modaledit = (props) => {
|
||||||
<div className="row justify-content-center pb-3">
|
<div className="row justify-content-center pb-3">
|
||||||
{
|
{
|
||||||
crrImages[crrIdx] ?
|
crrImages[crrIdx] ?
|
||||||
<Avatar shape="square" src={crrImages[crrIdx].includes("data:image") ? crrImages[crrIdx] : data.image_host + crrImages[crrIdx]} size={180} icon={<UserOutlined />} /> :
|
<Avatar shape="square" src={crrImages[crrIdx].includes("data:image") ? crrImages[crrIdx] : hostImg + crrImages[crrIdx]} size={180} icon={<UserOutlined />} /> :
|
||||||
<Avatar shape="square" size={180} icon={<UserOutlined />} />
|
<Avatar shape="square" size={180} icon={<UserOutlined />} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15008
app/yarn.lock
15008
app/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user