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

@@ -47,7 +47,10 @@
<!-- 创建投票侧弹窗 -->
</div>
<div v-for="(item, index) in allFormsData" :key="index">
<div
v-for="(item, index) in allFormsData"
:key="index + new Date().getTime()"
>
<VoteQuestion :item="item" @del="handleDel" />
</div>
@@ -252,6 +255,13 @@ export default {
console.log(888888888);
console.log(id);
console.log(curItem);
// 接口删除
if (curItem.voteStemId) {
api.deleteVoteStem(curItem.voteStemId).then((res) => {
console.log(56444);
console.log(res);
});
}
// 前端删除
state.allFormsData.forEach((item, index) => {
if (item.id === id) {
@@ -264,13 +274,6 @@ export default {
item.id = index + 1;
return item;
});
// 接口删除
if (curItem.voteStemId) {
api.deleteVoteStem(curItem.voteStemId).then((res) => {
console.log(56444);
console.log(res);
});
}
};
const handleSave = () => {

View File

@@ -26,9 +26,8 @@
<VoteQuestionItem
v-model:info="info"
v-for="(item, index) in curItem.optionDetailList"
:key="index"
:key="index + new Date().getTime()"
:item="item"
@input="input"
@src="imgSrc"
@delImg="delImg"
@del="del"
@@ -83,13 +82,6 @@ export default {
imgVal: "",
});
};
const input = ({ id, val }) => {
curItem.value.optionDetailList.forEach((item) => {
if (item.id === id) {
item.inputVal = val;
}
});
};
const imgSrc = ({ id, src }) => {
curItem.value.optionDetailList.forEach((item) => {
if (item.id === id) {
@@ -124,7 +116,6 @@ export default {
curItem,
handleTypesDel,
handleSingleAdd,
input,
imgSrc,
delImg,
del,

View File

@@ -12,7 +12,6 @@
show-count
:maxlength="30"
style="border-radius: 8px"
@change="handleInput"
/>
</div>
</div>
@@ -67,9 +66,6 @@ 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 });
@@ -112,7 +108,6 @@ export default {
return {
...toRefs(state),
curItem,
handleInput,
handleDel,
handleCancel,
beforeUpload,

View File

@@ -17,7 +17,10 @@
<div class="types" @click="handleTypes(3)">问答题</div>
<div class="types" @click="handleTypes(4)">评分题</div>
</div>
<div v-for="(item, index) in allFormsData" :key="index">
<div
v-for="(item, index) in allFormsData"
:key="index + new Date().getTime()"
>
<ResearchAddSingle
v-if="item.type === 1"
:item="item"
@@ -88,7 +91,7 @@
</div>
</template>
<script>
import { reactive, toRefs, computed, getCurrentInstance } from "vue";
import { reactive, toRefs, computed } from "vue";
// import { message } from "ant-design-vue";
// import { createResearch } from "../../api/indexResearch";
import ResearchAddSingle from "./components/ResearchAddSingle.vue";
@@ -121,11 +124,6 @@ export default {
ResearchAddPin,
},
setup() {
let { ctx: that } = getCurrentInstance();
const reload = () => {
that.$forceUpdate();
};
const router = useRouter();
const state = reactive({
assessmentId: "", //编辑时候传
@@ -158,8 +156,6 @@ export default {
];
sortBy(renderArr, "orderNumber"); //序号
state.allFormsData = parseData(renderArr, "questionType"); //类型
console.log("state.allFormsData11111111111");
console.log(state.allFormsData);
}
};
getInfoDate();
@@ -417,27 +413,9 @@ export default {
};
const handleDel = ({ id, type, curItem }) => {
console.log(888888888);
console.log(id);
console.log(curItem);
// 前端删除
state.allFormsData.forEach((item, index) => {
if (item.id === id) {
state.allFormsData.splice(index, 1);
}
});
console.log(5656777777777);
console.log(state.allFormsData);
state.allFormsData.map((item, index) => {
item.id = index + 1;
return item;
});
reload();
// 接口删除
if (state.assessmentId && curItem.orderNumber) {
if (type === 1) {
console.log(11111);
console.log(curItem);
deleteChoiceQuestion({
assessmentId: state.assessmentId,
questionType: "1",
@@ -445,12 +423,9 @@ export default {
}).then((res) => {
console.log(56444);
console.log(res);
reload();
});
}
if (type === 2) {
console.log(11111);
console.log(curItem);
deleteChoiceQuestion({
assessmentId: state.assessmentId,
questionType: "2",
@@ -458,12 +433,9 @@ export default {
}).then((res) => {
console.log(56444);
console.log(res);
reload();
});
}
if (type === 3) {
console.log(2222);
console.log(curItem);
deleteQuestionScAndQa({
assessmentId: state.assessmentId,
questionType: "3",
@@ -471,12 +443,9 @@ export default {
}).then((res) => {
console.log(56444);
console.log(res);
reload();
});
}
if (type === 4) {
console.log(2222);
console.log(curItem);
deleteQuestionScAndQa({
assessmentId: state.assessmentId,
questionType: "4",
@@ -484,10 +453,19 @@ export default {
}).then((res) => {
console.log(56444);
console.log(res);
reload();
});
}
}
// 前端删除
state.allFormsData.forEach((item, index) => {
if (item.id === id) {
state.allFormsData.splice(index, 1);
}
});
state.allFormsData.map((item, index) => {
item.id = index + 1;
return item;
});
};
const handleSave = () => {
@@ -497,8 +475,6 @@ export default {
if (!checkVal(filterData)) {
return false;
}
console.log(12121212);
console.log(filterData);
if (state.assessmentId) {
resultPost = {
@@ -511,8 +487,6 @@ export default {
"assessmentMaxScore",
"assessmentMinScore",
]);
console.log(1212334);
console.log(resultPost);
editResearchMessage(resultPost).then((res) => {
if (res.data.code === 200) {
message.success("编辑成功");

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,

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,