This commit is contained in:
kclf
2022-12-05 11:11:06 +08:00
parent 6d4421adfb
commit 0f041d8ba0
6 changed files with 49 additions and 110 deletions

View File

@@ -4,7 +4,7 @@
<div class="options">
<div class="name">
<div class="namebox">
<div class="inname">选项{{ item.id }}</div>
<div class="inname">选项{{ curItem.id }}</div>
</div>
<div class="in">
<a-input
@@ -12,7 +12,6 @@
show-count
:maxlength="30"
style="border-radius: 8px"
@change="handleInput"
/>
</div>
</div>
@@ -20,15 +19,15 @@
</div>
<div class="name uploadContent">
<a-upload
v-show="!item.imgVal"
v-show="!curItem.imgVal"
class="in uploadBtn"
:show-upload-list="false"
:before-upload="beforeUpload"
>
<div class="addimg">+添加图片</div>
</a-upload>
<div v-show="item.imgVal" class="picture" style="position: relative">
<img class="pictureimg" :src="item.imgVal" />
<div v-show="curItem.imgVal" class="picture" style="position: relative">
<img class="pictureimg" :src="curItem.imgVal" />
<div class="picturename" v-show="hasImgName">{{ hasImgName }}</div>
<img
style="
@@ -67,17 +66,18 @@ export default {
hasImgName: "",
});
const handleInput = () => {
emit("input", { id: curItem.value.id, val: curItem.value.inputVal });
};
const handleDel = () => {
handleCancel();
emit("del", { id: curItem.value.id, optionId: curItem.value.optionId });
};
const handleCancel = () => {
state.hasImgName = "";
emit("delImg", { id: curItem.value.id });
};
const handleDel = () => {
handleCancel();
emit("del", {
id: curItem.value.id,
optionId: curItem.value.optionId,
});
};
const beforeUpload = (file) => {
const isJpgOrPng =
file.type === "image/jpg" ||
@@ -99,7 +99,6 @@ export default {
const formData = new FormData();
formData.append("file", file);
console.log(file);
fileUp(formData).then((res) => {
if (res.data.code === 200) {
state.hasImgName = file.name;
@@ -112,7 +111,6 @@ export default {
return {
...toRefs(state),
curItem,
handleInput,
handleDel,
handleCancel,
beforeUpload,