diff --git a/config/routes.ts b/config/routes.ts index f421868..dcbd1c9 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -586,6 +586,11 @@ export default [ name: 'roles', component: './Setting/Roles/index', }, + { + path: '/setting/users', + name: 'users', + component: './Setting/Users/index', + }, ] }, { diff --git a/dist.zip b/dist.zip index 03f6267..6d9e7d7 100644 Binary files a/dist.zip and b/dist.zip differ diff --git a/package.json b/package.json index 5a420b5..7cf2e57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ant-design-pro", - "version": "4.5.65", + "version": "4.5.66", "private": true, "description": "An out-of-box UI solution for enterprise applications", "scripts": { diff --git a/src/models/user.ts b/src/models/user.ts index 70d6238..ad8d34b 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -32,6 +32,7 @@ export type CurrentUser = { ServerpartIds: string; // 服务区ids unreadCount: number; // 未读消息数量 SupplierID: number; + SupplierName?: string }; export type UserModelState = { diff --git a/src/pages/Setting/Users/components/edit.tsx b/src/pages/Setting/Users/components/edit.tsx new file mode 100644 index 0000000..add4bac --- /dev/null +++ b/src/pages/Setting/Users/components/edit.tsx @@ -0,0 +1,1217 @@ + +import ProForm, { ProFormRadio, ProFormSelect, ProFormText, ProFormTreeSelect } from "@ant-design/pro-form" +import { FooterToolbar, PageContainer } from "@ant-design/pro-layout" +import useRequest from "@ahooksjs/use-request"; +import { Card, Col, Form, Row, Tree, message, Switch, Button, TreeSelect, Radio, Drawer, Popconfirm } from "antd"; +import { useEffect, useRef, useState } from "react"; +import { history } from "umi"; + +import type { ProFormInstance } from "@ant-design/pro-form"; +import type { CurrentUser } from '@/models/user'; + +import { getMerchantTree, getMerchantTreeNosessoin, getOnwer } from "@/services/options"; +import { getUserDetail, getUserTypeTree, getServerpartTree, updataUser, modifyUserPassword, getMerchantShopTree, getWeiChatPush, handleGetServiceList, handleDeleteUSER, handleSynchroBEHAVIORRECORD } from "../service"; +import { getRoleList, getSystemMenuTree, handleAnalysisPermission, handleSupplierList } from "../../Roles/service"; +import session from "@/utils/session"; +import moment from 'moment' +import BusinessManDrawer from "@/pages/basicManage/businessMan/components/businessManDrawer"; +import { handeGetMERCHANTSList } from "@/pages/travelMember/service"; + +// 提交账号数据 +const handleAddUpdate = async (item: any, type: boolean) => { + console.log('handleAddUpdate', item); + + const loading = message.loading("正在提交...") + const result = await updataUser(item) + + loading() + if (result.Result_Code !== 100) { + message.error(`${result.Result_Desc}` || `${result.Result_Code}:提交失败`) + return false + } + if (type) { + message.success(item.USER_ID ? "更新成功!" : "新建成功!") + } + return result.Result_Data.USER_ID +} + +// 重置账号密码请求 +const handelResetPassWord = async (item: { UserId: number, Password: string }) => { + const loading = message.loading("正在提交...") + const result = await modifyUserPassword(item) + loading() + if (result.Result_Code !== 100) { + message.error(`${result.Result_Desc}` || `${result.Result_Code}:账户密码重置失败`) + } else { + message.success("账户密码重置成功!") + } + +} +/** + * @description: 主体编辑函数 + * @param {function} reloadTable 是否已经更新数据 + * @param {UserModel} detail 编辑账户数据时的数据对象 + * @param {CurrentUser} user 当前用户的用户信息 + * @return {ReactDOM} 返回页面节点 + */ +const Edit = ({ tableTab, openType, detail, reloadTable, currentUser, selectTab, pageType, BUSINESSMAN_ID, onShow }: { onShow?: boolean, BUSINESSMAN_ID?: any, pageType?: string, selectTab?: any, tableTab?: any, openType?: string, detail?: UserModel, reloadTable: any, currentUser: CurrentUser | undefined }) => { + const detailForm = useRef() // 表单对象 + const [checkedRole, setCheckedRole] = useState(); // 当前选中的行 角色 id + const [checkedServerpart, setCheckedServerpart] = useState(); // 当前选中的行 服务区id + const [checkedShop, setCheckedShop] = useState(); // 当前选中的行 服务区门店id + const [initialDetail, setInitialDetail] = useState(detail || {}); // 当前编辑页面的账户数据 + const [copyData, setCopyData] = useState()// 拷贝一份一开始接口返回的表单数据 与 最后提交可以进行对比 + const [companyList, setCompanyList] = useState()// 用户下面的公司列表 + const [selectDetail, setSelectDetail] = useState()// 选中的业主单位的省份 + const [serviceList, setServiceList] = useState()// 服务区列表 + const [showServiceList, setShowServiceList] = useState()// 展示要选择的服务区 + // const selectType = useRef() + const [showWeChatFlag, setShowWeChatFlag] = useState()// 微信推送权限是选择了false 还是 true + const [SPRegionList, setSPRegionList] = useState()// 片区的数组 + // type为1 的 + const [serverPartType1, setServerPartType1] = useState() + // 添加商户的抽屉 + const [showAddDrawer, setShowAddDrawer] = useState(false) + // const [supplierList,setSupplierList] = useState()// 供应商列表 + // 查询角色树 + const [roleTree, setRoleTree] = useState() // 角色树列表 + // const { data: roleTree } = useRequest(async () => { + // if (currentUser?.UserPattern===9000){ + // const req = { + // SystemRolePattern:currentUser?.UserPattern + // } + // return await getRoleList(req) + // } + // }) + const handleRoleList = async (value: number) => { + if (currentUser?.UserPattern === 9000) { + const req = { + ShowStatus: true + } + const data = await getRoleList(req) + setRoleTree(data) + + } else if (currentUser?.UserPattern === 1000 && value !== 3000) { + let req + if (currentUser?.SystemRolePID) { + req = { + SystemRolePID: currentUser?.SystemRolePID, + ShowStatus: true, + SystemRolePattern: value + } + } else { + req = { + ShowStatus: true, + SystemRolePattern: value + } + } + const data = await getRoleList(req) + setRoleTree(data) + } else if (currentUser?.UserPattern !== 3000) { + const req = { + ShowStatus: true, + SystemRolePattern: value + } + const data = await getRoleList(req) + console.log('reqreqreq', data); + + setRoleTree(data) + } + } + + // 查询可配置的服务区 + const { data: serverpartTree } = useRequest(async () => { + const data = await getServerpartTree() + console.log('all', data); + + + return data.map(n => n.children ? n : { ...n, children: [] }) + }) + // 查询可选商家 + // const { run: getMerchantTree, data: merchantTree } = useRequest(async () => { + // return await getMerchantTree() + // }) + + // 查询可选商家 + const { run: handleGetMerchantTree, data: merchantTree } = useRequest(async () => { + const data = await getMerchantTreeNosessoin() + console.log('3213123123213123213123', data); + + return data + }, { manual: true }) + + + const { data: supplierList } = useRequest(async () => { + const req = { + searchParameter: { + OWNERUNIT_ID: currentUser?.OwnerUnitId, + PROVINCE_CODE: currentUser?.ProvinceCode, + MERCHANTS_TYPE: "" + }, + PageIndex: 1, + PageSize: 999999, + } + const data = await handeGetMERCHANTSList(req); + console.log('datadatadatadatadata', data); + let list: any = [] + if (data.List && data.List.length > 0) { + data.List.forEach((item: any) => { + list.push({ label: item.MERCHANTS_NAME, value: item.MERCHANTS_ID }) + }) + } + return list + }) + + // 根据角色id查询权限树 + const { run: getRoleMenu, data: roleMenuTree } = useRequest(async (SystemRoleId?: number) => { + const data = await getSystemMenuTree(SystemRoleId ? `${SystemRoleId}` : '') + return data + }, { manual: true }) + + // 根据商家id查询门店列表 + const { run: getShopTree, data: shopTree } = useRequest(async (businessManId?: number) => { + const data = await getMerchantShopTree({ BusinessManId: businessManId ? `${businessManId}` : detail?.BUSINESSMAN_ID }) + console.log('shopTreeshopTreeshopTreeshopTree', data); + return data + }, { manual: !detail?.BUSINESSMAN_ID }) + + const companyType = { + 1000: "业主本部", + 1010: "服务区", + 1020: "区域", + 2000: "商户" + } + + const getServiceList = async (PROVINCEID: any, id: any) => { + const typeId = id || showServiceList + const req = { + ProvinceCode: PROVINCEID || selectDetail, + ServerpartType: typeId === 1020 ? 1010 : 1000, + ShowWholePower: true + } + const res = await handleGetServiceList(req) + // const service: any = [] + // const SPRegion: any = [] + // if (res.List && res.List.length>0){ + // res.List.forEach((item: any)=>{ + // SPRegion.push({label:item.label,value:item.value}) + // service.push({label:item.label,value:item.value}) + // // if (item.children && item.children.length>0){ + // // item.children.forEach((subItem: any)=>{ + // // service.push({label:subItem.label,value:subItem.value}) + // // }) + // // } + // }) + // } + if (res.List && res.List.length > 0) { + const list = JSON.parse(JSON.stringify(res.List)) + // for (let i=0;i<=list.length-1;i++){ + // for (let j=0;j<=list.length - i - 1;j++){ + // if (list[j] && list[j + 1] && list[j].value && list[j+1].value){ + // if (list[j].value > list[j+1].value){ + // const temp = list[j] + // list[j] = list[j + 1] + // list[j + 1] = temp + // } + // } + // } + // } + list.forEach((item: any) => { + if (item.type === 1) { + item.selectable = true + } else { + item.selectable = false + } + }) + + // setServiceList(list) + setSPRegionList(list) + } + } + + // 商戶管理拿到角色权限 + const handleRoleListShop = async () => { + const req = { + ShowStatus: true, + SystemRolePattern: 2000 + } + const data = await getRoleList(req) + console.log('data222', data); + + setRoleTree(data) + } + + + useEffect(() => { + // detailForm.current?.setFieldsValue({USER_PATTERN: Number(selectTab) }) + console.log('selectTab', Number(selectTab)) + if (pageType === 'merchantManagement') { + handleRoleListShop() + } else { + handleRoleList(Number(selectTab)) + } + handleGetMerchantTree() + setInitialDetail({ + ...initialDetail, + USER_PATTERN: Number(selectTab) + }) + }, [selectTab]); + + + // 删除角色 + const handleDeleteUser = async () => { + console.log('initialDetail', initialDetail); + + const req: any = { + USERId: initialDetail?.USER_ID + } + console.log('req', req); + + const data = await handleDeleteUSER(req) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + reloadTable(true, 'delete') + } else { + message.error(data.Result_Desc) + } + const baseInfo = session.get('basicInfo') + const browser = session.get('browserVersion') + const systemInfo = session.get('systemBasin') + + handleGetSynchroBEHAVIORRECORD(1002) + + } + + const handleGetSynchroBEHAVIORRECORD = async (type: number) => { + const baseInfo = session.get('basicInfo') + const browser = session.get('browserVersion') + const systemInfo = session.get('systemBasin') + + const req: any = { + USER_ID: initialDetail?.USER_ID, + USER_NAME: initialDetail?.USER_NAME, + USER_PASSPORT: initialDetail?.USER_PASSPORT, + USER_MOBILEPHONE: initialDetail?.USER_MOBILEPHONE, + BEHAVIORRECORD_TYPE: type, + BEHAVIORRECORD_EXPLAIN: '删除用户', + BEHAVIORRECORD_TIME: moment().format('YYYY-MM-DD HH:mm:ss'), + BEHAVIORRECORD_ROUT: pageType ? '/setting/merchantManagement' : '/setting/users', + BEHAVIORRECORD_ROUTNAME: pageType ? '商户管理' : '账号管理', + SOURCE_PLATFORM: '驿商云平台', + USER_LOGINIP: baseInfo?.ip ? baseInfo?.ip : '', + USER_LOGINPLACE: `${baseInfo?.prov ? baseInfo?.prov : ''}${baseInfo?.prov && baseInfo?.city ? '-' : ''}${baseInfo?.city ? baseInfo?.city : ''}`, + BROWSER_VERSION: browser || '', + OPERATING_SYSTEM: systemInfo || '', + } + handleSynchroBEHAVIORRECORD(req) + } + + + + + return ( + + { + if (detail) { + const initDetail = await getUserDetail(detail.USER_ID, true) + + // 格式转化 + // let haveList = initDetail.ServerpartList ? initDetail.ServerpartList.map(Number) : [] // 业主账号有服务区 有权限的全部服务区 + const haveList = initDetail.ServerpartList || [] // 业主账号有服务区 有权限的全部服务区 + + const firstType: any = [] + const serverpartTree = await getServerpartTree() + + if (serverpartTree && serverpartTree.length > 0) { + serverpartTree.forEach((item: any) => { + if (item.type === 1) { + firstType.push(item.value) + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + if (subItem.type === 1) { + firstType.push(subItem.value) + } + }) + } + } + }) + } + + + const serverpartList: any = [] + if (haveList && haveList.length > 0) { + if (firstType && firstType.length > 0) { + haveList.forEach((item: any) => { + if (firstType.indexOf(Number(item)) === -1) { + serverpartList.push(Number(item)) + } + }) + } + } + + + + const serverpartShopList = initDetail.ServerpartShopList ? initDetail.ServerpartShopList.map(Number) : [] // 商户账号有门店 + const systemRoleList = initDetail.SystemRoleList ? initDetail.SystemRoleList.map(Number) : [] + initDetail.USERTYPE_ID = initDetail.USERTYPE_ID || '' + setCheckedRole(initDetail.SystemRoleList) + setCheckedServerpart(serverpartList) + console.log('serverpartShopListserverpartShopListserverpartShopListserverpartShopList', serverpartShopList); + + setCheckedShop(serverpartShopList) + if (tableTab === '1000') { + getServiceList(initDetail.USER_PROVINCE, initDetail.PushList && initDetail.PushList.length > 0 && initDetail.PushList[0] ? initDetail.PushList[0].type : null) + } + const res = JSON.parse(JSON.stringify(initDetail)) + setSelectDetail(initDetail.USER_PROVINCE) + + console.log('initDetail', initDetail); + + + if (initDetail.PushList && initDetail.PushList.length > 0) { + if (initDetail.PushList[0].key) { + const keyList: any = [] + const list = initDetail.PushList[0].key.split(',') + list.forEach((item: any) => { + keyList.push(item) + }) + res.ServerpartIds = keyList + } + console.log('res', res); + + // res.ServerpartIds = initDetail.PushList[0].key?Number(initDetail.PushList[0].key):null + res.UserTypeIds = initDetail.PushList[0].type + setShowServiceList(initDetail.PushList[0].type) + setInitialDetail(res) + } else { + setInitialDetail(res) + } + setCompanyList(initDetail.PushList) + // setShowServiceList(initDetail.PushList[0].type) + setShowWeChatFlag(initDetail.PushPermission) + + + // 请求获取该账户绑定的角色拥有的模块权限 + if (initDetail.SystemRoleList.length > 0) { + getRoleMenu(initDetail.SystemRoleList.toString()) + } + setCopyData(res) + return { ...initDetail, ServerpartIds: res?.ServerpartIds || [], ServerpartList: serverpartList, SystemRoleList: systemRoleList, ServerpartShopList: serverpartShopList } + } + + handleGetMerchantTree() + + + // , USER_PATTERN: currentUser?.UserPattern + setInitialDetail({ USER_STATUS: 1, USER_REPEATLOGON: 1, SUPER_ADMIN: 0 }) + // , USER_PATTERN: currentUser?.UserPattern + setCopyData(JSON.parse(JSON.stringify({ USER_STATUS: 1, USER_REPEATLOGON: 1, SUPER_ADMIN: 0 }))) + // , USER_PATTERN: currentUser?.UserPattern + + if (pageType === 'merchantManagement') { + console.log('BUSINESSMAN_ID', BUSINESSMAN_ID); + + detailForm.current?.setFieldsValue({ USERTYPE_ID: '' }) + setInitialDetail({ ...initialDetail, BUSINESSMAN_NAME: BUSINESSMAN_ID?.label, BUSINESSMAN_ID: Number(BUSINESSMAN_ID?.value) }) + console.log('{ ...initialDetail, BUSINESSMAN_NAME: BUSINESSMAN_ID?.label }', { ...initialDetail, BUSINESSMAN_NAME: BUSINESSMAN_ID?.label || '' }); + setCheckedServerpart([]) // 清空选择的服务区/门店 + getShopTree(BUSINESSMAN_ID?.value) + } + + + return { USER_STATUS: 1, USER_REPEATLOGON: 1, SUPER_ADMIN: 0 } + }} + onFinish={async (value) => { + let newValue: any = { ...value } + + if (initialDetail) { // 编辑数据 + newValue = { ...initialDetail, ...value } + } + console.log('newValue1', newValue); + console.log('checkedServerpart', checkedServerpart); + + newValue.USER_STATUS = newValue.USER_STATUS ? 1 : 0 + newValue.USER_REPEATLOGON = newValue.USER_REPEATLOGON ? 1 : 0 + newValue.SUPER_ADMIN = newValue.SUPER_ADMIN ? 1 : 0 + newValue.USER_CITYAUTHORITY = checkedServerpart ? checkedServerpart.join(" ") : '' + newValue.ServerpartList = checkedServerpart && checkedServerpart.length > 0 ? checkedServerpart : [] + newValue.ServerpartShopList = checkedShop || [] + newValue.SystemRoleList = checkedRole && checkedRole.length > 0 ? checkedRole : [] + newValue.OperateUser = currentUser?.Name + newValue.ServerpartIds = newValue.ServerpartIds && newValue.ServerpartIds.length > 0 ? newValue.ServerpartIds.toString() : '' + + + // 拿到新修改的数据 + const newData = detailForm.current?.getFieldsValue() + // 比较开始数据 如果和开始数据不一样 就调用接口 + // 调用接口传入的是当前新的值 + if (newData.AnalysisPermission !== copyData.AnalysisPermission) { + handleAnalysisPermission({ + userId: copyData.USER_ID, + AuthorType: (selectDetail === 340000 && tableTab === '1000' || + selectDetail === 340000 && copyData?.AnalysisPermission === true && tableTab === '1000' || + selectDetail === 340000 && copyData?.AnalysisPermission === false && tableTab === '1000') && newData.AnalysisPermission, + OperateUser: currentUser?.Name + }) + } + + + + const success = await handleAddUpdate(newValue, false); + console.log('tableTab', tableTab); + + console.log('newData', newData); + console.log('copyData', copyData); + + + + if (success) { + // 比较开始数据 如果和开始数据不一样 就调用接口 + // 调用接口传入的是当前新的值 + // 因为如果没权限的时候要把错误提示弹出来显示 所以要做判断 + // 一个是没有微信授权 一个有微信授权的情况下 + // 微信没有授权的时候 就不会调用更新数据的接口 只会报未绑定 + // 微信有授权的时候就掉更新数据的接口 + if (newData.PushPermission !== copyData.PushPermission || + newData.UserTypeIds !== copyData.UserTypeIds || + newData.ServerpartIds !== copyData.ServerpartIds) { + let serverpartId = '' + if (newData.ServerpartIds && newData.ServerpartIds.length > 0) { + newData.ServerpartIds.forEach((item: any) => { + if (serverpartId === '') { + serverpartId = item.split('-')[1].toString() + } else { + serverpartId += `,${item.split('-')[1].toString()}` + } + }) + } + let req = {} + if (tableTab === '1000' || tableTab === '4000') { + req = { + userId: openType === 'add' ? success : copyData.USER_ID, + AuthorType: newData.PushPermission || false, + OperateUser: currentUser?.Name, + GroupType: newData.UserTypeIds || null, + ServerpartIds: serverpartId + } + } else if (tableTab === '2000') { + req = { + userId: openType === 'add' ? success : copyData.USER_ID, + AuthorType: newData.PushPermission || false, + OperateUser: currentUser?.Name, + } + } + getWeiChatPush(req).then(async res => { + if (res.Result_Code === 200) { + message.error(res.Result_Desc) + } else { + message.success(newValue.USER_ID ? "更新成功!" : "新建成功!") + } + }) + } else { + message.success(newValue.USER_ID ? "更新成功!" : "新建成功!") + } + } + + handleGetSynchroBEHAVIORRECORD(1001) + reloadTable(success) + }} + submitter={{ + render: (_, dom) => ( + + { + initialDetail?.USER_ID ? + { + handleDeleteUser() + }}> + + : '' + } + + {detail?.USER_ID && + + } + {dom[0]} + + + ), + }} + > + + + {currentUser?.UserPattern === 9000 || currentUser?.UserPattern === 1000 ? + + { + if (value === 1000) { + setSelectDetail(null) + } + detailForm.current?.setFieldsValue({ USERTYPE_ID: '', USER_PROVINCE: '', ServerpartList: [], PROVINCE_UNIT: '' }) + setInitialDetail({ ...initialDetail, USER_PATTERN: Number(value), PROVINCE_UNIT: '' }) + setCheckedServerpart([]) // 清空选择的服务区/门店 + handleRoleList(value) + } + }} + /> + : ''} + + + + + + + + + + + + + { + const options = await getOnwer() + return options; + }} + fieldProps={{ + showSearch: true, + placeholder: '请选择业主单位', + fieldNames: { + title: 'label', + // key: "value" + }, + onSelect: (_: any, options: any) => { + detailForm.current?.setFieldsValue({ ServerpartIds: [] }) + setSelectDetail(options.value) + getServiceList(options.value, showServiceList || null) + detailForm.current?.setFieldsValue({ USERTYPE_ID: '' }) + setInitialDetail({ ...initialDetail, PROVINCE_UNIT: options.label, }) + // if (initialDetail.USER_PATTERN === 4000){ + // const req = { + // ProvinceCode:currentUser?.ProvinceCode, + // // OwnerUnitId:e + // } + // const data = await handleSupplierList(req) + // setSupplierList(data.List) + // } + }, + onChange: async (e) => { + if (!e) { + setSelectDetail(undefined) + } + } + }} + + /> + + + + {/* {currentUser?.UserPattern === 9000 ||initialDetail.USER_PATTERN === 4000? + + { + const options = await getOnwer() + return options; + }} + fieldProps={{ + showSearch: true, + placeholder: '请选择业主单位', + fieldNames: { + title: 'label', + // key: "value" + }, + onSelect: (_: any, options: any) => { + detailForm.current?.setFieldsValue({ ServerpartIds: [] }) + setSelectDetail(options.value) + getServiceList(options.value, showServiceList || null) + detailForm.current?.setFieldsValue({ USERTYPE_ID: '' }) + setInitialDetail({ ...initialDetail, PROVINCE_UNIT: options.label, }) + // if (initialDetail.USER_PATTERN === 4000){ + // const req = { + // ProvinceCode:currentUser?.ProvinceCode, + // // OwnerUnitId:e + // } + // const data = await handleSupplierList(req) + // setSupplierList(data.List) + // } + }, + onChange: async (e) => { + if (!e) { + setSelectDetail(undefined) + } + } + }} + + /> + :'' + } */} + + + + { + console.log('params', params); + if (pageType === 'merchantManagement') { + const req: any = { + // ProvinceCode: currentUser?.ProvinceCode || '340000', + UserTypePattern: 2000 + } + const data = await getUserTypeTree(req) + console.log('data2', data) + if (data && data.length > 0) { + data.forEach((item: any) => { + item.disabled = true + }) + } + return data + } if (params.USER_PROVINCE || params.USER_PATTERN) { + const req: any = { + ProvinceCode: params.USER_PATTERN === 2000 ? params.BUSINESSMAN_ID : params.USER_PROVINCE, + UserTypePattern: tableTab === 9000 ? 1000 : tableTab + } + const data = await getUserTypeTree(req) + console.log('data2', data) + if (data && data.length > 0) { + data.forEach((item: any) => { + item.disabled = true + }) + } + return data + // return await getUserTypeTree({ ProvinceCode: params.USER_PATTERN === 1000 ? params.USER_PROVINCE : params.BUSINESSMAN_ID,UserTypePattern:tableTab==='4000'?tableTab:'' }) + } + return [] + }} + fieldProps={{ + fieldNames: { + key: "value", + title: 'label', + }, + treeDefaultExpandAll: true + }} + // addonAfter={} + /> + + + + + + + {(currentUser?.UserPattern === 9000 && initialDetail.USER_PATTERN === 2000) || pageType === 'merchantManagement' ? + + + + + + { + detailForm.current?.setFieldsValue({ USERTYPE_ID: '' }) + setInitialDetail({ ...initialDetail, BUSINESSMAN_NAME: options.label, }) + setCheckedServerpart([]) // 清空选择的服务区/门店 + getShopTree(value) + }} + placeholder="请选择所属商家,以便给商户授权门店" + allowClear + /> + + + + { + pageType === 'merchantManagement' ? + : '' + } + + + : initialDetail.USER_PATTERN === 4000 && selectDetail ? + + + { + + }} + placeholder="请选择所属供应商" + allowClear + /> + + : '' + } + + + + + {/* {currentUser?.UserPattern===9000 && + + + + + + } */} + + + + + + + + + + + + + + + { + selectDetail === 340000 && tableTab === '1000' || + selectDetail === 340000 && copyData?.AnalysisPermission === true && tableTab === '1000' || + selectDetail === 340000 && copyData?.AnalysisPermission === false && tableTab === '1000' + ? + + + + + : '' + } + { + tableTab === '2000' || tableTab === 2000 ? + + + { + setShowWeChatFlag(e) + }} + /> + + + : '' + } + + { + tableTab === '1000' ? + + + + { + setShowWeChatFlag(e) + }} + /> + + + {/* { */} + {/* { */} + {/* showFormdetail() */} + {/* }}> 111 */} + {/* } */} + { + showWeChatFlag && initialDetail?.USER_PATTERN !== 2000 ? + + + { + setShowServiceList(e.target.value) + setServiceList([]) + setSPRegionList([]) + detailForm.current?.setFieldsValue({ ServerpartIds: [] }) + getServiceList(selectDetail || null, e.target.value) + }} value={showServiceList}> + 业主本部 + 服务区 + 区域 + + + : '' + } + { + showWeChatFlag && showServiceList && showServiceList !== 1000 ? + + + { + }} + treeData={SPRegionList} + /> + + : '' + } + + : '' + } + + + + { + tableTab === '1000' || tableTab === '4000' || tableTab === '9000' ? + + {serverpartTree && + { + setCheckedServerpart([]) + detailForm.current?.setFieldsValue({ ServerpartList: [] }) + }}>取消选择}> + + { + + setCheckedServerpart(checkedKeys) + return checkedKeys + }} + > + + } + : '' + } + {/* {(currentUser?.UserPattern === 9000 ? initialDetail.USER_PATTERN === 1000 : currentUser?.UserPattern === 1000) && } */} + { + (initialDetail.USER_PATTERN === 2000 && initialDetail.BUSINESSMAN_NAME) || (pageType === 'merchantManagement' && BUSINESSMAN_ID?.label) ? + + { + shopTree && shopTree.length > 0 ? + < Card + style={{ borderColor: "#97D6FE", height: 424 }} + size="small" + title="门店权限" headStyle={{ backgroundColor: '#E7F7FF' }} + extra={ { + setCheckedServerpart([]) + setCheckedShop([]) + detailForm.current?.setFieldsValue({ ServerpartList: [], ServerpartShopList: [] }) + }}>取消选择}> + + { + + if (info.checkedNodes.length > 0) { + + const checkedPart = info.checkedNodes.reduce((accumulator, current) => { + accumulator[current.type].push(current.value) + return accumulator + }, { 1: [], 2: [] }) + setCheckedServerpart(checkedPart[1]) + setCheckedShop(checkedPart[2]) + // setInitialDetail({ ...initialDetail, ServerpartShopList: checkedPart[2] }) + } else { + setCheckedServerpart([]) + setCheckedShop([]) + // setInitialDetail({ ...initialDetail, ServerpartShopList: [] }) + } + return checkedKeys + }} + > + + : '' + } + + : '' + } + + {roleTree && { + setCheckedRole([]) + detailForm.current?.setFieldsValue({ SystemRoleList: [] }) + }}>取消选择}> + + { + setCheckedRole(checkedKeys) + if (checkedKeys.length > 0) { + getRoleMenu(checkedKeys.toString()) + } + return checkedKeys + }} + > + + + } + + {checkedRole && checkedRole.length > 0 && + + + + } + + + { + companyList && companyList.length > 0 ? + +
+ {/* 遍历公众号列表 展示item */} + { + companyList.map((item: any) => { + return
+ {/* {companyType[item.type]} */} + {`${item.label}公众号: ${companyType[item.type]}的每日营收汇总通知`} +
+ }) + } +
+
: '' + } +
+ + + + +
+ ) +} +export default Edit; diff --git a/src/pages/Setting/Users/index.tsx b/src/pages/Setting/Users/index.tsx new file mode 100644 index 0000000..61bf4c0 --- /dev/null +++ b/src/pages/Setting/Users/index.tsx @@ -0,0 +1,378 @@ +/* + * @Author: cclu + * @Date: 2021-12-13 11:01:23 + * @LastEditTime: 2024-08-30 18:54:12 + * @LastEditors: cclu 1106109051@qq.com + * @Description: 账号管理 + * @FilePath: \cloud-platform\src\pages\Setting\Users\index.tsx + */ +import { connect } from "umi"; +import React, { useState, useRef } from "react"; +import { Button, Drawer, Tree } from 'antd'; +import ProTable from "@ant-design/pro-table"; +import { PageContainer } from "@ant-design/pro-layout"; +import { PlusOutlined } from "@ant-design/icons"; + +import type { UserModel } from "./data"; +import type { ProColumns, ActionType } from '@ant-design/pro-table'; +import type { ProDescriptionsItemProps } from "@ant-design/pro-descriptions"; +import type { ConnectState } from "@/models/connect"; +import type { CurrentUser } from '@/models/user'; + +import Edit from './components/edit'; +import ProCard from "@ant-design/pro-card"; +import useRequest from "@ahooksjs/use-request"; +import ProDescriptions from "@ant-design/pro-descriptions"; + +import { getUserSystemRole, getUserList, getUserTypeTree } from './service' + +const UserList: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => { + const { currentUser } = props + const actionRef = useRef(); + const [showDetail, setShowDetail] = useState(false); + const [userTypeId, setUserTypeId] = useState>(); + const [tableTab, setTableTab] = useState(`${currentUser?.UserPattern}`); + const [openType, setOpenType] = useState()// 打开是编辑还是新增 + const [collapsible, setCollapsible] = useState(false) // 是否显示账号分类查询树 + const [currentRow, setCurrentRow] = useState(); // 当前选中行 + const [createModalVisible, handleModalVisible] = useState(false); // 分布更新窗口的弹窗 + const [userTypeObj, setUserTypeObj] = useState() + const selectTab = useRef(`${currentUser?.UserPattern}`) + const { loading: treeLoading, data: treeViews } = useRequest(async () => { + const req: any = { + ProvinceCode: currentUser?.UserPattern === 2000 ? currentUser?.BusinessManID : currentUser?.ProvinceCode, + } + const data = await getUserTypeTree(req) + let res: any = [] + if (data && data.length > 0) { + data.forEach((item: any) => { + res.push(item) + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + res.push(subItem) + if (subItem.children && subItem.children.length > 0) { + subItem.children.forEach((thirdItem: any) => { + res.push(thirdItem) + }) + } + }) + } + }) + } + console.log('res', res); + + let obj: any = {} + if (res && res.length > 0) { + res.forEach((item: any) => { + obj[item.value] = item.label + }) + } + console.log('obj', obj); + + setUserTypeObj(obj) + }) + // 请求账号部门tree + const { run: getUserTypeMenu, loading: typeLoading, data: userTypeTree } = useRequest((type) => getUserTypeTree({ UserTypePattern: type || tableTab, ShowStatus: true })) + // const [userTypeMenu, setUserTypeMenu] = useState<{1000: {}, 2000: {}}>(()=>getUserTypeTree(tableTab)); // 分布更新窗口的弹窗 + // 根据角色id查询权限树 + const { run: getRoleMenu, data: roleMenuTree } = useRequest(async (SystemRoleId?: number) => { + const data = await getUserSystemRole(SystemRoleId ? `${SystemRoleId}` : '') + return data + }, { manual: true }) + const leftTab = [{ key: `1000`, name: '业主' }, { key: `4000`, name: '供应商' }, { key: `2000`, name: '商户' }, { key: `3000`, name: '游客' }, { key: `9000`, name: '内部' }] + const ueserCloudTab = currentUser?.UserPattern === 9000 ? leftTab : currentUser?.UserPattern === 1000 ? [{ key: `1000`, name: '业主' }, { key: `4000`, name: '供应商' }] : leftTab.filter(n => n.key === `${currentUser?.UserPattern}`) + // const ueserCloudTab = leftTab + // 表格列数据显示配置 + const columns: ProColumns[] = [ + { + title: '查询账号', + dataIndex: 'searchKey', + hideInDescriptions: true, + hideInTable: true, + fieldProps: { + placeholder: '请输入账号/用户名称/业主单位/手机号/经营单位' + } + }, + { + title: '有效状态', + dataIndex: 'USER_STATUS', + hideInTable: true, + valueType: 'select', + valueEnum: { + "": "全部", + "1": "有效", + "0": "无效" + }, + initialValue: "1" + }, + { + title: '经营单位', + dataIndex: 'BUSINESSMAN_NAME', + sorter: (a, b) => { + return (a.BUSINESSMAN_NAME || '').localeCompare((b.BUSINESSMAN_NAME || '')) + }, + hideInSearch: true, + hideInTable: tableTab !== '2000', + hideInDescriptions: tableTab !== '2000', + }, + { + title: '账号部门', + dataIndex: 'USERTYPE_ID', + hideInTable: tableTab === '3000' || tableTab === '9000', + hideInSearch: true, + hideInDescriptions: true, + valueType: "treeSelect", + fieldProps: { + options: userTypeTree, + }, + }, + { + title: '账号', + dataIndex: 'USER_PASSPORT', + sorter: (a, b) => { + return (a.USER_PASSPORT || '').localeCompare((b.USER_PASSPORT || '')) + }, + hideInSearch: true, + }, + { + title: '用户名称', + dataIndex: 'USER_NAME', + sorter: (a, b) => { + return (a.USER_NAME || '').localeCompare((b.USER_NAME || '')) + }, + hideInDescriptions: true, + hideInSearch: true, + render: (_, record) => { + + return { + getRoleMenu(record.USER_ID) + setCurrentRow(record) + setShowDetail(true) + }}>{_} + } + }, + { + title: '手机号', + dataIndex: 'USER_MOBILEPHONE', + hideInSearch: true + }, + // { + // title: '账号类型', + // dataIndex: 'USER_PATTERN', + // hideInSearch: true, + // valueType: 'select', + // valueEnum: { + + // 1000: { text: '业主' }, + // 2000: { text: '商户' }, + // }, + // }, + { + title: '状态', + dataIndex: 'USER_STATUS', + hideInSearch: true, + filters: true, + onFilter: true, + valueType: 'select', + initialValue: 1, + valueEnum: { + all: { text: '全部', status: 'Default' }, + 0: { text: '无效', status: 'Default' }, + 1: { text: '有效', status: 'Processing' }, + }, + + }, + { + title: '业主单位', + dataIndex: 'PROVINCE_UNIT', + hideInSearch: true, + sorter: (a, b) => { + return (a.PROVINCE_UNIT || '').localeCompare((b.PROVINCE_UNIT || '')) + }, + hideInTable: tableTab === '2000', + valueType: "treeSelect", + fieldProps: { + options: userTypeTree, + }, + }, + { + title: '备注', + dataIndex: 'USER_DESC', + hideInSearch: true, + hideInTable: tableTab === '2000', + render: (_, record) => { + return record?.USER_DESC + } + }, + { + title: '操作', + valueType: 'option', + hideInDescriptions: true, + // width: 180, + render: (text, record) => [ + { + handleModalVisible(true); + setOpenType('edit') + setCurrentRow({ ...record }); + }} + > + 编辑 + , + ] + } + ] + return ( + + {/* 左侧树筛选 */} + { setCollapsible(!collapsible) }} />} + colSpan={!collapsible ? "360px" : "60px"} + // title={!collapsible ? "请选择账号部门" : ""} + // headerBordered + // collapsed={collapsible} + tabs={{ + activeKey: tableTab, + onChange: (key) => { + console.log('key', key) + setTableTab(key as string); + selectTab.current = key + getUserTypeMenu(key) + }, + }} + > + {ueserCloudTab.map(n => { + return + { + setUserTypeId({ [n.key]: checkedKeys }) + if (actionRef.current) { + // actionRef.current?.reset() + actionRef.current?.reload() + } + }} + > + + + })} + + {/* 右侧表格主体 */} + + + headerTitle="账号管理" + rowKey="USER_ID" + actionRef={actionRef} + request={async (params, sorter) => { + console.log('params', params); + + const sortstr = Object.keys(sorter).map(n => { + const value = sorter[n] + return value ? `${n} ${value.replace('end', '')}` : '' + }) + const data = await getUserList({ + ...params, + USER_STATUS: params?.USER_STATUS, + USER_PATTERN: tableTab, + UserTypeIds: userTypeId && userTypeId[tableTab] ? userTypeId[tableTab].toString() : '', + SortStr: sortstr ? sortstr.toString() : 'USER_INDEX', + keyWord: params.searchKey ? { key: "USER_PASSPORT,USER_NAME,USER_MOBILEPHONE,PROVINCE_UNIT,BUSINESSMAN_NAME", value: params.searchKey } : null, // 关键词查询 + }) + return data + }} + onReset={() => { + actionRef.current?.reload() + }} + params={{ USER_PATTERN: tableTab }} + columns={columns} + toolbar={{ + actions: + currentUser?.UserPattern === 1000 || currentUser?.UserPattern === 9000 ? + [ + , + ] : [] + }} + pagination={{ defaultPageSize: 10 }} + + /> + + + {/* 用户详情 */} + { + setCurrentRow(undefined); + setShowDetail(false); + handleModalVisible(false) + setOpenType('') + }} + closable={false} + bodyStyle={createModalVisible ? { backgroundColor: "#f9f9f9", padding: 0 } : {}} + > + {/* 编辑或新增账号 */} + {createModalVisible && { + if (success) { + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} />} + {/* 查看账号详情 */} + {showDetail && + column={1} + title={currentRow?.USER_NAME} + request={async () => ({ + data: currentRow || {}, + })} + params={{ + id: currentRow?.USER_NAME, + }} + columns={columns as ProDescriptionsItemProps[]} + > + + {roleMenuTree?.length ? + : '-'} + + + } + + + ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser, +}))(UserList); + diff --git a/src/pages/basicManage/Merchats/components/BrandTable.tsx b/src/pages/basicManage/Merchats/components/BrandTable.tsx new file mode 100644 index 0000000..d49b8c0 --- /dev/null +++ b/src/pages/basicManage/Merchats/components/BrandTable.tsx @@ -0,0 +1,390 @@ +/* + * @Author: your name + * @Date: 2022-04-28 10:47:35 + * @LastEditTime: 2024-08-23 15:25:03 + * @LastEditors: cclu 1106109051@qq.com + * @Description: 经营商户相关联系人管理组件 未对接接口 + * @FilePath: \cloud-platform\src\pages\basicManage\Merchats\components\LinkManTable.tsx + */ +import useRequest from '@ahooksjs/use-request'; +import React, { useImperativeHandle, useRef, useState } from 'react'; +import ProTable, { EditableProTable } from '@ant-design/pro-table'; + +import type { ActionType, ProColumns } from "@ant-design/pro-table"; +import type { LinkManModel } from "../data"; +import { getBrandList, getTreeList, handleDeleteRTCoopMerchants, handleRTCoopMerchantsList, handleSynchroRTCoopMerchants } from '../service'; +import { FormInstance, message } from "antd"; +import { Avatar, Button, Col, Menu, Modal, Popconfirm, Row, Image } from "antd"; +import { getBusniessBrandTree } from "@/pages/basicManage/service"; +import { getFieldEnumTree } from "@/services/options"; +import { getList } from "@/pages/Test/INTERFACE/service"; +import { FileSearchOutlined, PlusOutlined } from "@ant-design/icons"; +import { MerchantModel } from "../data"; +import { ModalForm, ProFormText } from "@ant-design/pro-form"; +import SubMenu from 'antd/lib/menu/SubMenu'; +import Item from 'antd/lib/list/Item'; +import moment from 'moment/moment' + +const BrandTable = ({ merchartsId, onRef, currentRow }: { merchartsId: number, onRef?: any, currentRow?: any }) => { + const formRef = useRef(); + const addFormRef = useRef(); + const actionRef = useRef(); + const brandActionRef = useRef(); + + const { loading, data } = useRequest(async () => { + if (merchartsId) { + const data = await getBrandList({ CoopMerchantsId: merchartsId }) + return data + } + return [] + }) + const { loadingBrand, data: busiessBrand = [] } = useRequest(getBusniessBrandTree) + const [modalVisible, setModalVisible] = useState(false) + const [brandVisible, setBrandVisible] = useState() // 选择品牌弹出框 + const [brand, setBrand] = useState() // 选中的品牌 + const [currenMenu, setCurrenMenu] = useState(); // 当前弹出的左侧菜单选中的详细数据 + const [selectedKeys, setSelectedKeys] = useState(); // 当前弹出的左侧菜单选中的ids值 + + const [dataSource, setDataSource] = useState() + const [editableKeys, setEditableRowKeys] = useState([]); + if (!loading && !dataSource) { + setDataSource(data) + } + + // 根据选中的经营业态查询品牌 + const searchBrand = (item: any) => { + setSelectedKeys(item.selectedKeys || []) + const [_, value] = item.key.split('-') + setCurrenMenu({ 'BRAND_INDUSTRY': value, current: 1 }) + brandActionRef.current?.reload() + } + + // 生成商户左侧菜单 + const getMenuDom = (data: any[], callback: () => void, noBrand?: boolean) => { + return (data.map((element: any) => { + if ((!noBrand && element.BrandTreeList && element.BrandTreeList.length > 0) || element.children) { + return ( + } + key={`BUSINESSTRADE_ID-${element.BusinessTrade_Id}`} + onTitleClick={(item) => { + if (!currenMenu || item.key !== `BUSINESSTRADE_ID-${currenMenu?.BUSINESSTRADE_ID}`) { + callback.call(callback, item) + } + item.domEvent.stopPropagation(); + }} + > + {!noBrand && element.BrandTreeList.length > 0 && element.BrandTreeList.map((c: any) => + } > + {c.Brand_Name} + + )} + {element.children && element.children.length > 0 && getMenuDom(element.children, callback, noBrand || undefined)} + + ) + } + return (} + key={`BUSINESSTRADE_ID-${element.BusinessTrade_Id}`}>{element.BusinessTrade_Name}) + })) + } + + // 拿到这一次选中的品牌 + const [currentBrand, setCurrentBrand] = useState() + + + const columns: ProColumns[] = [ + { + title: '品牌图标', + dataIndex: 'LINKER_NAME', + render: (_, record) => { + return + } + }, + { + title: '经营业态', + dataIndex: 'BUSINESSTRADE_NAME', + }, + + { + title: '经营品牌', + dataIndex: 'BRAND_NAME', + }, + { + title: '操作', + valueType: 'option', + width: 160, + render: (text, record, _, action) => [ + { + console.log('delete', record); + + handleDelete(record) + }} + > + 删除 + + ], + } + ] + + // 删除 + const handleDelete = async (obj: any) => { + const req: any = { + RTCoopMerchantsId: obj?.RTCOOPMERCHANTS_ID + } + const data = await handleDeleteRTCoopMerchants(req) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + } + + useImperativeHandle(onRef, () => ({ + dataSource + })); + + return ( + <> + { + return `${record?.INTERFACE_ID}` + }} + formRef={formRef} + headerTitle="品牌列表" // 列表表头 + actionRef={actionRef} + search={false} + request={async () => { + if (!merchartsId) { + return [] + } + const req: any = { + CoopMerchantsId: merchartsId + } + const data = await handleRTCoopMerchantsList(req) + console.log('currentBrand', currentBrand); + console.log('data', data); + + if (data && data.length > 0) { + setDataSource(data) + return { data, success: true } + } else { + setDataSource([]) + return { data: [], success: true } + } + }} + // dataSource={dataSource} + columns={columns} + toolbar={{ + actions: [ + // 新增按钮 + , + ], + }} + options={false} + pagination={false} + /> + { + setModalVisible(false) + setCurrentBrand(undefined) + }, + }} + onVisibleChange={(value) => { + + }} + onFinish={async (values) => { + // // 判断有没有品牌数据 + // let dataList: any = brandTableRef.current?.dataSource + // let resList: any = [] + // if(dataList && dataList.length>0){ + // dataList.forEach((item: any)=>{ + // resList.push({ + // label: item.BRAND_NAME, + // value: item.BRAND_ID, + // key: '', + // type:'', + // desc:'', + // ico: item.BRAND_INTRO + // }) + // }) + // } + console.log('CurrentBrand', currentBrand); + console.log('currentRow', currentRow); + + + + // 同步商户和品牌的关系列表 + const secondReq: any = { + COOPMERCHANTS_ID: currentRow?.COOPMERCHANTS_ID, + BUSINESS_TRADE: currentBrand?.BUSINESS_TRADE, + BUSINESS_BRAND: currentBrand?.BUSINESS_BRAND, + OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss') + // RTCOOPMERCHANTS_ID: '', + // COOPMERCHANTS_NAME: currentRow?.COOPMERCHANTS_NAME, + // BUSINESSTRADE_NAME: currentBrand?.BUSINESSTRADE_NAME, + // BRAND_NAME: currentBrand?.BRAND_NAME, + // SERVERPART_NAME:'', + // BRAND_ICO: currentBrand?.BRAND_INTRO, + } + const secondData = await handleSynchroRTCoopMerchants(secondReq) + if (secondData.Result_Code === 100) { + message.success(secondData.Result_Desc) + addFormRef.current?.setFieldsValue({ BRAND_NAME: '' }) + setCurrentBrand(undefined) + setModalVisible(false) + actionRef.current?.reload() + } else { + message.error(secondData.Result_Desc) + } + }} + > + } onClick={() => { + setBrandVisible(true) + }}>} + // rules={[ + // { + // required: true, + // message: '请选择经营品牌', + // }, + // ]} + readonly + /> + + + {/* 新增的弹出框 */} + { + setBrandVisible(false) + const data = { + ...brand, + BUSINESS_BRAND: brand?.BRAND_ID, + BRAND_NAME: brand?.BRAND_NAME, + } + setCurrentBrand(data) + addFormRef.current?.setFieldsValue(data) + }} + onCancel={() => { + setBrandVisible(false) + setBrand(undefined) + }} + afterClose={() => { + setCurrenMenu({}) + brandActionRef.current?.reset() + }} + bodyStyle={{ padding: 0 }} + > + + + { + { + searchBrand(item) + }} + >{getMenuDom(busiessBrand, searchBrand, true)} + + } + + + { + return {record.BRAND_NAME.substring(0, 1)} + }, + hideInDescriptions: true, + }, + { + dataIndex: 'BRAND_NAME', + title: '品牌名称', + hideInSearch: true + }, + + { + dataIndex: 'keyWord', + title: '品牌名称', + hideInTable: true + // hideInSearch: true + }, + + ]} + + request={async (params) => { + + if (brandVisible) { + const data = await getTreeList({ + ...params, + keyWord: params.keyWord ? { value: params.keyWord, key: 'BRAND_NAME' } : null + }) + return data + } + return { data: [], success: true } + }} + params={currenMenu} + search={{ span: 12, }} + pagination={{ defaultPageSize: 10, size: 'small', showSizeChanger: false }} + onReset={() => { + setCurrenMenu({}) + brandActionRef.current?.reload() + }} + options={false} + style={{ minHeight: 610 }} + actionRef={brandActionRef} + rowSelection={{ + + type: "radio", + onChange: (selectedRowKeys, selectedRows) => { + console.log('selectedRows', selectedRows); + setBrand(selectedRows[0]) + } + + }} + tableAlertRender={false} + > + + + + + + + + + ) +} + +export default BrandTable; diff --git a/src/pages/basicManage/Merchats/components/LinkManTable.tsx b/src/pages/basicManage/Merchats/components/LinkManTable.tsx new file mode 100644 index 0000000..176516a --- /dev/null +++ b/src/pages/basicManage/Merchats/components/LinkManTable.tsx @@ -0,0 +1,155 @@ +/* + * @Author: your name + * @Date: 2022-04-28 10:47:35 + * @LastEditTime: 2024-09-12 16:48:40 + * @LastEditors: cclu 1106109051@qq.com + * @Description: 经营商户相关联系人管理组件 未对接接口 + * @FilePath: \cloud-platform\src\pages\basicManage\Merchats\components\LinkManTable.tsx + */ +import useRequest from '@ahooksjs/use-request'; +import { Popconfirm } from 'antd'; +import { useEffect, useRef, useState } from 'react'; +import { EditableProTable } from '@ant-design/pro-table'; + +import type { ActionType, ProColumns } from "@ant-design/pro-table"; +import type { LinkManModel } from "../data"; +import { getLinkManList, updateLinkMan, delLinkMan } from '../service'; +import { getBusniessBrandTree } from "@/pages/basicManage/service"; + +const LinkManTable = ({ merchartsId, show }: { merchartsId: number, show: boolean }) => { + const actionRef = useRef(); + // const { loading, data } = useRequest(async () => { + // console.log('merchartsId', merchartsId); + + // if (merchartsId) { + // const data = await getLinkManList(merchartsId) + // console.log('datadasdasdasdas', data); + + // return data + // } + // return [] + // }) + // 请求经营品牌树 + + const [dataSource, setDataSource] = useState() + const [editableKeys, setEditableRowKeys] = useState([]); + // if (!loading && !dataSource) { + // setDataSource(data) + // } + const columns: ProColumns[] = [ + { + title: '联系人', + dataIndex: 'LINKER_NAME', + formItemProps: (form, { rowIndex }) => { + return { + rules: rowIndex > 2 ? [{ required: true, message: '此项为必填项' }] : [], + }; + }, + }, + { + title: '联系方式', + dataIndex: 'LINKER_MOBILEPHONE' + }, + + { + title: '状态', + dataIndex: 'LINKER_STATE', + + valueType: 'select', + // width:120, + valueEnum: { 1: { text: '有效', status: 'sucess' }, 0: { text: '无效', status: 'error' } } + }, + { + title: '操作', + valueType: 'option', + width: 160, + render: (text, record, _, action) => [ + { + action?.startEditable?.(record.COOPMERCHANTS_LINKER_ID); + }} + > + 编辑 + , + // { + // const sucesse = await delLinkMan(record.COOPMERCHANTS_LINKER_ID); + // if (sucesse && actionRef.current) { + // actionRef.current.reload(); + // } + // }} + // > + // 删除 + // + // { + // if (record.COOPMERCHANTS_LINKER_ID) { + // delLinkMan(record.COOPMERCHANTS_LINKER_ID); + // } + // }} + // > + // 移除 + // + ], + } + ] + + + // 拿到表格数据的方法 + const handleGetTableData = async () => { + const data = await getLinkManList(merchartsId) + setDataSource(data) + console.log('datadasdasdasdas', data); + } + + useEffect(async () => { + console.log('merchartsId', merchartsId); + if (merchartsId) { + handleGetTableData() + } + }, []) + + + + + return ( + + rowKey="COOPMERCHANTS_LINKER_ID" + columns={columns} + recordCreatorProps={{ + // newRecordType: "dataSource", + record: () => ({ + COOPMERCHANTS_LINKER_ID: new Date().getTime(), + LINKER_STATE: "1" + }), + + }} + // request={async () => dataSource} + value={dataSource} + onChange={setDataSource} + editable={{ + type: 'multiple', + editableKeys, + onSave: async (rowKey, data, row) => { + data.COOPMERCHANTS_ID = merchartsId; + await updateLinkMan(data) + await handleGetTableData() + }, + onDelete: async (key, row) => { + console.log('row', row); + delLinkMan(row.COOPMERCHANTS_LINKER_ID) + }, + onValuesChange: (record, recordList) => { + setDataSource(recordList); + }, + onChange: setEditableRowKeys, + }} + > + + ) +} + +export default LinkManTable; diff --git a/src/pages/basicManage/Merchats/components/addEdit.tsx b/src/pages/basicManage/Merchats/components/addEdit.tsx new file mode 100644 index 0000000..910e64a --- /dev/null +++ b/src/pages/basicManage/Merchats/components/addEdit.tsx @@ -0,0 +1,266 @@ +import { connect } from "umi"; +import type { ConnectState } from "@/models/connect"; +import { FormInstance, ModalForm, ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-form"; +import { MerchantModel } from "../data"; +import { useRef, useState } from "react"; +import { Col, Form, message, Row, Switch } from "antd"; +import { updateMerchants } from "../service"; +import { getFieldEnum } from "@/services/options"; +import LinkManTable from "./LinkManTable"; +import BrandTable from "./BrandTable"; +import Draggable from "react-draggable"; +import React from "react"; + + +// 更新信息 +const handleAddUpdate = async (fields: MerchantModel) => { + const hide = message.loading('正在提交...'); + + const result = await updateMerchants(fields); + hide(); + if (result.Result_Code !== 100) { + message.error(`${result.Result_Desc}` || `${result.Result_Code}:提交失败`); + return false; + } + message.success(fields.COOPMERCHANTS_ID ? '更新成功!' : '新建成功!'); + return true; +}; +type DetailProps = { + currentRow: any; + modalVisible: any; + handleModalVisible: any; + setCurrentRow: any + actionRef: any + disabled: any + setDraggleDisabled: any + bounds: any + onDraggaleStart: any + draggleRef: any +} +const AddEdit = ({ currentRow, modalVisible, handleModalVisible, setCurrentRow, actionRef, disabled, setDraggleDisabled, onDraggaleStart, bounds, draggleRef }: DetailProps) => { + const formRef = useRef(); + const brandTableRef = useRef() + + + + return ( +
+ {/* 编辑信息 */} + + title={ +
{ + if (disabled) { + setDraggleDisabled(false) + } + }} + onMouseOut={() => { + setDraggleDisabled(true) + }} + onFocus={() => { }} + onBlur={() => { }} + > + {currentRow ? '更新商户信息' : '新建商户'} +
+ } + modalProps={{ + modalRender: (modal) => { + return onDraggaleStart(event, uiData)} + > +
{modal}
+
+ }, + destroyOnClose: true, + onCancel: () => { + setCurrentRow(undefined); + handleModalVisible(false) + } + }} + layout={'horizontal'} + width={1024} + wrapperCol={{ span: 16 }} + labelCol={{ span: 6 }} + formRef={formRef} + visible={modalVisible} + autoFocusFirstInput + request={() => { + if (currentRow) { + return { ...currentRow, COOPMERCHANTS_STATE: currentRow.COOPMERCHANTS_STATE ? 1 : 0 } + } else { + return { COOPMERCHANTS_STATE: 1 } + } + }} + // onVisibleChange={(value) => { + // console.log('ModalForm', value); + + // handleModalVisible(value); + // if (value) { + // formRef.current?.setFieldsValue( + // currentRow ? { ...currentRow, COOPMERCHANTS_STATE: currentRow.COOPMERCHANTS_STATE ? 1 : 0 } : { COOPMERCHANTS_STATE: 1 }, + // ); + // console.log('currentRow', currentRow ? { ...currentRow, COOPMERCHANTS_STATE: currentRow.COOPMERCHANTS_STATE ? 1 : 0 } : { COOPMERCHANTS_STATE: 1 }); + + // } else { + // formRef.current?.resetFields(); + // setCurrentRow(undefined); + // } + // }} + + onFinish={async (values) => { + let newValue: MerchantModel = { ...values }; + if (currentRow) { + // 编辑数据 + newValue = { ...values, COOPMERCHANTS_ID: currentRow.COOPMERCHANTS_ID }; + } + newValue.COOPMERCHANTS_STATE = values.COOPMERCHANTS_STATE ? 1 : 0 + console.log('newValue', newValue); + const success = await handleAddUpdate(newValue as MerchantModel); + + if (success) { + if (actionRef.current) { + actionRef.current.reload(); + } + handleModalVisible(false); + } + + return false; + }} + > +
+ + + + + + + { + const options = await getFieldEnum({ FieldExplainField: 'MERCHANTS_TYPE' }); + return options + }} + /> + + + + + + + + {/* 当前依赖包动画过渡有问题 临时采用 Form.Item 方式进行Switch交互 */} + + + + + + + + + + + {/* 联系人列表 */} + { + modalVisible ? + : '' + } + + {/* 品牌列表编辑新增 */} + { + modalVisible ? + : '' + } +
+ +
+ ) +} + +export default connect(({ user, }: ConnectState) => ({ + currentUser: user.currentUser, +}))(AddEdit); diff --git a/src/pages/basicManage/Merchats/data.d.ts b/src/pages/basicManage/Merchats/data.d.ts new file mode 100644 index 0000000..6b3c2c4 --- /dev/null +++ b/src/pages/basicManage/Merchats/data.d.ts @@ -0,0 +1,68 @@ +export type MerchantModel = { + COOPMERCHANTS_ID: number // 商户内码 , + COOPMERCHANTS_PID: number // 父级内码 , + OWNERUNIT_ID: number // 业主内码 , + OWNERUNIT_NAME: string // 业主单位 , + PROVINCE_CODE: number // 省份标识 , + COOPMERCHANTS_NATURE: number // 商户性质 , + COOPMERCHANTS_TYPE: string // 商户类型 , + COOPMERCHANTS_CODE: string // 商户编码 , + COOPMERCHANTS_NAME: string // 商户名称 , + COOPMERCHANTS_EN: string // 商户简称 , + TAXPAYER_IDENTIFYCODE: string // 统一信用代码 , + COOPMERCHANTS_DRAWER: string // 开票人 , + BANK_NAME: string // 开户银行 , + BANK_ACCOUNT: string // 银行账号 , + COOPMERCHANTS_LINKMAN: string // 法人员 , + LINKER_NAME: string // 联系人员 , + LINKER_MOBILEPHONE: string // 手机号码 , + COOPMERCHANTS_TELEPHONE: string // 联系电话 , + COOPMERCHANTS_MOBILEPHONE: string // 手机号码 , + COOPMERCHANTS_ADDRESS: string // 联系地址 , + COOPMERCHANTS_STATE: number // 商户状态 , + STAFF_ID: number // 操作人内码 , + STAFF_NAME: string // 操作人员 , + OPERATE_DATE: string // 操作时间 , + COOPMERCHANTS_DESC: string // 备注 , + MERCHANTTYPE_ID: number // 自定义类别内码 , + MERCHANTTYPE_NAME: string // 自定类别名 , + COOPMERCHANTS_BRAND: string // 商户品牌 + BrandList?: any +}; + +export type MerchantTypeModel = { + AUTOTYPE_ID: number; // 内码; + AUTOTYPE_NAME: string; // 项目名称; + AUTOTYPE_CODE: string; // 科目代码; + AUTOTYPE_PID: number; // 上级类别; + AUTOTYPE_INDEX: number; // 显示顺序; + AUTOTYPE_LEVEL: number; // 项目级别; + DATASOURCE_TYPE: number; // 所属类别; + SERVERPART_ID: number; // 服务区内码; + SERVERPARTSHOP_ID: number; // 门店内码; + AUTOTYPE_STAFFID: number; // 人员内码; + AUTOTYPE_STAFF: string; // 配置人员; + AUTOTYPE_DATE: string; // 配置时间; + AUTOTYPE_VALID: number; // 有效状态; + AUTOTYPE_TYPEID: number; // 类别类型; + AUTOTYPE_TYPENAME: string; // 类型名称; + FINANCE_DEPARTMENT: string; // 审核部门; + AUTOTYPE_DESC: string; // 备注; +}; + +export type LinkManModel = { + COOPMERCHANTS_LINKER_ID: number;// 内码 , + COOPMERCHANTS_ID?: number;// 商户内码 , + BANK_NAME?: string;// 开户银行 , + BANK_ACCOUNT?: string;// 银行账号 , + COOPMERCHANTS_DRAWER?: string;// 开票人 , + LINKER_NAME?: string;// 联系人 , + LINKER_TELEPHONE?: string;// 联系电话 , + LINKER_MOBILEPHONE?: string;// 手机号码 , + LINKER_ADDRESS?: string;// 联系人地址 , + LINKER_STATE: string?;// 联系人状态(0无效,1有效) , + STAFF_ID?: number;// 操作人内码 , + STAFF_NAME?: string;// 操作人名称 , + OPERATE_DATE?: string;// 操作时间 , + COOPMERCHANTS_LINKER_DESC?: string;// 备注说明 +} diff --git a/src/pages/basicManage/Merchats/index.tsx b/src/pages/basicManage/Merchats/index.tsx new file mode 100644 index 0000000..22374de --- /dev/null +++ b/src/pages/basicManage/Merchats/index.tsx @@ -0,0 +1,506 @@ +/* + * @Author: cclu + * @Date: 2022-04-28 10:47:35 + * @LastEditTime: 2024-12-16 12:04:59 + * @LastEditors: cclu 1106109051@qq.com + * @Description: 经营商户信息管理 + * @FilePath: \cloud-platform\src\pages\basicManage\Merchats\index.tsx + */ + +import { getFieldEnum } from '@/services/options'; +import { PlusOutlined } from '@ant-design/icons'; +import ProDescriptions from '@ant-design/pro-descriptions'; +import { ModalForm, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; +import { PageContainer } from '@ant-design/pro-layout'; +import ProTable from '@ant-design/pro-table'; +import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; +import type { ActionType, ProColumns } from '@ant-design/pro-table'; +import type { FormInstance } from 'antd'; + +import { Button, Col, Drawer, message, Row, Switch, Form } from 'antd'; +import { useImperativeHandle, useRef, useState } from 'react'; + +import LinkManTable from './components/LinkManTable'; +import BrandTable from './components/BrandTable'; +import type { MerchantModel } from './data'; +import { getList, updateMerchants, getShopDetail, getLinkManList } from './service'; + +import './style.less' +import closeIcon from "@/assets/brand/closeIcon.png"; +import storeIcon from '@/assets/brand/storeIcon.png' +import legalPerson from '@/assets/brand/legalPerson.png' +import account from '@/assets/brand/account.png' +import code from '@/assets/brand/code.png' +import brandDesc from '@/assets/brand/brandDesc.png' +import shopIcon from '@/assets/brand/shopIcon.png' +import map from '@/assets/brand/map.png' +import button from '@/assets/brand/button.png' +import phone from '@/assets/brand/phone.png' +import success from '@/assets/brand/success.png' +import effective from "@/assets/brand/effective.png"; +import wrong from "@/assets/brand/wrong.png"; +import AddEdit from './components/addEdit'; +import React from 'react'; +import LoadingBox from '@/pages/reports/Finance/businessAnalysis/components/loading'; +import PageTitleBox from '@/components/PageTitleBox'; +// 更新信息 +const handleAddUpdate = async (fields: MerchantModel) => { + const hide = message.loading('正在提交...'); + + const result = await updateMerchants(fields); + hide(); + if (result.Result_Code !== 100) { + message.error(`${result.Result_Desc}` || `${result.Result_Code}:提交失败`); + return false; + } + message.success(fields.COOPMERCHANTS_ID ? '更新成功!' : '新建成功!'); + return true; +}; +type DetailProps = { + isComponent?: boolean + onRef?: any +} + +// const MerchatsTable = ({ isComponent, onRef }: DetailProps) => { +const MerchatsTable: React.FC<{ isComponent?: any, onRef?: any }> = (props) => { + const { isComponent, onRef } = props + + const actionRef = useRef(); + const formRef = useRef(); + const brandTableRef = useRef() + const [currentRow, setCurrentRow] = useState(); + const [showDetail, setShowDetail] = useState(); + const [modalVisible, handleModalVisible] = useState(); + const [showDrawer, setShowDrawer] = useState(false)// 是否显示抽屉 + const [detail, setDetail] = useState(); // 抽屉详情 + const [contactsList, setContactsList] = useState([])// 联系人列表 + // 点击商户名称的点击事件的加载效果 + const [detailLoading, setDetailLoading] = useState(false) + + const [disabled, setDraggleDisabled] = useState() // 是否拖动 + const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 + const draggleRef = React.createRef() + // 选中的行 + const [selectRow, setSelectRow] = useState() + // 选中的行详情 + const [selectRowDetail, setSelectRowDetail] = useState() + const onDraggaleStart = (event, uiData) => { + const { clientWidth, clientHeight } = window.document.documentElement; + const targetRect = draggleRef.current?.getBoundingClientRect(); + if (!targetRect) { + return; + } + setBounds({ + left: -targetRect.left + uiData.x, + right: clientWidth - (targetRect.right - uiData.x), + top: -targetRect.top + uiData.y, + bottom: clientHeight - (targetRect.bottom - uiData.y), + }); + }; + + const columns: ProColumns[] = [ + { + title: '查询条件', + dataIndex: 'searchKey', + hideInTable: true, + hideInDescriptions: true, + fieldProps: { + placeholder: "请输入商户名称/统一信用代码" + } + }, + { + dataIndex: 'COOPMERCHANTS_NAME', + title: '商户名称', + hideInSearch: true, + hideInDescriptions: true, + sorter: true, + render: (_, record) => { + return { + setShowDrawer(true) + await handleGetDetailData(record) + }} + > + {record.COOPMERCHANTS_NAME} + + } + }, + { + dataIndex: 'COOPMERCHANTS_EN', + title: '简称', + hideInSearch: true, + hideInTable: true, + }, + { + dataIndex: 'MERCHANTTYPE_NAME', + title: '类别', + hideInSearch: true, + hideInTable: true, + }, + { + dataIndex: 'LINKER_NAME', + title: '联系人', + align: 'center', + width: 100, + hideInSearch: true, + }, + { + dataIndex: 'LINKER_MOBILEPHONE', + title: '联系方式', + align: 'center', + width: 150, + hideInSearch: true, + }, + { + dataIndex: 'TAXPAYER_IDENTIFYCODE', + title: '统一信用代码', + hideInTable: true, + hideInSearch: true, + }, + { + dataIndex: 'COOPMERCHANTS_NATURE', + title: '商户性质', + valueType: 'select', + valueEnum: { 1000: '企业', 2000: '个体', 3000: '自然人' }, + hideInTable: true, + hideInSearch: true, + }, + { + dataIndex: 'BANK_NAME', + title: '开户行', + // width: 350, + hideInSearch: true, + }, + { + dataIndex: 'BANK_ACCOUNT', + title: '银行账号', + width: 200, + hideInSearch: true, + }, + { + dataIndex: 'COOPMERCHANTS_STATE', + title: '商户状态', + align: 'center', + width: 100, + valueType: 'select', + valueEnum: { 0: { text: '无效', status: 'error' }, 1: { text: '有效', status: 'success' } }, + initialValue: '1' + }, + { + dataIndex: 'MERCHANTS_ADDRESS', + title: '商户地址', + colSize: 24, + hideInTable: true, + hideInSearch: true, + }, + { + dataIndex: 'STAFF_NAME', + title: '操作员', + hideInSearch: true, + hideInTable: true, + }, + { + dataIndex: 'OPERATE_DATE', + title: '更新时间', + align: 'center', + width: 100, + valueType: 'fromNow', + hideInSearch: true, + }, + { + dataIndex: 'option', + title: '操作', + width: 80, + align: 'center', + valueType: 'option', + hideInSearch: true, + hideInTable: isComponent, + render: (_, record) => { + return ( + { + console.log('record', record); + setCurrentRow({ ...record }); + handleModalVisible(true); + }} + > + 编辑 + + ); + }, + }, + ]; + + // 拿到详情数据 + const handleGetDetailData = async (record: any) => { + setDetailLoading(true) + const data = await getShopDetail({ CoopMerchantsId: record.COOPMERCHANTS_ID }) + setDetail(data) + const options = await getFieldEnum({ FieldExplainField: 'MERCHANTS_TYPE' }); + options.forEach((item: any) => { + if (item.value === data.MERCHANTTYPE_ID) { + data.MERCHANTTYPE_IDNAME = item.label + } + }) + const contacts = await getLinkManList(Number(record.COOPMERCHANTS_ID)) + setContactsList(contacts) + setDetailLoading(false) + } + + + + useImperativeHandle(onRef, () => ({ + selectRow, + selectRowDetail + })); + + return ( + + + + style={{ height: 'calc(100vh - 135px)', background: '#fff' }} + scroll={{ y: 'calc(100vh - 410px)' }} + rowKey="COOPMERCHANTS_ID" + formRef={formRef} + headerTitle={} + className='MerchatsTable' + actionRef={actionRef} + search={{ span: 6 }} + request={async (params, sorter) => { + // 排序字段 + const sortstr = Object.keys(sorter).map(n => { + const value = sorter[n] + return value ? `${n} ${value.replace('end', '')}` : '' + }) + + const data = await getList({ + ...params, + sortstr: sortstr.length ? sortstr.toString() : "OPERATE_DATE desc", + keyWord: params.searchKey ? { key: "COOPMERCHANTS_NAME,TAXPAYER_IDENTIFYCODE", value: params.searchKey } : null, // 关键词查询 + pagesize: params.pageSize + }); + return data; + }} + columns={columns} + toolbar={{ + actions: [ + , + ], + }} + pagination={{ defaultPageSize: 10 }} + options={false} + rowSelection={isComponent ? { + type: "radio", + onChange: (_, selectedRows) => { + // setSelectRow + console.log('_', _); + console.log('selectedRows', selectedRows); + if (selectedRows && selectedRows.length > 0) { + setSelectRow(selectedRows[0].COOPMERCHANTS_NAME) + setSelectRowDetail(selectedRows) + } else { + setSelectRow('') + setSelectRowDetail(undefined) + } + } + } : false} + /> + { + setCurrentRow(undefined); + setShowDetail(false); + }} + closable={false} + > + {currentRow?.COOPMERCHANTS_NAME && ( + + column={2} + title={currentRow?.COOPMERCHANTS_NAME} + request={async () => ({ + data: currentRow || {}, + })} + params={{ + id: currentRow?.COOPMERCHANTS_ID, + }} + columns={columns as ProDescriptionsItemProps[]} + /> + )} + + + + + + + + { + setShowDrawer(false); + }} + bodyStyle={{ padding: 0 }} + footer={ +
+ + {/* */} +
+ } + closable={false} + + > + { + detailLoading ? + : + <> + { + detail ? +
+
+ 商家信息 + { setShowDrawer(false) }}> +
+
+
+
+
+
+ +
+
+

{detail.COOPMERCHANTS_NAME}

+

{detail.COOPMERCHANTS_NATURE === 1000 ? '企业' : '个体'}

+
+
+
+ { + detail.COOPMERCHANTS_STATE === 1 ? +
+ + {'有效'} +
+ :
+ + {'无效'} +
+ } +
+
+
+
+ + 法人信息 + { + !detail.COOPMERCHANTS_LINKMAN && !detail.COOPMERCHANTS_TELEPHONE ? - : +

{detail.COOPMERCHANTS_LINKMAN} {detail.COOPMERCHANTS_MOBILEPHONE}

+ } +
+ +
+ + 开户信息 + { + !detail.BANK_NAME && !detail.BANK_ACCOUNT ? - : +

{detail.BANK_NAME} {detail.BANK_ACCOUNT}

+ } +
+ +
+ + 统一信用代码 +

{detail.TAXPAYER_IDENTIFYCODE || '-'}

+
+
+
+ +
+
+ + 所属类别 + {detail.MERCHANTTYPE_IDNAME} +
+ +
+ + 商户简称 + {detail.COOPMERCHANTS_EN || '-'} +
+ +
+ + 商户地址 + {detail.COOPMERCHANTS_ADDRESS || '-'} +
+ +
+ + 联系人 +
+ { + contactsList.length && contactsList.length > 0 ? + contactsList.map((item: any) => { + return
+ {item.LINKER_NAME} + {item.LINKER_MOBILEPHONE} + { + item.LINKER_STATE === 1 ? +
+ + 有效 +
+ : +
+ + 无效 +
+ } +
+ }) : '' + } +
+
+ +
+ + 经营品牌 +
+ { + detail.BrandList.length && detail.BrandList.length > 0 ? + detail.BrandList.map((item: any) => { + return item.ico ? : '' + }) + // [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}].map((item: any)=>{ + // return + // }) + : '' + } +
+
+
+
+
+ : '' + } + + } +
+
+ ); +}; + +export default MerchatsTable; diff --git a/src/pages/basicManage/Merchats/service.ts b/src/pages/basicManage/Merchats/service.ts new file mode 100644 index 0000000..932a6d0 --- /dev/null +++ b/src/pages/basicManage/Merchats/service.ts @@ -0,0 +1,312 @@ +import { tableList } from '@/utils/format'; +import request from '@/utils/request'; +import type { LinkManModel, MerchantModel, MerchantTypeModel } from './data'; + +// 获取列表数据 +export async function getList(params?: any) { + const search = params ? { + searchParameter: { ...params }, keyWord: params.keyWord, + sortstr: params.sortstr, PageIndex: params.current, pagesize: params.pagesize + } : {}; + const data = await request(`/Merchants/GetCoopMerchantsList`, { + method: 'POST', + data: search, + }); + + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + + return tableList(data.Result_Data); +} + +export async function delMerchants(Merchantsid: number) { + return request(`/Merchants/DeleteCoopMerchants?Merchantid=${Merchantsid}`, { + method: 'POST', + + requestType: 'form', + }); +} + +export async function updateMerchants(Merchants: MerchantModel) { + return request(`/Merchants/SynchroCoopMerchants`, { + method: 'POST', + data: Merchants, + requestType: 'form', + }); +} + +// 获取联系人列表数据 +export async function getLinkManList(merchartsId: any) { + const search = { searchParameter: { COOPMERCHANTS_ID: merchartsId, LINKER_STATE: 1 }, PageIndex: 1, pagesize: 20 } + const data = await request(`/Merchants/GetCoopMerchantsLinkerList`, { + method: 'POST', + data: search, + }); + if (data.Result_Code !== 100) { + return [] + } + return data.Result_Data.List; +} + + + +export async function delLinkMan(Merchantsid: number) { + return request(`/Merchants/DeleteCoopMerchantsLinker?CoopMerchantsLinkerId=${Merchantsid}`, { + method: 'POST', + + requestType: 'form', + }); +} + +export async function updateLinkMan(Merchants: LinkManModel) { + return request(`/Merchants/SynchroCoopMerchantsLinker`, { + method: 'POST', + data: Merchants, + requestType: 'form', + }); +} + +// end=== + + +// 商户类别 +export async function getTypeList(params?: any) { + const search = params ? { ...params, PageIndex: params.current } : {}; + const data = await request(`/Merchants/GetAutoTypeList`, { + method: 'GET', + params: search, + }); + + if (data.Result_Code === 500) { + return []; + } + + return tableList(data.Result_Data); +} + +export async function delMerchantsType(autoTypeId: number) { + return request(`/Merchants/DeleteAutotype?autoTypeId=${autoTypeId}`, { + method: 'POST', + + requestType: 'form', + }); +} + +export async function updateMerchantsType(Merchants: MerchantTypeModel) { + return request(`/Merchants/SynchroAutotype`, { + method: 'POST', + data: Merchants, + requestType: 'form', + }); +} + +// 获取商家类别options 数据 +export async function getTypeOptions(params?: any) { + const search = params ? { ...params, PageIndex: params.current } : {}; + const data = await request(`/Merchants/GetAutoTypeList`, { + method: 'GET', + params: search, + }); + + if (data.Result_Code !== 100) { + return []; + } + if (data.Result_Data.List) { + const options: { label: string; value: number }[] = data.Result_Data.List.map((n: MerchantTypeModel) => { + const { AUTOTYPE_NAME, AUTOTYPE_ID } = n; + return ({ label: AUTOTYPE_NAME, value: AUTOTYPE_ID }); + }); + + + return options; + } + return []; +} + +// 获取列表数据 +export async function getMerchantsOpt(params?: any) { + + const search = { searchParameter: { ...params, COOPMERCHANTS_STATE: 1, pagesize: 9999, pageindex: 1 } } + const data = await request(`/Merchants/GetCoopMerchantsList`, { + method: 'POST', + data: search, + }); + + if (data.Result_Code !== 100) { + return [] + } + if (data.Result_Data.List) { + const options: { label: string; value: number }[] = data.Result_Data.List.map((n: MerchantModel) => { + const { COOPMERCHANTS_NAME, COOPMERCHANTS_ID } = n; + return ({ label: COOPMERCHANTS_NAME, value: COOPMERCHANTS_ID }); + }); + + + return options; + } + return data.Result_Data.List; +} + +// 商家详情信息 +export async function getShopDetail(params?: any) { + const data = await request(`/Merchants/GetCoopMerchantsDetail`, { + method: 'GET', + params, + }); + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + return data.Result_Data; +} + +// 拿到当期汇总信息 +export async function getMerchantSplit(params?: any) { + const data = await request(`/BusinessProject/GetMerchantSplit`, { + method: 'GET', + params, + }); + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + return data.Result_Data.List; +} +// 获取经营商户应收账款信息 +export async function getReceivalbles(params?: any) { + const data = await request(`/BusinessProject/GetMerchantsReceivables`, { + method: 'GET', + params, + }); + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + return data.Result_Data; +} + + +// 获取品牌列表 +export async function getBrandList(params?: any) { + const data = await request(`/Merchants/GetRTCoopMerchantsList`, { + method: 'GET', + params, + }); + + if (data.Result_Code !== 100) { + return [] + } + + return data.Result_Data.List; +} + +// 获取列表数据 +export async function getTreeList(params?: any) { + const search = params ? { + SearchParameter: { ...params }, keyWord: params.keyWord, + PageIndex: params.current, pagesize: params.pageSize, SortStr: params.sortstr + } : {}; + const data = await request(`/BaseInfo/GetBrandList`, { + method: 'POST', + data: search, + }); + + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + + return tableList(data.Result_Data); +} + + + + +// 获取经营商户品牌列表 +export async function handleRTCoopMerchantsList(params?: any) { + const data = await request(`/Merchants/GetRTCoopMerchantsList`, { + method: 'GET', + params, + }); + + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + + return data.Result_Data.List +} + + +// 删除经营商户品牌关联关系表 +export async function handleDeleteRTCoopMerchants(params?: any) { + const data = await request(`/Merchants/DeleteRTCoopMerchants`, { + method: 'GET', + params, + }); + + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + + return data +} + + +// 同步经营商户品牌关联关系表 +export async function handleSynchroRTCoopMerchants(params?: any) { + const data = await request(`/Merchants/SynchroRTCoopMerchants`, { + method: 'POST', + data: params, + }); + + if (data.Result_Code !== 100) { + return { + data: [], + current: 1, + pageSize: 10, + total: 0, + success: false + } + } + + return data +} \ No newline at end of file diff --git a/src/pages/basicManage/Merchats/style.less b/src/pages/basicManage/Merchats/style.less new file mode 100644 index 0000000..d1c55b0 --- /dev/null +++ b/src/pages/basicManage/Merchats/style.less @@ -0,0 +1,245 @@ +.MerchatsTable{ + .ant-pro-card{ + .ant-pro-card-body{ + .ant-pro-table-alert{ + display: none !important; + } + } + } +} + + +.drawer{ + width: 100%; + height: 100%; + box-sizing: border-box; + .drawerTop{ + width: 100%; + height: 56px; + border-bottom: 1px solid rgba(0,0,0,0.06); + box-sizing: border-box; + padding: 16px 24px; + display: flex; + justify-content: space-between; + align-items: center; + .drawerTitle{ + font-size: 16px; + font-family: PingFangSC-Medium, PingFang SC; + font-weight: 600; + color: rgba(0,0,0,0.85); + } + .closeIcon{ + width: 16px; + height: 16px; + cursor: pointer; + } + } + .drawerContent{ + width: 100%; + height: calc(100% - 80px); + box-sizing: border-box; + padding: 0 24px; + .drawerHeader{ + width: 100%; + background: linear-gradient(180deg, RGBA(246, 249, 255, 1) 0%, RGBA(255, 255, 255, 1) 100%); + border-radius: 8px; + border: 1px solid #EFEFF3; + box-sizing: border-box; + padding: 20px; + margin-top: 24px; + display: flex; + flex-direction: column; + .top{ + width: 100%; + display: flex; + align-items: flex-start; + justify-content: space-between; + .topLeft{ + display: flex; + align-items: center; + .image{ + width: 52px; + height: 52px; + background: #FFFFFF; + border-radius: 6px; + display: flex; + align-items: center; + justify-content: center; + .headerIcon{ + width: 40px; + height: 40px; + } + } + + .message{ + margin-left: 12px; + .companyName{ + font-size: 16px; + font-family: PingFangSC-Medium, PingFang SC; + font-weight: 600; + color: rgba(0,0,0,0.85); + line-height: 24px; + margin-bottom: 4px; + } + .label{ + display: inline-block; + padding: 1px 8px; + background: #FDF6E3; + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: #571519; + margin-bottom: 0; + line-height: 22px; + } + } + } + .topRight{ + .state{ + display: flex; + align-items: center; + .stateIcon{ + width: 16px; + height: 16px; + } + .stateText{ + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: #0DA241; + margin-left: 4px; + } + } + } + } + .list{ + margin-top: 20px; + .item{ + display: flex; + align-items: center; + margin-bottom: 8px; + p{ + margin-bottom: 0; + } + .icon{ + width: 16px; + height: 16px; + border-radius: 2px; + margin-right: 8px; + } + .messageLabel{ + display: inline-block; + min-width: 100px; + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: rgba(0,0,0,0.45); + line-height: 22px; + } + .text{ + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: rgba(0,0,0,0.85); + line-height: 22px; + margin-left: 24px; + } + } + } + } + .other{ + margin-top: 24px; + width: 100%; + .otherItem{ + display: flex; + align-items: center; + margin-bottom: 17px; + .icon{ + width: 16px; + height: 16px; + margin-right: 8px; + } + .label{ + min-width:80px; + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: rgba(0,0,0,0.65); + line-height: 22px; + margin-right: 24px; + } + .type{ + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: #0A2659; + line-height: 22px; + background: #EBF2FF; + border-radius: 2px; + padding: 1px 8px; + } + .value{ + flex: 1; + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: rgba(0,0,0,0.85); + line-height: 22px; + } + .list{ + .listItem{ + width: 304px; + height: 30px; + background: #F6F7F8; + border-radius: 2px; + box-sizing: border-box; + padding: 4px 16px; + display: flex; + justify-content: space-between; + margin-bottom: 8px; + .name{ + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: rgba(0,0,0,0.85); + line-height: 22px; + } + .phone{ + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: rgba(0,0,0,0.85); + line-height: 22px; + } + .state{ + display: flex; + align-items: center; + .icon{ + width: 14px; + height: 14px; + } + .text{ + font-size: 14px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: #0DA241; + line-height: 22px; + } + } + } + } + .imgList{ + flex: 1; + .imgItem{ + width: 40px; + height: 40px; + margin-right: 12px; + margin-bottom: 12px; + border-radius: 4px; + } + } + } + } + + } +} diff --git a/src/pages/basicManage/businessMan/components/addForm.tsx b/src/pages/basicManage/businessMan/components/addForm.tsx new file mode 100644 index 0000000..14c73bb --- /dev/null +++ b/src/pages/basicManage/businessMan/components/addForm.tsx @@ -0,0 +1,194 @@ +import { connect } from "umi"; +import type { ConnectState } from "@/models/connect"; +import ProForm, { FormInstance, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form"; +import { useImperativeHandle, useRef, useState } from "react"; +import { Button, Col, Drawer, Row } from "antd"; +import { handleGetBusinessManDetail, handleGetNestingOwnerUnitList } from "../service"; +import { getFieldEnum } from "@/services/options"; +import { PlusOutlined } from "@ant-design/icons"; +import MerchatsTable from "../../Merchats"; + +type DetailProps = { + onRef: any + currentRow: any + selectShopRef?: any + currentUser?: any + handleGetShopData: any + pageType?: any +} +const AddForm = ({ onRef, currentRow, selectShopRef, currentUser, handleGetShopData, pageType }: DetailProps) => { + + const MerchatsTableRef = useRef() + const formRef = useRef(); + // 表格的详情 + const [formDetail, setFormDetail] = useState() + // 客户单位后面点击的加号出现的抽屉 + const [onShowSelect, setOnShowSelect] = useState(false) + + useImperativeHandle(onRef, () => ({ + formRef, + formDetail + })); + + return ( +
+ { + if (currentRow?.OWNERUNIT_ID) { + const data = await handleGetBusinessManDetail({ BusinessManId: currentRow?.OWNERUNIT_ID }) + console.log('data312312', data); + let obj: any = data.Result_Data + // 原数据 + obj.PROVINCE_CODE = obj.PROVINCE_CODE.toString() + obj.OWNERUNIT_NATURE = obj.OWNERUNIT_NATURE.toString() + setFormDetail(data.Result_Data) + + selectShopRef.current?.handleShopSelected(obj?.ShopList) + await selectShopRef.current?.handleGetTreeData(obj?.PROVINCE_CODE) + + return data.Result_Data + } + // 左边选择门店的内容 因为需要拿到这边的省份数据 如果一起掉 它本身的会顶掉实际的 所以就在这儿掉 + selectShopRef.current?.handleGetTreeData(currentUser?.ProvinceCode) + return {} + }} + > + + + { + const data = await handleGetNestingOwnerUnitList({ ShowStatus: true }) + return data + }} + fieldProps={{ + fieldNames: { + label: 'OWNERUNIT_NAME', + value: 'OWNERUNIT_ID', + children: 'children' + }, + allowClear: true, + showSearch: true + }} + initialValue={currentRow?.OWNERUNIT_PID ? currentRow?.OWNERUNIT_PID : currentUser?.ProvinceCode === '340000' ? 275 : ''} + /> + + + + { + return await getFieldEnum({ + // 这里要手动添加枚举字段(从下面这些字典中选择一个):服务区内码[ServerpartIds] + FieldExplainField: 'PROVINCE_CODE', + notformate: true, + }); + }} + fieldProps={{ + onChange: (e: any) => { + console.log('e', e); + console.log('selectShopRef.current?', selectShopRef.current); + + selectShopRef.current?.handleGetTreeData(e) + } + }} + initialValue={currentUser?.ProvinceCode || '340000'} + /> + + + + { + return await getFieldEnum({ + // 这里要手动添加枚举字段(从下面这些字典中选择一个):服务区内码[ServerpartIds] + FieldExplainField: 'OWNERUNIT_NATURE', + notformate: true, + }); + }} + initialValue={'2000'} + /> + + + + + + + + + + + + + + + + + + + + + + + { + setOnShowSelect(false) + }} + destroyOnClose + title={'经营商户列表'} + closable={false} + bodyStyle={{ backgroundColor: "#f9f9f9", padding: 16 }} + footer={
+ +
} + > + +
+
+ ) +} + +export default connect(({ user, }: ConnectState) => ({ + currentUser: user.currentUser, +}))(AddForm); diff --git a/src/pages/basicManage/businessMan/components/businessManDetailDrawer.tsx b/src/pages/basicManage/businessMan/components/businessManDetailDrawer.tsx new file mode 100644 index 0000000..bb50bd8 --- /dev/null +++ b/src/pages/basicManage/businessMan/components/businessManDetailDrawer.tsx @@ -0,0 +1,384 @@ +/* + * @Author: cclu 1106109051@qq.com + * @Date: 2024-08-22 10:51:03 + * @LastEditors: cclu 1106109051@qq.com + * @LastEditTime: 2024-08-22 18:38:19 + * @FilePath: \cloud-platform\src\pages\basicManage\businessMan\components\businessManDetailDrawer.tsx + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { connect } from "umi"; +import type { ConnectState } from "@/models/connect"; +import { Col, Drawer, FormInstance, message, Popconfirm, Row } from "antd"; +import ProForm, { ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form"; +import { useRef, useState } from "react"; +import { handleDeleteAUTOTYPE, handleDeleteOWNERSERVERPART, handleDeleteOWNERSERVERPARTSHOP, handleGetBusinessManDetail, handleGetNestingOwnerUnitList } from "../service"; +import { getFieldEnum } from "@/services/options"; +import ProTable, { ActionType } from "@ant-design/pro-table"; +import moment from 'moment' +import useRequest from "@ahooksjs/use-request"; + +type DetailProps = { + showDetailDrawer: boolean + currentRow: any + setCurrentRow: any + setShowDetailDrawer: any + currentUser: any + parentRef: any +} +const BusinessManDetailDrawer = ({ showDetailDrawer, currentRow, setCurrentRow, setShowDetailDrawer, currentUser, parentRef }: DetailProps) => { + + const actionRef = useRef(); + const formRef = useRef(); + + const { loading: treeLoading, data: treeViews } = useRequest(async () => { + const data = await handleGetNestingOwnerUnitList({ ShowStatus: true }) + console.log('treeViews', data); + + return data + }) + + const [formDetail, setFormDetail] = useState() + // 上级类别的选择列表 + const [PIDSelectList, setPIDSelectList] = useState() + // 表格列表 + const [tableData, setTableData] = useState() + + const columns: any = [ + { + title: '经营范围', + dataIndex: 'AUTOTYPE_NAME' + }, + { + title: '显示顺序', + dataIndex: 'AUTOTYPE_INDEX' + }, + { + title: '所属公司', + dataIndex: 'OWNERUNIT_NAME' + }, + { + title: '有效状态', + dataIndex: 'AUTOTYPE_VALID', + valueType: 'select', + valueEnum: { + 1: "有效", + 0: "无效" + } + }, + { + title: '操作', + render: (_, record) => { + return record?.ServerpartList && record?.ServerpartList.length > 0 ? '' : record?.AUTOTYPE_VALID === 0 ? '' : { + console.log('record', record); + const data = await handleDeleteAUTOTYPE({ AUTOTYPEId: record?.AUTOTYPE_ID }) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + handleGetReload() + } else { + message.error(data.Result_Desc) + } + }} + > + 删除 + + } + } + ] + + const handleGetThirdColumns = (record?: any) => { + const columns: any = [ + { + title: '门店名称', + dataIndex: 'SHOPNAME' + }, + { + title: '门店编码', + dataIndex: 'SHOPCODE' + }, + { + title: '所属公司', + dataIndex: 'OWNERUNIT_NAME' + }, + { + title: '操作', + render: (_, record) => { + return { + console.log('record', record); + const data = await handleDeleteOWNERSERVERPARTSHOP({ OWNERSERVERPARTSHOPId: record?.OWNERSERVERPARTSHOP_ID }) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + handleGetReload() + } else { + message.error(data.Result_Desc) + } + }} + > + 删除 + + } + } + ] + return { + return `${record?.OWNERSERVERPARTSHOP_ID}` + }} + dataSource={record?.ShopList} + bordered + search={false} + options={false} + /> + } + + const handleGetSecondColumns = (record?: any) => { + console.log('record', record); + const columns: any = [ + { + title: '服务区名称', + dataIndex: 'SERVERPART_NAME' + }, + { + title: '服务区编码', + dataIndex: 'SERVERPART_CODE' + }, + { + title: '所属公司', + dataIndex: 'OWNERUNIT_NAME' + }, + { + title: '操作', + render: (_, record) => { + return record?.ShopList && record?.ShopList.length > 0 ? '' : { + console.log('record', record); + const data = await handleDeleteOWNERSERVERPART({ OWNERSERVERPARTId: record?.OWNERSERVERPART_ID }) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + handleGetReload() + } else { + message.error(data.Result_Desc) + } + }} + > + 删除 + + } + } + ] + + return { + return `${record?.OWNERSERVERPART_ID}` + }} + dataSource={record?.ServerpartList} + bordered + search={false} + options={false} + expandable={{ + expandedRowRender: handleGetThirdColumns + }} + /> + } + + + // 重新刷新下面的嵌套表数据 + const handleGetReload = async () => { + const data = await handleGetBusinessManDetail({ BusinessManId: currentRow?.OWNERUNIT_ID }) + let obj: any = data.Result_Data + setTableData(obj.OrganizationList) + } + + return ( +
+ { + setCurrentRow(undefined); + setShowDetailDrawer(false); + }} + title={编辑经营范围} + bodyStyle={{ backgroundColor: "#fff", padding: 16 }} + closable={false} + destroyOnClose + > + + { + if (currentRow?.OWNERUNIT_ID) { + const data = await handleGetBusinessManDetail({ BusinessManId: currentRow?.OWNERUNIT_ID }) + console.log('data312312', data); + let obj: any = data.Result_Data + // 原数据 + obj.PROVINCE_CODE = obj.PROVINCE_CODE.toString() + obj.OWNERUNIT_NATURE = obj.OWNERUNIT_NATURE.toString() + obj.OPERATE_DATE = moment(obj.OPERATE_DATE).format('YYYY-MM-DD HH:mm:ss') + obj.OWNERUNIT_PID = Number(obj.OWNERUNIT_PID) + obj.OWNERUNIT_ID = Number(obj.OWNERUNIT_ID) + let serverPartNumber: any = 0 + let serverPartShopNumber: any = [] + setFormDetail(data.Result_Data) + console.log('obj', obj); + + if (obj.OrganizationList && obj.OrganizationList.length > 0) { + setTableData(obj.OrganizationList) + let res: any = [] + obj.OrganizationList.forEach((item: any) => { + res.push({ label: item.AUTOTYPE_NAME, value: item.AUTOTYPE_ID }) + if (item.ServerpartList && item.ServerpartList.length > 0) { + serverPartNumber += item.ServerpartList.length + item.ServerpartList.forEach((subItem: any) => { + if (subItem.ShopList && subItem.ShopList.length > 0) { + subItem.ShopList.forEach((thirdItem: any) => { + if (serverPartShopNumber.indexOf(thirdItem.SERVERPARTSHOP_ID) === -1) { + serverPartShopNumber.push(thirdItem.SERVERPARTSHOP_ID) + } + }) + } + }) + } + }) + setPIDSelectList(res) + } else { + setPIDSelectList([]) + setTableData([]) + } + obj.serverPartNumber = serverPartNumber + obj.serverPartShopNumber = serverPartShopNumber && serverPartShopNumber.length > 0 ? serverPartShopNumber.length : '' + return obj + } + }} + > + + + { + const data = await handleGetNestingOwnerUnitList({ ShowStatus: true }) + return data + }} + fieldProps={{ + fieldNames: { + label: 'OWNERUNIT_NAME', + value: 'OWNERUNIT_ID', + children: 'children' + }, + allowClear: true, + showSearch: true, + // treeData: treeViews + }} + /> + + + + + + { + return await getFieldEnum({ + // 这里要手动添加枚举字段(从下面这些字典中选择一个):服务区内码[ServerpartIds] + FieldExplainField: 'OWNERUNIT_NATURE', + notformate: true, + }); + }} + /> + + + { + return await getFieldEnum({ + FieldExplainField: 'PROVINCE_CODE', + notformate: true, + }); + }} + /> + + + + + + + + + + + + + + + + + + + + + + + + { + return `${record?.AUTOTYPE_ID}` + }} + expandable={{ + expandedRowRender: handleGetSecondColumns + }} + /> + + +
+ ) +} + +export default connect(({ user, }: ConnectState) => ({ + currentUser: user.currentUser, +}))(BusinessManDetailDrawer); diff --git a/src/pages/basicManage/businessMan/components/businessManDrawer.tsx b/src/pages/basicManage/businessMan/components/businessManDrawer.tsx new file mode 100644 index 0000000..1a8d5eb --- /dev/null +++ b/src/pages/basicManage/businessMan/components/businessManDrawer.tsx @@ -0,0 +1,165 @@ +/* + * @Author: cclu 1106109051@qq.com + * @Date: 2024-08-22 09:16:52 + * @LastEditors: cclu 1106109051@qq.com + * @LastEditTime: 2024-08-22 19:19:15 + * @FilePath: \cloud-platform\src\pages\basicManage\businessMan\components\businessManDrawer.tsx + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +/* + * @Author: cclu 1106109051@qq.com + * @Date: 2024-08-22 09:16:52 + * @LastEditors: cclu 1106109051@qq.com + * @LastEditTime: 2024-08-22 09:23:09 + * @FilePath: \cloud-platform\src\pages\basicManage\businessMan\components\businessManDrawer.tsx + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { connect } from "umi"; +import type { ConnectState } from "@/models/connect"; +import { Button, Drawer, message, Popconfirm } from "antd"; +import moment from 'moment' +import { handleCreateBusinessMan, handleDeleteBusinessMan } from "../service"; +import { useEffect, useRef } from "react"; +import SelectShop from "./selectShop"; +import AddForm from "./addForm"; +import '../index.less' + +type DetailProps = { + showDrawer: boolean + currentRow?: any + setCurrentRow?: any + setShowDrawer: any + currentUser: any + parentRef?: any + pageType?: string + afterOk?: any +} +const BusinessManDrawer = ({ showDrawer, currentRow, setCurrentRow, setShowDrawer, currentUser, parentRef, pageType, afterOk }: DetailProps) => { + + const selectShopRef = useRef() + const addFormRef = useRef() + + // 新增客户单位的方法 + const handleGetAddNew = async (obj?: any) => { + let req: any = {} + let shopList: any = selectShopRef.current?.selectId + let detail: any = addFormRef.current?.formDetail + console.log('shopList', shopList); + + if (currentRow?.OWNERUNIT_ID) { + req = { + ...detail, + ...obj, + STAFF_ID: currentUser.ID, + STAFF_NAME: currentUser.Name, + OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'), + ShopList: shopList && shopList.length > 0 ? shopList : [] + } + } else { + req = { + ...obj, + OWNERUNIT_STATE: 1, + STAFF_ID: currentUser.ID, + STAFF_NAME: currentUser.Name, + OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'), + ShopList: shopList && shopList.length > 0 ? shopList : [] + } + } + + console.log('req', req); + const data = await handleCreateBusinessMan(req) + console.log('data', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + if (parentRef) { + parentRef.current?.reload() + } + if (pageType === 'edit') { + if (afterOk) { + afterOk() + } + } + } else { + message.success(data.Result_Desc) + } + } + + const handleGetShopData = async () => { + selectShopRef.current?.handleGetTreeData() + } + + useEffect(() => { + if (showDrawer && !currentRow) { + selectShopRef.current?.handleGetTreeData() + } + }, [showDrawer]) + + return ( +
+ { + if (setCurrentRow) { + setCurrentRow(undefined); + } + setShowDrawer(false); + }} + title={{currentRow?.OWNERUNIT_ID ? '编辑客户单位' : '新增客户单位'}} + className={"drawerBox"} + bodyStyle={{ backgroundColor: "#fff", padding: 16 }} + closable={false} + destroyOnClose + footer={
+ + { + currentRow?.OWNERUNIT_ID ? + { + const data = await handleDeleteBusinessMan({ BusinessManId: currentRow?.OWNERUNIT_ID }) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + if (parentRef) { + parentRef.current?.reload() + } + if (setCurrentRow) { + setCurrentRow(undefined); + } + setShowDrawer(false); + } else { + message.error(data.Result_Desc) + } + }} + > + + + : + '' + } +
} + > +
+ {/* 编辑当行信息或新增内容 */} +
+ +
+ + {/* 选择关联门店 */} +
+ +
+
+
+
+ ) +} + +export default connect(({ user, }: ConnectState) => ({ + currentUser: user.currentUser, +}))(BusinessManDrawer); diff --git a/src/pages/basicManage/businessMan/components/selectShop.less b/src/pages/basicManage/businessMan/components/selectShop.less new file mode 100644 index 0000000..089e414 --- /dev/null +++ b/src/pages/basicManage/businessMan/components/selectShop.less @@ -0,0 +1,20 @@ +.selectShop{ + width: 100%; + height: 100%; + border: 1px solid #97d6fe; + .selectShopTop{ + width: 100%; + box-sizing: border-box; + padding: 8px 12px; + background-color: #e7f7ff; + } + .treeContent{ + width: 100%; + height: calc(100% - 56px); + margin-top: 16px; + overflow-y: auto; + .ant-tree-treenode{ + padding-bottom: 16px + } + } +} diff --git a/src/pages/basicManage/businessMan/components/selectShop.tsx b/src/pages/basicManage/businessMan/components/selectShop.tsx new file mode 100644 index 0000000..f957e38 --- /dev/null +++ b/src/pages/basicManage/businessMan/components/selectShop.tsx @@ -0,0 +1,142 @@ +import { connect } from "umi"; +import type { ConnectState } from "@/models/connect"; +import { useEffect, useImperativeHandle, useState } from "react"; +import { Tree } from "antd"; +import { DownOutlined } from "@ant-design/icons"; +import './selectShop.less' +import LoadingBox from "@/pages/reports/Finance/businessAnalysis/components/loading"; +import { handleGetServerpartShopTree, handleGetSPRegionShopTree } from "../service"; + +type DetailProps = { + onRef: any + onShow?: boolean + currentUser: any + addFormRef?: any +} +const SelectShop = ({ onRef, onShow, currentUser, addFormRef }: DetailProps) => { + + const [treeData, setTreeData] = useState() + const [selectId, setSelectId] = useState() + const [treeLoading, setTreeLoading] = useState(false) + // 默认选择项 + const [defaultSelect,setDefaultSelect] = useState() + + + + // 拿到树形的数据 + const handleGetTreeData = async (code?: any) => { + // let provinceCode = + console.log('code', code); + let req: any = { + ProvinceCode: code || currentUser?.ProvinceCode || '340000', + ShowWholePower: true, + ShowState: true + } + console.log('req', req); + setTreeLoading(true) + const data = await handleGetSPRegionShopTree(req) + console.log('data3232', data); + + + // let list: any = [] + // if (data && data.length > 0) { + // data.forEach((item: any) => { + // let children: any = [] + // if (item.children && item.children.length > 0) { + // item.children.forEach((subItem: any) => { + // children.push({ title: subItem.label, key: `2-${subItem.value}`, value: subItem.value, type: 2 }) + // }) + // } + // let obj: any = { + // title: item.label, + // key: `1-${item.value}`, + // value: item.value, + // children: children, + // type: 1 + // } + // list.push(obj) + // }) + // } + // console.log('list', list); + setTreeData(data) + setSelectId(undefined) + setTreeLoading(false) + } + + // useEffect(() => { + // if (onShow) { + // handleGetTreeData() + // } + // }, [onShow]) + + // 赋值表单详情查到的门店选择 + const handleShopSelected = (list: any)=>{ + let res: any = [] + let idList: any = [] + if(list && list.length>0){ + list.forEach((item: any)=>{ + res.push({ + label: '', + type: 2, + value: item.value, + key:`2-${item.value}`, + }) + idList.push(`2-${item.value}`) + }) + } + console.log('res',res); + console.log('idList',idList); + + setDefaultSelect(idList) + setSelectId(res) + } + + + useImperativeHandle(onRef, () => ({ + selectId, + handleGetTreeData, + handleShopSelected + })); + + + + + return ( +
+
选择关联门店
+
+ { + treeLoading ? : + { + console.log('checkedKeys',checkedKeys); + setDefaultSelect(checkedKeys) + const selectedIds = info.checkedNodes.filter(n => n?.type === 2) + setSelectId(selectedIds) + console.log('info', info); + console.log('selectedIds', selectedIds); + // let list: any = [] + // if (selectedIds && selectedIds.length > 0) { + // selectedIds.forEach((item: any) => { + // list.push({ label: item.label, value: item.value }) + // }) + // } + }} + /> + } +
+ +
+ ) +} + +export default connect(({ user, }: ConnectState) => ({ + currentUser: user.currentUser, +}))(SelectShop); diff --git a/src/pages/basicManage/businessMan/index.less b/src/pages/basicManage/businessMan/index.less new file mode 100644 index 0000000..243eb92 --- /dev/null +++ b/src/pages/basicManage/businessMan/index.less @@ -0,0 +1,18 @@ +.drawerBox{ + .drawerBoxContent{ + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: space-between; + .leftContent{ + width: calc(50% - 16px); + height: 100%; + } + .rightContent{ + width: calc(50% - 16px); + height: 100%; + overflow-y: auto; + } + } +} \ No newline at end of file diff --git a/src/pages/basicManage/businessMan/index.tsx b/src/pages/basicManage/businessMan/index.tsx new file mode 100644 index 0000000..699c0cc --- /dev/null +++ b/src/pages/basicManage/businessMan/index.tsx @@ -0,0 +1,302 @@ +/* + * @Author: cclu 1106109051@qq.com + * @Date: 2024-08-21 15:09:24 + * @LastEditors: cclu 1106109051@qq.com + * @LastEditTime: 2024-08-23 09:37:09 + * @FilePath: \cloud-platform\src\pages\basicManage\businessMan\index.tsx + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { connect } from "umi"; +import type { CurrentUser } from "umi"; +import type { ConnectState } from "@/models/connect"; +import React, { useRef, useState } from "react"; +import { PlusOutlined } from "@ant-design/icons"; +import { Drawer, FormInstance, Popconfirm } from "antd"; +import { Button, message, Space, Spin } from "antd"; +import { getFieldEnum } from "@/services/options"; +import type { ActionType } from "@ant-design/pro-table"; +import ProTable from "@ant-design/pro-table"; +import { handleCreateBusinessMan, handleDeleteBusinessMan, handleGetNestingOwnerUnitList } from "./service"; +import AddForm from "./components/addForm"; +import SelectShop from "./components/selectShop"; +import './index.less' +import moment from 'moment' +import BusinessManDrawer from "./components/businessManDrawer"; +import BusinessManDetailDrawer from "./components/businessManDetailDrawer"; + +const businessMan: React.FC<{ currentUser: CurrentUser }> = (props) => { + const { currentUser } = props + const downloadBtnRef = useRef() + const actionRef = useRef(); + const formRef = useRef(); + const [reqDetailList, setReqDetailList] = useState(); // 合计项数据源 + const [printOut, setPrintOut] = useState(); // 打印数据的内容 + const [collapsible, setCollapsible] = useState(false) + const [treeView, setTreeView] = useState() + const [printIndex, setPrintIndex] = useState(new Date().getTime()) + + + // 树相关的属性和方法 + const [selectedId, setSelectedId] = useState() + // 导出的加载效果 + const [showLoading, setShowLoading] = useState(false) + // 是否显示打印的表格 + const [showExportTable, setShowExportTable] = useState(false) + // 查询的条件 + const [searchParams, setSearchParams] = useState() + // 点击行的详情 + const [currentRow, setCurrentRow] = useState() + // 显示编辑的抽屉 + const [showDrawer, setShowDrawer] = useState(false) + // 显示详情抽屉 + const [showDetailDrawer, setShowDetailDrawer] = useState(false) + + const columns: any = [ + { + title: '商户单位', + dataIndex: 'OWNERUNIT_NAME', + hideInSearch: true, + render: (_, record) => { + return record?.OWNERUNIT_NATURE === 2000 ? { + console.log('record', record); + setCurrentRow(record) + setShowDetailDrawer(true) + }}> + {record?.OWNERUNIT_NAME || ''} + : {record?.OWNERUNIT_NAME} + } + }, + { + title: '商户性质', + dataIndex: 'OWNERUNIT_NATURE', + width: 120, + hideInSearch: true, + valueType: 'select', + align: 'center', + initialValue: 1000, + request: async () => { + const options = await getFieldEnum({ FieldExplainField: 'OWNERUNIT_NATURE' }); + return options + }, + }, + + { + title: '所在省份', + dataIndex: 'PROVINCE_CODE', + width: 120, + hideInSearch: true, + valueType: 'select', + align: 'center', + request: async () => { + const options = await getFieldEnum({ FieldExplainField: 'PROVINCE_CODE',notformate: true}); + return options + }, + }, + { + title: '排序字段', + dataIndex: 'OWNERUNIT_INDEX', + hideInSearch: true, + align: 'center', + width: 100, + }, + { + dataIndex: 'OWNERUNIT_STATE', + title: '有效状态', + width: 100, + valueType: 'select', + align: 'center', + hideInSearch: true, + request: async () => { + const options = await getFieldEnum({ FieldExplainField: 'COMMODITYSTATE' }); + return options + }, + }, + { + dataIndex: 'option', + width: 120, + title: '操作', + align: 'center', + valueType: 'option', + hideInSearch: true, + render: (_, record) => { + return <> + { + record?.OWNERUNIT_NATURE === 2000 && record?.PROVINCE_CODE !== 0 ? + ( + { + setCurrentRow(record) + setShowDrawer(true) + }} + > + 编辑 + + { + handleDeleteRow(record?.OWNERUNIT_ID) + }} + > + 删除 + + ) + : '' + } + ; + }, + }, + ] + + const exportTable = (e) => { + e.stopPropagation(); // 防止Collapse组件收起 + const main = document.getElementsByClassName(`saleReportHideBox${printIndex}`)[0] + const thead = main.querySelector('thead').cloneNode(true); // 深克隆DOM节点 + const tbody = main.querySelector('tbody').cloneNode(true); // 深克隆DOM节点 + const container = document.querySelector('#hiddenBox'); + + const tempTable = document.createElement('table'); + tempTable.appendChild(thead); + tempTable.appendChild(tbody); + + tempTable.setAttribute('id', 'table-to-xls-businessMan'); // 给table添加id,值与按钮上的table字段对应 + + container.appendChild(tempTable); // 把创建的节点添加到页面容器中 + + setShowLoading(false) + + downloadBtnRef.current.handleDownload(); + setShowExportTable(false) + tempTable.remove() // 防止重复打印一个内容 + } + + + // 删除商户记录 + const handleDeleteRow = async (id: any) => { + const data = await handleDeleteBusinessMan({ BusinessManId: id }) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + } + + + return ( +
{ + // 打印报表 + if (!reqDetailList || reqDetailList.length === 0) return; + setPrintOut(el); + }} > + + { + showLoading ? +
+
+ + 数据导出中... +
+
: '' + } + +
+ { + showExportTable && reqDetailList && reqDetailList.length > 0 ? + : '' + } +
+
+ +
+
+ { + return `${record?.OWNERUNIT_ID}` + }} + headerTitle={'客户单位管理列表'} + search={{ span: 6 }} + request={async (params) => { + const req: any = { + ShowStatus: true + } + + setSearchParams(params) + + const data = await handleGetNestingOwnerUnitList(req) + console.log('data', data); + if (data && data.length > 0) { + return { data, suceess: true } + } + return { data: [], success: true } + + }} + toolbar={{ + actions: [ + + ] + }} + /> +
+
+ + {/* 新增编辑的组件 */} + + + + {/* 商户单位详情抽屉组件 */} + + +
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(businessMan); diff --git a/src/pages/basicManage/businessMan/service.ts b/src/pages/basicManage/businessMan/service.ts new file mode 100644 index 0000000..5bfc92b --- /dev/null +++ b/src/pages/basicManage/businessMan/service.ts @@ -0,0 +1,134 @@ +import { wrapTreeNode } from "@/utils/format"; +import request from "@/utils/request"; + +// 客户单位列表 +export async function handleGetNestingOwnerUnitList(params: any) { + const data = await request(`/BaseInfo/GetNestingOwnerUnitList`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return wrapTreeNode(data.Result_Data.List); +} + +// 客户单位编辑新增 +export async function handleCreateBusinessMan(params: any) { + const data = await request(`/BusinessMan/CreateBusinessMan`, { + method: 'POST', + data: params + }); + + if (data.Result_Code !== 100) { + return data + } + + return data; +} + + +// 客户单位详情 +export async function handleGetBusinessManDetail(params: any) { + const data = await request(`/Merchants/GetBusinessManDetail`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return data; +} + + +// 没有缓存的门店列表 +export async function handleGetServerpartShopTree(params: any) { + const data = await request(`/BaseInfo/GetServerpartShopTree`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return wrapTreeNode(data.Result_Data.List); +} + + +// 商户管理里面的选择门店的树列表 +export async function handleGetSPRegionShopTree(params: any) { + const data = await request(`/BaseInfo/GetSPRegionShopTree`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return wrapTreeNode(data.Result_Data.List); +} + + + +export async function handleDeleteBusinessMan(params: any) { + const data = await request(`/Merchants/DeleteBusinessMan`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return data; +} + + + +// 嵌套表最外面一层的删除 +export async function handleDeleteAUTOTYPE(params: any) { + const data = await request(`/BasicConfig/DeleteAUTOTYPE`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return data; +} + +// 嵌套列表第二层的删除 +export async function handleDeleteOWNERSERVERPART(params: any) { + const data = await request(`/BasicConfig/DeleteOWNERSERVERPART`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return data; +} + +// 嵌套列表第三层的删除 +export async function handleDeleteOWNERSERVERPARTSHOP(params: any) { + const data = await request(`/BasicConfig/DeleteOWNERSERVERPARTSHOP`, { + method: 'GET', + params + }); + + if (data.Result_Code !== 100) { + return data + } + + return data; +} \ No newline at end of file diff --git a/src/pages/basicManage/service.ts b/src/pages/basicManage/service.ts new file mode 100644 index 0000000..574d0a9 --- /dev/null +++ b/src/pages/basicManage/service.ts @@ -0,0 +1,75 @@ +/* + * @Author: zzy 411037547@qq.com + * @Date: 2022-04-28 10:47:35 + * @LastEditors: zzy 411037547@qq.com + * @LastEditTime: 2022-05-16 23:03:48 + * @FilePath: \cloud-platform\src\pages\basicManage\service.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { tableList, wrapTreeNode } from '@/utils/format'; +import request from '@/utils/request'; + + +// 获取列表数据 +export async function getBusniessBrandTree(params?: any) { + + const data = await request(`/BaseInfo/GetTradeBrandTree`, { + method: 'GET', + params, + }); + + if (data.Result_Code !== 100) { + return [] + } + + return wrapTreeNode(data.Result_Data.List); + +} + +// 获取经营商户 +export async function getBusinessMerchatsList(params?: any) { + + const data = await request(`/Merchants/GetTradeBrandMerchantsList`, { + method: 'POST', + data: { SearchParameter: { ...params }, keyWord: params.keyWord, PageIndex: params.current, pagesize: params.pageSize }, + }); + + if (data.Result_Code !== 100) { + return []; + } + + return tableList(data.Result_Data); +} + + +// 获取服务区门店简称 +export async function handleGetShopShortNames(params?: any) { + + const data = await request(`/BaseInfo/GetShopShortNames`, { + method: 'GET', + params, + }); + + if (data.Result_Code !== 100) { + return [] + } + + return data.Result_Data.List; + +} + +// 获取数据变更日志 +export async function handleGetChangeList(params?: any) { + + const data = await request(`/Log/GetChangeList`, { + method: 'GET', + params, + }); + + if (data.Result_Code !== 100) { + return [] + } + + return data.Result_Data.List; + +} \ No newline at end of file diff --git a/src/pages/travelMember/BookingMealOrder/components/orderDetailModal.tsx b/src/pages/travelMember/BookingMealOrder/components/orderDetailModal.tsx index d8b089e..2ef4f25 100644 --- a/src/pages/travelMember/BookingMealOrder/components/orderDetailModal.tsx +++ b/src/pages/travelMember/BookingMealOrder/components/orderDetailModal.tsx @@ -1,6 +1,6 @@ import { connect } from "umi"; import type { ConnectState } from "@/models/connect"; -import { Col, FormInstance, message, Modal, Row } from "antd"; +import { Button, Col, FormInstance, message, Modal, Popconfirm, Row, Space } from "antd"; import { useRef, useState } from "react"; import Draggable from "react-draggable"; import React from "react"; @@ -9,16 +9,26 @@ import moment from 'moment' import orderIcon from '@/assets/detail/orderIcon.png' import closeIcon from '@/assets/detail/closeIcon.png' import ProTable from "@ant-design/pro-table"; -import { handeGetSALEADDRESSList, handeGetSALEBILLDetail, handeGetSALEBILLList, handeGetSALEDETAILDetail, handeGetSALEDETAILList } from "../../service"; +import { PlusOutlined, DeleteOutlined } from '@ant-design/icons'; +import { handeDeleteSaleBillInfo, handeGetSALEADDRESSList, handeGetSALEBILLDetail, handeGetSALEBILLList, handeGetSALEDETAILDetail, handeGetSALEDETAILList, handeModifyTrackingInfo, handeSendSaleBillGoods } from "../../service"; import './style.less' +interface LogisticsInfo { + id: string; + company: string; + trackingNumber: string; +} + type DetailProps = { modalVisible: boolean //显示属性 handleCloseModal: any // 关闭调用的方法 currentRow: any detailType?: any // 判断是不是点餐的订单详情 可以显示不同内容 + showShipment?: boolean;// 判断 在待发货状态下 是否显示发货按钮 + currentUser?: any // 页面公参 + actionRef?: any// 父级表格实例 } -const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailType }: DetailProps) => { +const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailType, showShipment, currentUser, actionRef }: DetailProps) => { const formRef = useRef(); const draggleRef = React.createRef() const modalRef = useRef(); @@ -29,6 +39,10 @@ const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailTy const [disabled, setDraggleDisabled] = useState() // 是否拖动 // 订单详情 const [orderDetail, setOrderDetail] = useState() + // 物流信息列表 + const [logisticsList, setLogisticsList] = useState([ + { id: '1', company: '', trackingNumber: '' } + ]) const onDraggaleStart = (event, uiData) => { const { clientWidth, clientHeight } = window.document.documentElement; @@ -44,6 +58,44 @@ const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailTy }); }; + // 添加物流信息 + const addLogistics = () => { + const newLogistics: LogisticsInfo = { + id: Date.now().toString(), + company: '', + trackingNumber: '' + } + setLogisticsList([...logisticsList, newLogistics]) + } + + // 删除物流信息 + const removeLogistics = (id: string) => { + if (logisticsList.length > 1) { + const newList = logisticsList.filter(item => item.id !== id) + setLogisticsList(newList) + } else { + message.warning('至少保留一组物流信息') + } + } + + // 更新物流信息 + const updateLogistics = (id: string, field: 'company' | 'trackingNumber', value: string) => { + const newList = logisticsList.map((item: LogisticsInfo) => { + if (item.id === id) { + return { ...item, [field]: value } + } + return item + }) + setLogisticsList(newList) + } + + // 获取物流信息数据 + const getLogisticsData = () => { + return logisticsList.filter(logistics => + logistics.company.trim() && logistics.trackingNumber.trim() + ) + } + // 订单详情的表格 const orderDetailColumns: any = [ { @@ -97,6 +149,148 @@ const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailTy }, ] + // 商品发货 + const handleProductDelivery = async () => { + + console.log('logisticsList', logisticsList); + let isOk: boolean = false + let str: string = '' + if (currentRow?.TAKE_TYPE === 1000) { + isOk = true + } else { + if (logisticsList && logisticsList.length > 0) { + // 判断是否都是有值的 + let isAllHave: boolean = true + logisticsList.forEach((item: any) => { + if (!item.trackingNumber || !item.company) { + isAllHave = false + } + if (str) { + str += `,${item.trackingNumber}|${item.company}` + } else { + str = `${item.trackingNumber}|${item.company}` + } + }) + if (!isAllHave) { + message.error('请先输入物流公司和快递单号!') + return + } else { + isOk = true + } + } else { + message.error('请先输入物流公司和快递单号!') + return + } + } + + if (!isOk) { + return + } + const req: any = { + SaleBillChildId: currentRow?.SALEBILL_CHILD_ID, + SaleBillId: currentRow?.SALEBILL_ID, + TrackingInfo: str || "" + } + console.log('reqreq', req); + const data = await handeSendSaleBillGoods(req) + if (data.Result_Code === 100) { + message.success('发货成功!') + handleConfirmLoading(false) + if (handleCloseModal) { + handleCloseModal() + } + formRef.current?.resetFields(); + setLogisticsList([{ id: '1', company: '', trackingNumber: '' }]); + if (actionRef) { + actionRef.current?.reload() + } + } else { + message.error(data.Result_Desc) + } + } + + // 订单删除 + const handleGetDeleteOrder = async () => { + const req: any = { + SaleBillChildId: currentRow?.SALEBILL_CHILD_ID || "", + SaleBillId: currentRow?.SALEBILL_ID, + } + const data = await handeDeleteSaleBillInfo(req) + if (data.Result_Code === 100) { + message.success('删除成功!') + handleConfirmLoading(false) + if (handleCloseModal) { + handleCloseModal() + } + formRef.current?.resetFields(); + setLogisticsList([{ id: '1', company: '', trackingNumber: '' }]); + if (actionRef) { + actionRef.current?.reload() + } + } else { + message.error(data.Result_Desc) + } + + } + + // 更新物流信息 + const handleUpdateLogisticsInformation = async () => { + console.log('logisticsList', logisticsList); + let isOk: boolean = false + let str: string = '' + if (currentRow?.TAKE_TYPE === 1000) { + isOk = true + } else { + if (logisticsList && logisticsList.length > 0) { + // 判断是否都是有值的 + let isAllHave: boolean = true + logisticsList.forEach((item: any) => { + if (!item.trackingNumber || !item.company) { + isAllHave = false + } + if (str) { + str += `,${item.trackingNumber}|${item.company}` + } else { + str = `${item.trackingNumber}|${item.company}` + } + }) + if (!isAllHave) { + message.error('请先输入物流公司和快递单号!') + return + } else { + isOk = true + } + } else { + message.error('请先输入物流公司和快递单号!') + return + } + } + + if (!isOk) { + return + } + const req: any = { + SaleBillChildId: currentRow?.SALEBILL_CHILD_ID, + SaleBillId: currentRow?.SALEBILL_ID, + TrackingInfo: str || "" + } + const data = await handeModifyTrackingInfo(req) + if (data.Result_Code === 100) { + message.success('更新成功!') + handleConfirmLoading(false) + if (handleCloseModal) { + handleCloseModal() + } + formRef.current?.resetFields(); + setLogisticsList([{ id: '1', company: '', trackingNumber: '' }]); + if (actionRef) { + actionRef.current?.reload() + } + } else { + message.error(data.Result_Desc) + } + } + return (
{ formRef.current?.resetFields(); + setLogisticsList([{ id: '1', company: '', trackingNumber: '' }]); // setCurrentRow(undefined); }} onCancel={() => { @@ -123,7 +318,48 @@ const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailTy // handleModalVisible(false) // setCurrentRow(undefined); }} - footer={false} + footer={showShipment ? +
+
+ { + currentUser?.UserPattern === 9000 ? + { + await handleGetDeleteOrder() + }} + > + + : "" + } +
+
+ { + currentRow?.SALEBILL_STATE > 1020 && currentRow?.SALEBILL_STATE < 3000 ? + { + await handleUpdateLogisticsInformation() + }} + > + + : + currentRow?.SALEBILL_STATE === 1020 ? + + { + await handleProductDelivery() + }} + > + + : '' + } + +
+ +
+ : false} modalRender={(modal) => { return 0) { + list.forEach((item: any, index: number) => { + res.push({ + id: index + 1, + company: item.split('|')[1], + trackingNumber: item.split('|')[0], + }) + }) + } + if (res && res.length > 0) { + setLogisticsList(res) + } else { + setLogisticsList([{ id: '1', company: '', trackingNumber: '' }]); + } + } + return { ...data, ORDER_PERSON: addressObj?.USER_NAME || "", @@ -468,6 +724,90 @@ const OrderDetailModal = ({ modalVisible, handleCloseModal, currentRow, detailTy /> + + { + showShipment ? + <> + +
+
+ 物流信息 + +
+ {logisticsList.map((logistics, index) => ( +
+ + + {index + 1}. + + +
+ + updateLogistics(logistics.id, 'company', e.target.value)} + style={{ + width: '100%', + padding: '4px 11px', + border: '1px solid #d9d9d9', + borderRadius: '6px', + fontSize: '14px' + }} + /> +
+ + +
+ + updateLogistics(logistics.id, 'trackingNumber', e.target.value)} + style={{ + width: '100%', + padding: '4px 11px', + border: '1px solid #d9d9d9', + borderRadius: '6px', + fontSize: '14px' + }} + /> +
+ + + + +
+
+ ))} +
+ + : "" + } +
diff --git a/src/pages/travelMember/BookingMealOrder/components/style.less b/src/pages/travelMember/BookingMealOrder/components/style.less index 5afa067..94b47f9 100644 --- a/src/pages/travelMember/BookingMealOrder/components/style.less +++ b/src/pages/travelMember/BookingMealOrder/components/style.less @@ -31,6 +31,7 @@ background-color: #fff; border-top-left-radius: 16px; border-top-right-radius: 16px; + z-index: 999; .modalTopLeft { display: flex; diff --git a/src/pages/travelMember/MallOrderManage/index.tsx b/src/pages/travelMember/MallOrderManage/index.tsx index 14e37b9..7db1c7a 100644 --- a/src/pages/travelMember/MallOrderManage/index.tsx +++ b/src/pages/travelMember/MallOrderManage/index.tsx @@ -83,7 +83,7 @@ const MallOrderManage: React.FC<{ currentUser: CurrentUser, isComponent?: boolea } }, // initialValue: [moment().add(-1, 'M').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')], - initialValue: [moment().startOf('M'), moment()], + initialValue: [moment(moment().subtract(1, 'd')).startOf('M'), moment()], }, { title: "订单状态", @@ -100,7 +100,7 @@ const MallOrderManage: React.FC<{ currentUser: CurrentUser, isComponent?: boolea "9000": "订单已关闭", "9999": "订单已撤销" }, - initialValue: '0', + initialValue: '1010', hideInTable: true, }, { @@ -545,7 +545,7 @@ const MallOrderManage: React.FC<{ currentUser: CurrentUser, isComponent?: boolea
- + {/* = (props) => } }, // initialValue: [moment().add(-1, 'M').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')], - initialValue: [moment().startOf('M'), moment()], + initialValue: [moment(moment().subtract(1, 'd')).startOf('M'), moment()], }, { title: "订单状态", @@ -266,6 +266,57 @@ const OrderAfterSalesManage: React.FC<{ currentUser: CurrentUser }> = (props) => setCurrentRow(undefined); } + // // 删除订单 + // const handleGetDeleteOrder = async () => { + + // } + // 同意退款 + const handleGetAgreeToRefund = async () => { + console.log('currentRowcurrentRowcurrentRow', currentRow); + const req: any = { + mchid: "1672298991", + serial_no: "5BA7C0F427FC042DB5BF299E35B373D5EFCECD35", + mobileOrderCode: "", + saleBillCode: currentRow?.TABLE_NUMBER, + refundBillCode: currentRow?.SALEBILL_CODE, + refundReason: currentRow?.SALEBILL_DESC || "", + orderAmount: currentRow?.PAY_AMOUNT, + refundAmount: currentRow?.PAY_AMOUNT, + provinceCode: "530000" + } + console.log('reqreq', req); + const data = await handeWeChatRefundApply(req) + if (data.Result_Code === 100) { + message.success('退款成功!') + handleConfirmLoading(false) + handleModalVisible(false) + setCurrentRow(undefined); + + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + } + // 撤销退款 + const handleGetCancelRefund = async () => { + console.log('currentRowcurrentRowcurrentRow', currentRow); + const req: any = { + SaleBillChildId: "", + SaleBillId: currentRow?.SALEBILL_ID, + TrackingInfo: "" + } + const data = await handeWeRevokeRefundApply(req) + if (data.Result_Code === 100) { + message.success('撤销成功!') + handleConfirmLoading(false) + handleModalVisible(false) + setCurrentRow(undefined); + + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + } return (
@@ -367,7 +418,42 @@ const OrderAfterSalesManage: React.FC<{ currentUser: CurrentUser }> = (props) => handleModalVisible(false) setCurrentRow(undefined); }} - footer={false} + footer={
+ {/* style={{ width: "100%", display: 'flex', alignItems: 'center', justifyContent: 'space-between' }} */} + {/*
+ { + currentUser?.UserPattern === 9000 ? + { + await handleGetDeleteOrder() + }} + > + + : "" + } +
*/} +
+ { + await handleGetCancelRefund() + }} + > + + + { + await handleGetAgreeToRefund() + }} + > + + + +
+ +
} modalRender={(modal) => { return = (props) => ]} /> - + {/* = (props) => { label: "预约", value: 2000 }, ]} /> - - + */} + {/* = (props) => readonly style={{ marginBottom: '16px' }} /> - + */}
diff --git a/src/pages/travelMember/ProductListingManagement/index.tsx b/src/pages/travelMember/ProductListingManagement/index.tsx index a4b570e..81b7735 100644 --- a/src/pages/travelMember/ProductListingManagement/index.tsx +++ b/src/pages/travelMember/ProductListingManagement/index.tsx @@ -24,7 +24,7 @@ import { getFieldEnumTree, getFieldEnumName } from "@/services/options"; // 枚 import { getList, delcommodity, updatecommodity } from './service'; // 接口相关对象的引用 import PageTitleBox from "@/components/PageTitleBox"; import LeftSelectMallType from './component/LeftSelectMallType'; -import { handeDeleteCOMMODITY, handeDeleteRTCOMMODITY_MULTI, handeGetCOMMODITY_MULTIList, handeGetCOMMODITYDetail, handeGetCOMMODITYList, handeGetMERCHANTSList, handeGetRTCOMMODITY_MULTIList, handeSetCommodityState, handeSynchroCOMMODITY, handeSynchroRTCOMMODITYMULTIList, handleGetBRANDList, handlGetUSERDEFINEDTYPEList } from '../service'; +import { handeDeleteCOMMODITY, handeDeleteRTCOMMODITY_MULTI, handeGetCOMMODITY_MULTIList, handeGetCOMMODITYDetail, handeGetCOMMODITYList, handeGetMERCHANTSList, handeGetRTCOMMODITY_MULTIList, handeSetCommodityState, handeSetGoodsDutyParagraph, handeSynchroCOMMODITY, handeSynchroRTCOMMODITYMULTIList, handleGetBRANDList, handlGetUSERDEFINEDTYPEList } from '../service'; import session from '@/utils/session'; import { deleteAHYDPicture, deletePicture, uploadAHYDPicture, uploadPicture } from '@/services/picture'; import { handleSetlogSave } from '@/utils/format'; @@ -49,6 +49,8 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop const { confirm } = Modal; const actionRef = useRef(); const ruleActionRef = useRef(); + // 税率的表单 + const rateFormRef = useRef(); const formRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [showDetail, setShowDetail] = useState(); @@ -103,6 +105,10 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop const [toListLoading, setToListLoading] = useState(false) // 当前查询的文字 const [currentSearchText, setCurrentSearchText] = useState('') + // 税率悬浮框 + const [showRateModal, setShowRateModal] = useState(false) + // 税率悬浮框的加载效果 + const [rateLoading, setRateLoading] = useState(false) // 预览上传后的图片 const handlePreview = async (type: number) => { @@ -682,6 +688,16 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop } } + // 设置税率 + const handleSetTaxRate = async () => { + if (selectShopRowKey && selectShopRowKey.length > 0) { + console.log('selectShopRowKeyselectShopRowKeyselectShopRowKey', selectShopRowKey); + setShowRateModal(true) + } else { + message.error('请先选择商品!') + } + } + return (
@@ -752,25 +768,40 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop 新增商品 , , - + <> + { + currentUser?.UserPattern !== 4000 ? + <> + < Button + key="new" + type="primary" + loading={toListLoading} + onClick={() => { + handleBatchShopShelves(1) + }} + > + 审核上架 + + + : "" + } + ], }} pagination={{ defaultPageSize: 10 }} @@ -1148,7 +1179,8 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop message: "请选择供货商户" } ]} - + disabled={currentUser?.UserPattern === 4000} + initialValue={currentUser?.UserPattern === 4000 ? currentUser?.SupplierName : ''} /> 商品信息 @@ -1360,6 +1392,8 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop message: "请输入小程序!" } ]} + disabled={currentUser?.UserPattern === 4000 ? true : false} + initialValue={currentUser?.UserPattern === 4000 ? 38 : ''} /> @@ -1376,7 +1410,7 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop { label: "未上架", value: 0 }, { label: "已上架", value: 1 }, ]} - disabled={currentUser?.SupplierID ? true : false} + disabled={currentUser?.SupplierID || currentUser?.UserPattern === 4000 ? true : false} /> @@ -1768,6 +1802,63 @@ const COMMODITYTable: React.FC<{ currentUser: CurrentUser | undefined }> = (prop + + + {/* 税率悬浮框 */} + { + setShowRateModal(false) + }} + onOk={async () => { // 提交框内的数据 + rateFormRef.current?.validateFields().then(res => { + rateFormRef.current?.submit() + }) + }} + > + + { + const req: any = { + CommodityIds: selectShopRowKey.toString(), + DutyParagraph: value.selectRate + } + setRateLoading(true) + const data = await handeSetGoodsDutyParagraph(req) + setRateLoading(false) + if (data.Result_Code === 100) { + message.success('设置成功!') + setShowRateModal(false) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + + + }} + > + + + +
); diff --git a/src/pages/travelMember/service.ts b/src/pages/travelMember/service.ts index 4ed3829..ad9826d 100644 --- a/src/pages/travelMember/service.ts +++ b/src/pages/travelMember/service.ts @@ -1284,3 +1284,78 @@ export async function handeDeleteSERVERPARTSELLER(params: any) { } return data } + + +// 微信支付退款申请 +export async function handeWeChatRefundApply(params: any) { + const data = await requestEncryption(`/WeChatPay/WeChatRefundApply`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return data + } + return data +} + + +// 微信支付撤销退款申请 +export async function handeWeRevokeRefundApply(params: any) { + const data = await requestEncryption(`/WeChatPay/RevokeRefundApply`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return data + } + return data +} + + +// 订单发货 +export async function handeSendSaleBillGoods(params: any) { + const data = await requestEncryption(`/OnlineOrder/SendSaleBillGoods`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return data + } + return data +} + +// 更新物流信息 +export async function handeModifyTrackingInfo(params: any) { + const data = await requestEncryption(`/OnlineOrder/ModifyTrackingInfo`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return data + } + return data +} + +// 删除订单信息 +export async function handeDeleteSaleBillInfo(params: any) { + const data = await requestEncryption(`/OnlineOrder/DeleteSaleBillInfo`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return data + } + return data +} + +// 设置商品税率 +export async function handeSetGoodsDutyParagraph(params: any) { + const data = await requestEncryption(`/MallBasic/SetGoodsDutyParagraph`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return data + } + return data +} diff --git a/src/versionEnv.ts b/src/versionEnv.ts index 98d6a79..c58944d 100644 --- a/src/versionEnv.ts +++ b/src/versionEnv.ts @@ -1,4 +1,4 @@ // 由 scripts/writeVersion.js 自动生成 -export const VERSION = "4.5.65"; -export const GIT_HASH = "cc91234"; -export const BUILD_TIME = "2025-10-31T09:52:44.987Z"; +export const VERSION = "4.5.66"; +export const GIT_HASH = "4be0bb5"; +export const BUILD_TIME = "2025-11-01T07:07:35.002Z";