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

@@ -29,9 +29,8 @@
</div>
<ResearchAddItem
v-for="(item, index) in curItem.singleList"
:key="index"
:key="index + new Date().getTime()"
:item="item"
@input="input"
@src="imgSrc"
@delImg="delImg"
@del="del"
@@ -80,21 +79,8 @@ export default {
const curItem = ref(props.item);
const assessmentId = ref(props.assessmentId);
// watch(
// () => curItem,
// (newVal) => {
// console.log("6765555curItemcurItem");
// console.log(newVal);
// },
// { deep: true }
// );
const handleTypesDel = (type) => {
emit("del", { id: curItem.value.id, type, curItem: curItem.value });
// if (state.typesCur.includes(types)) {
// const arr = state.typesCur.filter((item) => item !== types);
// state.typesCur = arr;
// }
};
const handleSingleAdd = () => {
@@ -104,13 +90,6 @@ export default {
imgVal: "",
});
};
const input = ({ id, val }) => {
curItem.value.singleList.forEach((item) => {
if (item.id === id) {
item.inputVal = val;
}
});
};
const imgSrc = ({ id, src }) => {
curItem.value.singleList.forEach((item) => {
if (item.id === id) {
@@ -126,15 +105,6 @@ export default {
});
};
const del = ({ id, optionId }) => {
// 前端删除
curItem.value.singleList.forEach((item, index) => {
if (item.id === id) {
curItem.value.singleList.splice(index, 1);
}
});
curItem.value.singleList.map((item, index) => {
item.id = index + 1;
});
// 接口删除
if (assessmentId.value && optionId) {
deleteChoiceQuestion({
@@ -146,13 +116,21 @@ export default {
console.log(res);
});
}
// 前端删除
curItem.value.singleList.forEach((item, index) => {
if (item.id === id) {
curItem.value.singleList.splice(index, 1);
}
});
curItem.value.singleList.map((item, index) => {
item.id = index + 1;
});
};
return {
curItem,
handleTypesDel,
handleSingleAdd,
input,
imgSrc,
delImg,
del,