This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
import type { InspectionItemVO, InspectionItemForm, InspectionItemQuery } 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 inspectionItemList(params?: InspectionItemQuery) {
|
||||||
|
return requestClient.get<PageResult<InspectionItemVO>>('/property/inspectionItem/list', { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出巡检项目列表
|
||||||
|
* @param params
|
||||||
|
* @returns 巡检项目列表
|
||||||
|
*/
|
||||||
|
export function inspectionItemExport(params?: InspectionItemQuery) {
|
||||||
|
return commonExport('/property/inspectionItem/export', params ?? {});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询巡检项目详情
|
||||||
|
* @param id id
|
||||||
|
* @returns 巡检项目详情
|
||||||
|
*/
|
||||||
|
export function inspectionItemInfo(id: ID) {
|
||||||
|
return requestClient.get<InspectionItemVO>(`/property/inspectionItem/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增巡检项目
|
||||||
|
* @param data
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function inspectionItemAdd(data: InspectionItemForm) {
|
||||||
|
return requestClient.postWithMsg<void>('/property/inspectionItem', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新巡检项目
|
||||||
|
* @param data
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function inspectionItemUpdate(data: InspectionItemForm) {
|
||||||
|
return requestClient.putWithMsg<void>('/property/inspectionItem', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除巡检项目
|
||||||
|
* @param id id
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function inspectionItemRemove(id: ID | IDS) {
|
||||||
|
return requestClient.deleteWithMsg<void>(`/property/inspectionItem/${id}`);
|
||||||
|
}
|
49
apps/web-antd/src/api/property/inspectionManagement/inspectionItem/model.d.ts
vendored
Normal file
49
apps/web-antd/src/api/property/inspectionManagement/inspectionItem/model.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||||
|
|
||||||
|
export interface InspectionItemVO {
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
id: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目名称
|
||||||
|
*/
|
||||||
|
itemName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
remark: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InspectionItemForm extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
id?: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目名称
|
||||||
|
*/
|
||||||
|
itemName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
remark?: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InspectionItemQuery extends PageQuery {
|
||||||
|
/**
|
||||||
|
* 项目名称
|
||||||
|
*/
|
||||||
|
itemName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期范围参数
|
||||||
|
*/
|
||||||
|
params?: any;
|
||||||
|
}
|
@@ -4,6 +4,8 @@ import {renderDict} from "#/utils/render";
|
|||||||
import {getDictOptions} from "#/utils/dict";
|
import {getDictOptions} from "#/utils/dict";
|
||||||
import {h} from "vue";
|
import {h} from "vue";
|
||||||
import {Rate} from "ant-design-vue";
|
import {Rate} from "ant-design-vue";
|
||||||
|
import type {Dayjs} from "dayjs";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
|
||||||
export const querySchema: FormSchemaGetter = () => [
|
export const querySchema: FormSchemaGetter = () => [
|
||||||
@@ -39,6 +41,11 @@ export const columns: VxeGridProps['columns'] = [
|
|||||||
field: 'orderName',
|
field: 'orderName',
|
||||||
minWidth: 180,
|
minWidth: 180,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '工单类型',
|
||||||
|
field: 'typeName',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '派单时间',
|
title: '派单时间',
|
||||||
field: 'dispatchTime',
|
field: 'dispatchTime',
|
||||||
@@ -143,6 +150,7 @@ export const modalSchema: FormSchemaGetter = () => [
|
|||||||
showTime: true,
|
showTime: true,
|
||||||
format: 'YYYY-MM-DD HH:mm:ss',
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
disabledDate: disabledDate
|
||||||
},
|
},
|
||||||
rules: 'selectRequired',
|
rules: 'selectRequired',
|
||||||
},
|
},
|
||||||
@@ -208,3 +216,6 @@ export const modalSchema: FormSchemaGetter = () => [
|
|||||||
rules: 'selectRequired',
|
rules: 'selectRequired',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
const disabledDate = (current: Dayjs) => {
|
||||||
|
return current && current < dayjs().endOf('day');
|
||||||
|
};
|
||||||
|
@@ -35,6 +35,14 @@ const formOptions: VbenFormProps = {
|
|||||||
},
|
},
|
||||||
schema: querySchema(),
|
schema: querySchema(),
|
||||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||||
|
handleReset: async () => {
|
||||||
|
ordersType.value = '0';
|
||||||
|
const { formApi, reload } = tableApi;
|
||||||
|
await formApi.resetForm();
|
||||||
|
const formValues = formApi.form.values;
|
||||||
|
formApi.setLatestSubmissionValues(formValues);
|
||||||
|
await reload(formValues);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const gridOptions: VxeGridProps = {
|
const gridOptions: VxeGridProps = {
|
||||||
@@ -53,6 +61,7 @@ const gridOptions: VxeGridProps = {
|
|||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async ({page}, formValues = {}) => {
|
query: async ({page}, formValues = {}) => {
|
||||||
|
formValues.type = ordersType.value=='0'?undefined:ordersType.value;
|
||||||
return await workOrdersList({
|
return await workOrdersList({
|
||||||
pageNum: page.currentPage,
|
pageNum: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
@@ -85,7 +94,7 @@ function handleAdd() {
|
|||||||
modalApi.setData({});
|
modalApi.setData({});
|
||||||
modalApi.open();
|
modalApi.open();
|
||||||
}
|
}
|
||||||
function handleInfo(row) {
|
function handleInfo(row:any) {
|
||||||
detailApi.setData({id:row.id});
|
detailApi.setData({id:row.id});
|
||||||
detailApi.open();
|
detailApi.open();
|
||||||
}
|
}
|
||||||
@@ -139,21 +148,14 @@ async function queryOrderType() {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await queryOrderType()
|
await queryOrderType()
|
||||||
});
|
});
|
||||||
|
|
||||||
async function changeOrdersType(val: string) {
|
|
||||||
await tableApi.formApi.setValues({
|
|
||||||
type: val === '0' ? undefined : val, // '0' 表示全部工单,传 undefined 或清除该字段
|
|
||||||
});
|
|
||||||
console.log(tableApi.formApi.getValues(),'==================')
|
|
||||||
await tableApi.query()
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page :auto-content-height="true">
|
<Page :auto-content-height="true">
|
||||||
<BasicTable table-title="工单处理列表">
|
<BasicTable table-title="工单处理列表" class="order-work-left-radio">
|
||||||
<template #table-title>
|
<template #table-title>
|
||||||
<RadioGroup v-model:value="ordersType" button-style="solid" @change="changeOrdersType">
|
<RadioGroup v-model:value="ordersType" button-style="solid"
|
||||||
|
@change="() => tableApi.reload()">
|
||||||
<RadioButton v-for="item in ordersTypeList"
|
<RadioButton v-for="item in ordersTypeList"
|
||||||
:value="item.value">{{ item.label }}
|
:value="item.value">{{ item.label }}
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
@@ -219,3 +221,18 @@ async function changeOrdersType(val: string) {
|
|||||||
<WorkOrdersDetail/>
|
<WorkOrdersDetail/>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
:where(.css-dev-only-do-not-override-aza1th).ant-radio-group {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow-y: hidden;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<style lang="scss">
|
||||||
|
.order-work-left-radio{
|
||||||
|
.vxe-toolbar .vxe-buttons--wrapper, .vxe-toolbar .vxe-tools--wrapper {
|
||||||
|
max-width: 70% !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@@ -24,7 +24,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const orderDetail = shallowRef<null | WorkOrdersVO>(null);
|
const orderDetail = shallowRef<null | WorkOrdersVO>(null);
|
||||||
|
const handleRecords=ref<any[]>([])
|
||||||
async function handleOpenChange(open: boolean) {
|
async function handleOpenChange(open: boolean) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
return null;
|
return null;
|
||||||
@@ -34,6 +34,13 @@ async function handleOpenChange(open: boolean) {
|
|||||||
const {id} = modalApi.getData() as { id: number | string };
|
const {id} = modalApi.getData() as { id: number | string };
|
||||||
// 赋值
|
// 赋值
|
||||||
orderDetail.value = await workOrdersInfo(id);
|
orderDetail.value = await workOrdersInfo(id);
|
||||||
|
if(orderDetail.value){
|
||||||
|
handleRecords.value=[
|
||||||
|
{type:orderDetail.value.typeName,time:orderDetail.value.compleTime,personName:orderDetail.value.handlerText},
|
||||||
|
{type:'跟进',time:orderDetail.value.dispatchTime,personName:orderDetail.value.initiatorNameText},
|
||||||
|
{type:'创建工单',time:orderDetail.value.createTime,personName:orderDetail.value.initiatorNameText},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
modalApi.modalLoading(false);
|
modalApi.modalLoading(false);
|
||||||
}
|
}
|
||||||
@@ -52,18 +59,16 @@ async function handleOpenChange(open: boolean) {
|
|||||||
{{ orderDetail.orderName }}
|
{{ orderDetail.orderName }}
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="工单类型">
|
<DescriptionsItem label="工单类型">
|
||||||
<component
|
{{orderDetail.typeName}}
|
||||||
:is="renderDict(orderDetail.customerType,'wy_khlx')"
|
|
||||||
/>
|
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="发起人">
|
<DescriptionsItem label="发起人">
|
||||||
{{ orderDetail.rentalPeriod }}
|
{{ orderDetail.initiatorNameText+'-'+orderDetail.initiatorPhone}}
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="派单时间">
|
<DescriptionsItem label="派单时间">
|
||||||
{{ orderDetail.dispatchTime }}
|
{{ orderDetail.dispatchTime }}
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="处理人">
|
<DescriptionsItem label="处理人">
|
||||||
{{ orderDetail.totalAmount + "元" }}
|
{{ orderDetail.handlerText }}
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="具体位置" :span="2">
|
<DescriptionsItem label="具体位置" :span="2">
|
||||||
{{ orderDetail.location }}
|
{{ orderDetail.location }}
|
||||||
@@ -74,7 +79,7 @@ async function handleOpenChange(open: boolean) {
|
|||||||
<DescriptionsItem label="完成时间">
|
<DescriptionsItem label="完成时间">
|
||||||
{{ orderDetail.compleTime }}
|
{{ orderDetail.compleTime }}
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="评价">
|
<DescriptionsItem label="服务评价">
|
||||||
<Rate :value="orderDetail.serviceEvalua" disabled/>
|
<Rate :value="orderDetail.serviceEvalua" disabled/>
|
||||||
</DescriptionsItem>
|
</DescriptionsItem>
|
||||||
<DescriptionsItem label="是否超时">
|
<DescriptionsItem label="是否超时">
|
||||||
@@ -86,11 +91,11 @@ async function handleOpenChange(open: boolean) {
|
|||||||
<Divider orientation="left" orientation-margin="0px">
|
<Divider orientation="left" orientation-margin="0px">
|
||||||
处理记录
|
处理记录
|
||||||
</Divider>
|
</Divider>
|
||||||
<Timeline>
|
<Timeline v-if="handleRecords.length">
|
||||||
<TimelineItem>
|
<TimelineItem v-for="item in handleRecords">
|
||||||
<p>类型:</p>
|
<p>类型:{{item.type}}</p>
|
||||||
<p>时间:</p>
|
<p>时间:{{item.time}}</p>
|
||||||
<p>处理人:</p>
|
<p>处理人:{{item.personName}}</p>
|
||||||
</TimelineItem>
|
</TimelineItem>
|
||||||
</Timeline>
|
</Timeline>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
import type { FormSchemaGetter } from '#/adapter/form';
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
|
||||||
|
export const querySchema: FormSchemaGetter = () => [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'itemName',
|
||||||
|
label: '项目名称',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||||
|
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||||
|
export const columns: VxeGridProps['columns'] = [
|
||||||
|
{ type: 'checkbox', width: 60 },
|
||||||
|
{
|
||||||
|
title: '主键id',
|
||||||
|
field: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '项目名称',
|
||||||
|
field: 'itemName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
field: 'remark',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'action' },
|
||||||
|
title: '操作',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const modalSchema: FormSchemaGetter = () => [
|
||||||
|
{
|
||||||
|
label: '主键id',
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
show: () => false,
|
||||||
|
triggerFields: [''],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '项目名称',
|
||||||
|
fieldName: 'itemName',
|
||||||
|
component: 'Input',
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
fieldName: 'remark',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
];
|
@@ -0,0 +1,182 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
||||||
|
import { getVxePopupContainer } from '@vben/utils';
|
||||||
|
|
||||||
|
import { Modal, Popconfirm, Space } from 'ant-design-vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import {
|
||||||
|
useVbenVxeGrid,
|
||||||
|
vxeCheckboxChecked,
|
||||||
|
type VxeGridProps
|
||||||
|
} from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import {
|
||||||
|
inspectionItemExport,
|
||||||
|
inspectionItemList,
|
||||||
|
inspectionItemRemove,
|
||||||
|
} from '#/api/property/inspectionManagement/inspectionItem';
|
||||||
|
import type { InspectionItemForm } from '#/api/property/inspectionManagement/inspectionItem/model';
|
||||||
|
import { commonDownloadExcel } from '#/utils/file/download';
|
||||||
|
|
||||||
|
import inspectionItemModal from './inspectionItem-modal.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',
|
||||||
|
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
|
||||||
|
// 不需要直接删除
|
||||||
|
// fieldMappingTime: [
|
||||||
|
// [
|
||||||
|
// 'createTime',
|
||||||
|
// ['params[beginTime]', 'params[endTime]'],
|
||||||
|
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
};
|
||||||
|
|
||||||
|
const gridOptions: VxeGridProps = {
|
||||||
|
checkboxConfig: {
|
||||||
|
// 高亮
|
||||||
|
highlight: true,
|
||||||
|
// 翻页时保留选中状态
|
||||||
|
reserve: true,
|
||||||
|
// 点击行选中
|
||||||
|
// trigger: 'row',
|
||||||
|
},
|
||||||
|
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||||
|
// columns: columns(),
|
||||||
|
columns,
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
pagerConfig: {},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues = {}) => {
|
||||||
|
return await inspectionItemList({
|
||||||
|
pageNum: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
// 表格全局唯一表示 保存列配置需要用到
|
||||||
|
id: 'property-inspectionItem-index'
|
||||||
|
};
|
||||||
|
|
||||||
|
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||||
|
formOptions,
|
||||||
|
gridOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [InspectionItemModal, modalApi] = useVbenModal({
|
||||||
|
connectedComponent: inspectionItemModal,
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
modalApi.setData({});
|
||||||
|
modalApi.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleEdit(row: Required<InspectionItemForm>) {
|
||||||
|
modalApi.setData({ id: row.id });
|
||||||
|
modalApi.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(row: Required<InspectionItemForm>) {
|
||||||
|
await inspectionItemRemove(row.id);
|
||||||
|
await tableApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMultiDelete() {
|
||||||
|
const rows = tableApi.grid.getCheckboxRecords();
|
||||||
|
const ids = rows.map((row: Required<InspectionItemForm>) => row.id);
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
okType: 'danger',
|
||||||
|
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||||
|
onOk: async () => {
|
||||||
|
await inspectionItemRemove(ids);
|
||||||
|
await tableApi.query();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDownloadExcel() {
|
||||||
|
commonDownloadExcel(inspectionItemExport, '巡检项目数据', 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="['property:inspectionItem:export']"
|
||||||
|
@click="handleDownloadExcel"
|
||||||
|
>
|
||||||
|
{{ $t('pages.common.export') }}
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||||
|
danger
|
||||||
|
type="primary"
|
||||||
|
v-access:code="['property:inspectionItem:remove']"
|
||||||
|
@click="handleMultiDelete">
|
||||||
|
{{ $t('pages.common.delete') }}
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
v-access:code="['property:inspectionItem:add']"
|
||||||
|
@click="handleAdd"
|
||||||
|
>
|
||||||
|
{{ $t('pages.common.add') }}
|
||||||
|
</a-button>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<template #action="{ row }">
|
||||||
|
<Space>
|
||||||
|
<ghost-button
|
||||||
|
v-access:code="['property:inspectionItem: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="['property:inspectionItem:remove']"
|
||||||
|
@click.stop=""
|
||||||
|
>
|
||||||
|
{{ $t('pages.common.delete') }}
|
||||||
|
</ghost-button>
|
||||||
|
</Popconfirm>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
<InspectionItemModal @reload="tableApi.query()" />
|
||||||
|
</Page>
|
||||||
|
</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 { inspectionItemAdd, inspectionItemInfo, inspectionItemUpdate } from '#/api/property/inspectionManagement/inspectionItem';
|
||||||
|
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-[550px]',
|
||||||
|
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 inspectionItemInfo(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 ? inspectionItemUpdate(data) : inspectionItemAdd(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>
|
||||||
|
|
Reference in New Issue
Block a user