Merge branch 'master' of http://47.109.37.87:3000/by2025/admin-vben5
Some checks failed
/ Explore-Gitea-Actions (push) Failing after 5m28s
Some checks failed
/ Explore-Gitea-Actions (push) Failing after 5m28s
This commit is contained in:
commit
36f93721ad
@ -43,6 +43,7 @@ export interface ArrangementVO {
|
||||
userGroupList?: any[];
|
||||
attendanceGroup?: any;
|
||||
dateType?: number;
|
||||
areaList: any[]; //区域
|
||||
}
|
||||
|
||||
export interface ArrangementForm extends BaseEntity {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
import type {PageQuery, BaseEntity} from '#/api/common';
|
||||
import type {
|
||||
QuestionItemForm
|
||||
QuestionItemForm, QuestionItemVO
|
||||
} from "#/api/property/customerService/questionnaire/questionItem/model";
|
||||
|
||||
export interface QuestionVO {
|
||||
@ -39,6 +39,19 @@ export interface QuestionVO {
|
||||
*/
|
||||
sort: number;
|
||||
|
||||
/**
|
||||
* 问题选项
|
||||
*/
|
||||
questionnaireQuestionItemVos: QuestionItemVO[];
|
||||
|
||||
options: string[];
|
||||
|
||||
answer: string;
|
||||
|
||||
rate:number;
|
||||
|
||||
checked:string[];
|
||||
|
||||
}
|
||||
|
||||
export interface QuestionForm extends BaseEntity {
|
||||
@ -80,17 +93,17 @@ export interface QuestionForm extends BaseEntity {
|
||||
/**
|
||||
* 选项
|
||||
*/
|
||||
questionnaireQuestionItems:QuestionItemForm[]
|
||||
questionnaireQuestionItems: QuestionItemForm[]
|
||||
|
||||
/**
|
||||
* 评分预览
|
||||
*/
|
||||
rate?:number;
|
||||
rate?: number;
|
||||
|
||||
/**
|
||||
* 时间预览
|
||||
*/
|
||||
dateTime?:string;
|
||||
dateTime?: string;
|
||||
|
||||
}
|
||||
|
||||
@ -126,7 +139,7 @@ export interface QuestionQuery extends PageQuery {
|
||||
sort?: number;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
import type {QuestionForm} from "#/api/property/customerService/questionnaire/question/model";
|
||||
import type {
|
||||
QuestionForm,
|
||||
QuestionVO
|
||||
} from "#/api/property/customerService/questionnaire/question/model";
|
||||
|
||||
export interface QuestionnaireVO {
|
||||
/**
|
||||
@ -36,7 +39,10 @@ export interface QuestionnaireVO {
|
||||
* 状态(1草稿2已发布3未发布)
|
||||
*/
|
||||
status: string;
|
||||
|
||||
/**
|
||||
* 问题
|
||||
*/
|
||||
questionnaireQuestionVos:QuestionVO[];
|
||||
}
|
||||
|
||||
export interface QuestionnaireForm extends BaseEntity {
|
||||
|
@ -19,9 +19,20 @@ export const columns: VxeGridProps['columns'] = [
|
||||
width: 'auto',
|
||||
},
|
||||
{
|
||||
title: '摄像机id',
|
||||
field: 'deviceManageId',
|
||||
title: '摄像机',
|
||||
field: 'areaDevice',
|
||||
minWidth: 300,
|
||||
slots: {
|
||||
default: ({ row }: { row: any }) => {
|
||||
if (!row.areaDevice || !Array.isArray(row.areaDevice)) {
|
||||
return '';
|
||||
}
|
||||
return row.areaDevice
|
||||
.map((device: any) => device.remoteSisDeviceManage?.deviceName || '')
|
||||
.filter((deviceName: string) => deviceName)
|
||||
.join(', ');
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ let formModal = reactive<{
|
||||
dateType: number | undefined;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
areaId: string;
|
||||
areaId: string[];
|
||||
userGroupList: any[];
|
||||
}>({
|
||||
id: '',
|
||||
@ -43,7 +43,7 @@ let formModal = reactive<{
|
||||
// dateRange: [null, null],
|
||||
startDate: '', //开始日期
|
||||
endDate: '', //结束日期
|
||||
areaId: '', //区域
|
||||
areaId: [], //区域
|
||||
userGroupList: [
|
||||
// scheduleId:undefined,//排班ID
|
||||
// employeeId:undefined,//员工ID
|
||||
@ -77,7 +77,7 @@ const columns = [
|
||||
},
|
||||
{
|
||||
title: '部门',
|
||||
dataIndex: ['dept', 'unitName'],
|
||||
dataIndex: ['dept', 'deptName'],
|
||||
key: 'dept',
|
||||
width: 120,
|
||||
customRender: ({
|
||||
@ -313,7 +313,7 @@ async function handleConfirm() {
|
||||
dateType: undefined,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
areaId: '',
|
||||
areaId: [],
|
||||
userGroupList: [],
|
||||
});
|
||||
// 重置其他数据
|
||||
@ -338,7 +338,7 @@ async function handleClosed() {
|
||||
dateType: undefined,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
areaId: '',
|
||||
areaId: [],
|
||||
userGroupList: [],
|
||||
});
|
||||
|
||||
@ -422,6 +422,7 @@ onMounted(() => {});
|
||||
v-model:value="formModal.areaId"
|
||||
:options="areaOptions"
|
||||
placeholder="请选择"
|
||||
mode="multiple"
|
||||
@change="chooseGroup"
|
||||
/>
|
||||
</FormItem>
|
||||
@ -442,7 +443,7 @@ onMounted(() => {});
|
||||
:columns="columns"
|
||||
:dataSource="tableData"
|
||||
:pagination="false"
|
||||
rowKey="dept.unitId"
|
||||
rowKey="dept.deptId"
|
||||
bordered
|
||||
/>
|
||||
</div>
|
||||
|
@ -160,9 +160,7 @@ const scheduleData: {
|
||||
date: string;
|
||||
list: { type: BadgeProps['status']; content: string }[];
|
||||
}[] = [
|
||||
{ date: '2025-07-08', list: [{ type: 'warning', content: '7月8日事件' }] },
|
||||
{ date: '2025-07-06', list: [{ type: 'success', content: '8月8日事件' }] },
|
||||
// ...
|
||||
//组件需要数据结构 { date: '2025-07-08', list: [{ type: 'warning', content: '7月8日事件' }] },
|
||||
];
|
||||
// 切换视图模式
|
||||
function handleViewModeChange(e: RadioChangeEvent): void {
|
||||
@ -180,45 +178,11 @@ const getListData2 = (
|
||||
if (found) {
|
||||
return found.list;
|
||||
}
|
||||
|
||||
}
|
||||
// 如果没有找到数据,返回空数组
|
||||
return [];
|
||||
};
|
||||
|
||||
const getListData = (
|
||||
value: Dayjs,
|
||||
): { type: BadgeProps['status']; content: string }[] => {
|
||||
let listData: { type: BadgeProps['status']; content: string }[] | undefined;
|
||||
switch (value.date()) {
|
||||
case 8:
|
||||
listData = [
|
||||
{ type: 'warning', content: 'This is warning event.' },
|
||||
{ type: 'success', content: 'This is usual event.' },
|
||||
];
|
||||
break;
|
||||
case 10:
|
||||
listData = [
|
||||
{ type: 'warning', content: 'This is warning event.' },
|
||||
{ type: 'success', content: 'This is usual event.' },
|
||||
{ type: 'error', content: 'This is error event.' },
|
||||
];
|
||||
break;
|
||||
case 15:
|
||||
listData = [
|
||||
{ type: 'warning', content: 'This is warning event' },
|
||||
{ type: 'success', content: 'This is very long usual event。。....' },
|
||||
{ type: 'error', content: 'This is error event 1.' },
|
||||
{ type: 'error', content: 'This is error event 2.' },
|
||||
{ type: 'error', content: 'This is error event 3.' },
|
||||
{ type: 'error', content: 'This is error event 4.' },
|
||||
];
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return listData || [];
|
||||
};
|
||||
|
||||
function customHeader() {
|
||||
// 返回想要的VNode或null
|
||||
return null; // 什么都不显示
|
||||
@ -284,6 +248,11 @@ function handleViewDateDetails(date: string) {
|
||||
onMounted(() => {
|
||||
fetchCalendarData();
|
||||
});
|
||||
|
||||
// 暴露方法给父组件调用
|
||||
defineExpose({
|
||||
fetchCalendarData,
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex h-full flex-col">
|
||||
|
@ -59,7 +59,7 @@ export const querySchema: FormSchemaGetter = () => [
|
||||
export const unitQuerySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'scheduleName',
|
||||
fieldName: 'userName',
|
||||
label: '姓名',
|
||||
},
|
||||
{
|
||||
@ -339,6 +339,22 @@ export const workforceDayDetailColumns: VxeGridProps['columns'] = [
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '区域',
|
||||
field: 'areaList',
|
||||
width: 'auto',
|
||||
slots: {
|
||||
default: ({ row }: { row: any }) => {
|
||||
if (!row.areaList || !Array.isArray(row.areaList)) {
|
||||
return '';
|
||||
}
|
||||
return row.areaList
|
||||
.map((item: any) => item.area || '')
|
||||
.filter((areaName: string) => areaName)
|
||||
.join(', ');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '班组人数',
|
||||
field: 'userCount',
|
||||
|
@ -1,22 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ref, nextTick } from 'vue';
|
||||
import calendarView from './calendarView.vue';
|
||||
import scheduleView from './scheduleView.vue';
|
||||
const viewMode = ref<'calender' | 'schedule'>('calender');
|
||||
// const isCalenderView = ref(true);
|
||||
const calendarViewRef = ref();
|
||||
const scheduleViewRef = ref();
|
||||
|
||||
function handleViewModeChange(mode: 'calender' | 'schedule') {
|
||||
viewMode.value = mode;
|
||||
// 切换视图后,需要重新加载对应视图的数据
|
||||
nextTick(() => {
|
||||
if (mode === 'calender') {
|
||||
// 触发日历视图的数据加载
|
||||
calendarViewRef.value?.fetchCalendarData();
|
||||
} else if (mode === 'schedule') {
|
||||
// 触发班表视图的数据加载
|
||||
scheduleViewRef.value?.tableApi?.query();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="h-full p-4">
|
||||
<div class="h-full bg-white p-4">
|
||||
<calendarView
|
||||
ref="calendarViewRef"
|
||||
v-show="viewMode === 'calender'"
|
||||
:viewMode="viewMode"
|
||||
@changeView="handleViewModeChange"
|
||||
/>
|
||||
<scheduleView
|
||||
ref="scheduleViewRef"
|
||||
v-show="viewMode === 'schedule'"
|
||||
:viewMode="viewMode"
|
||||
@changeView="handleViewModeChange"
|
||||
|
@ -82,15 +82,15 @@ function handleAdd() {
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<ArrangementForm>) {
|
||||
modalApi.setData({ id: row.scheduleId });
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<ArrangementForm>) {
|
||||
await arrangementRemove(row.scheduleId);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
// 暴露方法给父组件调用
|
||||
defineExpose({
|
||||
tableApi,
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="h-full">
|
||||
|
@ -22,14 +22,14 @@ let formModal = reactive<{
|
||||
id: string | number;
|
||||
groupId?: string | number;
|
||||
attendanceType: string;
|
||||
areaId: string;
|
||||
areaId: string[];
|
||||
userGroupList: any[];
|
||||
dateType: number | undefined;
|
||||
}>({
|
||||
id: '',
|
||||
groupId: '',
|
||||
attendanceType: '', //考勤组类型
|
||||
areaId: '', //区域
|
||||
areaId: [], //区域
|
||||
userGroupList: [
|
||||
// scheduleId:undefined,//排班ID
|
||||
// employeeId:undefined,//员工ID
|
||||
@ -44,7 +44,7 @@ const groupOptions = ref<any[]>([]); //考勤组
|
||||
const areaOptions = ref<any[]>([]); //区域
|
||||
const groupMap = ref<Record<string, any>>({}); // 用于快速查找
|
||||
let tableData = reactive<
|
||||
{ dept: { unitId: string | number; unitName: string }; users: PersonVO[] }[]
|
||||
{ dept: { deptId: string | number; deptName: string }; users: PersonVO[] }[]
|
||||
>([]); //存放考勤组人员列表数据
|
||||
const columns = [
|
||||
{
|
||||
@ -56,10 +56,10 @@ const columns = [
|
||||
},
|
||||
{
|
||||
title: '部门',
|
||||
dataIndex: ['dept', 'unitName'],
|
||||
dataIndex: ['dept', 'deptName'],
|
||||
key: 'dept',
|
||||
width: 120,
|
||||
customRender: ({ record }: { record: any }) => record.dept.unitName,
|
||||
customRender: ({ record }: { record: any }) => record.dept.deptName,
|
||||
},
|
||||
{
|
||||
title: '已选人数',
|
||||
@ -124,12 +124,11 @@ function handleTableData(newTableData: any) {
|
||||
if (newTableData.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理有数据的情况
|
||||
for (const newItem of newTableData) {
|
||||
// 查找是否已存在相同部门
|
||||
const existingDeptIndex = tableData.findIndex(
|
||||
(item) => item.dept.unitId === newItem.dept.unitId,
|
||||
(item) => item.dept.deptId === newItem.dept.deptId,
|
||||
);
|
||||
|
||||
if (existingDeptIndex !== -1) {
|
||||
@ -179,6 +178,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
formModal.id = record.id;
|
||||
formModal.groupId = record.attendanceGroup.id;
|
||||
formModal.dateType = record.dateType;
|
||||
formModal.areaId = record.areaList?.map((area: any) => area.id) || [];
|
||||
|
||||
if (record.userGroupList) {
|
||||
// 按部门分组处理 userGroupList
|
||||
@ -190,7 +190,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
|
||||
if (!deptMap.has(deptId)) {
|
||||
deptMap.set(deptId, {
|
||||
dept: { unitId: deptId, unitName: deptName },
|
||||
dept: { deptId: deptId, deptName: deptName },
|
||||
users: [],
|
||||
});
|
||||
}
|
||||
@ -203,8 +203,6 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
tableData.splice(0, 0, ...Array.from(deptMap.values()));
|
||||
}
|
||||
}
|
||||
console.log(tableData);
|
||||
|
||||
// await markInitialized();
|
||||
modalApi.modalLoading(false);
|
||||
},
|
||||
@ -251,11 +249,10 @@ async function handleConfirm() {
|
||||
modalApi.lock(true);
|
||||
await formRef.value.validate(); // 先校验
|
||||
const data = formModal;
|
||||
console.log(tableData);
|
||||
data.userGroupList = tableData.flatMap((item) =>
|
||||
item.users.map((user) => ({
|
||||
deptId: item.dept.unitId,
|
||||
deptName: item.dept.unitName,
|
||||
deptId: item.dept.deptId,
|
||||
deptName: item.dept.deptName,
|
||||
employeeId: user.userId,
|
||||
employeeName: user.userName,
|
||||
})),
|
||||
@ -270,7 +267,7 @@ async function handleConfirm() {
|
||||
dateType: undefined,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
areaId: '',
|
||||
areaId: [],
|
||||
userGroupList: [],
|
||||
});
|
||||
// 重置其他数据
|
||||
@ -292,7 +289,7 @@ async function handleClosed() {
|
||||
dateType: undefined,
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
areaId: '',
|
||||
areaId: [],
|
||||
userGroupList: [],
|
||||
});
|
||||
|
||||
@ -332,6 +329,7 @@ onMounted(() => {});
|
||||
v-model:value="formModal.areaId"
|
||||
:options="areaOptions"
|
||||
placeholder="请选择"
|
||||
mode="multiple"
|
||||
@change="chooseGroup"
|
||||
/>
|
||||
</FormItem>
|
||||
@ -352,7 +350,7 @@ onMounted(() => {});
|
||||
:columns="columns"
|
||||
:dataSource="tableData"
|
||||
:pagination="false"
|
||||
rowKey="dept.unitId"
|
||||
rowKey="dept.deptId"
|
||||
bordered
|
||||
/>
|
||||
</div>
|
||||
|
@ -1,104 +1,84 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
import { renderDict } from '#/utils/render';
|
||||
import {h} from "vue";
|
||||
import {Rate} from "ant-design-vue";
|
||||
import {renderDict} from "#/utils/render";
|
||||
import {getDictOptions} from "#/utils/dict";
|
||||
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions('type_contingency_plan'),
|
||||
},
|
||||
fieldName: 'contingenPlanType',
|
||||
label: '预案类型',
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'dutyPersion',
|
||||
label: '责任人',
|
||||
component: 'Input',
|
||||
fieldName: 'head',
|
||||
label: '问卷标题',
|
||||
},
|
||||
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions('pro_exercise_status'),
|
||||
options:getDictOptions('wy_dcwjzt')
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '演练状态',
|
||||
label: '问卷状态',//(1草稿2已发布3未发布)
|
||||
},
|
||||
];
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
export const columns: VxeGridProps['columns'] = [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
title: '序号',
|
||||
field: 'id',
|
||||
slots: {
|
||||
default: ({rowIndex}) => {
|
||||
return (rowIndex + 1).toString();
|
||||
}
|
||||
}
|
||||
title: '问卷标题',
|
||||
field: 'head',
|
||||
width:200,
|
||||
},
|
||||
{
|
||||
title: '预案名称',
|
||||
field: 'contingenPlanName',
|
||||
title: '问卷描述',
|
||||
field: 'depict',
|
||||
minWidth:180,
|
||||
},
|
||||
{
|
||||
title: '预案类型',
|
||||
field: 'contingenPlanType',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return renderDict(row.contingenPlanType, 'type_contingency_plan');
|
||||
},
|
||||
},
|
||||
title: '匿名收集',
|
||||
field: 'isAnonyCollec',
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return row.isAnonyCollec=='1'?'是':'否'
|
||||
}},
|
||||
width:100,
|
||||
},
|
||||
{
|
||||
title: '风险等级',
|
||||
field: 'grade',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return h(Rate, {
|
||||
value: row.grade || 0,
|
||||
disabled: true,
|
||||
});
|
||||
},
|
||||
},
|
||||
minWidth: '150'
|
||||
title: '多次提交',
|
||||
field: 'isCommit',
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return row.isCommit=='1'?'是':'否'
|
||||
}},
|
||||
width:100,
|
||||
},
|
||||
{
|
||||
title: '发起人',
|
||||
field: 'initiatName',
|
||||
title: '截止日期',
|
||||
field: 'deadline',
|
||||
width:150,
|
||||
},
|
||||
{
|
||||
title: '演练状态',
|
||||
title: '问卷状态',//(1草稿2已发布3未发布)
|
||||
field: 'status',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
return renderDict(row.status, 'pro_exercise_status');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '责任人',
|
||||
field: 'dutyPersionName',
|
||||
},
|
||||
{
|
||||
title: '完成时间',
|
||||
field: 'compleTimes',
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return renderDict(row.status,'wy_dcwjzt')
|
||||
}},
|
||||
width:100,
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 240,
|
||||
width: 280,
|
||||
},
|
||||
];
|
||||
|
||||
export const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '主键',
|
||||
label: 'id',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
@ -107,52 +87,46 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '预案名称',
|
||||
fieldName: 'contingenPlanName',
|
||||
label: '问卷标题',
|
||||
fieldName: 'head',
|
||||
component: 'Textarea',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '问卷描述',
|
||||
fieldName: 'depict',
|
||||
component: 'Textarea',
|
||||
},
|
||||
{
|
||||
label: '是否匿名收集',
|
||||
fieldName: 'isAnonyCollec',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '预案类型',
|
||||
fieldName: 'contingenPlanType',
|
||||
component: 'Select',
|
||||
label: '是否多次提交',
|
||||
fieldName: 'isCommit',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '截止日期',
|
||||
fieldName: 'deadline',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
options: getDictOptions('type_contingency_plan'),
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '发起人',
|
||||
fieldName: 'initiat',
|
||||
component: 'ApiSelect',
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '责任人',
|
||||
fieldName: 'dutyPersion',
|
||||
component: 'ApiSelect',
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '预案内容',
|
||||
fieldName: 'contingenPlanContent',
|
||||
component: 'RichTextarea',
|
||||
componentProps: {
|
||||
// disabled: false, // 是否只读
|
||||
// height: 400 // 高度 默认400
|
||||
},
|
||||
formItemClass: 'col-span-2'
|
||||
},
|
||||
{
|
||||
label: '风险等级',
|
||||
fieldName: 'grade',
|
||||
component: 'Rate',
|
||||
componentProps: {
|
||||
allowHalf: false,
|
||||
count: 5,
|
||||
tooltips: ['1星', '2星', '3星', '4星', '5星'],
|
||||
defaultValue: 0
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '状态(1草稿2已发布3未发布)',
|
||||
fieldName: 'status',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -1,28 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import { Modal, Popconfirm, Space } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
useVbenVxeGrid,
|
||||
vxeCheckboxChecked,
|
||||
type VxeGridProps
|
||||
} from '#/adapter/vxe-table';
|
||||
import {onMounted} from "vue";
|
||||
|
||||
import {
|
||||
contingenPlanExport,
|
||||
contingenPlanList,
|
||||
contingenPlanRemove,
|
||||
contingenPlanUpdate
|
||||
} from '#/api/property/customerService/contingenPlan';
|
||||
import type { ContingenPlanForm } from '#/api/property/customerService/contingenPlan/model';
|
||||
questionnaireExport,
|
||||
questionnaireList,
|
||||
questionnaireRemove,
|
||||
} from '#/api/property/customerService/questionnaire/questionnaire';
|
||||
import type { QuestionnaireForm } from '#/api/property/customerService/questionnaire/questionnaire/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import contingenPlanModal from './questionnaire-modal.vue';
|
||||
import contingenPlanDetail from './questionnaire-detail.vue';
|
||||
import questionnaireModal from './questionnaire-modal.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
import {personList} from "#/api/property/resident/person";
|
||||
import {renderDictValue} from "#/utils/render";
|
||||
|
||||
import questionnaireDetail from './questionnaire-detail.vue'
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
labelWidth: 80,
|
||||
@ -40,6 +38,8 @@ const gridOptions: VxeGridProps = {
|
||||
highlight: true,
|
||||
// 翻页时保留选中状态
|
||||
reserve: true,
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
columns,
|
||||
height: 'auto',
|
||||
@ -48,7 +48,7 @@ const gridOptions: VxeGridProps = {
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues = {}) => {
|
||||
return await contingenPlanList({
|
||||
return await questionnaireList({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
@ -60,7 +60,7 @@ const gridOptions: VxeGridProps = {
|
||||
keyField: 'id',
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: 'system-contingenPlan-index'
|
||||
id: 'property-questionnaire-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
@ -68,113 +68,76 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const [ContingenPlanModal, modalApi] = useVbenModal({
|
||||
connectedComponent: contingenPlanModal,
|
||||
const [QuestionnaireModal, modalApi] = useVbenModal({
|
||||
connectedComponent: questionnaireModal,
|
||||
});
|
||||
|
||||
const [contingenPlanDetailModal, contingenPlanDetailApi] = useVbenModal({
|
||||
connectedComponent: contingenPlanDetail,
|
||||
const [QuestionnaireDetail, detailApi] = useVbenModal({
|
||||
connectedComponent: questionnaireDetail,
|
||||
});
|
||||
|
||||
async function handleInfo(row: Required<ContingenPlanForm>) {
|
||||
contingenPlanDetailApi.setData({ id: row.id });
|
||||
contingenPlanDetailApi.open();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
modalApi.setData({});
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<ContingenPlanForm>) {
|
||||
async function handleEdit(row: Required<QuestionnaireForm>) {
|
||||
modalApi.setData({ id: row.id });
|
||||
modalApi.open();
|
||||
}
|
||||
async function handleInfo(row: Required<QuestionnaireForm>) {
|
||||
detailApi.setData({ id: row.id });
|
||||
detailApi.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<ContingenPlanForm>) {
|
||||
await contingenPlanRemove(row.id);
|
||||
async function handleDelete(row: Required<QuestionnaireForm>) {
|
||||
await questionnaireRemove(row.id);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
async function handleExamine(row: Required<ContingenPlanForm>) {
|
||||
row.status = '1'
|
||||
await contingenPlanUpdate(row);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function handleMultiDelete() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: Required<ContingenPlanForm>) => row.id);
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
okType: 'danger',
|
||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
onOk: async () => {
|
||||
await contingenPlanRemove(ids);
|
||||
await tableApi.query();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(contingenPlanExport, '应急预案管理数据', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
}
|
||||
|
||||
async function queryPersonData() {
|
||||
let params = {
|
||||
pageSize: 1000,
|
||||
pageNum: 1,
|
||||
}
|
||||
const res = await personList(params);
|
||||
const options = res.rows.map((user) => ({
|
||||
label: user.userName + '-' + renderDictValue(user.gender, 'sys_user_sex') + '-' + user.phone,
|
||||
value: user.id,
|
||||
}));
|
||||
tableApi.formApi.updateSchema([
|
||||
{
|
||||
componentProps: () => ({
|
||||
options: options,
|
||||
showSearch:true,
|
||||
filterOption: filterOption
|
||||
}),
|
||||
fieldName: 'dutyPersion',
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
const filterOption = (input: string, option: any) => {
|
||||
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await queryPersonData()
|
||||
})
|
||||
// function handleMultiDelete() {
|
||||
// const rows = tableApi.grid.getCheckboxRecords();
|
||||
// const ids = rows.map((row: Required<QuestionnaireForm>) => row.id);
|
||||
// Modal.confirm({
|
||||
// title: '提示',
|
||||
// okType: 'danger',
|
||||
// content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
// onOk: async () => {
|
||||
// await questionnaireRemove(ids);
|
||||
// await tableApi.query();
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// function handleDownloadExcel() {
|
||||
// commonDownloadExcel(questionnaireExport, '调查问卷数据', tableApi.formApi.form.values, {
|
||||
// fieldMappingTime: formOptions.fieldMappingTime,
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true">
|
||||
<BasicTable table-title="应急预案管理列表">
|
||||
<BasicTable table-title="调查问卷列表">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<a-button
|
||||
v-access:code="['system:contingenPlan:export']"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||
danger
|
||||
type="primary"
|
||||
v-access:code="['system:contingenPlan:remove']"
|
||||
@click="handleMultiDelete">
|
||||
{{ $t('pages.common.delete') }}
|
||||
</a-button>
|
||||
<!-- <a-button-->
|
||||
<!-- v-access:code="['property:questionnaire:export']"-->
|
||||
<!-- @click="handleDownloadExcel"-->
|
||||
<!-- >-->
|
||||
<!-- {{ $t('pages.common.export') }}-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button-->
|
||||
<!-- :disabled="!vxeCheckboxChecked(tableApi)"-->
|
||||
<!-- danger-->
|
||||
<!-- type="primary"-->
|
||||
<!-- v-access:code="['property:questionnaire:remove']"-->
|
||||
<!-- @click="handleMultiDelete">-->
|
||||
<!-- {{ $t('pages.common.delete') }}-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
type="primary"
|
||||
v-access:code="['system:contingenPlan:add']"
|
||||
v-access:code="['property:questionnaire:add']"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
@ -183,28 +146,16 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<Popconfirm
|
||||
v-if="row.status === '0'"
|
||||
:get-popup-container="getVxePopupContainer"
|
||||
placement="left"
|
||||
title="确认审核?"
|
||||
@confirm="handleExamine(row)"
|
||||
>
|
||||
<ghost-button
|
||||
@click.stop=""
|
||||
>
|
||||
{{ '审核' }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
<ghost-button
|
||||
v-access:code="['property:questionnaire:info']"
|
||||
@click.stop="handleInfo(row)"
|
||||
>
|
||||
{{ $t('pages.common.info') }}
|
||||
预览问卷
|
||||
</ghost-button>
|
||||
<ghost-button
|
||||
v-if="row.status === '0'"
|
||||
v-access:code="['system:contingenPlan:edit']"
|
||||
v-access:code="['property:questionnaire:edit']"
|
||||
@click.stop="handleEdit(row)"
|
||||
:disabled="row.status!=='1'"
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
@ -216,16 +167,23 @@ onMounted(async () => {
|
||||
>
|
||||
<ghost-button
|
||||
danger
|
||||
v-access:code="['system:contingenPlan:remove']"
|
||||
v-access:code="['property:questionnaire:remove']"
|
||||
@click.stop=""
|
||||
:disabled="row.status!=='1'"
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
<ghost-button
|
||||
v-access:code="['property:questionnaire:info']"
|
||||
@click.stop="handleEdit(row)"
|
||||
>
|
||||
统计分析
|
||||
</ghost-button>
|
||||
</Space>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<ContingenPlanModal @reload="tableApi.query()" />
|
||||
<contingenPlanDetailModal/>
|
||||
<QuestionnaireModal @reload="tableApi.query()" />
|
||||
<QuestionnaireDetail/>
|
||||
</Page>
|
||||
</template>
|
||||
|
@ -1,96 +1,158 @@
|
||||
<script setup lang="ts">
|
||||
import type {ContingenPlanVO} from '#/api/property/customerService/contingenPlan/model';
|
||||
import {shallowRef} from 'vue';
|
||||
import {reactive, shallowRef} from 'vue';
|
||||
import {useVbenModal} from '@vben/common-ui';
|
||||
import {questionnaireInfo} from "#/api/property/customerService/questionnaire/questionnaire";
|
||||
import type {
|
||||
QuestionnaireVO
|
||||
} from "#/api/property/customerService/questionnaire/questionnaire/model";
|
||||
import {
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Divider,
|
||||
Tag,
|
||||
RadioGroup,
|
||||
Radio,
|
||||
CheckboxGroup,
|
||||
Rate,
|
||||
Timeline,
|
||||
TimelineItem
|
||||
} from 'ant-design-vue';
|
||||
import {contingenPlanInfo} from '#/api/property/customerService/contingenPlan';
|
||||
import {renderDict} from "#/utils/render";
|
||||
DatePicker,
|
||||
Textarea,
|
||||
Input,
|
||||
Popover
|
||||
} from 'ant-design-vue'
|
||||
import {QuestionCircleOutlined} from '@ant-design/icons-vue';
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
fullscreen: true,
|
||||
onOpenChange: handleOpenChange,
|
||||
cancelText: '保存为草稿',
|
||||
confirmText: '保存并发布',
|
||||
onClosed() {
|
||||
contingenPlanIDetail.value = null;
|
||||
questionnaireDetail.value = null;
|
||||
},
|
||||
onConfirm: () => {
|
||||
questionnaireDetail.value = null;
|
||||
modalApi.close()
|
||||
},
|
||||
});
|
||||
|
||||
const contingenPlanIDetail = shallowRef<null | ContingenPlanVO>(null);
|
||||
const handleRecords = shallowRef<null | ContingenPlanVO>(null);
|
||||
const questionnaireDetail = shallowRef<null | QuestionnaireVO>(null);
|
||||
|
||||
async function handleOpenChange(open: boolean) {
|
||||
if (!open) {
|
||||
return null;
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
const {id} = modalApi.getData() as { id: number | string };
|
||||
const response = await contingenPlanInfo(id);
|
||||
contingenPlanIDetail.value = response;
|
||||
handleRecords.value = response.contingenPlanRecordVos.map(item => ({
|
||||
status: item.status,
|
||||
createTime: item.createTime,
|
||||
handlerName: item.dutyPersionName
|
||||
}));
|
||||
console.log(handleRecords.value)
|
||||
questionnaireDetail.value = await questionnaireInfo(id);
|
||||
if (questionnaireDetail.value.questionnaireQuestionVos) {
|
||||
questionnaireDetail.value.questionnaireQuestionVos.forEach(item => {
|
||||
item.answer = ''
|
||||
if (item.questionnaireQuestionItemVos) {
|
||||
item.options = item.questionnaireQuestionItemVos.map(item => item.itemContent)
|
||||
}
|
||||
})
|
||||
}
|
||||
modalApi.modalLoading(false);
|
||||
}
|
||||
|
||||
const radioStyle = reactive({
|
||||
display: 'flex',
|
||||
height: '30px',
|
||||
lineHeight: '30px',
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :footer="false" :fullscreen-button="false" title="详情" class="w-[70%]">
|
||||
<Descriptions v-if="contingenPlanIDetail" size="small" :column="2" bordered :labelStyle="{width:'120px'}">
|
||||
<DescriptionsItem label="预案名称">
|
||||
{{ contingenPlanIDetail.contingenPlanName }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="创建时间">
|
||||
{{ contingenPlanIDetail.createTime }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="预案类型" v-if="contingenPlanIDetail.contingenPlanType!=null">
|
||||
<component
|
||||
:is="renderDict(contingenPlanIDetail.contingenPlanType,'type_contingency_plan')"
|
||||
/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="最后更新时间">
|
||||
{{ contingenPlanIDetail.updateTime }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="演练状态" v-if="contingenPlanIDetail.status!=null">
|
||||
<component
|
||||
:is="renderDict(contingenPlanIDetail.status,'pro_exercise_status')"
|
||||
/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="完成时间">
|
||||
{{ contingenPlanIDetail.compleTimes }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="发起人">
|
||||
{{ contingenPlanIDetail.initiatName }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="责任人">
|
||||
{{ contingenPlanIDetail.dutyPersionName}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="预案内容" :span="2">
|
||||
<div v-html="contingenPlanIDetail.contingenPlanContent"></div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="风险等级">
|
||||
<Rate :value="contingenPlanIDetail.grade" disabled />
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
|
||||
<Divider orientation="left" orientation-margin="0px">
|
||||
处理记录
|
||||
</Divider>
|
||||
<Timeline>
|
||||
<TimelineItem v-for="(item,index) in handleRecords" :key="index">
|
||||
<p style="display: flex;">类型:
|
||||
<component
|
||||
:is="renderDict(item.status,'pro_exercise_status')"
|
||||
/></p>
|
||||
<p>时间:{{item.createTime}}</p>
|
||||
<p>处理人:{{item.handlerName}}</p>
|
||||
</TimelineItem>
|
||||
</Timeline>
|
||||
<BasicModal :fullscreen-button="false" title="预览问卷">
|
||||
<div v-if="questionnaireDetail" class="questionnaire-container">
|
||||
<div class="head-title">{{ questionnaireDetail.head }}</div>
|
||||
<div class="subtitle">{{ questionnaireDetail.depict }}</div>
|
||||
<div v-for="(item,index) in questionnaireDetail.questionnaireQuestionVos"
|
||||
class="question-content">
|
||||
<div class="question-head">
|
||||
<Tag :bordered="false">{{ index + 1 }}</Tag>
|
||||
<span>{{ item.head }}</span>
|
||||
<Popover title="问题描述" placement="right">
|
||||
<template #content>
|
||||
<p>{{ item.depict }}</p>
|
||||
</template>
|
||||
<QuestionCircleOutlined v-if="item.depict!=null"
|
||||
style="font-size: 10px;margin-left: 10px"/>
|
||||
</Popover>
|
||||
<span style="color: red;margin-left: 5px" v-if="item.isRequired=='1'">*</span>
|
||||
</div>
|
||||
<div class="question-item">
|
||||
<div v-if="item.type=='1'">
|
||||
<Input style="width: 80%;" v-model:value="item.answer"
|
||||
placeholder="请输入您的详细回答"/>
|
||||
</div>
|
||||
<div v-if="item.type=='2'">
|
||||
<Textarea style="width: 80%;" v-model:value="item.answer"
|
||||
placeholder="请输入您的详细回答"/>
|
||||
</div>
|
||||
<div v-if="item.type=='3'">
|
||||
<RadioGroup v-model:value="item.answer">
|
||||
<Radio :style="radioStyle"
|
||||
v-for="option in item.questionnaireQuestionItemVos"
|
||||
:value="option.itemContent">{{ option.itemContent }}
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div v-if="item.type=='4'">
|
||||
<CheckboxGroup class="vertical-checkbox-group" v-model:value="item.checked"
|
||||
:options="item.options"/>
|
||||
</div>
|
||||
<div v-if="item.type=='5'">
|
||||
<Rate v-model:value="item.rate"/>
|
||||
<span style="color:#8f8e8e;margin-left: 20px">请评分</span>
|
||||
</div>
|
||||
<div v-if="item.type=='6'">
|
||||
<DatePicker style="width: 200px" v-model:value="item.answer"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.questionnaire-container {
|
||||
.head-title {
|
||||
text-align: center;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
line-height: 60px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.question-content {
|
||||
margin-left: 20px;
|
||||
|
||||
.question-item {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.vertical-checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
:deep(.ant-checkbox-wrapper) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.question-head {
|
||||
margin: 20px 0 10px 0;
|
||||
|
||||
:deep(.ant-tag) {
|
||||
font-size: 16px;
|
||||
line-height: 21px;
|
||||
margin-inline-end: 7px;
|
||||
padding-inline: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -14,11 +14,24 @@ import {
|
||||
Divider,
|
||||
Rate,
|
||||
Popover,
|
||||
Badge
|
||||
Badge,
|
||||
message
|
||||
} from 'ant-design-vue'
|
||||
import {PlusOutlined, DeleteOutlined} from '@ant-design/icons-vue';
|
||||
import {renderDictValue} from "#/utils/render";
|
||||
import {getDictOptions} from "#/utils/dict";
|
||||
import type {
|
||||
QuestionnaireForm
|
||||
} from "#/api/property/customerService/questionnaire/questionnaire/model";
|
||||
import type {QuestionForm} from "#/api/property/customerService/questionnaire/question/model";
|
||||
import {
|
||||
questionnaireAdd,
|
||||
questionnaireUpdate,
|
||||
questionnaireInfo
|
||||
} from '#/api/property/customerService/questionnaire/questionnaire';
|
||||
import type {
|
||||
QuestionItemForm
|
||||
} from "#/api/property/customerService/questionnaire/questionItem/model";
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
const isUpdate = ref(false);
|
||||
@ -26,35 +39,10 @@ const title = computed(() => {
|
||||
return isUpdate.value ? '编辑问卷' : '新增问卷';
|
||||
});
|
||||
|
||||
// const [BasicForm, formApi] = useVbenForm({
|
||||
// commonConfig: {
|
||||
// // 默认占满两列
|
||||
// formItemClass: 'col-span-1',
|
||||
// // 默认label宽度 px
|
||||
// labelWidth: 80,
|
||||
// // 通用配置项 会影响到所有表单项
|
||||
// componentProps: {
|
||||
// class: 'w-full',
|
||||
// }
|
||||
// },
|
||||
// schema: modalSchema(),
|
||||
// showDefaultActions: false,
|
||||
// wrapperClass: 'grid-cols-2',
|
||||
// });
|
||||
|
||||
// const {onBeforeClose, markInitialized, resetInitialized} = useBeforeCloseDiff(
|
||||
// {
|
||||
// initializedGetter: defaultFormValueGetter(formApi),
|
||||
// currentGetter: defaultFormValueGetter(formApi),
|
||||
// },
|
||||
// );
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
// 在这里更改宽度
|
||||
fullscreenButton: false,
|
||||
fullscreen: true,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
@ -64,44 +52,53 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
// const record = await contingenPlanInfo(id);
|
||||
// await formApi.setValues(record);
|
||||
const record = await questionnaireInfo(id);
|
||||
Object.assign(counts, badgeCounts);
|
||||
let questions: QuestionForm[] = [];
|
||||
if (record.questionnaireQuestionVos) {
|
||||
questions = record.questionnaireQuestionVos.map(item => {
|
||||
const question: QuestionForm = { ...item };
|
||||
switch (item.type) {
|
||||
case '1': counts.inputCount++; break;
|
||||
case '2': counts.textareaCount++; break;
|
||||
case '3': counts.radioCount++; break;
|
||||
case '4': counts.checkboxCount++; break;
|
||||
case '5': counts.rateCount++; break;
|
||||
case '6': counts.datePickerCount++; break;
|
||||
}
|
||||
if (item.questionnaireQuestionItemVos) {
|
||||
question.questionnaireQuestionItems = item.questionnaireQuestionItemVos.map(
|
||||
option => ({ ...option } as QuestionItemForm)
|
||||
);
|
||||
}
|
||||
return question;
|
||||
});
|
||||
}
|
||||
Object.assign(formState, {
|
||||
...record,
|
||||
questionnaireQuestions: questions,
|
||||
});
|
||||
}
|
||||
// await markInitialized();
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
},
|
||||
});
|
||||
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
modalApi.lock(true);
|
||||
// const {valid} = await formApi.validate();
|
||||
// if (!valid) {
|
||||
// return;
|
||||
// }
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
// const data = cloneDeep(await formApi.getValues());
|
||||
// await (isUpdate.value ? contingenPlanUpdate(data) : contingenPlanAdd(data));
|
||||
// resetInitialized();
|
||||
emit('reload');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
modalApi.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
// await formApi.resetForm();
|
||||
// resetInitialized();
|
||||
formRef.value.clearValidate();
|
||||
Object.assign(formState, initialState);
|
||||
Object.assign(counts, badgeCounts);
|
||||
formState.questionnaireQuestions = [];
|
||||
}
|
||||
|
||||
const initialState = {
|
||||
username: '',
|
||||
password: '',
|
||||
questionList: [],
|
||||
const initialState: QuestionnaireForm = {
|
||||
id: '',
|
||||
head: '',
|
||||
depict: '',
|
||||
isAnonyCollec: '1',
|
||||
isCommit: '1',
|
||||
deadline: '',
|
||||
status: '',
|
||||
questionnaireQuestions: [] as Array<QuestionForm>
|
||||
};
|
||||
|
||||
const badgeCounts = {
|
||||
@ -114,74 +111,110 @@ const badgeCounts = {
|
||||
}
|
||||
|
||||
const counts = reactive({...badgeCounts})
|
||||
const formState = reactive({
|
||||
...initialState
|
||||
});
|
||||
const formState = reactive({...initialState});
|
||||
|
||||
async function handleCancel() {
|
||||
formRef.value.clearValidate();
|
||||
Object.assign(formState, initialState);
|
||||
Object.assign(counts, badgeCounts);
|
||||
formState.questionList = [];
|
||||
formState.questionnaireQuestions = [];
|
||||
await modalApi.close();
|
||||
}
|
||||
|
||||
function handleAddQuestion(type: number) {
|
||||
formState.questionList.push({type})
|
||||
function handleAddQuestion(type: string) {
|
||||
let question: QuestionForm = {
|
||||
type,
|
||||
questionnaireQuestionItems: [],
|
||||
isRequired: '1',
|
||||
}
|
||||
switch (type) {
|
||||
case 1:
|
||||
case '1':
|
||||
counts.inputCount++;
|
||||
break;
|
||||
case 2:
|
||||
case '2':
|
||||
counts.textareaCount++;
|
||||
break;
|
||||
case 3:
|
||||
case '3':
|
||||
counts.radioCount++;
|
||||
question.questionnaireQuestionItems.push({itemContent: ''});
|
||||
break;
|
||||
case 4:
|
||||
case '4':
|
||||
counts.checkboxCount++;
|
||||
question.questionnaireQuestionItems.push({itemContent: ''});
|
||||
break;
|
||||
case 5:
|
||||
case '5':
|
||||
counts.rateCount++;
|
||||
break;
|
||||
case 6:
|
||||
case '6':
|
||||
counts.datePickerCount++;
|
||||
break;
|
||||
}
|
||||
formState.questionnaireQuestions.push(question);
|
||||
}
|
||||
|
||||
function addOptions(val: any) {
|
||||
|
||||
function addOptions(index: number) {
|
||||
formState.questionnaireQuestions[index]?.questionnaireQuestionItems.push({itemContent: ''})
|
||||
}
|
||||
|
||||
function deleteOptions(index: number, type: number) {
|
||||
formState.questionList.splice(index, 1)
|
||||
function deleteOptions(index: number, type: string) {
|
||||
formState.questionnaireQuestions.splice(index, 1)
|
||||
switch (type) {
|
||||
case 1:
|
||||
case '1':
|
||||
counts.inputCount--;
|
||||
break;
|
||||
case 2:
|
||||
case '2':
|
||||
counts.textareaCount--;
|
||||
break;
|
||||
case 3:
|
||||
case '3':
|
||||
counts.radioCount--;
|
||||
break;
|
||||
case 4:
|
||||
case '4':
|
||||
counts.checkboxCount--;
|
||||
break;
|
||||
case 5:
|
||||
case '5':
|
||||
counts.rateCount--;
|
||||
break;
|
||||
case 6:
|
||||
case '6':
|
||||
counts.datePickerCount--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave(type: number) {
|
||||
await modalApi.close();
|
||||
const formRef = ref();
|
||||
|
||||
async function handleSave(type: string) {
|
||||
try {
|
||||
await formRef.value.validate();
|
||||
const data = cloneDeep(formState);
|
||||
if (!data.questionnaireQuestions.length) {
|
||||
message.error('还没有问题,请添加');
|
||||
return;
|
||||
}
|
||||
modalApi.lock(true);
|
||||
data.status = type;
|
||||
data.questionnaireQuestions.forEach((item, index) => {
|
||||
item.sort = index + 1;
|
||||
item.questionnaireQuestionItems.forEach((option, i) => {
|
||||
option.sort = i + 1;
|
||||
});
|
||||
});
|
||||
await (isUpdate.value ? questionnaireUpdate(data) : questionnaireAdd(data));
|
||||
emit('reload');
|
||||
await modalApi.close();
|
||||
} catch (error: any) {
|
||||
if (error.errorFields) {
|
||||
const firstErrorField = error.errorFields[0].name[0];
|
||||
formRef.value.scrollToField(firstErrorField);
|
||||
message.error('请完善问卷');
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
} finally {
|
||||
modalApi.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
onMounted(() => {
|
||||
getDictOptions('wy_wtsjlx')
|
||||
})
|
||||
|
||||
@ -194,22 +227,22 @@ onMounted(()=>{
|
||||
<div class="left-options">
|
||||
<div class="header-title">问题设计</div>
|
||||
<Badge :count="counts.inputCount" :number-style="{ backgroundColor: '#3996f3' }">
|
||||
<a-button size="large" @click="handleAddQuestion(1)">单行文本</a-button>
|
||||
<a-button size="large" @click="handleAddQuestion('1')">单行文本</a-button>
|
||||
</Badge>
|
||||
<Badge :count="counts.textareaCount" :number-style="{ backgroundColor: '#3996f3' }">
|
||||
<a-button size="large" @click="handleAddQuestion(2)">多行文本</a-button>
|
||||
<a-button size="large" @click="handleAddQuestion('2')">多行文本</a-button>
|
||||
</Badge>
|
||||
<Badge :count="counts.radioCount" :number-style="{ backgroundColor: '#3996f3' }">
|
||||
<a-button size="large" @click="handleAddQuestion(3)">单选题</a-button>
|
||||
<a-button size="large" @click="handleAddQuestion('3')">单选题</a-button>
|
||||
</Badge>
|
||||
<Badge :count="counts.checkboxCount" :number-style="{ backgroundColor: '#3996f3' }">
|
||||
<a-button size="large" @click="handleAddQuestion(4)">多选题</a-button>
|
||||
<a-button size="large" @click="handleAddQuestion('4')">多选题</a-button>
|
||||
</Badge>
|
||||
<Badge :count="counts.rateCount" :number-style="{ backgroundColor: '#3996f3' }">
|
||||
<a-button size="large" @click="handleAddQuestion(5)">评分题</a-button>
|
||||
<a-button size="large" @click="handleAddQuestion('5')">评分题</a-button>
|
||||
</Badge>
|
||||
<Badge :count="counts.datePickerCount" :number-style="{ backgroundColor: '#3996f3' }">
|
||||
<a-button size="large" @click="handleAddQuestion(6)">日期选择</a-button>
|
||||
<a-button size="large" @click="handleAddQuestion('6')">日期选择</a-button>
|
||||
</Badge>
|
||||
</div>
|
||||
</Col>
|
||||
@ -219,24 +252,25 @@ onMounted(()=>{
|
||||
<Form
|
||||
:model="formState"
|
||||
name="basic"
|
||||
ref="formRef"
|
||||
>
|
||||
<FormItem
|
||||
label="问卷标题"
|
||||
name="username"
|
||||
:rules="[{ required: true, message: '问卷标题不能为空' }]"
|
||||
name="head"
|
||||
:rules="[{ required: true, }]"
|
||||
>
|
||||
<Input v-model:value="formState.username"/>
|
||||
<Input v-model:value="formState.head" placeholder="请输入"/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="问卷描述"
|
||||
name="password"
|
||||
:rules="[{ required: true, message: 'Please input your password!' }]"
|
||||
name="depict"
|
||||
:rules="[{ required: true, }]"
|
||||
>
|
||||
<Input v-model:value="formState.password"/>
|
||||
<Input v-model:value="formState.depict" placeholder="请输入"/>
|
||||
</FormItem>
|
||||
<div v-if="formState.questionList.length">
|
||||
<div v-for="(item,index) in formState.questionList">
|
||||
<div v-if="formState.questionnaireQuestions.length">
|
||||
<div v-for="(item,index) in formState.questionnaireQuestions">
|
||||
<Divider orientation="left">
|
||||
问题{{ (index + 1) + '\xa0' + renderDictValue(item.type, 'wy_wtsjlx') }}
|
||||
<Popover placement="top">
|
||||
@ -252,32 +286,42 @@ onMounted(()=>{
|
||||
</Divider>
|
||||
<FormItem
|
||||
label="问题标题"
|
||||
name="username"
|
||||
:name="['questionnaireQuestions',index,'head']"
|
||||
:rules="[{ required: true }]"
|
||||
>
|
||||
<Input v-model:value="formState.username"/>
|
||||
<Input v-model:value="item.head" placeholder="请输入"/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="问题描述"
|
||||
name="password"
|
||||
:rules="[{ required: true }]"
|
||||
:label="'\xa0\xa0\xa0问题描述'"
|
||||
:name="['questionnaireQuestions',index,'depict']"
|
||||
>
|
||||
<Input v-model:value="formState.password"/>
|
||||
<Input v-model:value="item.depict" placeholder="请输入"/>
|
||||
</FormItem>
|
||||
<Row :gutter="24" v-if="item.type==3||item.type==4">
|
||||
<Row :gutter="24" v-if="item.type=='3'||item.type=='4'">
|
||||
<Col class="gutter-row" :span="12">
|
||||
<FormItem
|
||||
label="选项设置"
|
||||
name="password"
|
||||
:name="['questionnaireQuestions',index,'questionnaireQuestionItems']"
|
||||
:rules="[{ required: true }]"
|
||||
>
|
||||
<Input style="margin-bottom: 10px" v-model:value="formState.password"
|
||||
placeholder="选项1"/>
|
||||
<Input v-model:value="formState.password" placeholder="选项1"/>
|
||||
<div v-for="(option, i) in item.questionnaireQuestionItems" :key="i"
|
||||
class="option-item">
|
||||
<FormItem
|
||||
:name="['questionnaireQuestions', index, 'questionnaireQuestionItems', i, 'itemContent']"
|
||||
:rules="[{ required: true, message: '' }]"
|
||||
>
|
||||
<Input
|
||||
style="margin-bottom: 10px"
|
||||
v-model:value="option.itemContent"
|
||||
:placeholder="`选项${i + 1}`"
|
||||
/>
|
||||
</FormItem>
|
||||
</div>
|
||||
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col class="gutter-row" :span="12">
|
||||
<a-button @click="addOptions(item)">
|
||||
<a-button @click="addOptions(index)">
|
||||
<template #icon>
|
||||
<PlusOutlined/>
|
||||
</template>
|
||||
@ -286,25 +330,25 @@ onMounted(()=>{
|
||||
</Col>
|
||||
</Row>
|
||||
<FormItem
|
||||
v-if="item.type==5"
|
||||
v-if="item.type=='5'"
|
||||
label="评分预览"
|
||||
name="password"
|
||||
:name="['questionnaireQuestions',index,'rate']"
|
||||
>
|
||||
<Rate v-model:value="formState.username"/>
|
||||
<Rate v-model:value="item.rate"/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
v-if="item.type==6"
|
||||
v-if="item.type=='6'"
|
||||
label="日期选择预览"
|
||||
name="password"
|
||||
:name="['questionnaireQuestions',index,'dateTime']"
|
||||
>
|
||||
<DatePicker style="width: 180px" v-model:value="formState.username"/>
|
||||
<DatePicker style="width: 180px" v-model:value="item.dateTime"/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="是否必填"
|
||||
name="password"
|
||||
:rules="[{ required: true, message: 'Please input your password!' }]"
|
||||
:name="['questionnaireQuestions',index,'isRequired']"
|
||||
:rules="[{ required: true}]"
|
||||
>
|
||||
<Switch v-model:checked="formState.username"/>
|
||||
<Switch v-model:checked="item.isRequired" checkedValue="1" unCheckedValue="2"/>
|
||||
</FormItem>
|
||||
</div>
|
||||
</div>
|
||||
@ -316,28 +360,30 @@ onMounted(()=>{
|
||||
<Col class="gutter-row" :span="6">
|
||||
<FormItem
|
||||
label="匿名收集"
|
||||
name="username"
|
||||
name="isAnonyCollec"
|
||||
:rules="[{ required: true, message: '匿名收集不能为空' }]"
|
||||
>
|
||||
<Switch v-model:checked="formState.username"/>
|
||||
<Switch v-model:checked="formState.isAnonyCollec" checkedValue="1"
|
||||
unCheckedValue="2"/>
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col class="gutter-row" :span="6">
|
||||
<FormItem
|
||||
label="允许多次提交"
|
||||
name="username"
|
||||
:rules="[{ required: true, message: '多次提交不能为空' }]"
|
||||
name="isCommit"
|
||||
:rules="[{ required: true }]"
|
||||
>
|
||||
<Switch v-model:checked="formState.username"/>
|
||||
<Switch v-model:checked="formState.isCommit" checkedValue="1"
|
||||
unCheckedValue="2"/>
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col class="gutter-row" :span="12">
|
||||
<FormItem
|
||||
label="截至日期"
|
||||
name="username"
|
||||
:rules="[{ required: true, message: '截止日期不能为空' }]"
|
||||
name="deadline"
|
||||
:rules="[{ required: true }]"
|
||||
>
|
||||
<DatePicker style="width: 180px" v-model:value="formState.username"/>
|
||||
<DatePicker style="width: 180px" v-model:value="formState.deadline" format="YYYY-MM-DD" value-format="YYYY-MM-DD"/>
|
||||
</FormItem>
|
||||
</Col>
|
||||
</Row>
|
||||
@ -346,8 +392,8 @@ onMounted(()=>{
|
||||
</Col>
|
||||
</Row>
|
||||
<div class="footer-button">
|
||||
<a-button type="primary" @click="handleSave(1)">保存并发布</a-button>
|
||||
<a-button @click="handleSave(2)">保存为草稿</a-button>
|
||||
<a-button type="primary" @click="handleSave('2')">保存并发布</a-button>
|
||||
<a-button @click="handleSave('1')">保存为草稿</a-button>
|
||||
<a-button @click="handleCancel">取消</a-button>
|
||||
|
||||
</div>
|
||||
@ -382,6 +428,25 @@ onMounted(()=>{
|
||||
max-height: 87vh;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
|
||||
.option-item {
|
||||
:deep(.ant-form-item .ant-form-item-control-input) {
|
||||
margin-bottom: -20px;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
height: 50vh;
|
||||
border: 2px dashed #dce0e6;
|
||||
border-radius: 10px;
|
||||
|
||||
:deep(.ant-empty .ant-empty-image) {
|
||||
margin-top: 15vh;
|
||||
}
|
||||
|
||||
margin-bottom: 10px;
|
||||
margin-left: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-button {
|
||||
@ -399,23 +464,7 @@ onMounted(()=>{
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
height: 50vh;
|
||||
border: 2px dashed #dce0e6;
|
||||
border-radius: 10px;
|
||||
|
||||
:deep(.ant-empty .ant-empty-image) {
|
||||
margin-top: 15vh;
|
||||
}
|
||||
|
||||
margin-bottom: 10px;
|
||||
margin-left: 80px;
|
||||
}
|
||||
|
||||
.question-item-title {
|
||||
font-weight: bold;
|
||||
margin: 5px 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user