2、维修知识管理
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import type { KnowledgeVO, KnowledgeForm, KnowledgeQuery } from './model';
|
||||
|
||||
import type { ID, IDS } from '#/api/common';
|
||||
import type { PageResult } from '#/api/common';
|
||||
|
||||
import { commonExport } from '#/api/helper';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 查询维保知识管理列表
|
||||
* @param params
|
||||
* @returns 维保知识管理列表
|
||||
*/
|
||||
export function knowledgeList(params?: KnowledgeQuery) {
|
||||
return requestClient.get<PageResult<KnowledgeVO>>('/property/knowledge/list', { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出维保知识管理列表
|
||||
* @param params
|
||||
* @returns 维保知识管理列表
|
||||
*/
|
||||
export function knowledgeExport(params?: KnowledgeQuery) {
|
||||
return commonExport('/property/knowledge/export', params ?? {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询维保知识管理详情
|
||||
* @param id id
|
||||
* @returns 维保知识管理详情
|
||||
*/
|
||||
export function knowledgeInfo(id: ID) {
|
||||
return requestClient.get<KnowledgeVO>(`/property/knowledge/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增维保知识管理
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function knowledgeAdd(data: KnowledgeForm) {
|
||||
return requestClient.postWithMsg<void>('/property/knowledge', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新维保知识管理
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function knowledgeUpdate(data: KnowledgeForm) {
|
||||
return requestClient.putWithMsg<void>('/property/knowledge', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除维保知识管理
|
||||
* @param id id
|
||||
* @returns void
|
||||
*/
|
||||
export function knowledgeRemove(id: ID | IDS) {
|
||||
return requestClient.deleteWithMsg<void>(`/property/knowledge/${id}`);
|
||||
}
|
129
apps/web-antd/src/api/property/maintenance/knowledge/model.d.ts
vendored
Normal file
129
apps/web-antd/src/api/property/maintenance/knowledge/model.d.ts
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
|
||||
export interface KnowledgeVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* 状态(0草稿1状态2已发布)
|
||||
*/
|
||||
status: string;
|
||||
|
||||
/**
|
||||
* 封面
|
||||
*/
|
||||
covers: string;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
depict: string;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
releaseTime: string;
|
||||
|
||||
/**
|
||||
* 位置类型(0操作指引,1处理案例2常见问题)
|
||||
*/
|
||||
type: string;
|
||||
|
||||
}
|
||||
|
||||
export interface KnowledgeForm extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* 状态(0草稿1状态2已发布)
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
/**
|
||||
* 封面
|
||||
*/
|
||||
covers?: string;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
content?: string;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
depict?: string;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
releaseTime?: string;
|
||||
|
||||
/**
|
||||
* 位置类型(0操作指引,1处理案例2常见问题)
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface KnowledgeQuery extends PageQuery {
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* 状态(0草稿1状态2已发布)
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
/**
|
||||
* 封面
|
||||
*/
|
||||
covers?: string;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
content?: string;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
depict?: string;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
releaseTime?: string;
|
||||
|
||||
/**
|
||||
* 位置类型(0操作指引,1处理案例2常见问题)
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
@@ -93,10 +93,10 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
label: item.label,
|
||||
shiftValue: '休息',
|
||||
isRest: 1,
|
||||
id: null,
|
||||
shiftId: null,
|
||||
})
|
||||
})
|
||||
settingData.cycleData = [{id: ''}, {id: ''}];
|
||||
settingData.cycleData = [{scheduleId: ''}, {scheduleId: ''}];
|
||||
}
|
||||
await markInitialized();
|
||||
modalApi.modalLoading(false);
|
||||
@@ -115,7 +115,7 @@ async function handleConfirm() {
|
||||
if (data.attendanceType == 1) {
|
||||
let hasError = false;
|
||||
settingData.cycleData.forEach((item, index) => {
|
||||
if (!item.id) {
|
||||
if (!item.scheduleId) {
|
||||
message.warning('请选择周期天数对应班次。');
|
||||
return;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ function handleShiftInfo(info: ShiftVO) {
|
||||
settingData.shiftId = info.id
|
||||
shiftInfo.value = info;
|
||||
settingData.weekdayData.forEach(item => {
|
||||
item.id = info.id
|
||||
item.shiftId = info.id
|
||||
let str = ''
|
||||
if (info.isRest) {
|
||||
str = `${info.name}:${info.startTime}~${info.restStartTime} ${info.restEndTime}~${info.endTime}`;
|
||||
@@ -209,7 +209,7 @@ function handleShiftList(list: any[]) {
|
||||
function addCycleHandle() {
|
||||
if (settingData.cycleData.length < 31) {
|
||||
settingData.cycleData.push({
|
||||
id: '',
|
||||
scheduleId: '',
|
||||
})
|
||||
} else {
|
||||
message.warning('周期天数最多31天。');
|
||||
@@ -244,12 +244,12 @@ function changeShiftHandle(type: number, index: number) {
|
||||
function restHandle(index: number) {
|
||||
settingData.weekdayData[index].isRest = 1
|
||||
settingData.weekdayData[index].shiftValue = '休息'
|
||||
settingData.weekdayData[index].id = null
|
||||
settingData.weekdayData[index].shiftId = null
|
||||
}
|
||||
|
||||
function handleAfterValue(val: ShiftVO) {
|
||||
if (tableIndex.value > -1 && val) {
|
||||
settingData.weekdayData[tableIndex.value].id = val.id
|
||||
settingData.weekdayData[tableIndex.value].shiftId = val.id
|
||||
let str = ''
|
||||
if (val.isRest) {
|
||||
str = `${val.name}:${val.startTime}~${val.restStartTime} ${val.restEndTime}~${val.endTime}`;
|
||||
|
147
apps/web-antd/src/views/property/maintenance/knowledge/data.ts
Normal file
147
apps/web-antd/src/views/property/maintenance/knowledge/data.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import {getDictOptions} from "#/utils/dict";
|
||||
import {renderDict} from "#/utils/render";
|
||||
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'title',
|
||||
label: '标题',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options:getDictOptions('wy_wbzszt')
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '发布状态',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions('wy_wbzslx')
|
||||
},
|
||||
fieldName: 'type',
|
||||
label: '知识类型',
|
||||
},
|
||||
];
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
export const columns: VxeGridProps['columns'] = [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
title: '标题',
|
||||
field: 'title',
|
||||
minWidth: 180
|
||||
},
|
||||
{
|
||||
title: '发布状态',
|
||||
field: 'status',
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return renderDict(row.status,'wy_wbzszt')
|
||||
}
|
||||
},
|
||||
width:180
|
||||
},
|
||||
{
|
||||
title: '发布时间',
|
||||
field: 'releaseTime',
|
||||
width:180
|
||||
},
|
||||
{
|
||||
title: '知识类型',
|
||||
field: 'type',
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return renderDict(row.type,'wy_wbzslx')
|
||||
}
|
||||
},
|
||||
width:180
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 180,
|
||||
},
|
||||
];
|
||||
|
||||
export const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '主键',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '标题',
|
||||
fieldName: 'title',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options:getDictOptions('wy_wbzszt')
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '发布状态',
|
||||
rules: 'selectRequired',
|
||||
formItemClass:'col-span-1'
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions('wy_wbzslx')
|
||||
},
|
||||
fieldName: 'type',
|
||||
label: '知识类型',
|
||||
rules: 'selectRequired',
|
||||
formItemClass:'col-span-1'
|
||||
},
|
||||
{
|
||||
label: '封面',
|
||||
fieldName: 'covers',
|
||||
component: 'ImageUpload',
|
||||
componentProps:{
|
||||
maxCount: 1,
|
||||
},
|
||||
// rules: 'required',
|
||||
formItemClass:'col-span-1'
|
||||
},
|
||||
{
|
||||
label: '发布时间',
|
||||
fieldName: 'releaseTime',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
rules: 'required',
|
||||
formItemClass:'col-span-1'
|
||||
},
|
||||
{
|
||||
label: '内容',
|
||||
fieldName: 'content',
|
||||
component: 'RichTextarea',
|
||||
componentProps: {
|
||||
// disabled: false, // 是否只读
|
||||
// height: 400 // 高度 默认400
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '描述',
|
||||
fieldName: 'depict',
|
||||
component: 'Textarea',
|
||||
},
|
||||
];
|
181
apps/web-antd/src/views/property/maintenance/knowledge/index.vue
Normal file
181
apps/web-antd/src/views/property/maintenance/knowledge/index.vue
Normal file
@@ -0,0 +1,181 @@
|
||||
<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 {
|
||||
knowledgeExport,
|
||||
knowledgeList,
|
||||
knowledgeRemove,
|
||||
} from '#/api/property/maintenance/knowledge';
|
||||
import type { KnowledgeForm } from '#/api/property/maintenance/knowledge/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import knowledgeModal from './knowledge-modal.vue';
|
||||
import knowledgeDetail from './knowledge-detail.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
labelWidth: 80,
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
schema: querySchema(),
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps = {
|
||||
checkboxConfig: {
|
||||
// 高亮
|
||||
highlight: true,
|
||||
// 翻页时保留选中状态
|
||||
reserve: true,
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues = {}) => {
|
||||
return await knowledgeList({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: 'domain-knowledge-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const [KnowledgeModal, modalApi] = useVbenModal({
|
||||
connectedComponent: knowledgeModal,
|
||||
});
|
||||
const [KnowledgeDetail, detailApi] = useVbenModal({
|
||||
connectedComponent: knowledgeDetail,
|
||||
});
|
||||
|
||||
// function handleAdd() {
|
||||
// modalApi.setData({});
|
||||
// modalApi.open();
|
||||
// }
|
||||
|
||||
async function handleInfo(row: Required<KnowledgeForm>) {
|
||||
detailApi.setData({ id: row.id });
|
||||
detailApi.open();
|
||||
}
|
||||
async function handleEdit(row: Required<KnowledgeForm>) {
|
||||
modalApi.setData({ id: row.id });
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<KnowledgeForm>) {
|
||||
await knowledgeRemove(row.id);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function handleMultiDelete() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: Required<KnowledgeForm>) => row.id);
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
okType: 'danger',
|
||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
onOk: async () => {
|
||||
await knowledgeRemove(ids);
|
||||
await tableApi.query();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(knowledgeExport, '维保知识管理数据', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true">
|
||||
<BasicTable table-title="维保知识列表">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<a-button
|
||||
v-access:code="['domain:knowledge:export']"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||
danger
|
||||
type="primary"
|
||||
v-access:code="['domain:knowledge:remove']"
|
||||
@click="handleMultiDelete">
|
||||
{{ $t('pages.common.delete') }}
|
||||
</a-button>
|
||||
<!-- <a-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- v-access:code="['domain:knowledge:add']"-->
|
||||
<!-- @click="handleAdd"-->
|
||||
<!-- >-->
|
||||
<!-- {{ $t('pages.common.add') }}-->
|
||||
<!-- </a-button>-->
|
||||
</Space>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['domain:knowledge:info']"
|
||||
@click.stop="handleInfo(row)"
|
||||
>
|
||||
{{ $t('pages.common.info') }}
|
||||
</ghost-button>
|
||||
<ghost-button
|
||||
v-access:code="['domain:knowledge:edit']"
|
||||
@click.stop="handleEdit(row)"
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
<Popconfirm
|
||||
:get-popup-container="getVxePopupContainer"
|
||||
placement="left"
|
||||
title="确认删除?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<ghost-button
|
||||
danger
|
||||
v-access:code="['domain:knowledge:remove']"
|
||||
@click.stop=""
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<KnowledgeModal @reload="tableApi.query()" />
|
||||
<KnowledgeDetail></KnowledgeDetail>
|
||||
</Page>
|
||||
</template>
|
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import {shallowRef} from 'vue';
|
||||
import {useVbenModal} from '@vben/common-ui';
|
||||
import {Descriptions, DescriptionsItem} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import {renderDict} from "#/utils/render";
|
||||
import {knowledgeInfo} from "#/api/property/maintenance/knowledge";
|
||||
import type {KnowledgeVO} from "#/api/property/maintenance/knowledge/model";
|
||||
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
onOpenChange: handleOpenChange,
|
||||
onClosed() {
|
||||
knowledgeDetail.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
const knowledgeDetail = shallowRef<null | KnowledgeVO>(null);
|
||||
|
||||
async function handleOpenChange(open: boolean) {
|
||||
if (!open) {
|
||||
return null;
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
const {id} = modalApi.getData() as { id: number | string };
|
||||
knowledgeDetail.value = await knowledgeInfo(id);
|
||||
modalApi.modalLoading(false);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :footer="false" :fullscreen-button="false" title="维修知识详情" class="w-[70%]">
|
||||
<Descriptions v-if="knowledgeDetail" size="small" :column="2" bordered
|
||||
:labelStyle="{width:'100px'}">
|
||||
<DescriptionsItem label="标题" :span="2">
|
||||
{{ knowledgeDetail.title }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="发布状态">
|
||||
<component
|
||||
:is="renderDict(knowledgeDetail.status,'wy_wbzszt')"
|
||||
/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="知识类型">
|
||||
<component
|
||||
:is="renderDict(knowledgeDetail.type,'wy_wbzslx')"
|
||||
/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="封面" :span="2">
|
||||
<img style="width: 100px" :src="knowledgeDetail.covers"/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="发布时间" :span="2">
|
||||
{{ knowledgeDetail.releaseTime}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="内容" :span="2">
|
||||
<span v-html="knowledgeDetail.content"></span>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="描述" :span="2">
|
||||
{{knowledgeDetail.depict}}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
</BasicModal>
|
||||
</template>
|
@@ -0,0 +1,101 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { knowledgeAdd, knowledgeInfo, knowledgeUpdate } from '#/api/property/maintenance/knowledge';
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
import { modalSchema } from './data';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
const [BasicForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 默认占满两列
|
||||
formItemClass: 'col-span-2',
|
||||
// 默认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({
|
||||
// 在这里更改宽度
|
||||
class: 'w-[70%]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
const { id } = modalApi.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await knowledgeInfo(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
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 ? knowledgeUpdate(data) : knowledgeAdd(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
modalApi.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :title="title">
|
||||
<BasicForm />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
@@ -0,0 +1,222 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, reactive, ref} from 'vue';
|
||||
|
||||
import {useVbenModal} from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
knowledgeList,
|
||||
} from '#/api/property/maintenance/knowledge';
|
||||
import knowledgeModal from '../knowledge/knowledge-modal.vue';
|
||||
import {
|
||||
Form,
|
||||
FormItem,
|
||||
SelectOption,
|
||||
Select,
|
||||
Card,
|
||||
CardMeta,
|
||||
Row,
|
||||
Col,
|
||||
Pagination,
|
||||
Empty
|
||||
} from 'ant-design-vue'
|
||||
import {PlusOutlined} from '@ant-design/icons-vue';
|
||||
import {getDictOptions} from "#/utils/dict";
|
||||
import type {KnowledgeForm, KnowledgeVO} from "#/api/property/maintenance/knowledge/model";
|
||||
import {renderDict} from "#/utils/render";
|
||||
import knowledgeDetail from '../knowledge/knowledge-detail.vue';
|
||||
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
||||
|
||||
const [KnowledgeModal, modalApi] = useVbenModal({
|
||||
connectedComponent: knowledgeModal,
|
||||
});
|
||||
|
||||
const [KnowledgeDetail, detailApi] = useVbenModal({
|
||||
connectedComponent: knowledgeDetail,
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
modalApi.setData({});
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
interface FormState {
|
||||
status?: string | undefined;
|
||||
type?: string | undefined;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
const formState = reactive<FormState>({
|
||||
status: undefined,
|
||||
type: undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 8,
|
||||
});
|
||||
|
||||
const pageList = ref<KnowledgeVO[]>([])
|
||||
const total = ref<number>(0)
|
||||
|
||||
const handleClean = () => {
|
||||
formState.status = undefined;
|
||||
formState.type = undefined;
|
||||
formState.pageNum = 1;
|
||||
queryPageList()
|
||||
}
|
||||
|
||||
async function queryPageList() {
|
||||
const res = await knowledgeList(formState)
|
||||
pageList.value = res.rows
|
||||
total.value = res.total
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
queryPageList()
|
||||
})
|
||||
|
||||
async function handleInfo(row: Required<KnowledgeForm>) {
|
||||
detailApi.setData({ id: row.id });
|
||||
detailApi.open();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="knowledge-content">
|
||||
<Form
|
||||
:model="formState"
|
||||
layout="inline"
|
||||
class="form-content"
|
||||
>
|
||||
<FormItem label="知识分类">
|
||||
<Select
|
||||
v-model:value="formState.type"
|
||||
style="width: 180px"
|
||||
>
|
||||
<SelectOption v-for="item in getDictOptions('wy_wbzslx')" :value="item.value">
|
||||
{{ item.label }}
|
||||
</SelectOption>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem label="发布状态">
|
||||
<Select
|
||||
v-model:value="formState.status"
|
||||
style="width: 180px"
|
||||
>
|
||||
<SelectOption v-for="item in getDictOptions('wy_wbzszt')" :value="item.value">
|
||||
{{ item.label }}
|
||||
</SelectOption>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<a-button @click="handleClean">重置</a-button>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<a-button type="primary" class="primary-button"
|
||||
@click="queryPageList">搜索
|
||||
</a-button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div class="right-button">
|
||||
<a-button @click="handleAdd" type="primary">
|
||||
<template #icon>
|
||||
<PlusOutlined/>
|
||||
</template>
|
||||
添加知识
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="middle-card" v-if="pageList.length">
|
||||
<Row :gutter="[16, 24]">
|
||||
<Col class="gutter-row" :span="6" v-for="item in pageList">
|
||||
<div class="gutter-box">
|
||||
<Card hoverable @click="handleInfo(item)">
|
||||
<template #cover>
|
||||
<img class="card-img"
|
||||
alt="图片加载失败"
|
||||
:src="item.covers"/>
|
||||
</template>
|
||||
<CardMeta :title="item.title">
|
||||
<template #description>
|
||||
<div class="card-desc">{{ item.depict }}</div>
|
||||
<div class="card-bottom-tag">
|
||||
<component
|
||||
:is="renderDict(item.status,'wy_wbzszt')"
|
||||
/>
|
||||
<component
|
||||
:is="renderDict(item.type,'wy_wbzslx')"
|
||||
/>
|
||||
<span>{{ item.releaseTime }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</CardMeta>
|
||||
</Card>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
<div v-else>
|
||||
<Empty style="margin-top: 100px" :image="simpleImage"/>
|
||||
</div>
|
||||
<div class="footer-pagination">
|
||||
<span>共 {{ total }} 条记录</span>
|
||||
<Pagination v-model:current="formState.pageNum"
|
||||
:showSizeChanger="false"
|
||||
:total="total"
|
||||
:pageSize="formState.pageSize"
|
||||
@change="queryPageList"
|
||||
show-less-items/>
|
||||
</div>
|
||||
<KnowledgeModal @reload="queryPageList"></KnowledgeModal>
|
||||
<KnowledgeDetail></KnowledgeDetail>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.knowledge-content {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.form-content {
|
||||
margin: 20px 0 0 20px;
|
||||
}
|
||||
|
||||
.right-button {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.middle-card {
|
||||
padding: 20px;
|
||||
|
||||
.card-img {
|
||||
height: 22vh;
|
||||
}
|
||||
|
||||
.card-desc {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.ant-card .ant-card-body) {
|
||||
padding: 14px 18px;
|
||||
}
|
||||
|
||||
.card-bottom-tag {
|
||||
display: inline-flex;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-pagination {
|
||||
padding-left: 20px;
|
||||
|
||||
:deep(.ant-pagination) {
|
||||
display: inline;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user