313 lines
7.7 KiB
Plaintext
313 lines
7.7 KiB
Plaintext
<template>
|
|
<PageWrapper>
|
|
<a-card :bordered="false" class="pt-3 mb-3 proCard">
|
|
<BasicForm
|
|
@register="register"
|
|
@submit="handleSubmit"
|
|
@reset="handleReset"
|
|
@advanced="formAdvanced"
|
|
:labelCol="{ span: 4 }"
|
|
>
|
|
<template #statusSlot="{ model, field }">
|
|
<a-input v-model:value="model[field]" placeholder="请输入状态" />
|
|
</template>
|
|
</BasicForm>
|
|
</a-card>
|
|
<a-card :bordered="false" class="proCard">
|
|
<BasicTable
|
|
:columns="columns"
|
|
:request="loadDataTable"
|
|
:row-key="(row) => row.id"
|
|
ref="actionRef"
|
|
:actionColumn="actionColumn"
|
|
@columns-change="onColumnsChange"
|
|
@update:checked-row-keys="onCheckedRow"
|
|
>
|
|
<template #tableTitle>
|
|
<a-button type="primary" @click="addTable">
|
|
<template #icon>
|
|
<PlusOutlined />
|
|
</template>
|
|
新建
|
|
</a-button>
|
|
</template>
|
|
|
|
<template #toolbar>
|
|
<a-button type="primary" @click="reloadTable">刷新数据</a-button>
|
|
</template>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.key === 'action'">
|
|
<TableAction
|
|
:actions="[
|
|
{
|
|
label: '删除',
|
|
type: 'primary',
|
|
danger: true,
|
|
size: 'middle',
|
|
icon: renderIcon(DeleteOutlined),
|
|
popConfirm: {
|
|
title: '您真的,确定要删除吗?',
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
confirm: handleDelete.bind(null, record),
|
|
},
|
|
},
|
|
{
|
|
label: '编辑',
|
|
type: 'primary',
|
|
size: 'middle',
|
|
icon: renderIcon(FormOutlined),
|
|
onClick: handleEdit.bind(null, record),
|
|
},
|
|
]"
|
|
:dropDownActions="[
|
|
{
|
|
label: '启用',
|
|
size: 'middle',
|
|
key: 'enabled',
|
|
// 根据业务控制是否显示: 非enable状态的不显示启用按钮
|
|
ifShow: () => {
|
|
return true;
|
|
},
|
|
onClick: handleActionSelect.bind(null, record),
|
|
},
|
|
{
|
|
label: '禁用',
|
|
key: 'disabled',
|
|
ifShow: () => {
|
|
return true;
|
|
},
|
|
onClick: handleActionSelect.bind(null, record),
|
|
},
|
|
]"
|
|
:dropDownProps="{
|
|
label: '更多',
|
|
type: 'primary',
|
|
size: 'middle',
|
|
icon: renderIcon(DownOutlined),
|
|
// iconPlacement: 'left',
|
|
}"
|
|
/>
|
|
</template>
|
|
</template>
|
|
</BasicTable>
|
|
</a-card>
|
|
</PageWrapper>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { reactive, ref } from 'vue';
|
|
import { message } from 'ant-design-vue';
|
|
import { BasicTable, TableAction } from '@/components/Table';
|
|
import { PageWrapper } from '@/components/Page';
|
|
import { BasicForm, useForm, FormSchema } from '@/components/Form/index';
|
|
import { getTableList } from '@/api/table/list';
|
|
import { columns } from './columns';
|
|
import { PlusOutlined, DeleteOutlined, FormOutlined, DownOutlined } from '@ant-design/icons-vue';
|
|
import { useRouter } from 'vue-router';
|
|
import { renderIcon } from '@/utils';
|
|
|
|
const schemas: FormSchema[] = [
|
|
{
|
|
name: 'name',
|
|
labelMessage: '这是一个提示',
|
|
component: 'Input',
|
|
label: '姓名',
|
|
componentProps: {
|
|
placeholder: '请输入姓名',
|
|
onChange: (e: any) => {
|
|
console.log(e);
|
|
},
|
|
},
|
|
rules: [{ required: true, message: '请输入姓名', trigger: ['blur'] }],
|
|
},
|
|
{
|
|
name: 'mobile',
|
|
component: 'InputNumber',
|
|
label: '手机',
|
|
componentProps: {
|
|
placeholder: '请输入手机号码',
|
|
showButton: false,
|
|
onChange: (e: any) => {
|
|
console.log(e);
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: 'type',
|
|
component: 'Select',
|
|
label: '类型',
|
|
componentProps: {
|
|
placeholder: '请选择类型',
|
|
options: [
|
|
{
|
|
label: '舒适性',
|
|
value: 1,
|
|
},
|
|
{
|
|
label: '经济性',
|
|
value: 2,
|
|
},
|
|
],
|
|
onUpdateValue: (e: any) => {
|
|
console.log(e);
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: 'makeDate',
|
|
component: 'DatePicker',
|
|
label: '预约时间',
|
|
//defaultValue: 1183135260000,
|
|
componentProps: {
|
|
type: 'date',
|
|
onUpdateValue: (e: any) => {
|
|
console.log(e);
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: 'status',
|
|
label: '状态',
|
|
//插槽
|
|
slot: 'statusSlot',
|
|
},
|
|
{
|
|
name: 'makeTime',
|
|
component: 'Input',
|
|
label: '停留时间',
|
|
//自定义 高于外面定义的
|
|
// colProps: {
|
|
// span: 4,
|
|
// },
|
|
componentProps: {
|
|
clearable: true,
|
|
onUpdateValue: (e: any) => {
|
|
console.log(e);
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: 'makeProject',
|
|
component: 'Select',
|
|
label: '预约项目',
|
|
//自定义 高于外面定义的
|
|
// colProps: {
|
|
// span: 5,
|
|
// },
|
|
componentProps: {
|
|
placeholder: '请选择预约项目',
|
|
options: [
|
|
{
|
|
label: '种牙',
|
|
value: 1,
|
|
},
|
|
{
|
|
label: '补牙',
|
|
value: 2,
|
|
},
|
|
{
|
|
label: '根管',
|
|
value: 2,
|
|
},
|
|
],
|
|
onUpdateValue: (e: any) => {
|
|
console.log(e);
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
const router = useRouter();
|
|
|
|
const actionRef = ref();
|
|
|
|
const showModal = ref(false);
|
|
const formParams = reactive({
|
|
name: '',
|
|
address: '',
|
|
date: null,
|
|
});
|
|
|
|
const params = ref({
|
|
pageSize: 10,
|
|
name: '',
|
|
});
|
|
|
|
const actionColumn = reactive({
|
|
width: 280,
|
|
title: '操作',
|
|
dataIndex: 'action',
|
|
key: 'action',
|
|
fixed: 'right',
|
|
align: 'center',
|
|
});
|
|
|
|
const [register, {}] = useForm({
|
|
rowProps: { gutter: [16, 0], wrap: true },
|
|
colProps: {
|
|
xs: 24,
|
|
sm: 24,
|
|
md: 12,
|
|
lg: 8,
|
|
xl: 6,
|
|
},
|
|
size: 'small',
|
|
labelCol: { span: 4, offset: 0 },
|
|
schemas,
|
|
});
|
|
|
|
function onColumnsChange(columns) {
|
|
console.log('columns', columns);
|
|
}
|
|
|
|
function formAdvanced(status) {
|
|
console.log(status);
|
|
actionRef.value.redoHeight();
|
|
}
|
|
|
|
function addTable() {
|
|
showModal.value = true;
|
|
}
|
|
|
|
const loadDataTable = async (res) => {
|
|
return await getTableList({ ...formParams, ...params.value, ...res });
|
|
};
|
|
|
|
function onCheckedRow(rowKeys) {
|
|
console.log(rowKeys);
|
|
}
|
|
|
|
function reloadTable() {
|
|
actionRef.value.reload();
|
|
}
|
|
|
|
function handleEdit(record: Recordable) {
|
|
console.log('点击了编辑', record);
|
|
router.push({ name: 'BasicInfo', params: { id: record.id } });
|
|
}
|
|
|
|
function handleDelete(record: Recordable) {
|
|
console.log('点击了删除', record);
|
|
message.info('点击了删除');
|
|
}
|
|
|
|
function handleSubmit(values: Recordable) {
|
|
console.log(values);
|
|
params.value = Object.assign(formParams, values) as any;
|
|
reloadTable();
|
|
}
|
|
|
|
function handleReset(values: Recordable) {
|
|
console.log(values);
|
|
}
|
|
|
|
function handleActionSelect(record: Recordable, key: string) {
|
|
console.log(record);
|
|
console.log(key);
|
|
message.info(`您点击,${key} 按钮`);
|
|
}
|
|
</script>
|
|
|
|
<style lang="less" scoped></style>
|