Browse Source

新增:订阅消息提醒管理

dev
科技小王子 2 months ago
parent
commit
dafbac660d
  1. 4
      .env.development
  2. 1
      src/api/system/user/model/index.ts
  3. 106
      src/api/system/userOauth/index.ts
  4. 39
      src/api/system/userOauth/model/index.ts
  5. 161
      src/components/SelectMerchant/components/select-data.vue
  6. 64
      src/components/SelectMerchant/index.vue
  7. 149
      src/views/hjm/userAlert/components/Edit.vue
  8. 36
      src/views/hjm/userAlert/components/search.vue
  9. 171
      src/views/hjm/userAlert/index.vue
  10. 53
      src/views/passport/login/index.vue
  11. 42
      src/views/system/userOauth/components/search.vue
  12. 209
      src/views/system/userOauth/components/userOauthEdit.vue
  13. 223
      src/views/system/userOauth/index.vue

4
.env.development

@ -1,10 +1,10 @@
VITE_APP_NAME=后台管理系统
VITE_SOCKET_URL=wss://server.gxwebsoft.com
VITE_SERVER_URL=https://server.gxwebsoft.com/api
VITE_API_URL=https://cms-api.websoft.top/api
#VITE_API_URL=https://cms-api.websoft.top/api
#VITE_SOCKET_URL=ws://127.0.0.1:9191
#VITE_SERVER_URL=http://127.0.0.1:8000/api
#VITE_API_URL=http://127.0.0.1:9000/api
VITE_API_URL=http://127.0.0.1:9000/api
#/booking/bookingItem

1
src/api/system/user/model/index.ts

@ -19,6 +19,7 @@ export interface User {
// 昵称
nickname?: string;
openId?: string;
officeOpenid?: string;
sessionKey?: string;
// 别名
alias?: string;

106
src/api/system/userOauth/index.ts

@ -0,0 +1,106 @@
import request from '@/utils/request';
import type {ApiResult, PageResult} from '@/api';
import type {UserOauth, UserOauthParam} from './model';
import {SERVER_API_URL} from '@/config/setting';
/**
*
*/
export async function pageUserOauth(params: UserOauthParam) {
const res = await request.get<ApiResult<PageResult<UserOauth>>>(
SERVER_API_URL + '/system/user-oauth/page',
{
params
}
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function listUserOauth(params?: UserOauthParam) {
const res = await request.get<ApiResult<UserOauth[]>>(
SERVER_API_URL + '/system/user-oauth',
{
params
}
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function addUserOauth(data: UserOauth) {
const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/system/user-oauth',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function updateUserOauth(data: UserOauth) {
const res = await request.put<ApiResult<unknown>>(
SERVER_API_URL + '/system/user-oauth',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function removeUserOauth(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
SERVER_API_URL + '/system/user-oauth/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function removeBatchUserOauth(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
SERVER_API_URL + '/system/user-oauth/batch',
{
data
}
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* id查询第三方用户信息表
*/
export async function getUserOauth(id: number) {
const res = await request.get<ApiResult<UserOauth>>(
SERVER_API_URL + '/system/user-oauth/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}

39
src/api/system/userOauth/model/index.ts

@ -0,0 +1,39 @@
import type { PageParam } from '@/api';
/**
*
*/
export interface UserOauth {
// 主键ID
id?: number;
// 用户ID
userId?: number;
// 第三方登陆类型(MP-WEIXIN)
oauthType?: string;
// 第三方用户唯一标识 (uid openid)
oauthId?: string;
// 微信unionID
unionid?: string;
// 排序(数字越小越靠前)
sortNumber?: number;
// 备注
comments?: string;
// 状态, 0正常, 1冻结
status?: number;
// 是否删除, 0否, 1是
deleted?: number;
// 租户id
tenantId?: number;
// 注册时间
createTime?: string;
// 修改时间
updateTime?: string;
}
/**
*
*/
export interface UserOauthParam extends PageParam {
id?: number;
keywords?: string;
}

161
src/components/SelectMerchant/components/select-data.vue

@ -0,0 +1,161 @@
<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="merchantId"
: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 === '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 { pageShopMerchant } from '@/api/shop/shopMerchant';
import { EleProTable } from 'ele-admin-pro';
import { ShopMerchant, ShopMerchantParam } from '@/api/shop/shopMerchant/model';
const props = defineProps<{
//
visible: boolean;
//
title?: string;
//
shopType?: string;
type?: string;
//
data?: ShopMerchant | null;
}>();
const emit = defineEmits<{
(e: 'done', data: ShopMerchant): 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: 'LOGO',
dataIndex: 'image',
key: 'image',
align: 'center'
},
{
title: '商户名称',
dataIndex: 'merchantName'
},
{
title: '商户类型',
dataIndex: 'shopType',
// key: 'shopType'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
//
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
//
if (searchText.value) {
where.keywords = searchText.value;
}
if (props.shopType == 'empty') {
where.emptyType = true;
} else {
where.shopType = props.shopType;
}
if (props.type) {
where.type = props.type;
}
return pageShopMerchant({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: ShopMerchantParam) => {
tableRef?.value?.reload({ page: 1, where });
};
const onRadio = (record: ShopMerchant) => {
updateVisible(false);
emit('done', record);
};
/* 自定义行属性 */
const customRow = (record: ShopMerchant) => {
return {
//
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
//
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
};
</script>
<style lang="less"></style>

64
src/components/SelectMerchant/index.vue

@ -0,0 +1,64 @@
<template>
<div>
<a-input-group compact>
<a-input
disabled
style="width: calc(100% - 32px)"
v-model:value="content"
: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"
:shopType="shopType"
@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 { ShopMerchant } from '@/api/shop/shopMerchant/model';
const props = withDefaults(
defineProps<{
value?: any;
customerType?: string;
placeholder?: string;
shopType?: string;
}>(),
{
placeholder: '请选择商户'
}
);
const emit = defineEmits<{
(e: 'done', ShopMerchant): void;
(e: 'clear'): void;
}>();
//
const showEdit = ref(false);
const content = ref<string>(props.value)
//
const current = ref<ShopMerchant | null>(null);
/* 打开编辑弹窗 */
const openEdit = (row?: ShopMerchant) => {
current.value = row ?? null;
showEdit.value = true;
};
const onChange = (row) => {
emit('done', row);
};
</script>

149
src/views/hjm/userAlert/components/Edit.vue

@ -0,0 +1,149 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑推送提醒接收员' : '添加推送提醒接收员'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="openid" name="officeOpenid">
<a-input
allow-clear
placeholder="openid"
v-model:value="form.officeOpenid"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject} from 'ele-admin-pro';
import {addUser, updateUser} from '@/api/system/user';
import {User} from '@/api/system/user/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FormInstance} from 'ant-design-vue/es/form';
//
const isUpdate = ref(false);
const useForm = Form.useForm;
//
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const props = defineProps<{
//
visible: boolean;
//
data?: User | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
//
const loading = ref(false);
//
const maxable = ref(true);
//
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
//
const form = reactive<User>({
userId: undefined,
officeOpenid: undefined,
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
//
const rules = reactive({
officeOpenid: [
{
required: true,
message: '请输入openid',
trigger: 'blur'
}
]
});
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateUser : addUser;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{immediate: true}
);
</script>

36
src/views/hjm/userAlert/components/search.vue

@ -0,0 +1,36 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
1设置角色为邮政协会/管局即可出现以下列表2关注微信公众号3然后<a href="https://mp.weixin.qq.com/" target="_blank">获取openId</a> 并填入表格即可接受到微信的订阅消息提醒
</a-space>
</template>
<script lang="ts" setup>
import { watch } from 'vue';
import {UserParam} from "@/api/system/user/model";
const props = withDefaults(
defineProps<{
//
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: UserParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
//
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

171
src/views/hjm/userAlert/index.vue

@ -0,0 +1,171 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="userOauthId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import Edit from './components/Edit.vue';
import {pageUsers} from "@/api/system/user";
import {User, UserParam} from "@/api/system/user/model";
//
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
//
const selection = ref<User[]>([]);
//
const current = ref<User | null>(null);
//
const showEdit = ref(false);
//
const showMove = ref(false);
//
const loading = ref(true);
//
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders
}) => {
where.organizationId = 421;
return pageUsers({
...where,
...orders,
page,
limit
});
};
//
const columns = ref<ColumnItem[]>([
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
width: 120
},
{
title: '姓名',
dataIndex: 'realName',
key: 'realName',
align: 'center',
width: 170
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
align: 'center',
width: 170
},
{
title: 'openId(微信公众号)',
dataIndex: 'officeOpenid',
key: 'officeOpenid',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: UserParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: User) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: User) => {
return {
//
onClick: () => {
// console.log(record);
},
//
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'User'
};
</script>
<style lang="less" scoped></style>

53
src/views/passport/login/index.vue

@ -29,21 +29,29 @@
class="login-form ele-bg-white"
>
<div class="login-title flex justify-center items-center px-12">
<h4
class="title-btn"
:class="loginType === 'sms' ? 'active' : ''"
@click="onLoginType('sms')"
>短信登录</h4
>
<a-divider type="vertical" style="height: 20px"/>
<h4
class="title-btn"
:class="loginType === 'account' ? 'active' : ''"
@click="onLoginType('account')"
>密码登录</h4
>
<template v-if="loginType === 'scan'">
<h4
class="title-btn"
>扫码登录</h4
>
</template>
<template v-else>
<h4
class="title-btn"
:class="loginType === 'sms' ? 'active' : ''"
@click="onLoginType('sms')"
>短信登录</h4
>
<a-divider type="vertical" style="height: 20px"/>
<h4
class="title-btn"
:class="loginType === 'account' ? 'active' : ''"
@click="onLoginType('account')"
>密码登录</h4
>
</template>
</div>
<div class="login-bar absolute top-0 right-0 cursor-pointer">
<div class="login-bar absolute top-0 z-50 right-0 cursor-pointer" @click="onScan">
<div class="go-to-register cursor-pointer">
<img src="https://img.alicdn.com/imgextra/i3/O1CN01yz6fEl1MwaRtkJyvf_!!6000000001499-55-tps-70-70.svg"
alt=""/>
@ -51,7 +59,6 @@
<div class="absolute top-3 right-3 text-lg text-white font-bold cursor-pointer">
<QrcodeOutlined/>
</div>
<!-- <span class="absolute top-3 right-1.5 text-sm text-white font-bold cursor-pointer">{{ '登录' }}</span>-->
</div>
<template v-if="loginType === 'account'">
@ -114,7 +121,7 @@
>
{{ loading ? t('login.loading') : t('login.login') }}
</a-button>
<div class="register text-center pt-5"><a @click="push('/register')">免费注册</a></div>
<!-- <div class="register text-center pt-5"><a @click="push('/register')">免费注册</a></div>-->
</a-form-item>
</template>
<template v-if="loginType === 'sms'">
@ -159,9 +166,12 @@
>
{{ loading ? t('login.loading') : t('login.login') }}
</a-button>
<div class="register text-center pt-5"><a @click="push('/register')">免费注册</a></div>
<!-- <div class="register text-center pt-5"><a @click="push('/register')">免费注册</a></div>-->
</a-form-item>
</template>
<template v-if="loginType == 'scan'">
二维码
</template>
</a-form>
<div class="login-copyright">
<a-space>
@ -236,7 +246,6 @@
import {ref, reactive, unref, watch} from 'vue';
import {useI18n} from 'vue-i18n';
import {useRouter} from 'vue-router';
import {getTenantId} from '@/utils/domain';
import {Form, message} from 'ant-design-vue';
import {
LockOutlined,
@ -492,6 +501,14 @@ const onLoginType = (text) => {
loginType.value = text;
};
const onScan = () => {
if(loginType.value == 'scan'){
loginType.value = 'sms'
}else {
loginType.value = 'scan'
}
}
// const goBack = () => {
// openUrl(getDomain());
// return;

42
src/views/system/userOauth/components/search.vue

@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
//
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
//
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

209
src/views/system/userOauth/components/userOauthEdit.vue

@ -0,0 +1,209 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑第三方用户信息表' : '添加第三方用户信息表'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入用户ID"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="第三方登陆类型(MP-WEIXIN)" name="oauthType">
<a-input
allow-clear
placeholder="请输入第三方登陆类型(MP-WEIXIN)"
v-model:value="form.oauthType"
/>
</a-form-item>
<a-form-item label="第三方用户唯一标识 (uid openid)" name="oauthId">
<a-input
allow-clear
placeholder="请输入第三方用户唯一标识 (uid openid)"
v-model:value="form.oauthId"
/>
</a-form-item>
<a-form-item label="微信unionID" name="unionid">
<a-input
allow-clear
placeholder="请输入微信unionID"
v-model:value="form.unionid"
/>
</a-form-item>
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="状态, 0正常, 1冻结" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addUserOauth, updateUserOauth } from '@/api/system/userOauth';
import { UserOauth } from '@/api/system/userOauth/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
//
const isUpdate = ref(false);
const useForm = Form.useForm;
//
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
//
visible: boolean;
//
data?: UserOauth | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
//
const loading = ref(false);
//
const maxable = ref(true);
//
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
//
const form = reactive<UserOauth>({
id: undefined,
userId: undefined,
oauthType: undefined,
oauthId: undefined,
unionid: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
//
const rules = reactive({
userOauthName: [
{
required: true,
type: 'string',
message: '请填写第三方用户信息表名称',
trigger: 'blur'
}
]
});
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateUserOauth : addUserOauth;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

223
src/views/system/userOauth/index.vue

@ -0,0 +1,223 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="userOauthId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<UserOauthEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import UserOauthEdit from './components/userOauthEdit.vue';
import { pageUserOauth, removeUserOauth, removeBatchUserOauth } from '@/api/system/userOauth';
import type { UserOauth, UserOauthParam } from '@/api/system/userOauth/model';
//
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
//
const selection = ref<UserOauth[]>([]);
//
const current = ref<UserOauth | null>(null);
//
const showEdit = ref(false);
//
const showMove = ref(false);
//
const loading = ref(true);
//
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
where.tenantId = 10519;
return pageUserOauth({
...where,
...orders,
page,
limit
});
};
//
const columns = ref<ColumnItem[]>([
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '渠道',
dataIndex: 'oauthType',
key: 'oauthType',
align: 'center',
},
{
title: 'oauthId',
dataIndex: 'oauthId',
key: 'oauthId',
align: 'center',
},
{
title: 'unionid',
dataIndex: 'unionid',
key: 'unionid',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: UserOauthParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: UserOauth) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: UserOauth) => {
const hide = message.loading('请求中..', 0);
removeUserOauth(row.userOauthId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchUserOauth(selection.value.map((d) => d.userOauthId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: UserOauth) => {
return {
//
onClick: () => {
// console.log(record);
},
//
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'UserOauth'
};
</script>
<style lang="less" scoped></style>
Loading…
Cancel
Save