1.日常考评菜单分类重写
2.增加月度,季度,年度考评评价 3.增加员工个人档案,和档案列表 4.增加考评评价管理 4.日常填报中增加考评列表,展示总加分和总减分,并且可以查看详情
This commit is contained in:
parent
1631322c5d
commit
251689fad9
2
auto-imports.d.ts
vendored
2
auto-imports.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
// Generated by 'unplugin-auto-import'
|
// Generated by 'unplugin-auto-import'
|
||||||
export {}
|
export {}
|
||||||
declare global {
|
declare global {
|
||||||
const layer: typeof import('@layui/layer-vue')['layer']
|
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,55 @@ export function evaluationGroupIndexrecordsList(data: any) {
|
|||||||
return Http.post('/api/backend/Evaluate/groupIndexrecordsList', data)
|
return Http.post('/api/backend/Evaluate/groupIndexrecordsList', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 教育列表
|
||||||
|
export function educationList(data: any) {
|
||||||
|
return Http.post('/api/backend/party_style/getPartyStylData', data)
|
||||||
|
}
|
||||||
|
// 教育新增
|
||||||
|
export function educationCreate(data: any) {
|
||||||
|
return Http.post('/api/backend/party_style/create', data)
|
||||||
|
}
|
||||||
|
// 教育编辑
|
||||||
|
export function educationUpdate(data: any) {
|
||||||
|
return Http.post('/api/backend/party_style/update', data)
|
||||||
|
}
|
||||||
|
// 教育删除
|
||||||
|
export function educationDelete(data: any) {
|
||||||
|
return Http.post('/api/backend/party_style/delete', data)
|
||||||
|
}
|
||||||
|
// 问卷列表
|
||||||
|
export function getQuestionnaireIndex(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/questionnaireIndex', data)
|
||||||
|
}
|
||||||
|
// 问卷列表新增
|
||||||
|
export function getQuestionnaireInfoAdd(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/questionnaireAdd', data)
|
||||||
|
}
|
||||||
|
// 问卷列表编辑
|
||||||
|
export function getQuestionnaireInfoEdit(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/questionnaireEdit', data)
|
||||||
|
}
|
||||||
|
// 问卷列表删除
|
||||||
|
export function getQuestionnaireInfoDelete(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/questionnaireDel', data)
|
||||||
|
}
|
||||||
|
// 问卷列表删除
|
||||||
|
export function getQuestionnaireInfoFind(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/questionnairefind', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问卷列表编辑
|
||||||
|
export function getQuestionnaireEdit(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/topicEdit', data)
|
||||||
|
}
|
||||||
|
// 问卷列表删除
|
||||||
|
export function getQuestionnaireDelete(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/topicDel', data)
|
||||||
|
}
|
||||||
|
// 问卷列表新增
|
||||||
|
export function getQuestionnaireAdd(data: any) {
|
||||||
|
return Http.post('/api/backend/questionnaire/topicAdd', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<lay-card>
|
<lay-card>
|
||||||
<div style="padding: 10px">
|
<div style="padding: 10px">
|
||||||
<span style="font-size: 18px;vertical-align: center;margin-right: 20px">党风廉政教育</span>
|
<span style="font-size: 18px;vertical-align: center;margin-right: 20px">党风廉政教育</span>
|
||||||
<lay-button type="primary" @click="openNew()" size="sm">新增教育</lay-button>
|
<lay-button v-if="userStore.userInfo.level == 4" type="primary" @click="openNew()" size="sm">新增内容</lay-button>
|
||||||
</div>
|
</div>
|
||||||
<lay-table :page="page" height="600px" size="lg" @change="changePage" :columns="columns" :data-source="dataSource">
|
<lay-table :page="page" height="600px" size="lg" @change="changePage" :columns="columns" :data-source="dataSource">
|
||||||
<!-- <template v-slot:content="{ data }">
|
<!-- <template v-slot:content="{ data }">
|
||||||
@ -15,6 +15,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-slot:operator="{ data }">
|
<template v-slot:operator="{ data }">
|
||||||
<lay-space size="lg">
|
<lay-space size="lg">
|
||||||
|
<span style="color: #00A394;cursor: pointer" @click="viewDetail(data)">查看</span>
|
||||||
<span style="color: #00A394;cursor: pointer" @click="editShowMsd(data)">编辑</span>
|
<span style="color: #00A394;cursor: pointer" @click="editShowMsd(data)">编辑</span>
|
||||||
<lay-popconfirm trigger="click" content="确定要删除吗?" @confirm="delShowMsd(data)">
|
<lay-popconfirm trigger="click" content="确定要删除吗?" @confirm="delShowMsd(data)">
|
||||||
<span style="color: #00A394;cursor: pointer">删除</span>
|
<span style="color: #00A394;cursor: pointer">删除</span>
|
||||||
@ -27,43 +28,46 @@
|
|||||||
:area="['950px', '100%']" :btn="addButton">
|
:area="['950px', '100%']" :btn="addButton">
|
||||||
<lay-container fluid="true" style="padding: 20px">
|
<lay-container fluid="true" style="padding: 20px">
|
||||||
<lay-form :model="addData">
|
<lay-form :model="addData">
|
||||||
<lay-form-item required label="内容标题" prop="title">
|
<lay-form-item required label="内容标题" prop="party_style_name">
|
||||||
<lay-input v-model="addData.title" placeholder="请输入教育标题"></lay-input>
|
<lay-input v-model="addData.party_style_name" placeholder="请输入教育标题"></lay-input>
|
||||||
</lay-form-item>
|
</lay-form-item>
|
||||||
<lay-form-item required label="发布人" prop="author">
|
<lay-form-item required label="教育内容" prop="party_style_countent">
|
||||||
<lay-input v-model="addData.author" placeholder="请输入发布人"></lay-input>
|
|
||||||
</lay-form-item>
|
|
||||||
<lay-form-item required label="教育内容" prop="content">
|
|
||||||
<div class="editor">
|
<div class="editor">
|
||||||
<!-- 这两个都是获取值的必要条件: v-model:content contentType="html" -->
|
|
||||||
<quill-editor ref="editorRef" v-model:content="content" :options="options"
|
<quill-editor ref="editorRef" v-model:content="content" :options="options"
|
||||||
contentType="html"></quill-editor>
|
contentType="html"></quill-editor>
|
||||||
</div>
|
</div>
|
||||||
</lay-form-item>
|
</lay-form-item>
|
||||||
<lay-form-item required label="状态" prop="status">
|
|
||||||
<lay-select v-model="addData.status" placeholder="请选择">
|
|
||||||
<lay-select-option :value="0" label="隐藏"></lay-select-option>
|
|
||||||
<lay-select-option :value="1" label="显示"></lay-select-option>
|
|
||||||
</lay-select>
|
|
||||||
</lay-form-item>
|
|
||||||
</lay-form>
|
</lay-form>
|
||||||
</lay-container>
|
</lay-container>
|
||||||
</lay-layer>
|
</lay-layer>
|
||||||
|
<lay-layer v-model="detailShow" title="党风廉政教育详情" :type="4" :shade="true"
|
||||||
|
:area="['950px', '100%']" :btn="detailButton">
|
||||||
|
<lay-container fluid="true" style="padding: 20px">
|
||||||
|
<h2 style="text-align: center; margin-bottom: 20px;">{{detailData.party_style_name}}</h2>
|
||||||
|
<div class="detail-content" v-html="detailData.party_style_countent"></div>
|
||||||
|
</lay-container>
|
||||||
|
</lay-layer>
|
||||||
</lay-container>
|
</lay-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
uploadImage
|
uploadImage,
|
||||||
|
educationList,
|
||||||
|
educationCreate,
|
||||||
|
educationUpdate,
|
||||||
|
educationDelete
|
||||||
} from '../../api/module/home'
|
} from '../../api/module/home'
|
||||||
import { ref, onMounted, reactive, shallowRef, watch, nextTick, toRaw } from 'vue'
|
import { ref, onMounted, reactive, shallowRef, watch, nextTick, toRaw } from 'vue'
|
||||||
import { layer } from '@layui/layer-vue'
|
import { layer } from '@layui/layer-vue'
|
||||||
import { baseURL } from '@/api/http'
|
import { baseURL } from '@/api/http'
|
||||||
|
import { useUserStore } from '@/store/user'
|
||||||
|
const userStore = useUserStore()
|
||||||
// Update editor configuration
|
// Update editor configuration
|
||||||
// 引入富文本编辑器与样式
|
// 引入富文本编辑器与样式
|
||||||
import { Quill, QuillEditor } from '@vueup/vue-quill'
|
import { Quill, QuillEditor } from '@vueup/vue-quill'
|
||||||
import '@vueup/vue-quill/dist/vue-quill.snow.css'
|
import '@vueup/vue-quill/dist/vue-quill.snow.css'
|
||||||
|
const addShow = ref(false);
|
||||||
const content = ref('')
|
const content = ref('')
|
||||||
const editorRef = ref<any>(null)
|
const editorRef = ref<any>(null)
|
||||||
// !!!如果方法报错,把imageHandler 方法放到options的上面
|
// !!!如果方法报错,把imageHandler 方法放到options的上面
|
||||||
@ -241,6 +245,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openNew = () => {
|
||||||
|
addShow.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 自定义粘贴事件
|
// 自定义粘贴事件
|
||||||
const customPaste = (e: ClipboardEvent) => {
|
const customPaste = (e: ClipboardEvent) => {
|
||||||
// Prevent default paste behavior
|
// Prevent default paste behavior
|
||||||
@ -257,28 +266,26 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface EducationData {
|
|
||||||
id?: number;
|
|
||||||
title: string;
|
|
||||||
author: string;
|
|
||||||
content: string;
|
|
||||||
status: number;
|
|
||||||
}
|
|
||||||
// 分页变化
|
// 分页变化
|
||||||
const changePage = (ppc) => {
|
const changePage = (ppc: { current: number; limit: number }) => {
|
||||||
page.current = ppc.current;
|
page.current = ppc.current;
|
||||||
page.limit = ppc.limit;
|
page.limit = ppc.limit;
|
||||||
getNoticeList();
|
getNoticeList();
|
||||||
}
|
}
|
||||||
// 列表数据
|
// 列表数据
|
||||||
const dataSource = ref<EducationData[]>([]);
|
const dataSource = ref([]);
|
||||||
const addShow = ref(false);
|
|
||||||
// 1 add 2 edit
|
// 1 add 2 edit
|
||||||
const addIsEdit = ref(1);
|
const addIsEdit = ref(1);
|
||||||
|
|
||||||
|
// 定义数据类型接口
|
||||||
|
interface EducationData {
|
||||||
|
id: number;
|
||||||
|
party_style_name: string;
|
||||||
|
party_style_countent: string;
|
||||||
|
status?: number; // 添加可选的状态字段,如果后端支持
|
||||||
|
}
|
||||||
|
|
||||||
// 修改分页参数定义
|
// 修改分页参数定义
|
||||||
const page = reactive({
|
const page = reactive({
|
||||||
current: 1,
|
current: 1,
|
||||||
@ -286,17 +293,17 @@
|
|||||||
total: 1
|
total: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 修改数据结构以匹配数据库字段
|
||||||
const addData = reactive<EducationData>({
|
const addData = reactive<EducationData>({
|
||||||
title: '',
|
id: 0,
|
||||||
author: '',
|
party_style_name: '',
|
||||||
content: '',
|
party_style_countent: ''
|
||||||
status: 1
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
//getNoticeList()
|
getNoticeList()
|
||||||
|
|
||||||
// Wait for editor to be mounted and initialized
|
// Wait for editor to be mounted and initialized
|
||||||
// nextTick(() => {
|
// nextTick(() => {
|
||||||
@ -312,19 +319,9 @@
|
|||||||
// })
|
// })
|
||||||
});
|
});
|
||||||
|
|
||||||
const openNew = () => {
|
|
||||||
addData.id = undefined;
|
|
||||||
addData.title = '';
|
|
||||||
addData.author = '';
|
|
||||||
addData.content = '';
|
|
||||||
content.value = '';
|
|
||||||
addData.status = 1;
|
|
||||||
addIsEdit.value = 1;
|
|
||||||
addShow.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getNoticeList = () => {
|
const getNoticeList = () => {
|
||||||
noticeList({ page: page.current, size: page.limit }).then((res) => {
|
educationList({ page: page.current, size: page.limit }).then((res: any) => {
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
dataSource.value = res.data.data;
|
dataSource.value = res.data.data;
|
||||||
page.total = res.data.count;
|
page.total = res.data.count;
|
||||||
@ -337,21 +334,19 @@
|
|||||||
const editShowMsd = (data: EducationData) => {
|
const editShowMsd = (data: EducationData) => {
|
||||||
addShow.value = true;
|
addShow.value = true;
|
||||||
addData.id = data.id;
|
addData.id = data.id;
|
||||||
addData.title = data.title;
|
addData.party_style_name = data.party_style_name;
|
||||||
addData.author = data.author;
|
addData.party_style_countent = data.party_style_countent;
|
||||||
addData.content = data.content;
|
content.value = data.party_style_countent;
|
||||||
content.value = data.content;
|
|
||||||
addData.status = parseInt(data.status.toString());
|
|
||||||
addIsEdit.value = 2;
|
addIsEdit.value = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch for changes in valueHtml and update addData.content
|
// 监听内容变化
|
||||||
watch(content, (newValue) => {
|
watch(content, (newValue) => {
|
||||||
addData.content = newValue;
|
addData.party_style_countent = newValue;
|
||||||
})
|
})
|
||||||
|
|
||||||
const delShowMsd = async (data: EducationData) => {
|
const delShowMsd = async (data: EducationData) => {
|
||||||
const res = await noticeDelete({ id: data.id });
|
const res = await educationDelete({ id: data.id });
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
layer.msg('删除成功!', { icon: 1 })
|
layer.msg('删除成功!', { icon: 1 })
|
||||||
getNoticeList();
|
getNoticeList();
|
||||||
@ -362,32 +357,15 @@
|
|||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: "教育标题",
|
title: "内容标题",
|
||||||
width: "180px",
|
width: "180px",
|
||||||
key: "title"
|
key: "party_style_name"
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "发布人",
|
|
||||||
width: "120px",
|
|
||||||
key: "author"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "教育内容",
|
|
||||||
width: "280px",
|
|
||||||
key: "content",
|
|
||||||
ellipsisTooltip: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "发布时间",
|
title: "发布时间",
|
||||||
width: "180px",
|
width: "180px",
|
||||||
key: "createtime"
|
key: "createtime"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "状态",
|
|
||||||
width: "100px",
|
|
||||||
customSlot: 'status',
|
|
||||||
key: "status"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: '120px',
|
width: '120px',
|
||||||
@ -404,24 +382,22 @@
|
|||||||
{
|
{
|
||||||
text: "确认",
|
text: "确认",
|
||||||
callback: async () => {
|
callback: async () => {
|
||||||
console.log(addData);
|
// 取消调试用的return语句
|
||||||
return;
|
// console.log(addData);
|
||||||
if (addData.title == '') {
|
// return;
|
||||||
|
|
||||||
|
if (addData.party_style_name === '') {
|
||||||
layer.msg('教育标题不能为空!', { icon: 2 })
|
layer.msg('教育标题不能为空!', { icon: 2 })
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (addData.author == '') {
|
if (addData.party_style_countent === '') {
|
||||||
layer.msg('发布人不能为空!', { icon: 2 })
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (addData.content == '') {
|
|
||||||
layer.msg('教育内容不能为空!', { icon: 2 })
|
layer.msg('教育内容不能为空!', { icon: 2 })
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = addIsEdit.value == 1
|
const res = addIsEdit.value == 1
|
||||||
? await noticeAdd(addData)
|
? await educationCreate(addData)
|
||||||
: await noticeEdit(addData);
|
: await educationUpdate(addData);
|
||||||
|
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
layer.msg('提交成功!', { icon: 1 })
|
layer.msg('提交成功!', { icon: 1 })
|
||||||
@ -439,6 +415,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// 详情查看相关
|
||||||
|
const detailShow = ref(false);
|
||||||
|
const detailData = reactive<EducationData>({
|
||||||
|
id: 0,
|
||||||
|
party_style_name: '',
|
||||||
|
party_style_countent: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const viewDetail = (data: EducationData) => {
|
||||||
|
detailShow.value = true;
|
||||||
|
detailData.id = data.id;
|
||||||
|
detailData.party_style_name = data.party_style_name;
|
||||||
|
detailData.party_style_countent = data.party_style_countent;
|
||||||
|
}
|
||||||
|
|
||||||
|
const detailButton = ref([
|
||||||
|
{
|
||||||
|
text: "关闭",
|
||||||
|
callback: () => {
|
||||||
|
detailShow.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
:deep(.w-e-text-container) {
|
:deep(.w-e-text-container) {
|
||||||
@ -462,5 +462,10 @@
|
|||||||
:deep(.layui-input-block){
|
:deep(.layui-input-block){
|
||||||
max-width: 85%;
|
max-width: 85%;
|
||||||
}
|
}
|
||||||
|
:deep(.detail-content) {
|
||||||
|
padding: 10px;
|
||||||
|
max-height: calc(100vh - 200px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -1,7 +1,414 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<lay-container style="padding: 20px">
|
||||||
<h1>问卷发布</h1>
|
<lay-card>
|
||||||
</div>
|
<div style="padding: 10px">
|
||||||
|
<span style="font-size: 18px;vertical-align: center;margin-right: 20px">党风廉政教育问卷</span>
|
||||||
|
<lay-button type="primary" @click="openNew()" size="sm">新增问卷</lay-button>
|
||||||
|
</div>
|
||||||
|
<lay-table @change="changePage" :page="page" size="lg" ref="tableRef6" children-column-name="children"
|
||||||
|
:columns="columns6" :data-source="dataSource6">
|
||||||
|
<template v-slot:status="{ data }">
|
||||||
|
<span v-if="data.status == '1'">启用</span>
|
||||||
|
<span v-if="data.status == '0'">禁用</span>
|
||||||
|
</template>
|
||||||
|
<template v-slot:weigh="{ data }">
|
||||||
|
<lay-input v-model="data.weigh" type="number" @input="weighUpdate(data)" />
|
||||||
|
</template>
|
||||||
|
<template v-slot:operator="{ data }">
|
||||||
|
<lay-space size="lg">
|
||||||
|
<span style="color: #00A394;cursor: pointer" @click="addShowMsd(data, data.id)">新增题目</span>
|
||||||
|
<span style="color: #00A394;cursor: pointer" @click="editShowQuestMsd(data.id)">编辑题目</span>
|
||||||
|
<span style="color: #00A394;cursor: pointer" @click="editShowMsd(data)">编辑</span>
|
||||||
|
<lay-popconfirm trigger="click" content="确定要删除吗?" @confirm="delShowMsd(data)">
|
||||||
|
<span style="color: #00A394;cursor: pointer">删除</span>
|
||||||
|
</lay-popconfirm>
|
||||||
|
</lay-space>
|
||||||
|
</template>
|
||||||
|
</lay-table>
|
||||||
|
</lay-card>
|
||||||
|
<lay-layer v-model="addShow" :title="addIsEdit == 1 ? '新增问卷' : '新增问卷'" :shade="true" :area="['500px', '500px']"
|
||||||
|
:btn="addButton">
|
||||||
|
<lay-container fluid="true" style="padding: 20px">
|
||||||
|
<lay-form :model="addData">
|
||||||
|
<lay-form-item required label="问卷标题" prop="title">
|
||||||
|
<lay-input v-model="addData.title" placeholder="请输入菜单名称"></lay-input>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item required label="问卷简介" prop="title">
|
||||||
|
<lay-textarea v-model="addData.materialcontent" placeholder="请输入问卷简介">
|
||||||
|
</lay-textarea>
|
||||||
|
</lay-form-item>
|
||||||
|
</lay-form>
|
||||||
|
</lay-container>
|
||||||
|
</lay-layer>
|
||||||
|
|
||||||
|
<!-- 新增题目弹窗 -->
|
||||||
|
<lay-layer v-model="questionnaireAddMode" title="新增题目" :type="4" :shade="true" :area="['800px', '100%']"
|
||||||
|
:btn="questionnaireButton">
|
||||||
|
<lay-container fluid="true" style="padding: 20px; overflow-y: auto;">
|
||||||
|
<lay-form>
|
||||||
|
<lay-card v-for="(item, index) in questionnaireData" :key="index"
|
||||||
|
style="margin-bottom: 15px; position: relative;">
|
||||||
|
<lay-form-item label="类型">
|
||||||
|
<lay-radio v-model="item.type" name="type" :value="1">单选题</lay-radio>
|
||||||
|
<lay-radio v-model="item.type" name="type" :value="2">多选题</lay-radio>
|
||||||
|
<lay-radio v-model="item.type" name="type" :value="3">问答题</lay-radio>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item label="排序">
|
||||||
|
<lay-input v-model="item.wight" type="number" placeholder="请输入排序"></lay-input>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item label="题目">
|
||||||
|
<lay-input v-model="item.title" placeholder="请输入题目"></lay-input>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item :label="op.name" v-for="(op, opi) in item.option" :key="opi" v-if="item.type != 3">
|
||||||
|
<div style="display: flex;align-items: center;">
|
||||||
|
<lay-input v-model="op.val" placeholder="请输入选项答案"></lay-input>
|
||||||
|
<lay-button type="primary" size="sm" @click="delOptionItem(index, opi)"><lay-icon
|
||||||
|
type="layui-icon-delete"></lay-icon></lay-button>
|
||||||
|
</div>
|
||||||
|
</lay-form-item>
|
||||||
|
<div style="text-align: center" v-if="item.type != 3">
|
||||||
|
<lay-button @click="addOption(index)" type="primary">添加一个选项</lay-button>
|
||||||
|
</div>
|
||||||
|
<div style="position: absolute; right: 20px; top: 20px">
|
||||||
|
<lay-button @click="delOptionTop(index)" type="danger" size="sm">删除题目</lay-button>
|
||||||
|
</div>
|
||||||
|
</lay-card>
|
||||||
|
<div style="text-align: center; margin-top: 30px">
|
||||||
|
<lay-button @click="addQuestionnaire()" type="warm">添加一个题目</lay-button>
|
||||||
|
</div>
|
||||||
|
</lay-form>
|
||||||
|
</lay-container>
|
||||||
|
</lay-layer>
|
||||||
|
<lay-layer header="编辑题目" v-model="questionnaireUpdateMode" :type="4" :shade="true" :area="['800px', '100%']"
|
||||||
|
:btn="questionnaireButtonEdit">
|
||||||
|
<lay-form>
|
||||||
|
<lay-card v-for="(item, index) in questionnaire" style="margin-bottom: 10px;position: relative;">
|
||||||
|
<lay-form-item label="类型">
|
||||||
|
<lay-radio-group v-model="item.type">
|
||||||
|
<lay-radio :value="1">单选题</lay-radio>
|
||||||
|
<lay-radio :value="2">多选题</lay-radio>
|
||||||
|
<lay-radio :value="3">问答题</lay-radio>
|
||||||
|
</lay-radio-group>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item label="排序">
|
||||||
|
<lay-input v-model="item.wight" placeholder="请输入排序"></lay-input>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item label="题目">
|
||||||
|
<lay-input v-model="item.title" placeholder="请输入题目"></lay-input>
|
||||||
|
</lay-form-item>
|
||||||
|
<lay-form-item v-for="(op, opi) in item.option" :label="op.name" v-if="item.type != 3">
|
||||||
|
<div style="display: flex;align-items: center;">
|
||||||
|
<lay-input v-model="op.val" placeholder="请输入选项答案"></lay-input>
|
||||||
|
<lay-button type="primary" size="sm" @click="delUpdateOptionItem(index, opi)"><lay-icon
|
||||||
|
type="layui-icon-delete"></lay-icon></lay-button>
|
||||||
|
</div>
|
||||||
|
</lay-form-item>
|
||||||
|
<div style="text-align: center" v-if="item.type != 3">
|
||||||
|
<lay-button @click="addOption(index)" type="warm">添加一个选项</lay-button>
|
||||||
|
</div>
|
||||||
|
<div style="position:absolute;right: 20px;top: 20px">
|
||||||
|
<lay-popconfirm content="确认删除吗" @confirm="delUpdateOptionTop(index, item)">
|
||||||
|
<lay-button type="danger" size="sm" style="margin-left: 20px">删除题目</lay-button>
|
||||||
|
</lay-popconfirm>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center;margin-top: 20px">
|
||||||
|
<lay-button @click="updateOption(item)" type="primary">保存</lay-button>
|
||||||
|
</div>
|
||||||
|
</lay-card>
|
||||||
|
</lay-form>
|
||||||
|
</lay-layer>
|
||||||
|
</lay-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
menuDataAdd,
|
||||||
|
menuDataEdit,
|
||||||
|
menuDataDel,
|
||||||
|
menuData,
|
||||||
|
getQuestionnaireIndex,
|
||||||
|
getQuestionnaireInfoAdd,
|
||||||
|
getQuestionnaireInfoEdit,
|
||||||
|
getQuestionnaireInfoFind,
|
||||||
|
getQuestionnaireDelete,
|
||||||
|
getQuestionnaireAdd
|
||||||
|
} from '../../api/module/home' // 确保 API 路径正确
|
||||||
|
import { ref, watch, onMounted, reactive } from 'vue'
|
||||||
|
import { layer } from '@layui/layer-vue'
|
||||||
|
const page = reactive({
|
||||||
|
current: 1,
|
||||||
|
limit: 10,
|
||||||
|
total: 1
|
||||||
|
});
|
||||||
|
// 列表内容
|
||||||
|
const dataSource6 = ref([]);
|
||||||
|
const addShow = ref(false)
|
||||||
|
// 1 add 2 edit
|
||||||
|
const addIsEdit = ref(1)
|
||||||
|
const addData = reactive({
|
||||||
|
title: '',
|
||||||
|
materialcontent: ''
|
||||||
|
})
|
||||||
|
const questionnaireUpdateMode = ref(false)
|
||||||
|
// 新增题目相关数据和方法
|
||||||
|
const questionnaireAddMode = ref(false)
|
||||||
|
const currentQuestionnaireId = ref(0)
|
||||||
|
const questionnaireData = ref([{
|
||||||
|
type: 1, title: '', wight: 0, option: [{ name: 'A', val: "" }, { name: 'B', val: "" }]
|
||||||
|
}])
|
||||||
|
// 初始化一个题目
|
||||||
|
const initQuestionItem = () => {
|
||||||
|
return {
|
||||||
|
type: 1,
|
||||||
|
wight: 0,
|
||||||
|
title: "",
|
||||||
|
option: [
|
||||||
|
{ name: "选项A", val: "" },
|
||||||
|
{ name: "选项B", val: "" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const questionnaire = ref([]);
|
||||||
|
const editShowQuestMsd = (id) => {
|
||||||
|
questionnaireUpdateMode.value = true;
|
||||||
|
getQuestionnaireInfoFind({ id: id }).then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.code == 1) {
|
||||||
|
questionnaire.value = res.data;
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, { icon: 2 });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 添加一个题目
|
||||||
|
const addQuestionnaire = () => {
|
||||||
|
questionnaireData.value.push(initQuestionItem())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加一个选项
|
||||||
|
const addOption = (index) => {
|
||||||
|
const optionLength = questionnaireData.value[index].option.length
|
||||||
|
const lastOption = questionnaireData.value[index].option[optionLength - 1]
|
||||||
|
const lastChar = lastOption.name.charAt(lastOption.name.length - 1)
|
||||||
|
const nextChar = String.fromCharCode(lastChar.charCodeAt(0) + 1)
|
||||||
|
questionnaireData.value[index].option.push({
|
||||||
|
name: `${nextChar}`,
|
||||||
|
val: ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除选项
|
||||||
|
const delOptionItem = (index, opi) => {
|
||||||
|
if (questionnaireData.value[index].option.length <= 2) {
|
||||||
|
layer.msg('至少需要两个选项', { icon: 2 })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
questionnaireData.value[index].option.splice(opi, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除题目
|
||||||
|
const delOptionTop = (index) => {
|
||||||
|
questionnaireData.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开新增题目弹窗
|
||||||
|
const openQuestionnaireAdd = (data) => {
|
||||||
|
questionnaireAddMode.value = true
|
||||||
|
currentQuestionnaireId.value = data.id
|
||||||
|
questionnaireData.value = [initQuestionItem()]
|
||||||
|
}
|
||||||
|
|
||||||
|
const delUpdateOptionTop = (index, item) => {
|
||||||
|
console.log(item);
|
||||||
|
if (questionnaire.value.length <= 1) {
|
||||||
|
layer.msg('至少保留一个题目', { icon: 2 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
questionnaire.value.splice(index, 1);
|
||||||
|
getQuestionnaireDelete({ id: item.id }).then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.code == 1) {
|
||||||
|
//删除成功
|
||||||
|
layer.msg('删除成功', { icon: 1 });
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, { icon: 2 });
|
||||||
|
}
|
||||||
|
editShowQuestMsd(item.id);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交问卷题目
|
||||||
|
const submitQuestionnaire = async () => {
|
||||||
|
// 这里添加提交逻辑
|
||||||
|
for (let item of questionnaireData.value) {
|
||||||
|
if (!item.title) {
|
||||||
|
layer.msg('题目不能为空', { icon: 2 })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (item.type != 3) {
|
||||||
|
for (let op of item.option) {
|
||||||
|
if (!op.val) {
|
||||||
|
layer.msg('选项内容不能为空', { icon: 2 })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let jsonString = JSON.stringify(questionnaireData.value);
|
||||||
|
// 调用API保存题目
|
||||||
|
try {
|
||||||
|
//这里替换为实际的API调用
|
||||||
|
const res = await getQuestionnaireAdd({
|
||||||
|
id: currentQuestionnaireId.value,
|
||||||
|
topic: jsonString
|
||||||
|
})
|
||||||
|
if (res.code == 1) {
|
||||||
|
layer.msg('保存成功', { icon: 1 })
|
||||||
|
questionnaireAddMode.value = false
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, { icon: 2 })
|
||||||
|
}
|
||||||
|
layer.msg('保存成功', { icon: 1 })
|
||||||
|
questionnaireAddMode.value = false
|
||||||
|
} catch (error) {
|
||||||
|
layer.msg('保存失败', { icon: 2 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问卷题目弹窗按钮
|
||||||
|
const questionnaireButton = ref([
|
||||||
|
{
|
||||||
|
text: "确认",
|
||||||
|
callback: submitQuestionnaire
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "取消",
|
||||||
|
callback: () => {
|
||||||
|
questionnaireAddMode.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
// 修改现有的addShowMsd方法,使其能够处理新增题目
|
||||||
|
const addShowMsd = (data, pid) => {
|
||||||
|
console.log(data);
|
||||||
|
// 如果是新增题目
|
||||||
|
questionnaireAddMode.value = true;
|
||||||
|
currentQuestionnaireId.value = data.id;
|
||||||
|
}
|
||||||
|
const columns6 = [
|
||||||
|
{
|
||||||
|
title: "问卷标题",
|
||||||
|
width: "200px",
|
||||||
|
key: "title"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "发布时间",
|
||||||
|
width: "100px",
|
||||||
|
key: "releasetime"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "填写人数",
|
||||||
|
width: "300px",
|
||||||
|
key: "url"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: '180px',
|
||||||
|
customSlot: 'operator',
|
||||||
|
key: 'operator',
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'right'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getHierarchicalData()
|
||||||
|
})
|
||||||
|
|
||||||
|
const changePage = (page) => {
|
||||||
|
console.log(page);
|
||||||
|
page.current = page.current;
|
||||||
|
page.limit = page.limit;
|
||||||
|
getHierarchicalData();
|
||||||
|
}
|
||||||
|
|
||||||
|
const openNew = () => {
|
||||||
|
addData.id = 0;
|
||||||
|
addIsEdit.value = 1;
|
||||||
|
addData.title = '';
|
||||||
|
addShow.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const getHierarchicalData = () => {
|
||||||
|
getQuestionnaireIndex({ page: page.current, size: page.limit }).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
if (res.code == 1) {
|
||||||
|
dataSource6.value = res.data.data;
|
||||||
|
page.total = res.data.count;
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, { icon: 2 })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const editShowMsd = (data) => {
|
||||||
|
console.log(data);
|
||||||
|
addShow.value = true;
|
||||||
|
addData.id = data.id;
|
||||||
|
addData.title = data.title;
|
||||||
|
addData.materialcontent = data.materialcontent;
|
||||||
|
addIsEdit.value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const delShowMsd = async (data) => {
|
||||||
|
var res = await menuDataDel({ id: data.id });
|
||||||
|
console.log(res)
|
||||||
|
if (res.code == 1) {
|
||||||
|
layer.msg('删除成功!', { icon: 1 })
|
||||||
|
getHierarchicalData();
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, { icon: 2 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const addButton = ref([
|
||||||
|
{
|
||||||
|
text: "确认",
|
||||||
|
callback: async () => {
|
||||||
|
console.log(addData);
|
||||||
|
if (addData.title == '') {
|
||||||
|
layer.msg('问卷标题不能为空!', { icon: 2 })
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (addData.materialcontent == '') {
|
||||||
|
layer.msg('问卷简介不能为空!', { icon: 2 })
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (addIsEdit.value == 1) {
|
||||||
|
var res = await getQuestionnaireInfoAdd(addData);
|
||||||
|
} else {
|
||||||
|
var res = await getQuestionnaireInfoEdit(addData);
|
||||||
|
}
|
||||||
|
console.log(res)
|
||||||
|
if (res.code == 1) {
|
||||||
|
layer.msg('提交成功!', { icon: 1 })
|
||||||
|
addShow.value = false;
|
||||||
|
getHierarchicalData();
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, { icon: 2 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "取消",
|
||||||
|
callback: () => {
|
||||||
|
addShow.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
</script>
|
||||||
|
<style scoped></style>
|
Loading…
x
Reference in New Issue
Block a user