优化网站导航模块

This commit is contained in:
2024-08-23 22:28:24 +08:00
parent 1d81fa9270
commit 13832d9de0
964 changed files with 90774 additions and 31362 deletions

View File

@@ -0,0 +1,146 @@
<template>
<ele-modal
:width="750"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<template #toolbar>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 200px"
@search="reload"
@pressEnter="reload"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'thumb'">
<a-avatar
v-if="record.thumb"
:src="record.thumb"
:preview="false"
:width="45"
/>
</template>
<template v-if="column.key === 'shopType'">
<a-tag v-if="record.shopType === 10">企业</a-tag>
<a-tag v-if="record.shopType === 20">政府单位</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-button type="primary" @click="onRadio(record)">选择</a-button>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { pageBookingSite } from '@/api/booking/bookingSite';
import { EleProTable } from 'ele-admin-pro';
import {
BookingSite,
BookingSiteParam
} from '@/api/booking/bookingSite/model';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 标题
title?: string;
// 商户类型
shopType?: string;
// 修改回显的数据
data?: BookingSite | null;
}>();
const emit = defineEmits<{
(e: 'done', data: BookingSite): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 搜索内容
const searchText = ref(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'thumb',
key: 'thumb',
align: 'center'
},
{
title: '场馆名称',
key: 'name',
dataIndex: 'name'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
return pageBookingSite({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: BookingSiteParam) => {
tableRef?.value?.reload({ page: 1, where });
};
const onRadio = (record: BookingSite) => {
updateVisible(false);
emit('done', record);
};
/* 自定义行属性 */
const customRow = (record: BookingSite) => {
return {
// 行点击事件
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
// 行双击事件
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
};
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,61 @@
<template>
<div>
<a-input-group compact>
<a-input
disabled
style="width: calc(100% - 32px)"
v-model:value="value"
:placeholder="placeholder"
/>
<a-button @click="openEdit">
<template #icon><BulbOutlined class="ele-text-warning" /></template>
</a-button>
</a-input-group>
<!-- 选择弹窗 -->
<SelectData
v-model:visible="showEdit"
:data="current"
:title="placeholder"
:customer-type="customerType"
@done="onChange"
/>
</div>
</template>
<script lang="ts" setup>
import { BulbOutlined } from '@ant-design/icons-vue';
import { ref } from 'vue';
import SelectData from './components/select-data.vue';
import { BookingSite } from '@/api/booking/bookingSite/model';
withDefaults(
defineProps<{
value?: any;
customerType?: string;
placeholder?: string;
}>(),
{
placeholder: '请选择场馆'
}
);
const emit = defineEmits<{
(e: 'done', BookingSite): void;
(e: 'clear'): void;
}>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 当前编辑数据
const current = ref<BookingSite | null>(null);
/* 打开编辑弹窗 */
const openEdit = (row?: BookingSite) => {
current.value = row ?? null;
showEdit.value = true;
};
const onChange = (row) => {
emit('done', row);
};
</script>

View File

@@ -40,7 +40,7 @@
<a-tag v-if="record.shopType === 20">政府单位</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-radio @click="onRadio(record)" />
<a-button type="primary" @click="onRadio(record)">选择</a-button>
</template>
</template>
</ele-pro-table>
@@ -86,11 +86,6 @@
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: '操作',
key: 'action',
align: 'center'
},
{
title: 'LOGO',
dataIndex: 'image',
@@ -105,6 +100,11 @@
title: '商户类型',
dataIndex: 'shopType',
key: 'shopType'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);

View File

@@ -0,0 +1,144 @@
<template>
<ele-modal
:width="750"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<template #toolbar>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 200px"
@search="reload"
@pressEnter="reload"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<template v-if="pageId == record.id">
<a-radio v-model:checked="checked" @click="onRadio(record)" />
</template>
<template v-else>
<lebal>
<a-radio @click="onRadio(record)" />
<span class="ele-text-secondary">选择</span>
</lebal>
</template>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { pageNavigation } from '@/api/cms/navigation';
import { EleProTable } from 'ele-admin-pro';
import type { Navigation, NavigationParam } from '@/api/cms/navigation/model';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 标题
title?: string;
// 修改回显的数据
data?: Navigation | null;
}>();
const emit = defineEmits<{
(e: 'done', data: Navigation): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 搜索内容
const searchText = ref(null);
const pageId = ref<number>(0);
const checked = ref<boolean>(true);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: '页面名称',
dataIndex: 'title',
key: 'title'
},
{
title: '路径',
dataIndex: 'path',
key: 'path'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
// 搜索条件
if (searchText.value) {
where.keywords = searchText.value;
}
return pageNavigation({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: NavigationParam) => {
tableRef?.value?.reload({ page: 1, where });
};
const onRadio = (record: Navigation) => {
pageId.value = Number(record.navigationId);
updateVisible(false);
emit('done', record);
};
/* 自定义行属性 */
const customRow = (record: Navigation) => {
return {
// 行点击事件
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
// 行双击事件
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
};
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,59 @@
<template>
<div>
<a-input-group compact>
<a-input
disabled
style="width: calc(100% - 32px)"
v-model:value="value"
:placeholder="placeholder"
/>
<a-button @click="openEdit">
<template #icon><BulbOutlined class="ele-text-warning" /></template>
</a-button>
</a-input-group>
<!-- 选择弹窗 -->
<SelectData
v-model:visible="showEdit"
:data="current"
:title="placeholder"
@done="onChange"
/>
</div>
</template>
<script lang="ts" setup>
import { BulbOutlined } from '@ant-design/icons-vue';
import { ref } from 'vue';
import SelectData from './components/select-data.vue';
import { Navigation } from '@/api/cms/navigation/model';
withDefaults(
defineProps<{
value?: any;
placeholder?: string;
}>(),
{
placeholder: '请选择数据'
}
);
const emit = defineEmits<{
(e: 'done', Navigation): void;
(e: 'clear'): void;
}>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 当前编辑数据
const current = ref<Navigation | null>(null);
/* 打开编辑弹窗 */
const openEdit = (row?: Navigation) => {
current.value = row ?? null;
showEdit.value = true;
};
const onChange = (row) => {
emit('done', row);
};
</script>

View File

@@ -51,6 +51,7 @@
// 弹窗是否打开
visible: boolean;
title?: string;
organizationId?: number;
// 修改回显的数据
data?: User | null;
}>();

View File

@@ -49,10 +49,11 @@
import { EleProTable } from 'ele-admin-pro';
import useSearch from '@/utils/use-search';
defineProps<{
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
title?: string;
organizationId?: number;
// 修改回显的数据
data?: User | null;
}>();
@@ -96,13 +97,17 @@
},
{
title: '姓名',
dataIndex: 'nickname'
dataIndex: 'realName'
},
{
title: '手机号码',
dataIndex: 'mobile',
key: 'mobile'
},
{
title: '昵称',
dataIndex: 'nickname'
},
{
title: '所属部门',
dataIndex: 'organizationName'
@@ -121,6 +126,9 @@
if (searchText.value) {
where.keywords = searchText.value;
}
if (props.organizationId) {
where.organizationId = props.organizationId;
}
return pageUsers({
...where,
...orders,

View File

@@ -16,6 +16,7 @@
v-model:visible="showEdit"
:data="current"
:title="placeholder"
:organizationId="organizationId"
@done="onChange"
/>
</div>
@@ -31,6 +32,7 @@
defineProps<{
value?: any;
placeholder?: string;
organizationId?: number;
}>(),
{
placeholder: '请选择'

View File

@@ -8,42 +8,55 @@
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
<a-input-search
allow-clear
v-model:value="where.keywords"
placeholder="用户ID|手机号码|姓名"
class="w-full mb-3"
@search="search"
@pressEnter="search"
/>
<a-table
ref="tableRef"
row-key="userId"
:datasource="datasource"
:dataSource="list"
:columns="columns"
:pagination="false"
>
<template #toolbar>
<a-space>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="用户ID|手机号码"
style="width: 280px"
@search="reload"
@pressEnter="reload"
/>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'avatar'">
<a-avatar
:size="30"
:src="`${record.avatar}`"
style="margin-right: 4px"
>
<template #icon>
<UserOutlined />
</template>
</a-avatar>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a-button type="primary" @click="done(record)">选择</a-button>
</a-space>
</template>
</template>
</ele-pro-table>
</a-table>
<div class="flex justify-center py-3">
<a-pagination
v-model:current="where.page"
:total="total"
show-less-items
@change="reload"
/>
</div>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { UserOutlined } from '@ant-design/icons-vue';
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
import { pageUsers } from '@/api/system/user';
import { User, UserParam } from '@/api/system/user/model';
import { EleProTable } from 'ele-admin-pro';
@@ -68,13 +81,14 @@
};
// 搜索内容
const searchText = ref(null);
const list = ref<User[]>([]);
const total = ref<number>(0);
// 表单数据
const { where } = useSearch<UserParam>({
userId: undefined,
nickname: undefined,
isStaff: true,
keywords: ''
keywords: '',
page: 1
});
// 表格实例
@@ -86,22 +100,19 @@
title: 'ID',
dataIndex: 'userId'
},
{
title: '头像',
dataIndex: 'avatar'
},
{
title: '姓名',
dataIndex: 'realName'
},
{
title: '手机号码',
dataIndex: 'mobile',
key: 'mobile'
},
{
title: '所属部门',
dataIndex: 'organizationName'
title: '头像',
dataIndex: 'avatar',
key: 'avatar'
},
{
title: '姓名',
dataIndex: 'realName'
},
{
title: '操作',
@@ -111,29 +122,25 @@
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
// 搜索条件
if (searchText.value) {
where.keywords = searchText.value;
}
return pageUsers({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: UserParam) => {
// selection.value = [];
tableRef?.value?.reload({ page: 1, where });
};
const done = (record: User) => {
updateVisible(false);
emit('done', record);
};
const search = () => {
where.page = 1;
reload();
};
/* 搜索 */
const reload = () => {
pageUsers(where).then((res) => {
if (res?.list) {
list.value = res?.list;
total.value = res.count;
}
});
};
reload();
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,149 @@
<template>
<ele-modal
:width="750"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
{{ data }}
<ele-pro-table
ref="tableRef"
row-key="id"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<template #toolbar>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 200px"
@search="reload"
@pressEnter="reload"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image
v-if="record.image"
:src="record.image"
:preview="false"
:width="45"
/>
</template>
<template v-if="column.key === 'action'">
<a-button type="primary" @click="onRadio(record)">选择</a-button>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { pageThinkInvoice } from '@/api/think/thinkInvoice';
import { EleProTable } from 'ele-admin-pro';
import {
ThinkInvoice,
ThinkInvoiceParam
} from '@/api/think/thinkInvoice/model';
import { ThinkOrder } from '@/api/think/thinkOrder/model';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 标题
title?: string;
// 商户类型
shopType?: string;
// 修改回显的数据
data?: ThinkOrder | null;
}>();
const emit = defineEmits<{
(e: 'done', data: ThinkInvoice): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 搜索内容
const searchText = ref(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: '单位名称',
dataIndex: 'name',
key: 'name',
align: 'center'
},
{
title: '场馆名称',
dataIndex: 'name'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
// 搜索条件
if (searchText.value) {
where.keywords = searchText.value;
}
where.uid = props.data?.uid;
return pageThinkInvoice({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: ThinkInvoiceParam) => {
tableRef?.value?.reload({ page: 1, where });
};
const onRadio = (record: ThinkInvoice) => {
updateVisible(false);
emit('done', record);
};
/* 自定义行属性 */
const customRow = (record: ThinkInvoice) => {
return {
// 行点击事件
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
// 行双击事件
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
};
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,61 @@
<template>
<div>
<a-input-group compact>
<a-input
disabled
style="width: calc(100% - 32px)"
v-model:value="value"
:placeholder="placeholder"
/>
<a-button @click="openEdit">
<template #icon><BulbOutlined class="ele-text-warning" /></template>
</a-button>
</a-input-group>
<!-- 选择弹窗 -->
<SelectData
v-model:visible="showEdit"
:data="order"
:title="placeholder"
@done="onChange"
/>
</div>
</template>
<script lang="ts" setup>
import { BulbOutlined } from '@ant-design/icons-vue';
import { ref } from 'vue';
import SelectData from './components/select-data.vue';
import { ThinkSite } from '@/api/think/thinkSite/model';
import { ThinkOrder } from '@/api/think/thinkOrder/model';
withDefaults(
defineProps<{
value?: any;
order?: ThinkOrder;
placeholder?: string;
}>(),
{
placeholder: '请选择开票信息'
}
);
const emit = defineEmits<{
(e: 'done', Merchant): void;
(e: 'clear'): void;
}>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 当前编辑数据
const current = ref<ThinkSite | null>(null);
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkSite) => {
current.value = row ?? null;
showEdit.value = true;
};
const onChange = (row) => {
emit('done', row);
};
</script>

View File

@@ -0,0 +1,143 @@
<template>
<ele-modal
:width="750"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<template #toolbar>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 200px"
@search="reload"
@pressEnter="reload"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image
v-if="record.image"
:src="record.image"
:preview="false"
:width="45"
/>
</template>
<template v-if="column.key === 'action'">
<a-button type="primary" @click="onRadio(record)">选择</a-button>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { pageThinkSite } from '@/api/think/thinkSite';
import { EleProTable } from 'ele-admin-pro';
import { ThinkSite, ThinkSiteParam } from '@/api/think/thinkSite/model';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 标题
title?: string;
// 商户类型
shopType?: string;
// 修改回显的数据
data?: ThinkSite | null;
}>();
const emit = defineEmits<{
(e: 'done', data: ThinkSite): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 搜索内容
const searchText = ref(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: '场馆ID',
dataIndex: 'id',
key: 'id',
align: 'center'
},
{
title: '场馆名称',
dataIndex: 'name'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
// 搜索条件
if (searchText.value) {
where.keywords = searchText.value;
}
return pageThinkSite({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: ThinkSiteParam) => {
tableRef?.value?.reload({ page: 1, where });
};
const onRadio = (record: ThinkSite) => {
updateVisible(false);
emit('done', record);
};
/* 自定义行属性 */
const customRow = (record: ThinkSite) => {
return {
// 行点击事件
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
// 行双击事件
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
};
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,61 @@
<template>
<div>
<a-input-group compact>
<a-input
disabled
style="width: calc(100% - 32px)"
v-model:value="value"
:placeholder="placeholder"
/>
<a-button @click="openEdit">
<template #icon><BulbOutlined class="ele-text-warning" /></template>
</a-button>
</a-input-group>
<!-- 选择弹窗 -->
<SelectData
v-model:visible="showEdit"
:data="current"
:title="placeholder"
:customer-type="customerType"
@done="onChange"
/>
</div>
</template>
<script lang="ts" setup>
import { BulbOutlined } from '@ant-design/icons-vue';
import { ref } from 'vue';
import SelectData from './components/select-data.vue';
import { ThinkSite } from '@/api/think/thinkSite/model';
withDefaults(
defineProps<{
value?: any;
customerType?: string;
placeholder?: string;
}>(),
{
placeholder: '请选择场馆'
}
);
const emit = defineEmits<{
(e: 'done', Merchant): void;
(e: 'clear'): void;
}>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 当前编辑数据
const current = ref<ThinkSite | null>(null);
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkSite) => {
current.value = row ?? null;
showEdit.value = true;
};
const onChange = (row) => {
emit('done', row);
};
</script>

View File

@@ -0,0 +1,67 @@
<!-- 场馆选择下拉框 -->
<template>
<a-select
allow-clear
mode="multiple"
:value="sid"
:placeholder="placeholder"
@update:value="updateValue"
@blur="onBlur"
>
<a-select-option v-for="item in data" :key="item.id" :value="item.id">
{{ item.name }}
</a-select-option>
</a-select>
</template>
<script lang="ts" setup>
import { ref, computed } from 'vue';
import { message } from 'ant-design-vue/es';
import type { ThinkSite } from '@/api/think/thinkSite/model';
import { listThinkSite } from '@/api/think/thinkSite';
const emit = defineEmits<{
(e: 'update:value', value: ThinkSite[]): void;
(e: 'blur'): void;
}>();
const props = withDefaults(
defineProps<{
// 选中的场馆
value?: ThinkSite[];
//
placeholder?: string;
}>(),
{
placeholder: '请选择场馆'
}
);
// 选中的场馆id
const sid = computed(() => props.value?.map((d) => d.id as number));
// 场馆数据
const data = ref<ThinkSite[]>([]);
/* 更新选中数据 */
const updateValue = (value: number[]) => {
emit(
'update:value',
value.map((v) => ({ id: v }))
);
};
/* 获取场馆数据 */
listThinkSite({})
.then((list) => {
data.value = list;
})
.catch((e) => {
message.error(e.message);
});
/* 失去焦点 */
const onBlur = () => {
emit('blur');
};
</script>

View File

@@ -0,0 +1,130 @@
<template>
<ele-modal
:width="750"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
ref="tableRef"
row-key="userId"
:datasource="datasource"
:columns="columns"
:pagination="false"
>
<template #toolbar>
<a-space>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 200px"
@search="reload"
@pressEnter="reload"
/>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a-button type="primary" @click="done(record)">选择</a-button>
</a-space>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { pageThinkUsers } from '@/api/think/thinkUsers';
import { ThinkUsers, ThinkUsersParam } from '@/api/think/thinkUsers/model';
import { EleProTable } from 'ele-admin-pro';
import useSearch from '@/utils/use-search';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
title?: string;
id?: number;
// 修改回显的数据
data?: ThinkUsers | null;
}>();
const emit = defineEmits<{
(e: 'done', data: ThinkUsers, id: number): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 搜索内容
const searchText = ref(null);
// 表单数据
const { where } = useSearch<ThinkUsersParam>({
id: undefined,
keywords: ''
});
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: '用户ID',
dataIndex: 'id'
},
{
title: '姓名',
dataIndex: 'truename'
},
{
title: '手机号码',
dataIndex: 'phone',
key: 'phone'
},
{
title: '操作',
key: 'action',
align: 'center',
hideInSetting: true
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
// 搜索条件
if (searchText.value) {
where.keywords = searchText.value;
}
return pageThinkUsers({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: ThinkUsersParam) => {
// selection.value = [];
tableRef?.value?.reload({ page: 1, where });
};
const done = (record: ThinkUsers) => {
updateVisible(false);
emit('done', record, Number(props.id));
};
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,138 @@
<template>
<ele-modal
:width="750"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
ref="tableRef"
row-key="userId"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<template #toolbar>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 200px"
@search="reload"
@pressEnter="reload"
/>
</template>
<template #bodyCell="{ column }">
<template v-if="column.key === 'action'">
<a-space>
<a-button type="link">选择</a-button>
</a-space>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { pageUsers } from '@/api/system/user';
import { User, UserParam } from '@/api/system/user/model';
import { EleProTable } from 'ele-admin-pro';
defineProps<{
// 弹窗是否打开
visible: boolean;
title?: string;
// 修改回显的数据
data?: User | null;
}>();
const emit = defineEmits<{
(e: 'done', data: User): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 搜索内容
const searchText = ref(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '姓名',
dataIndex: 'nickname'
},
{
title: '联系电话',
dataIndex: 'phone',
key: 'phone'
},
{
title: '所属部门',
dataIndex: 'organizationName'
},
{
title: '操作',
key: 'action',
align: 'center',
hideInSetting: true
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
// 搜索条件
if (searchText.value) {
where.keywords = searchText.value;
}
where.isStaff = true;
return pageUsers({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: UserParam) => {
// selection.value = [];
tableRef?.value?.reload({ page: 1, where });
};
/* 自定义行属性 */
const customRow = (record: User) => {
return {
// 行点击事件
onClick: () => {
updateVisible(false);
emit('done', record);
}
};
};
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,52 @@
<template>
<div>
<a @click="openEdit">变更绑定</a>
<!-- 选择弹窗 -->
<select-data
v-model:visible="showEdit"
:data="current"
:title="placeholder"
:id="id"
@done="onChange"
/>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import SelectData from './components/select-data.vue';
import { ThinkUsers } from '@/api/think/thinkUsers/model';
withDefaults(
defineProps<{
value?: any;
placeholder?: string;
id?: number;
}>(),
{
placeholder: '请选择'
}
);
const emit = defineEmits<{
(e: 'done', ThinkUsers, id: number): void;
(e: 'clear'): void;
}>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 当前编辑数据
const current = ref<ThinkUsers | null>(null);
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkUsers) => {
current.value = row ?? null;
showEdit.value = true;
};
const onChange = (row?: ThinkUsers, id?: number) => {
emit('done', row, Number(id));
};
// 查询租户列表
// const appList = ref<App[] | undefined>([]);
</script>