feat(survey): 添加取消投放功能
- 在 survey/index.js 中新增 modify 函数,用于修改投放状态 - 在 Survey/Index.vue 中添加取消投放逻辑 - 优化 Publish/Index.vue 的样式
This commit is contained in:
@@ -74,7 +74,9 @@
|
||||
<el-text style="color: #71b73c">预览</el-text>
|
||||
</el-button>
|
||||
<el-button color="#6fb937" :disabled="item.source === 0" @click="toPublish(item)">
|
||||
<el-text style="color: white">开启投放</el-text>
|
||||
<el-text style="color: white">{{
|
||||
item.status === 1 ? '取消投放' : '开启投放'
|
||||
}}</el-text>
|
||||
</el-button>
|
||||
</div>
|
||||
<el-dropdown
|
||||
@@ -106,6 +108,7 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { getSurveysPage, copySurveys, deleteSurveys, saveTemplates } from '@/api/home/index.js';
|
||||
import { modify } from '@/api/survey/index.js';
|
||||
import { showDialog, showConfirmDialog, showFailToast, showSuccessToast, showToast } from 'vant';
|
||||
import { useRouter } from 'vue-router';
|
||||
const router = useRouter();
|
||||
@@ -134,7 +137,7 @@ const onLoad = () => {
|
||||
fetchSurveys();
|
||||
}, 500);
|
||||
};
|
||||
const fetchSurveys = async() => {
|
||||
const fetchSurveys = async () => {
|
||||
const params = {
|
||||
page: form.value.page,
|
||||
per_page: form.value.pageSize,
|
||||
@@ -172,7 +175,7 @@ const deleteItem = (item) => {
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#03B03C'
|
||||
})
|
||||
.then(async() => {
|
||||
.then(async () => {
|
||||
const res = await deleteSurveys(item.sn);
|
||||
if (res.data.message) {
|
||||
showToast(res.data.message);
|
||||
@@ -196,7 +199,7 @@ const copyItem = (item) => {
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#03B03C'
|
||||
})
|
||||
.then(async() => {
|
||||
.then(async () => {
|
||||
const res = await copySurveys(item.sn);
|
||||
if (res.data.code === 200 || res.data.code === 201) {
|
||||
showSuccessToast('复制成功');
|
||||
@@ -221,12 +224,21 @@ const toPreview = (item) => {
|
||||
});
|
||||
};
|
||||
const toPublish = (item) => {
|
||||
router.push({
|
||||
path: '/publish',
|
||||
query: {
|
||||
sn: item.sn
|
||||
}
|
||||
});
|
||||
if (item.status === 1) {
|
||||
console.log(item);
|
||||
modify({ surveyPublishId: '' }).then((res) => {
|
||||
if (res.data) {
|
||||
// 吧 数据改掉
|
||||
}
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
path: '/publish',
|
||||
query: {
|
||||
sn: item.sn
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
const editItem = (item) => {
|
||||
router.push({
|
||||
@@ -237,7 +249,7 @@ const editItem = (item) => {
|
||||
});
|
||||
};
|
||||
// 保存为模板
|
||||
const saveTemplate = async(item) => {
|
||||
const saveTemplate = async (item) => {
|
||||
const data = JSON.parse(JSON.stringify(item));
|
||||
const res = await saveTemplates(item.sn, data);
|
||||
if (res.data.code === 200 || res.data.code === 201) {
|
||||
|
||||
Reference in New Issue
Block a user