diff --git a/src/api/account_center/organization.ts b/src/api/account_center/organization.ts new file mode 100644 index 0000000..f4e4318 --- /dev/null +++ b/src/api/account_center/organization.ts @@ -0,0 +1,25 @@ +import request from '@/utils/request' + +// 组织列表 +export function organzationLists(params?: any) { + return request.get({ url: '/organization/list', params }) +} + +// 添加组织 +export function organzationtAdd(params: any) { + return request.post({ url: '/organization/add', params }) +} + +// 编辑组织 +export function organzationEdit(params: any) { + return request.post({ url: '/organization/edit', params }) +} + +// 删除组织 +export function organzationDelete(params: any) { + return request.post({ url: '/organization/del', params }) +} +// 组织详情 +export function organzationDetail(params: any) { + return request.get({ url: '/organization/detail', params }) +} diff --git a/src/api/account_center/postion.ts b/src/api/account_center/postion.ts new file mode 100644 index 0000000..63a15fc --- /dev/null +++ b/src/api/account_center/postion.ts @@ -0,0 +1,30 @@ +import request from '@/utils/request' + +// 岗位列表 +export function postLists(params?: any) { + return request.get({ url: '/system/post/list', params }) +} +// 岗位列表 +export function postAll(params?: any) { + return request.get({ url: '/system/post/all', params }) +} + +// 添加岗位 +export function postAdd(params: any) { + return request.post({ url: '/system/post/add', params }) +} + +// 编辑岗位 +export function postEdit(params: any) { + return request.post({ url: '/system/post/edit', params }) +} + +// 删除岗位 +export function postDelete(params: any) { + return request.post({ url: '/system/post/del', params }) +} + +// 岗位详情 +export function postDetail(params: any) { + return request.get({ url: '/system/post/detail', params }) +} diff --git a/src/api/account_center/sub_account.ts b/src/api/account_center/sub_account.ts new file mode 100644 index 0000000..07d09ab --- /dev/null +++ b/src/api/account_center/sub_account.ts @@ -0,0 +1,18 @@ +import request from '@/utils/request' + +// 新增子账号 +export function subAccountAdd(params: Record) { + return request.post({ url: '/user/sonAdd', params }) +} +// 编辑子账号 +export function subAccountEdit(params: Record) { + return request.post({ url: '/user/sonEdit', params }) +} +// 子账号列表 +export function subAccountList(params: Record) { + return request.get({ url: '/user/selectOrganizationAllUser', params }) +} +// 账号名额 +export function subAccountNumber() { + return request.get({ url: '/user/validUserCount' }) +} diff --git a/src/enums/index.ts b/src/enums/index.ts new file mode 100644 index 0000000..db52410 --- /dev/null +++ b/src/enums/index.ts @@ -0,0 +1,8 @@ +export enum StatusEnum { + Normal = 1, + Stop = 0 +} +export enum DataFlowEnum { + DEFAULT = 0, + SPECIFIC = 1 +} diff --git a/src/utils/validate.ts b/src/utils/validate.ts index fdbf4a0..0bbc56a 100644 --- a/src/utils/validate.ts +++ b/src/utils/validate.ts @@ -30,7 +30,7 @@ export function isExternal(path: string) { export function validateContact(rule: any, value: any, callback: any) { if (value) { if (!mobileReg.test(value)) { - callback(new Error('请输入正确的手机号')) + callback(new Error('请输入正确的联系电话')) } else { callback() } diff --git a/src/views/account_center/organization/edit.vue b/src/views/account_center/organization/edit.vue index 52840b5..e7d3bd6 100644 --- a/src/views/account_center/organization/edit.vue +++ b/src/views/account_center/organization/edit.vue @@ -1,15 +1,8 @@ diff --git a/src/views/account_center/sub_account/modules/account-list.vue b/src/views/account_center/sub_account/modules/account-list.vue index 7c3768b..80f2f34 100644 --- a/src/views/account_center/sub_account/modules/account-list.vue +++ b/src/views/account_center/sub_account/modules/account-list.vue @@ -1,7 +1,7 @@ @@ -53,8 +53,9 @@ import feedback from '@/utils/feedback' import { Plus, Delete } from '@element-plus/icons-vue' import accountDialog from '../components/account-list/account-dialog.vue' import { useDebounceFn } from '@vueuse/core' +import { subAccountList } from '@/api/account_center/sub_account' -defineProps({ +const props = defineProps({ curOrganization: { type: Object, default: () => ({}) @@ -76,50 +77,26 @@ const proTableRef = ref() const tableData = ref([]) const columns = reactive([ { type: 'selection', fixed: 'left', width: 70, reserveSelection: true }, - { prop: 'accountName', label: '账号名称', width: 180 }, + { prop: 'username', label: '账号名称', width: 180 }, { prop: 'mobile', label: '联系电话', width: 180 }, - { prop: 'organization', label: '所属组织', width: 180 }, - { prop: 'position', label: '岗位', width: 180 }, - { prop: 'accountStatus', label: '账号状态', width: 180 }, + { prop: 'organizationName', label: '所属组织', width: 180 }, + { prop: 'postName', label: '岗位', width: 180 }, + { prop: 'status', label: '账号状态', width: 180 }, { prop: 'operation', label: '操作', fixed: 'right', width: 250 } ]) const isGroupLeader = computed(() => (groupLeader: number) => groupLeader == 1) const btnText = computed(() => (groupLeader: number) => isGroupLeader.value(groupLeader) ? '取消设为组长' : '设置组长') -const fetchTableList = () => { +const fetchTableList = async (nodeId?: number) => { loading.value = true - setTimeout(() => { - tableData.value = [ - { - id: 1, - accountName: '张三', - mobile: '18138952909', - organization: '广州团队-A组', - position: '电销老师', - accountStatus: 1, - groupLeader: 1 - }, - { - id: 2, - accountName: '李四', - mobile: '18138952909', - organization: '广州团队-A组', - position: '电销老师', - accountStatus: 1, - groupLeader: 0 - }, - { - id: 3, - accountName: '王五', - mobile: '18138952909', - organization: '广州团队-A组', - position: '招生老师', - accountStatus: 0, - groupLeader: 0 - } - ] - loading.value = false - }, 500) + try { + const params = { + organizationId: nodeId ?? props.curOrganization.id + } + const result = await subAccountList(params) + tableData.value = result ?? [] + } catch (error) {} + loading.value = false } const handleStatusChange = row => { console.log(row) @@ -151,13 +128,16 @@ const deleteCommon = async (row?: any) => { } proTableRef.value.tableRef.clearSelection() } +const handleEdit = row => { + showAccountDialog(row) +} defineExpose({ fetchTableList }) const accountDialogRef = ref>() -const showAccountDialog = () => { +const showAccountDialog = (row?: any) => { accountDialogRef.value?.openDialog({ - title: '新建账号', + title: row?.id ? '编辑账号' : '新建账号', width: 400, data: {} }) diff --git a/src/views/account_center/sub_account/modules/account-number.vue b/src/views/account_center/sub_account/modules/account-number.vue index 048e339..87d0bea 100644 --- a/src/views/account_center/sub_account/modules/account-number.vue +++ b/src/views/account_center/sub_account/modules/account-number.vue @@ -1,14 +1,27 @@ - + diff --git a/src/views/account_center/sub_account/modules/organization.vue b/src/views/account_center/sub_account/modules/organization.vue index 5df8a5a..2dadbf1 100644 --- a/src/views/account_center/sub_account/modules/organization.vue +++ b/src/views/account_center/sub_account/modules/organization.vue @@ -12,6 +12,7 @@ import organizationTree, { type Tree } from '../components/organization/organiza import groupLeaderDialog from '../components/organization/groupLeader-dialog.vue' import { ORGANIZATION_INJECTION_KEY } from '@/config/symbol' import type { PropType } from 'vue' +import { organzationLists } from '@/api/account_center/organization' defineProps({ curSelectedNode: { @@ -25,49 +26,14 @@ const loading = ref(false) const setSelectedNode = (data: Tree) => { emit('setSelectedNode', data) } -const fetchOrganizationList = () => { - console.log('fetchOrganizationList') +const fetchOrganizationList = async () => { loading.value = true - setTimeout(() => { - data.value = [ - { - id: 1, - label: '合创云公司', - children: [ - { - id: 11, - label: '湛江团队', - children: [ - { - id: 111, - label: 'A组' - }, - { - id: 112, - label: 'B组' - }, - { - id: 113, - label: 'C组' - } - ] - }, - { - id: 12, - label: '广州团队', - children: [ - { - id: 121, - label: 'A组' - } - ] - } - ] - } - ] + try { + const result = await organzationLists() + data.value = result loading.value = false data.value.length > 0 && setSelectedNode(data.value[0]) - }, 500) + } catch (error) {} } provide(ORGANIZATION_INJECTION_KEY, { fetchOrganizationList,