mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 04:16:47 +08:00
--fix 添加投票
This commit is contained in:
@@ -1,45 +1,28 @@
|
||||
<!-- 评估管理-创建评估页面 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:visible="createVoteVisible"
|
||||
class="drawerStyle createvoteDrawer"
|
||||
width="100%"
|
||||
placement="right"
|
||||
@after-visible-change="afterVisibleChange"
|
||||
:visible="createVoteVisible"
|
||||
class="drawerStyle createvoteDrawer"
|
||||
width="100%"
|
||||
placement="right"
|
||||
@after-visible-change="afterVisibleChange"
|
||||
>
|
||||
<div class="researchadd">
|
||||
<div class="header">
|
||||
<div class="headerTitle">{{ ballotId ? "编辑投票题干" : "创建投票题干" }}</div>
|
||||
<img
|
||||
style="width: 29px; height: 29px; cursor: pointer"
|
||||
src="../../assets/images/basicinfo/close.png"
|
||||
@click="closeDrawer"
|
||||
style="width: 29px; height: 29px; cursor: pointer"
|
||||
src="../../assets/images/basicinfo/close.png"
|
||||
@click="closeDrawer"
|
||||
/>
|
||||
</div>
|
||||
<div class="main_left">
|
||||
<!-- <div class="main_item">
|
||||
|
||||
<div class="signbox">
|
||||
<div class="sign">
|
||||
<img src="@/assets/images/coursewareManage/asterisk.png" alt="" />
|
||||
</div>
|
||||
<span style="margin-right: 3px">投票名称:</span>
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-input
|
||||
v-model:value="ballotName"
|
||||
style="width: 424px; height: 32px"
|
||||
placeholder="请输入任务名称"
|
||||
maxlength="20"
|
||||
/>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="main_item">
|
||||
<div class="signbox">
|
||||
<div class="sign">
|
||||
<img
|
||||
src="@/assets/images/coursewareManage/asterisk.png"
|
||||
alt="asterisk"
|
||||
src="@/assets/images/coursewareManage/asterisk.png"
|
||||
alt="asterisk"
|
||||
/>
|
||||
</div>
|
||||
<span>创建题干:</span>
|
||||
@@ -48,40 +31,38 @@
|
||||
<button class="xkbtn" @click="handleTypes">添加题干</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 创建投票侧弹窗 -->
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="(item, index) in allFormsData"
|
||||
:key="index + new Date().getTime()"
|
||||
v-for="(item, index) in allFormsData"
|
||||
:key="index + new Date().getTime()"
|
||||
>
|
||||
<VoteQuestion :item="item" @del="handleDel" />
|
||||
<VoteQuestion :item="item" @del="handleDel"/>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="btn">
|
||||
<a-button
|
||||
type="primary"
|
||||
style="
|
||||
type="primary"
|
||||
style="
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
background-color: #4ea6ff;
|
||||
"
|
||||
@click="handleSave"
|
||||
@click="handleSave"
|
||||
>
|
||||
保存
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
style="
|
||||
type="primary"
|
||||
ghost
|
||||
style="
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
margin-left: 14px;
|
||||
border-radius: 8px;
|
||||
"
|
||||
@click="handleAllCancel"
|
||||
@click="handleAllCancel"
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
@@ -91,19 +72,11 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
<script>
|
||||
import { reactive, toRefs, toRef, watch } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
// import { createResearch } from "../../api/indexResearch";
|
||||
import {reactive, toRefs, toRef, watch} from "vue";
|
||||
import {message} from "ant-design-vue";
|
||||
import VoteQuestion from "./VoteQuestion.vue";
|
||||
|
||||
import { sortBy, traverseArr } from "../../utils/utils";
|
||||
|
||||
//import store from "@/store";
|
||||
import {sortBy, traverseArr} from "../../utils/utils";
|
||||
import * as api from "@/api/indexVote";
|
||||
//import { useRouter } from "vue-router";
|
||||
import {} from "@/api/indexResearch";
|
||||
|
||||
//import { message } from "ant-design-vue";
|
||||
|
||||
export default {
|
||||
name: "CreateVote",
|
||||
@@ -115,37 +88,26 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
ballotId: {
|
||||
voteId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
ballot_name: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
editChild: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
setup(props, ctx) {
|
||||
const ballotIdWatch = toRef(props, "ballotId");
|
||||
const ballotIdWatch = toRef(props, "voteId");
|
||||
const state = reactive({
|
||||
ballotId: "",
|
||||
ballotName: "",
|
||||
voteId: "",
|
||||
allFormsData: [],
|
||||
});
|
||||
watch(ballotIdWatch, (newValue) => {
|
||||
if (!newValue) {
|
||||
state.ballotId = "";
|
||||
state.ballotName = "";
|
||||
state.voteId = "";
|
||||
state.allFormsData = [];
|
||||
}
|
||||
});
|
||||
|
||||
// const router = useRouter();
|
||||
const afterVisibleChange = () => {
|
||||
if (props.ballotId) {
|
||||
if (props.voteId) {
|
||||
getInfoDate();
|
||||
} else {
|
||||
handleTypes();
|
||||
@@ -154,22 +116,14 @@ export default {
|
||||
const closeDrawer = () => {
|
||||
handleAllCancel();
|
||||
ctx.emit("update:createVoteVisible", false);
|
||||
ctx.emit("update:ballotId", state.ballotId);
|
||||
ctx.emit("update:ballot_name", state.ballotName);
|
||||
ctx.emit("update:voteId", state.voteId);
|
||||
};
|
||||
// 详情
|
||||
const getInfoDate = async () => {
|
||||
console.log("props.editChild=====", props.editChild);
|
||||
if (props.ballotId) {
|
||||
console.log("props.editChild2=====", props.editChild);
|
||||
let res = await api.queryStemByStemId(props.ballotId).then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
return res.data.data;
|
||||
}
|
||||
});
|
||||
state.ballotId = res.ballotId;
|
||||
state.ballotName = res.ballotName;
|
||||
let renderArr = [...res.voteStemVoList];
|
||||
if (props.voteId) {
|
||||
let res = await api.queryStemByStemId(props.voteId).then((res) => res.data.data);
|
||||
state.voteId = res.id;
|
||||
let renderArr = [...res.voteStemDtoList];
|
||||
sortBy(renderArr, "orderNumber"); //序号
|
||||
state.allFormsData = parseData(renderArr);
|
||||
}
|
||||
@@ -264,7 +218,7 @@ export default {
|
||||
state.allFormsData.push(obj);
|
||||
};
|
||||
|
||||
const handleDel = ({ id, curItem }) => {
|
||||
const handleDel = ({id, curItem}) => {
|
||||
if (state.allFormsData.length > 1) {
|
||||
// 接口删除
|
||||
if (curItem.voteStemId) {
|
||||
@@ -292,57 +246,24 @@ export default {
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
let resultPost = {};
|
||||
let filterData = restData(state.allFormsData);
|
||||
console.log("555555555555555555", filterData);
|
||||
|
||||
// 校验
|
||||
|
||||
if (!checkVal(filterData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state.ballotId) {
|
||||
resultPost = {
|
||||
ballotId: state.ballotId,
|
||||
ballotName: state.ballotName,
|
||||
voteStemDtoList: filterData,
|
||||
};
|
||||
console.log("resultPostresultPost");
|
||||
console.log(resultPost);
|
||||
api.updateStemMessage(resultPost).then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
state.ballotId = res.data.data.ballotId;
|
||||
console.log("res.data.data==============", res.data.data);
|
||||
console.log("res.state.ballotId==============", state.ballotId);
|
||||
message.success("编辑成功");
|
||||
closeDrawer();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resultPost = {
|
||||
ballotName: state.ballotName,
|
||||
voteStemDtoList: filterData,
|
||||
};
|
||||
console.log("=========", resultPost);
|
||||
api.createStemMessage(resultPost).then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
state.ballotId = res.data.data.ballotId;
|
||||
console.log("res.data.data2==============", res.data.data);
|
||||
console.log("res.state.ballotId=2s=============", state.ballotId);
|
||||
message.success("创建成功");
|
||||
closeDrawer();
|
||||
}
|
||||
});
|
||||
}
|
||||
api.createStemMessage({
|
||||
id: state.voteId,
|
||||
voteStemDtoList: filterData,
|
||||
}).then((res) => {
|
||||
message.success(state.voteId ? "修改成功" : "创建成功");
|
||||
state.voteId = res.data.data.id;
|
||||
closeDrawer();
|
||||
});
|
||||
};
|
||||
const handleAllCancel = () => {
|
||||
state.allFormsData = [];
|
||||
};
|
||||
|
||||
const checkVal = (filterData) => {
|
||||
console.log("filterData.====", filterData);
|
||||
|
||||
for (let item of filterData) {
|
||||
if (!item.voteStemName) {
|
||||
message.error("题干为必填 请确认");
|
||||
|
||||
Reference in New Issue
Block a user