6 changed files with 330 additions and 81 deletions
@ -0,0 +1,43 @@ |
|||||||
|
<template> |
||||||
|
<BasicModal |
||||||
|
v-bind="$attrs" |
||||||
|
width="720px" |
||||||
|
:showOkBtn="false" |
||||||
|
@register="registerModal" |
||||||
|
> |
||||||
|
<BasicForm @register="registerForm"/> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup> |
||||||
|
import { ref } from 'vue'; |
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||||
|
import { userFormSchema } from './friend.data'; |
||||||
|
import { getUser } from '/@/api/platform/system/controller/user'; |
||||||
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
import { useRoute } from 'vue-router'; |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const tag = ref<Nullable<string>>(''); |
||||||
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
const router = useRoute(); |
||||||
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||||
|
labelWidth: 100, |
||||||
|
schemas: userFormSchema, |
||||||
|
showActionButtonGroup: false, |
||||||
|
baseColProps: { span: 24 } |
||||||
|
}); |
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||||
|
// 处理清除脏数据 |
||||||
|
await resetFields(); |
||||||
|
await clearValidate(); |
||||||
|
// 处理设置数据 |
||||||
|
tag.value = data._tag; |
||||||
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
|
props.title = '查看好友'; |
||||||
|
let user = await getUser(data.record?.id); |
||||||
|
await setFieldsValue(user.result); |
||||||
|
// 尾部:设置处理后的最终配置数据 |
||||||
|
setModalProps(props); |
||||||
|
}); |
||||||
|
</script> |
@ -0,0 +1,154 @@ |
|||||||
|
import { BasicColumn } from '/@/components/Table'; |
||||||
|
import { FormSchema } from '/@/components/Table'; |
||||||
|
import { h } from 'vue'; |
||||||
|
import { Tag } from 'ant-design-vue'; |
||||||
|
|
||||||
|
/** 表格列配置 */ |
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: '用户昵称', |
||||||
|
dataIndex: 'nickName', |
||||||
|
width: 120 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '性别', |
||||||
|
dataIndex: 'sex', |
||||||
|
width: 80, |
||||||
|
customRender: ({ record }) => { |
||||||
|
const sex = record.sex; |
||||||
|
const enable = ~~sex === 0; |
||||||
|
const color = enable ? 'green' : 'red'; |
||||||
|
const text = enable ? '男' : '女'; |
||||||
|
return h(Tag, { color: color }, () => text); |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '机构名称', |
||||||
|
dataIndex: 'deptName', |
||||||
|
width: 200 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '邮箱', |
||||||
|
dataIndex: 'email', |
||||||
|
width: 120 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '手机号码', |
||||||
|
dataIndex: 'phone', |
||||||
|
width: 200 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建时间', |
||||||
|
dataIndex: 'createTime', |
||||||
|
width: 180 |
||||||
|
} |
||||||
|
]; |
||||||
|
|
||||||
|
/** 搜索表单配置 */ |
||||||
|
export const searchFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
field: 'nickName', |
||||||
|
label: '用户昵称', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入用户昵称', |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
} |
||||||
|
]; |
||||||
|
|
||||||
|
/** 用户表单配置 */ |
||||||
|
export const userFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
field: 'id', |
||||||
|
label: 'ID', |
||||||
|
component: 'Input', |
||||||
|
show: false |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'nickName', |
||||||
|
label: '用户昵称', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
}, |
||||||
|
colProps: { |
||||||
|
span: 12 |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'deptId', |
||||||
|
label: '归属机构', |
||||||
|
component: 'TreeSelect', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
fieldNames: { |
||||||
|
label: 'name', |
||||||
|
key: 'deptId', |
||||||
|
value: 'deptId' |
||||||
|
}, |
||||||
|
getPopupContainer: () => document.body |
||||||
|
}, |
||||||
|
colProps: { |
||||||
|
span: 12 |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'phone', |
||||||
|
label: '手机号', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'email', |
||||||
|
label: '邮箱', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'sex', |
||||||
|
label: '性别', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
options: [ |
||||||
|
{ label: '男', value: '0' }, |
||||||
|
{ label: '女', value: '1' } |
||||||
|
] |
||||||
|
}, |
||||||
|
colProps: { |
||||||
|
span: 12 |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'userType', |
||||||
|
label: '用户类型', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
options: [ |
||||||
|
{ label: '系统管理员', value: '0' }, |
||||||
|
{ label: '普通用户', value: '1' }, |
||||||
|
{ label: '企业用户', value: '2' }, |
||||||
|
{ label: '收样员', value: '3' }, |
||||||
|
{ label: '客服', value: '4' }, |
||||||
|
] |
||||||
|
}, |
||||||
|
colProps: { |
||||||
|
span: 12 |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '备注', |
||||||
|
field: 'remarks', |
||||||
|
component: 'InputTextArea', |
||||||
|
componentProps: { |
||||||
|
disabled: true, |
||||||
|
rows: 6 |
||||||
|
} |
||||||
|
} |
||||||
|
]; |
@ -0,0 +1,126 @@ |
|||||||
|
<template> |
||||||
|
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #bodyCell="{ column, record }"> |
||||||
|
<template v-if="column.key === 'action'"> |
||||||
|
<TableAction |
||||||
|
:actions="[ |
||||||
|
{ |
||||||
|
label: '查看', |
||||||
|
icon: 'fa6-regular:pen-to-square', |
||||||
|
onClick: handleViewEdit.bind(null, record) |
||||||
|
}]" |
||||||
|
:dropDownActions="[ |
||||||
|
{ |
||||||
|
label: '关注', |
||||||
|
icon: 'ant-design:delete-outlined', |
||||||
|
disabled: !!record?.cfStatus || !!record?.bId, |
||||||
|
onClick: handleAddFriend.bind(null, record) |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '加入黑名单', |
||||||
|
icon: 'ant-design:delete-outlined', |
||||||
|
disabled: !!record?.bId, |
||||||
|
onClick: handleBlacklist.bind(null, record) |
||||||
|
}]" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
</template> |
||||||
|
</BasicTable> |
||||||
|
<!--弹出窗体区域--> |
||||||
|
<FriendModal @register="registerModal" @success="handleRefreshTable"/> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script lang="ts" setup> |
||||||
|
/** |
||||||
|
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
|
* author entfrm开发团队-王翔 |
||||||
|
*/ |
||||||
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||||
|
import { addPushConcernFan, listPushFriend } from '/@/api/platform/common/controller/pushConcernFan'; |
||||||
|
import { useModal } from '/@/components/Modal'; |
||||||
|
import FriendModal from './FriendModal.vue'; |
||||||
|
import { columns, searchFormSchema } from './friend.data'; |
||||||
|
import { useMessage } from '/@/hooks/web/useMessage'; |
||||||
|
import { useUserStore } from '/@/store/modules/user'; |
||||||
|
import { addPushBlacklist } from '/@/api/platform/common/controller/pushBlacklist'; |
||||||
|
|
||||||
|
const userStore = useUserStore(); |
||||||
|
const userInfoStore = userStore.getUserInfo; |
||||||
|
const { createConfirm, createMessage } = useMessage(); |
||||||
|
const [registerModal, { openModal }] = useModal(); |
||||||
|
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||||
|
title: '好友列表', |
||||||
|
api: listPushFriend, |
||||||
|
rowKey: 'id', |
||||||
|
columns, |
||||||
|
formConfig: { |
||||||
|
compact: true, |
||||||
|
labelWidth: 80, |
||||||
|
schemas: searchFormSchema, |
||||||
|
autoSubmitOnEnter: true, |
||||||
|
showAdvancedButton: true, |
||||||
|
autoAdvancedLine: 3, |
||||||
|
}, |
||||||
|
rowSelection: { type: 'checkbox' }, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
bordered: true, |
||||||
|
clickToRowSelect: false, |
||||||
|
showIndexColumn: false, |
||||||
|
actionColumn: { |
||||||
|
width: 220, |
||||||
|
title: '操作', |
||||||
|
dataIndex: 'action', |
||||||
|
fixed: false |
||||||
|
}, |
||||||
|
}); |
||||||
|
|
||||||
|
/** 查看按钮操作,行内查看 */ |
||||||
|
function handleViewEdit(record?: Recordable) { |
||||||
|
record = record || { id: getSelectRowKeys() }; |
||||||
|
openModal(true, { _tag: 'view', record }); |
||||||
|
} |
||||||
|
|
||||||
|
async function handleAddFriend(record?: Recordable) { |
||||||
|
createConfirm({ |
||||||
|
iconType: 'warning', |
||||||
|
title: '警告', |
||||||
|
content: `是否关注用户为${record?.nickName}的数据?`, |
||||||
|
onOk: async () => { |
||||||
|
await addPushConcernFan({ |
||||||
|
concernUserId: userInfoStore.id, |
||||||
|
fanUserId: record?.id |
||||||
|
}); |
||||||
|
createMessage.success('申请成功!'); |
||||||
|
handleRefreshTable(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
function handleBlacklist(record?: Recordable) { |
||||||
|
createConfirm({ |
||||||
|
iconType: 'warning', |
||||||
|
title: '警告', |
||||||
|
content: `是否确认把${record?.nickName}的用户加入打黑名单?`, |
||||||
|
onOk: async () => { |
||||||
|
await addPushBlacklist({ |
||||||
|
concernUserId: userInfoStore.id, |
||||||
|
fanUserId: record?.id |
||||||
|
}); |
||||||
|
createMessage.success('添加成功!'); |
||||||
|
handleRefreshTable(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** 处理表格刷新 */ |
||||||
|
function handleRefreshTable() { |
||||||
|
clearSelectedRowKeys(); |
||||||
|
reload(); |
||||||
|
} |
||||||
|
|
||||||
|
</script> |
Loading…
Reference in new issue