mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 04:16:47 +08:00
部分修改
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
<!-- 评估管理-创建评估页面 -->
|
||||
<template>
|
||||
<a-drawer :visible="createVoteVisible" class="drawerStyle createvoteDrawer" width="100%" placement="right"
|
||||
@after-visible-change="afterVisibleChange">
|
||||
<a-drawer
|
||||
:visible="createVoteVisible"
|
||||
class="drawerStyle createvoteDrawer"
|
||||
width="100%"
|
||||
placement="right"
|
||||
@after-visible-change="afterVisibleChange"
|
||||
>
|
||||
<div class="researchadd">
|
||||
<div class="header">
|
||||
<div class="headerTitle">创建投票</div>
|
||||
<img style="width: 29px; height: 29px; cursor: pointer" src="../../assets/images/basicinfo/close.png"
|
||||
@click="closeDrawer" />
|
||||
<div class="headerTitle">{{ ballotId ? "编辑投票" : "创建投票" }}</div>
|
||||
<img
|
||||
style="width: 29px; height: 29px; cursor: pointer"
|
||||
src="../../assets/images/basicinfo/close.png"
|
||||
@click="closeDrawer"
|
||||
/>
|
||||
</div>
|
||||
<div class="main_left">
|
||||
<div class="main_item">
|
||||
@@ -17,8 +25,12 @@
|
||||
<span style="margin-right: 3px">投票名称:</span>
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-input v-model:value="ballotName" style="width: 424px; height: 32px" placeholder="请输入任务名称"
|
||||
maxlength="20" />
|
||||
<a-input
|
||||
v-model:value="ballotName"
|
||||
style="width: 424px; height: 32px"
|
||||
placeholder="请输入任务名称"
|
||||
maxlength="20"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main_item">
|
||||
@@ -36,26 +48,34 @@
|
||||
</div>
|
||||
|
||||
<div v-for="(item, index) in allFormsData" :key="index">
|
||||
<VoteQuestion v-model:info="information" :item="item" :optionId="optionId" @delOption="delOption"
|
||||
@del="handleDel" @edits="edits" @addOption="addOption" />
|
||||
<VoteQuestion :item="item" @del="handleDel" />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="btn">
|
||||
<a-button type="primary" style="
|
||||
<a-button
|
||||
type="primary"
|
||||
style="
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
background-color: #409eff;
|
||||
" @click="handleSave">
|
||||
"
|
||||
@click="handleSave"
|
||||
>
|
||||
保存
|
||||
</a-button>
|
||||
<a-button type="primary" ghost style="
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
style="
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
margin-left: 14px;
|
||||
border-radius: 8px;
|
||||
" @click="handleAllCancel">
|
||||
"
|
||||
@click="handleAllCancel"
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
</div>
|
||||
@@ -70,7 +90,7 @@ import { message } from "ant-design-vue";
|
||||
import VoteQuestion from "./VoteQuestion.vue";
|
||||
|
||||
import {
|
||||
// sortBy,
|
||||
sortBy,
|
||||
traverseArr,
|
||||
//filterCommon,
|
||||
// deepCloneFilterString,
|
||||
@@ -79,7 +99,7 @@ import {
|
||||
//import store from "@/store";
|
||||
import * as api from "@/api/indexVote";
|
||||
//import { useRouter } from "vue-router";
|
||||
import { } from "@/api/indexResearch";
|
||||
import {} from "@/api/indexResearch";
|
||||
|
||||
//import { message } from "ant-design-vue";
|
||||
|
||||
@@ -107,8 +127,6 @@ export default {
|
||||
ballotId: "",
|
||||
ballotName: "",
|
||||
allFormsData: [],
|
||||
allFormsData1: [],
|
||||
|
||||
});
|
||||
// const router = useRouter();
|
||||
const afterVisibleChange = () => {
|
||||
@@ -116,9 +134,7 @@ export default {
|
||||
getInfoDate();
|
||||
} else {
|
||||
handleTypes();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
const closeDrawer = () => {
|
||||
ctx.emit("update:createVoteVisible", false);
|
||||
@@ -130,49 +146,39 @@ export default {
|
||||
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;
|
||||
}
|
||||
});
|
||||
console.log("res====", res);
|
||||
state.ballotName = res.ballotId;
|
||||
// let renderArr = [...res];
|
||||
// sortBy(renderArr, "orderNumber"); //序号
|
||||
state.allFormsData = parseData(res); //类型
|
||||
state.allFormsData1 = parseData(res); //类型
|
||||
|
||||
console.log(state.allFormsData);
|
||||
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];
|
||||
sortBy(renderArr, "orderNumber"); //序号
|
||||
state.allFormsData = parseData(renderArr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 转换成前端格式
|
||||
const parseData = (arr) => {
|
||||
const resultArr = [];
|
||||
state.ballotId = arr.ballotId;
|
||||
state.ballotName = arr.ballotName;
|
||||
|
||||
console.log("arr.voteStemVoList=====", arr.voteStemVoList);
|
||||
arr.voteStemVoList.forEach((item) => {
|
||||
console.log("arr.voteStemVoList=====", arr);
|
||||
arr.forEach((item) => {
|
||||
let obj = {};
|
||||
let restList = traverseArr(item.optionDetailList, {
|
||||
inputVal: "optionName",
|
||||
imgVal: "optionPictureAddress",
|
||||
optionId: "optionId",
|
||||
voteStemId: "voteStemId",
|
||||
stem: "stem",
|
||||
}).map((itm, idx) => {
|
||||
itm.id = idx + 1;
|
||||
return itm;
|
||||
});
|
||||
|
||||
obj = {
|
||||
voteStemId: item.voteStemId,
|
||||
valueSingle: item.voteStemName,
|
||||
singleList: restList,
|
||||
orderNumber: item.orderNumber,
|
||||
};
|
||||
resultArr.push(obj);
|
||||
});
|
||||
@@ -189,34 +195,25 @@ export default {
|
||||
arr.forEach((item) => {
|
||||
let obj = {};
|
||||
console.log("item=======", item);
|
||||
// if (item[typeKey] === 1) {
|
||||
let restList = traverseArr(item.singleList, {
|
||||
optionName: "inputVal",
|
||||
optionPictureAddress: "imgVal",
|
||||
optionId: "optionId",
|
||||
voteStemId: "voteStemId",
|
||||
stem: "stem",
|
||||
}).map((itm, idx) => {
|
||||
itm.optionOrderNum = idx + 1;
|
||||
return itm;
|
||||
});
|
||||
restList.forEach((item) => {
|
||||
item.optionId = item.optionId
|
||||
? item.optionId
|
||||
: "";
|
||||
item.optionId = item.optionId ? item.optionId : "";
|
||||
});
|
||||
|
||||
obj = {
|
||||
|
||||
voteStemName: item.valueSingle,
|
||||
optionDetailList: restList,
|
||||
voteStemId: item.voteStemId,
|
||||
|
||||
singleList: restList,
|
||||
orderNumber: item.orderNumber,
|
||||
};
|
||||
resultArr.push(obj);
|
||||
// }
|
||||
console.log("resultArr=======", resultArr);
|
||||
|
||||
});
|
||||
resultArr.map((itm, idx) => {
|
||||
itm.orderNumber = idx + 1;
|
||||
@@ -226,40 +223,26 @@ export default {
|
||||
};
|
||||
|
||||
// 解散传值
|
||||
const parseItem = (arrr) => {
|
||||
// const filterComObj = filterCommon(arr, "questionType");
|
||||
const parseItem = (arrSingle) => {
|
||||
console.log("arrSingle");
|
||||
console.log(arrSingle);
|
||||
let resultObj = {};
|
||||
// for (let key in filterComObj) {
|
||||
// if (key === "1") {
|
||||
// let arrSingle = arrr
|
||||
//filterComObj[key];
|
||||
console.log("arrr======", arrr);
|
||||
/*
|
||||
let arr = [];
|
||||
arrSingle.forEach((item) => {
|
||||
console.log("item======",item);
|
||||
if (item.singleList.length) {
|
||||
item.singleList.forEach((itm) => {
|
||||
arr.push({
|
||||
...itm,
|
||||
optionName: item.optionName,
|
||||
optionOrderNum: item.optionOrderNum,
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
});*/
|
||||
resultObj.voteStemDtoList = arrr;
|
||||
// }
|
||||
arr.push({
|
||||
voteStemName: item.voteStemName,
|
||||
orderNumber: item.orderNumber,
|
||||
optionDetailList: item.singleList,
|
||||
});
|
||||
});
|
||||
resultObj.voteStemDtoList = arr;
|
||||
console.log("resultObj======", resultObj);
|
||||
// }
|
||||
return resultObj;
|
||||
};
|
||||
|
||||
|
||||
const handleTypes = () => {
|
||||
let obj = {
|
||||
id: state.allFormsData.length,
|
||||
id: state.allFormsData.length + 1,
|
||||
valueSingle: "",
|
||||
singleList: [
|
||||
{
|
||||
@@ -275,107 +258,49 @@ export default {
|
||||
],
|
||||
};
|
||||
state.allFormsData.push(obj);
|
||||
state.allFormsData1.push(obj);
|
||||
};
|
||||
|
||||
const handleDel = ({ id }) => {
|
||||
console.log('1234523432434234234', id, state.allFormsData)
|
||||
const handleDel = ({ id, curItem }) => {
|
||||
console.log(888888888);
|
||||
console.log(id);
|
||||
console.log(curItem);
|
||||
|
||||
state.allFormsData.forEach((item, index) => {
|
||||
if (item.id === id) {
|
||||
console.log('oooooo', item)
|
||||
state.allFormsData.splice(index, 1);
|
||||
}
|
||||
});
|
||||
console.log(5656777777777);
|
||||
console.log(state.allFormsData);
|
||||
state.allFormsData.map((item, index) => {
|
||||
item.id = index + 1;
|
||||
return item;
|
||||
});
|
||||
|
||||
// state.allFormsData.map((item, index) => {
|
||||
// item.id = index + 1;
|
||||
// return item;
|
||||
// });
|
||||
|
||||
// orderNumber: curItem.orderNumber,
|
||||
api.deleteVoteStem(curItem.voteStemId).then((res) => {
|
||||
console.log(56444);
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
|
||||
const delOption = (data) => {
|
||||
console.log('datadatadatadatadata', data, state.allFormsData)
|
||||
state.allFormsData.forEach((item, index) => {
|
||||
if (item.voteStemId === data.value.voteStemId) {
|
||||
state.allFormsData[index].singleList.forEach((ii, nn) => {
|
||||
if (ii.id == data.value.id) {
|
||||
console.log(1212121212, state.allFormsData[index].singleList[nn], nn)
|
||||
state.allFormsData[index].singleList.splice(nn, 1)
|
||||
console.log('12', state.allFormsData)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
state.allFormsData1.forEach((item, index) => {
|
||||
if (item.voteStemId === data.value.voteStemId) {
|
||||
state.allFormsData1[index].singleList.forEach((ii, nn) => {
|
||||
if (ii.id == data.value.id) {
|
||||
console.log(1212121212, state.allFormsData1[index].singleList[nn], nn)
|
||||
state.allFormsData1[index].singleList.splice(nn, 1)
|
||||
console.log('33', state.allFormsData1)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
const edits = (data) => {
|
||||
console.log('我传递过来了吗---111', data, data.value.id, state.allFormsData1)
|
||||
|
||||
state.allFormsData1.forEach((item, index) => {
|
||||
if (item.voteStemId === data.value.voteStemId) {
|
||||
item.singleList.forEach((ii, nn) => {
|
||||
if (ii.id === data.value.id) {
|
||||
// ii.optionName = data.value.inputVal
|
||||
state.allFormsData1[index].singleList[nn].inputVal = data.value.inputVal
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
console.log('123-456-789', state.allFormsData1)
|
||||
}
|
||||
|
||||
// 增加选项
|
||||
const addOption = (data) => {
|
||||
console.log(data)
|
||||
state.allFormsData1.forEach((item, index) => {
|
||||
if (item.voteStemId === data.value.voteStemId) {
|
||||
state.allFormsData1[index].singleList = data.value.singleList
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const handleSave = () => {
|
||||
|
||||
|
||||
let resultPost = {};
|
||||
let filterData = parseItem(restData(state.allFormsData));
|
||||
|
||||
let filterData = parseItem(restData(state.allFormsData1, "type"));
|
||||
|
||||
console.log("filterData==111", filterData)
|
||||
|
||||
if (!state.ballotName) {
|
||||
return message.warning("请输入投票名称");
|
||||
}
|
||||
// 校验s
|
||||
console.log("filterData==111", filterData);
|
||||
|
||||
// 校验
|
||||
if (!state.ballotName) {
|
||||
message.warning("请输入投票名称");
|
||||
return false;
|
||||
}
|
||||
if (!checkVal(filterData)) {
|
||||
return false;
|
||||
}
|
||||
// checkVal(filterData);
|
||||
console.log(12121212);
|
||||
console.log(filterData);
|
||||
console.log('111111222223333----0000', state.ballotId)
|
||||
console.log("111111222223333----0000", state.ballotId);
|
||||
|
||||
if (state.ballotId) {
|
||||
resultPost = {
|
||||
ballotId: state.ballotId,
|
||||
@@ -391,7 +316,7 @@ export default {
|
||||
console.log(resultPost);
|
||||
api.updateStemMessage(resultPost).then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
state.ballotId = res.data.data.ballotId
|
||||
state.ballotId = res.data.data.ballotId;
|
||||
console.log("res.data.data==============", res.data.data);
|
||||
console.log("res.state.ballotId==============", state.ballotId);
|
||||
message.success("编辑成功");
|
||||
@@ -408,11 +333,10 @@ export default {
|
||||
"assessmentMaxScore",
|
||||
"assessmentMinScore",
|
||||
]);*/
|
||||
|
||||
console.log("=========", resultPost);
|
||||
api.createStemMessage(resultPost).then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
state.ballotId = res.data.data.ballotId
|
||||
state.ballotId = res.data.data.ballotId;
|
||||
console.log("res.data.data2==============", res.data.data);
|
||||
console.log("res.state.ballotId=2s=============", state.ballotId);
|
||||
message.success("创建成功");
|
||||
@@ -420,7 +344,6 @@ export default {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
const handleAllCancel = () => {
|
||||
state.allFormsData = [];
|
||||
@@ -447,7 +370,6 @@ export default {
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
handleTypes,
|
||||
@@ -456,9 +378,6 @@ export default {
|
||||
handleDel,
|
||||
afterVisibleChange,
|
||||
closeDrawer,
|
||||
edits,
|
||||
delOption,
|
||||
addOption
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user