Browse Source

refactor: 重构企业管理

master
wangxiang 2 years ago
parent
commit
cee2e6cf02
  1. 12
      src/api/platform/common/controller/pushEnterprise.ts
  2. 2
      src/api/platform/common/entity/pushEnterprise.ts
  3. 24
      src/views/common/push/pushEnterprise/EnterpriseModal.vue
  4. 78
      src/views/common/push/pushEnterprise/enterprise.data.ts
  5. 104
      src/views/common/push/pushEnterprise/index.vue

12
src/api/platform/common/controller/pushEnterprise.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import type { PushChatMessage, PushChatMessageParams, PushChatMessageResult } from '/@/api/platform/common/entity/pushChatMessage';
import type { PushEnterprise, PushEnterpriseParams, PushEnterpriseResult } from '/@/api/platform/common/entity/pushEnterprise';
import { defHttp } from '/@/utils/http/axios';
enum Api {
@ -11,15 +11,15 @@ enum Api { @@ -11,15 +11,15 @@ enum Api {
revokeAuth = '/common_proxy/common/pushEnterprise/revokeAuth'
}
export const listPushEnterprise = (params?: Partial<PushChatMessageParams>) => defHttp.get<PushChatMessageResult>({ url: Api.list, params }, { isReturnResultResponse: true });
export const listPushEnterprise = (params?: Partial<PushEnterpriseParams>) => defHttp.get<PushEnterpriseResult>({ url: Api.list, params }, { isReturnResultResponse: true });
export const addPushEnterprise = (params: Partial<PushChatMessage>) => defHttp.post({ url: Api.add, data: params });
export const addPushEnterprise = (params: Partial<PushEnterprise>) => defHttp.post({ url: Api.add, data: params });
export const editPushEnterprise = (params: Partial<PushChatMessage>) => defHttp.put({ url: Api.edit, data: params });
export const editPushEnterprise = (params: Partial<PushEnterprise>) => defHttp.put({ url: Api.edit, data: params });
export const getPushEnterprise = (id: string) => defHttp.get<PushChatMessage>({ url: `${Api.get}/${id}` });
export const getPushEnterprise = (id: string) => defHttp.get<PushEnterprise>({ url: `${Api.get}/${id}` });
export const getPushEnterpriseByUserId = (id: string) => defHttp.get<PushChatMessage>({ url: `${Api.getByUserId}/${id}` });
export const getPushEnterpriseByUserId = (id: string) => defHttp.get<PushEnterprise>({ url: `${Api.getByUserId}/${id}` });
export const revokeAuthPushEnterprise = () => defHttp.delete({ url: Api.revokeAuth });

2
src/api/platform/common/entity/pushEnterprise.ts

@ -8,7 +8,7 @@ export interface PushEnterprise extends CommonEntity { @@ -8,7 +8,7 @@ export interface PushEnterprise extends CommonEntity {
name: string;
repName: string;
phone: string;
license: string;
license: string | string[];
userId: string;
creditCode: string;
idCard: string;

24
src/views/common/push/pushEnterprise/ThirdPartyModal.vue → src/views/common/push/pushEnterprise/EnterpriseModal.vue

@ -9,16 +9,10 @@ @@ -9,16 +9,10 @@
</BasicModal>
</template>
<script lang="ts" setup>
/**
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致
* 采用vben-动态表格表单封装组件编写,采用 setup 写法
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔
*/
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './thirdParty.data';
import { addPushThirdParty, editPushThirdParty, getPushThirdParty, getPushThirdPartyByUserId } from '/@/api/platform/common/controller/pushThirdParty';
import { formSchema } from './enterprise.data';
import { addPushEnterprise, editPushEnterprise, getPushEnterprise, getPushEnterpriseByUserId } from '/@/api/platform/common/controller/pushEnterprise';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
/** 通用变量统一声明区域 */
@ -46,11 +40,16 @@ @@ -46,11 +40,16 @@
break;
case 'edit':
props.title = '编辑企业';
await setFieldsValue(await getPushThirdParty(refId));
let enterprise = await getPushEnterprise(refId);
enterprise.license = String(enterprise.license).split(',');
await setFieldsValue(enterprise);
break;
case 'view':
//
props.title = '查看企业';
await setFieldsValue(await getPushThirdPartyByUserId(refId));
let enterpriseByUserId = await getPushEnterpriseByUserId(refId);
enterpriseByUserId.license = String(enterpriseByUserId.license).split(',');
await setFieldsValue(enterpriseByUserId);
await setProps({ disabled: true });
break;
}
@ -63,15 +62,16 @@ @@ -63,15 +62,16 @@
try {
//
const formData = await validate();
formData.license = Array(formData.license).join(',');
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addPushThirdParty(formData);
await addPushEnterprise(formData);
break;
case 'edit':
await editPushThirdParty(formData);
await editPushEnterprise(formData);
break;
}
//

78
src/views/common/push/pushEnterprise/thirdParty.data.ts → src/views/common/push/pushEnterprise/enterprise.data.ts

@ -1,15 +1,17 @@ @@ -1,15 +1,17 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { listUser } from '/@/api/platform/system/controller/user';
import { commonUpload } from '/@/api/platform/core/controller/upload';
/** 表格列配置 */
export const columns: BasicColumn[] = [
{
title: '法定代表人',
dataIndex: 'statutoryRepName',
title: '企业名称',
dataIndex: 'name'
},
{
title: '企业名称',
dataIndex: 'entName'
title: '法定代表人',
dataIndex: 'repName',
},
{
title: '手机号',
@ -32,7 +34,7 @@ export const columns: BasicColumn[] = [ @@ -32,7 +34,7 @@ export const columns: BasicColumn[] = [
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [
{
field: 'entName',
field: 'name',
label: '企业名称',
component: 'Input',
componentProps: {
@ -51,28 +53,31 @@ export const formSchema: FormSchema[] = [ @@ -51,28 +53,31 @@ export const formSchema: FormSchema[] = [
show: false,
},
{
field: 'statutoryRepName',
label: '法定代表人',
component: 'Input',
required: true,
},
{
field: 'idCard',
label: '身份证',
field: 'name',
label: '企业名称',
component: 'Input',
required: true,
colProps: {
span: 12
},
},
{
field: 'entName',
label: '企业名称',
field: 'repName',
label: '法定代表人',
component: 'Input',
required: true,
colProps: {
span: 12
},
},
{
field: 'phone',
label: '手机号',
component: 'Input',
required: true,
colProps: {
span: 12
},
rules: [
{
required: true,
@ -85,11 +90,54 @@ export const formSchema: FormSchema[] = [ @@ -85,11 +90,54 @@ export const formSchema: FormSchema[] = [
}
]
},
{
field: 'userId',
label: '关联用户',
component: 'ApiSelect',
required: true,
componentProps: {
api: listUser,
params: {
size: 99
},
labelField: 'nickName',
valueField: 'id',
resultField: 'data'
},
},
{
field: 'license',
label: '营业执照',
component: 'Upload',
required: true,
componentProps: {
multiple: true,
maxSize: 20,
maxNumber: 10,
showUploadSaveBtn: true,
showPreviewNumber: true,
emptyHidePreview: true,
api: commonUpload,
accept: ['image/*']
}
},
{
field: 'creditCode',
label: '信用代码',
component: 'Input',
required: true,
colProps: {
span: 12
},
},
{
field: 'idCard',
label: '身份证',
component: 'Input',
required: true,
colProps: {
span: 12
},
},
{
field: 'detailedAddress',

104
src/views/common/push/pushEnterprise/index.vue

@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
@selection-change="handleSelectionChange"
>
<template #toolbar>
<!--<a-button type="primary"
<a-button type="primary"
@click="handleAdd()"
>新增第三方</a-button>-->
>新增企业</a-button>
<a-button
type="primary"
:disabled="state.single"
@ -19,24 +19,9 @@ @@ -19,24 +19,9 @@
@click="handleDel()"
>删除企业</a-button>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: '加入黑名单',
icon: 'fa6-regular:pen-to-square',
onClick: handleBlacklist.bind(null, record)
},
{
label: '加入白名单',
icon: 'fa6-regular:pen-to-square',
onClick: handleWhitelist.bind(null, record)
},
{
label: '推送申请',
icon: 'fa6-regular:pen-to-square',
onClick: handlePushAdd.bind(null, record)
},
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction :actions="[
{
label: '编辑',
icon: 'fa6-regular:pen-to-square',
@ -48,34 +33,24 @@ @@ -48,34 +33,24 @@
color: 'error',
onClick: handleDel.bind(null, record)
}]"
/>
/>
</template>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ThirdPartyModal @register="registerModal" @success="handleRefreshTable"/>
<EnterpriseModal @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 { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listPushThirdParty, delPushThirdParty } from '/@/api/platform/common/controller/pushThirdParty';
import { listPushEnterprise, delPushEnterprise } from '/@/api/platform/common/controller/pushEnterprise';
import { useModal } from '/@/components/Modal';
import ThirdPartyModal from './ThirdPartyModal.vue';
import { columns, searchFormSchema } from './thirdParty.data';
import EnterpriseModal from './EnterpriseModal.vue';
import { columns, searchFormSchema } from './enterprise.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { addPushPassList } from '/@/api/platform/common/controller/pushPassList';
import { addPushUserManage } from '/@/api/platform/common/controller/pushUserManage';
import {useUserStore} from '/@/store/modules/user';
const userStore = useUserStore();
const userInfoStore = userStore.getUserInfo;
/** 类型规范统一声明定义区域 */
interface TableState {
single: boolean;
@ -93,7 +68,7 @@ @@ -93,7 +68,7 @@
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '企业列表',
api: listPushThirdParty,
api: listPushEnterprise,
rowKey: 'id',
columns,
formConfig: {
@ -114,7 +89,6 @@ @@ -114,7 +89,6 @@
width: 450,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
fixed: false
},
searchInfo: {
@ -141,58 +115,6 @@ @@ -141,58 +115,6 @@
openModal(true, { _tag: 'edit', record });
}
function handleWhitelist(record?: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否添加白名单编号为${record?.userId}的数据?`,
onOk: async () => {
await addPushPassList({
fromPushId: record?.userId,
toPushId: userInfoStore.id,
type: '1'
});
createMessage.success('添加成功!');
handleRefreshTable();
}
});
}
function handleBlacklist(record?: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否添加黑名单编号为${record?.userId}的数据?`,
onOk: async () => {
await addPushPassList({
fromPushId: record?.userId,
toPushId: userInfoStore.id,
type: '0'
});
createMessage.success('添加成功!');
handleRefreshTable();
}
});
}
function handlePushAdd(record?: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否添加推送申请编号为${record?.userId}的数据?`,
onOk: async () => {
await addPushUserManage({
fromUserId: record?.userId,
toUserId: userInfoStore.id,
userName: record?.entName,
type: '1'
});
createMessage.success('申请成功!');
handleRefreshTable();
}
});
}
/** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) {
const ids = record?.id || getSelectRowKeys();
@ -201,7 +123,7 @@ @@ -201,7 +123,7 @@
title: '警告',
content: `是否确认删除编号为${ids}的数据?`,
onOk: async () => {
await delPushThirdParty(ids);
await delPushEnterprise(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}

Loading…
Cancel
Save