mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-22 17:26:46 +08:00
-- fix 投票bug
This commit is contained in:
@@ -34,37 +34,37 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="(_, index) in formData.list" :key="index">
|
||||
<VoteQuestion v-model:item="formData[index]" :index="index" @del="itemDel"/>
|
||||
<div v-for="(item, index) in formData" :key="index+Math.random()">
|
||||
<VoteQuestion v-if="!item.deleted" :item="item" :index="index" @del="itemDel"/>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="btn">
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
style="
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
"
|
||||
@click="closeDrawer"
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
style="
|
||||
margin-left: 14px;
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
background-color: #4ea6ff;
|
||||
"
|
||||
@click="confirm"
|
||||
>
|
||||
保存
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
style="
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
margin-left: 14px;
|
||||
border-radius: 8px;
|
||||
"
|
||||
@click="closeDrawer"
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,64 +73,58 @@
|
||||
<script setup>
|
||||
import {defineEmits, defineProps, ref, watch} from "vue";
|
||||
import VoteQuestion from "./VoteQuestion.vue";
|
||||
import {message} from "ant-design-vue";
|
||||
|
||||
const prop = defineProps({
|
||||
options: [],
|
||||
list: []
|
||||
const props = defineProps({
|
||||
options: []
|
||||
})
|
||||
const emit = defineEmits({})
|
||||
const formData = ref({list: [{}]})
|
||||
const initData = ref({list: [{}]})
|
||||
|
||||
console.log(prop.options.length);
|
||||
const emit = defineEmits({})
|
||||
const formData = ref(props.options && props.options.length ? [...props.options] : [{
|
||||
voteStemName: '',
|
||||
optionDetailList: []
|
||||
}])
|
||||
|
||||
const visible = ref(false)
|
||||
|
||||
function openDrawer() {
|
||||
|
||||
if (prop.options.length > 0) {
|
||||
|
||||
for(let i in initData.value) {
|
||||
console.log(formData.value[i])
|
||||
if (initData.value[i].valueSingle != formData.value[i].valueSingle) {
|
||||
console.log('不等于')
|
||||
formData.value[i].valueSingle = initData.value[i].valueSingle
|
||||
}
|
||||
}
|
||||
watch(() => props.options.length, () => {
|
||||
formData.value = props.options && props.options.length ? [...props.options] : [{
|
||||
voteStemName: '',
|
||||
optionDetailList: []
|
||||
}]
|
||||
})
|
||||
|
||||
}else {
|
||||
formData.value.list = []
|
||||
setTimeout(() =>{
|
||||
formData.value.list = [{}]
|
||||
}, 100)
|
||||
}
|
||||
function openDrawer() {
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
watch(formData.value, () => {
|
||||
console.log('111',formData.value)
|
||||
})
|
||||
|
||||
const closeDrawer = () => {
|
||||
console.log('formData',formData.value)
|
||||
// formData.value = JSON.parse(JSON.stringify(initData.value));
|
||||
visible.value = false
|
||||
formData.value = props.options && props.options.length ? [...props.options] : [{
|
||||
voteStemName: '',
|
||||
optionDetailList: []
|
||||
}]
|
||||
};
|
||||
|
||||
async function confirm() {
|
||||
console.log('confirm');
|
||||
initData.value = JSON.parse(JSON.stringify(formData.value));
|
||||
emit('update:options', formData.value.list)
|
||||
// closeDrawer()
|
||||
console.log(formData.value)
|
||||
if (formData.value.some(t => !t.voteStemName && !t.deleted)) {
|
||||
message.warning('请输入题干名称')
|
||||
return
|
||||
}
|
||||
visible.value = false
|
||||
emit('update:options', formData.value)
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
formData.value.list.push({})
|
||||
formData.value.push({
|
||||
voteStemName: '',
|
||||
optionDetailList: []
|
||||
})
|
||||
}
|
||||
|
||||
function itemDel(i) {
|
||||
formData.value.list.splice(i, 1)
|
||||
formData.value[i].deleted = true
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user