From 4c7c8707abd979e0392dd42695b2f204c587e998 Mon Sep 17 00:00:00 2001 From: ylj20011123 Date: Thu, 3 Jul 2025 21:06:54 +0800 Subject: [PATCH] update --- config/routes.ts | 30 + src/layouts/BasicLayout.tsx | 30 + .../NewProductApproval/index.tsx | 1164 ++++++++++++++ .../ProductApprovalProcess/index.tsx | 228 +++ .../ProductApprovalProcess/service.ts | 82 + .../ProductChangeInfoApproval/index.tsx | 1349 +++++++++++++++++ .../ProductChangePriceApproval/index.tsx | 904 +++++++++++ .../travelMember/scenicSpotConfig/index.tsx | 670 ++++++++ src/pages/travelMember/service.ts | 37 + src/utils/request.ts | 8 +- 10 files changed, 4501 insertions(+), 1 deletion(-) create mode 100644 src/pages/reports/productControl/NewProductApproval/index.tsx create mode 100644 src/pages/reports/productControl/ProductApprovalProcess/index.tsx create mode 100644 src/pages/reports/productControl/ProductApprovalProcess/service.ts create mode 100644 src/pages/reports/productControl/ProductChangeInfoApproval/index.tsx create mode 100644 src/pages/reports/productControl/ProductChangePriceApproval/index.tsx create mode 100644 src/pages/travelMember/scenicSpotConfig/index.tsx diff --git a/config/routes.ts b/config/routes.ts index ad99775..2811740 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -438,6 +438,30 @@ export default [ name: 'setUserDefinedType', component: './reports/productControl/setUserDefinedType', }, + { + path: 'ProductApprovalProcess', + name: 'ProductApprovalProcess', + component: './reports/productControl/ProductApprovalProcess', + }, + // 新增商品流程 + { + path: 'NewProductApproval', + name: 'NewProductApproval', + component: './reports/productControl/NewProductApproval', + }, + // 商品调价审批 + { + path: 'ProductChangePriceApproval', + name: 'ProductChangePriceApproval', + component: './reports/productControl/ProductChangePriceApproval', + }, + // 商品信息修改审批 + { + path: 'ProductChangeInfoApproval', + name: 'ProductChangeInfoApproval', + component: './reports/productControl/ProductChangeInfoApproval', + }, + { path: 'highwayHeadlines', name: 'highwayHeadlines', @@ -963,6 +987,12 @@ export default [ name: 'serverpartInfo', component: './travelMember/serverpartInfo/index' }, + // 景区信息配置 + { + path: 'scenicSpotConfig', + name: 'scenicSpotConfig', + component: './travelMember/scenicSpotConfig/index' + } ] }, { diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 2739bf7..eea14b6 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -205,6 +205,36 @@ const BasicLayout: React.FC = (props) => { // 拿到所有枚举的方法 const handleGetAllFieldEnum = async () => { + // 景区状态 + getFieldEnumTree({ FieldExplainField: 'BUSINESSSTATE' }).then((BUSINESSSTATE: any) => { + if (BUSINESSSTATE && BUSINESSSTATE.length > 0) { + const obj: any = {} + const list: any = [] + BUSINESSSTATE.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + obj[item.value] = item.label + }) + session.set('BUSINESSSTATEList', list); + session.set('BUSINESSSTATEObj', obj); + session.set('BUSINESSSTATETree', BUSINESSSTATE); + } + }) + + // 景区类型 + getFieldEnumTree({ FieldExplainField: 'SCENICAREA_TYPE' }).then((SCENICAREATYPE: any) => { + if (SCENICAREATYPE && SCENICAREATYPE.length > 0) { + const obj: any = {} + const list: any = [] + SCENICAREATYPE.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + obj[item.value] = item.label + }) + session.set('SCENICAREATYPEList', list); + session.set('SCENICAREATYPEObj', obj); + session.set('SCENICAREATYPETree', SCENICAREATYPE); + } + }) + // 承载情况 getFieldEnumTree({ FieldExplainField: 'LOAD_BEARING' }).then((LOADBEARING: any) => { if (LOADBEARING && LOADBEARING.length > 0) { diff --git a/src/pages/reports/productControl/NewProductApproval/index.tsx b/src/pages/reports/productControl/NewProductApproval/index.tsx new file mode 100644 index 0000000..ea44394 --- /dev/null +++ b/src/pages/reports/productControl/NewProductApproval/index.tsx @@ -0,0 +1,1164 @@ +// 新增商品审批 +import { connect } from "umi"; +import type { CurrentUser } from "umi"; +import type { ConnectState } from "@/models/connect"; +import React, { useRef, useState } from "react"; +import type { FormInstance } from "antd"; +import { Button, Col, message, Modal, Popconfirm, Row, Space, Spin, Tree } from "antd"; +import type { ActionType } from "@ant-design/pro-table"; +import ProTable from "@ant-design/pro-table"; +import PageTitleBox from "@/components/PageTitleBox"; +import { handleGetExamineList } from "@/pages/examine/examineList/service"; +import ProForm, { ProFormDateTimePicker, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form"; +import { getServerpartTree } from "@/services/options"; +import { handleGetAPPROVALROUTEList } from "@/pages/Setting/serviceConfig/service"; +import { handleGetNestingCOMMODITYTYPETree, handleGetServerpartShopTrade } from "../commodityInfo/service"; +import { handleGetUSERDEFINEDTYPEList } from "../userDefinedType/service"; +import useRequest from "@ahooksjs/use-request"; +import moment from 'moment' +import { handleApproveCommodityProInst, handleCreateCommodityProInst, handleGetBUSINESSAPPROVALDetail, handleGetCOMMODITYRUNNINGList, handleRejectCommodityProInst } from "../ProductApprovalProcess/service"; + +const ProductChangeInfoApproval: React.FC<{ currentUser: CurrentUser }> = (props) => { + const { currentUser } = props + const downloadBtnRef = useRef() + const actionRef = useRef(); + const formRef = useRef(); + const modalFormRef = useRef(); + const modalShopFormRef = useRef(); + const modalApproveFormRef = useRef(); + + // 新增商品申请 + const [showApplyFor, setShowApplyFor] = useState(false); + // 显示新增商品的悬浮框 + const [showAddShopModal, setShowAddShopModal] = useState(false); + // 选择的当前商品行 + const [currentRow, setCurrentRow] = useState() + // 商品列表数据 + const [shopData, setShopData] = useState() + const [selectSERVERPARTID, setSelectSERVERPARTID] = useState() + // 商品业态的搜索框内容 + const [commodityList, setCommodityList] = useState([]) + const [selectBUSINESSTYPE, setSelectBUSINESSTYPE] = useState() + const [customClassList, setCustomClassList] = useState() + const [treeView, setTreeView] = useState() + // 审批的悬浮框 + const [approveModal, setApproveModal] = useState(false); + // 点击审批的行数据 + const [approveCurrentRow, setApproveCurrentRow] = useState() + // 下一个审批流程 + const [nextApproval, setNextApproval] = useState() + // 下一审批流程的审批人 + const [nextApprovalPerson, setNextApprovalPerson] = useState() + // 新增申请的加载效果 + const [addApprovalLoading, setAddApprovalLoading] = useState(false); + // 审批还是驳回 1 审批 2 驳回 + const [ApprovalType, setApprovaType] = useState(0) + // 审批记录详情 + const [BUSINESSAPPROVALDETAIL, setBUSINESSAPPROVALDETAIL] = useState() + // 加载服务区树 + const { loading: treeLoading, data: treeViews } = useRequest(async () => { + const req = { + PROVINCE_CODE: currentUser?.ProvinceCode, + COMMODITYTYPE_VALID: 1, + ShowCode: true + } + const data = await handleGetNestingCOMMODITYTYPETree(req) + setTreeView(data) + return data + }) + + const columns: any = [ + { + dataIndex: 'BusinessProcess_StateSearch', + title: '流程状态', + width: 200, + ellipsis: true, + align: 'center', + hideInTable: true, + valueEnum: { + "0": "全部", + "2000": "待审核", + "2010,2020,2030,2040,2050,2060,2070,2080,2090": "审核中", + "9000": "已审结" + }, + }, + { + dataIndex: 'BusinessProcess_Name', + title: '业务名称', + width: 300, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Serverpart_Name', + title: '服务区名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ServerpartShop_Name', + title: '门店名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ApproveStaff_Name', + title: '待审核人', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StateText', + title: '待审核环节', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Accept_Code', + title: '业务类别', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_EndDate', + title: '办结时间', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StartDate', + title: '流程开始', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + align: 'center', + hideInSearch: true, + width: 120, + fixed: "right", + ellipsis: true, + render: (_, record) => { + return ( + record?.ApproveStaff_ID === currentUser?.ID && record?.BusinessProcess_State !== 9000 + ? + + { + record?.BusinessProcess_State === 1000 + ? + { + setShowApplyFor(true) + setCurrentRow(record) + }} + > + 编辑 + : "" + } + { + setApprovaType(1) + setApproveCurrentRow(record) + setApproveModal(true) + }} + > + 审批 + + { + setApprovaType(2) + setApproveCurrentRow(record) + setApproveModal(true) + }}> + 驳回 + + : "" + + ); + }, + }, + ] + + const modalColumns: any = [ + { + title: "序号", + width: 70, + dataIndex: "index", + valueType: "index", + align: 'center', + ellipsis: true, + }, + { + title: "名称", + width: 300, + dataIndex: "COMMODITY_NAME", + ellipsis: true, + align: 'center', + }, + { + title: "条码", + width: 150, + dataIndex: "COMMODITY_BARCODE", + ellipsis: true, + align: 'center', + }, + { + title: "零售价", + width: 150, + dataIndex: "COMMODITY_RETAILPRICE", + ellipsis: true, + align: 'center', + }, + { + title: "规格", + width: 150, + dataIndex: "COMMODITY_RULE", + ellipsis: true, + align: 'center', + }, + { + title: "单位", + width: 150, + dataIndex: "COMMODITY_UNIT", + ellipsis: true, + align: 'center', + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + align: 'center', + hideInSearch: true, + width: 120, + fixed: "right", + ellipsis: true, + render: (_, record) => { + return ( + + { + setCurrentRow(record) + setShowAddShopModal(true) + }} + > + 编辑 + + { + console.log('record', record); + let oldData: any = JSON.parse(JSON.stringify(shopData)) + let list: any = [] + oldData.forEach((item: any) => { + if (item.ADDTIME !== record?.ADDTIME) { + list.push(item) + } + }) + setShopData(list) + + }} + > + 删除 + + + ); + }, + }, + ] + + // 拿到对应的商品业态 + const handleGetCommodity = async (id: any) => { + const req: any = { + ProvinceCode: currentUser?.ProvinceCode, + ServerpartId: id + } + const data = await handleGetServerpartShopTrade(req) + console.log('data', data) + setCommodityList(data) + } + + // 请求自定义类的选择列表 + const handleGetCustomClassList = async (id: any) => { + const req: any = { + SearchParameter: { + USERDEFINEDTYPE_STATE: 1, + SERVERPART_ID: id, + BUSINESSTYPE: selectBUSINESSTYPE + }, + PageIndex: 1, + PageSize: 999999, + pageSize: 999999, + } + const data = await handleGetUSERDEFINEDTYPEList(req) + if (data && data.length > 0) { + const list: any = [] + data.forEach((item: any) => { + list.push({ label: item.USERDEFINEDTYPE_NAME, value: item.USERDEFINEDTYPE_ID }) + }) + setCustomClassList(list) + } + console.log('data', data) + } + + + return ( +
+
+
+ } // 列表表头 + search={{ span: 6 }} + request={async (params) => { + const req: any = { + QueryType: 0, + SearchParameter: { + Operation_Type: 6, + Accept_Code: "6-100100", + BusinessProcess_StateSearch: params?.BusinessProcess_StateSearch === 0 ? '' : params?.BusinessProcess_StateSearch + }, + PageIndex: 1, + PageSize: 999999 + } + const data = await handleGetExamineList(req) + console.log('data', data) + if (data.data && data.data.length > 0) { + data.data.forEach((item: any) => { + if (item.BusinessProcess_State === 1000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State === 2000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State > 2000 && item.BusinessProcess_State < 9000) { + item.BusinessProcess_StateText = "审核中" + } else if (item.BusinessProcess_State = 9000) { + item.BusinessProcess_StateText = "已审结" + } + }) + + + return { data: data.data, success: true, total: data.data.length } + } + return { data: [], success: true } + }} + toolbar={{ + actions: [ + + ] + }} + /> +
+
+ + {/* 审批的悬浮框 */} + { + setApproveCurrentRow(undefined) + setApproveModal(false) + setApprovaType(0) + }} + onOk={() => { + modalApproveFormRef?.current?.validateFields().then(() => { + modalApproveFormRef?.current?.submit() + }) + }} + > + { + console.log('approveCurrentRowapproveCurrentRowapproveCurrentRow', approveCurrentRow); + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: "100100", + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + console.log('dataStatedataStatedataState', dataState); + let obj: any = {} + let currentIndex: number = 0 + if (dataState && dataState.length > 0) { + dataState.forEach((item: any, index: number) => { + if (item.APPROVALROUTE_STATE === approveCurrentRow.BusinessProcess_State) { + obj = item + currentIndex = index + } + }) + } + if (obj) { + // 审批的时候 拿到当前状态 去找下一个状态 + if (ApprovalType === 1) { + // 拿到当前状态的信息 判断下一状态 是不是结束了 结束了 就不显示 下一结算审批人 不是结束 就拿到下一流程的审批人 + setNextApproval(obj.NEXT_STATE) + let nextObj: any = currentIndex + 1 <= dataState.length ? dataState[currentIndex + 1] : {} + if (nextObj) { + let personTotal: number = nextObj.APPROVALSTAFF_ID.split(',').length || 0 + if (personTotal > 0) { + let STAFFIDList: number[] = nextObj.APPROVALSTAFF_ID.split(',') + let STAFFNAMEList: string[] = nextObj.APPROVALSTAFF_NAME.split(',') + let list: any = [] + for (let i = 0; i < personTotal; i++) { + list.push({ label: STAFFNAMEList[i], value: STAFFIDList[i] }) + } + setNextApprovalPerson(list) + } + } + } else { + // 驳回的话 去找历史状态 + if (dataState && dataState.length > 0) { + let list: any = [] + dataState.forEach((item: any, index: number) => { + if (obj.APPROVALROUTE_STATE > item.APPROVALROUTE_STATE) { + list.push({ label: item.APPROVALROUTE_NAME, value: item.APPROVALROUTE_STATE }) + } + }) + setNextApprovalPerson(list) + } + + } + + } + return {} + }} + onFinish={async (res) => { + setAddApprovalLoading(true) + let data: any = {} + + if (ApprovalType === 1) { + // 审批 + const req: any = { + businessApprovalId: approveCurrentRow?.BusinessApproval_ID, + UserId: currentUser?.ID, + ApproveInfo: res.ApproveInfo, + nextApproveStaffId: res.nextApproveStaffId || "", + nextApproveState: nextApproval || "" + } + + data = await handleApproveCommodityProInst(req) + } else { + // 驳回 + const req: any = { + businessApprovalId: approveCurrentRow?.BusinessApproval_ID, + UserId: currentUser?.ID, + RejectInfo: res.ApproveInfo, + nextApproveState: res.nextApproveState || "" + } + console.log('reqreqreqreq', req); + + data = await handleRejectCommodityProInst(req) + } + setAddApprovalLoading(false) + console.log('datadatadata', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + setApproveCurrentRow(undefined) + setApproveModal(false) + setNextApproval(null) + setNextApprovalPerson(null) + setApprovaType(0) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + + }} + > + { + ApprovalType === 1 ? + + { + nextApproval === 9000 ? '' : + + + + + } + + + + : ApprovalType === 2 ? + + + + + + + + + : "" + } + + + + {/* 新增申请的悬浮框 */} + { + setShowApplyFor(false) + setCurrentRow(undefined) + setShopData([]) + setBUSINESSAPPROVALDETAIL(undefined) + }} + onOk={() => { + formRef?.current?.validateFields().then(() => { + modalFormRef?.current?.submit() + }) + + }} + > + { + if (currentRow?.BusinessApproval_ID) { + const req: any = { + BUSINESSAPPROVALId: currentRow?.BusinessApproval_ID, + } + const data = await handleGetBUSINESSAPPROVALDetail(req) + console.log('datadatadata', data); + setBUSINESSAPPROVALDETAIL(data.Result_Data) + + const shopData = await handleGetCOMMODITYRUNNINGList({ + SearchParameter: { + BUSINESSAPPROVAL_ID: currentRow?.BusinessApproval_ID, + }, + PageIndex: 1, + pageSize: 999999, + }) + console.log('shopDatashopDatashopDatashopData', shopData); + setShopData(shopData.Result_Data.List) + return { + reasonForApplication: data.Result_Data.BUSINESSAPPROVAL_DESC, + ServerpartId: data.Result_Data.SERVERPART_ID, + NextApproveStaffId: data.Result_Data.APPOVED_IDS + } + } else { + return false + } + }} + onFinish={async (res) => { + const req: any = { + ProinstName: res.reasonForApplication, + UserId: currentUser?.ID, + OperateType: "100100", + ServerpartId: res.ServerpartId, + NextApproveStaffId: res.NextApproveStaffId, + NextApproveState: 2000, + CommodityRunningList: shopData + } + const data = await handleCreateCommodityProInst(req) + console.log('dsaidjaskda', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + setShowApplyFor(false) + setCurrentRow(undefined) + actionRef.current?.reload() + + } else { + message.error(data.Result_Desc) + } + + }} + > + + + + + + { + const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) + const list: any = [] + if (data && data.length > 0) { + data.forEach((item: any) => { + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + list.push({ label: subItem.label, value: subItem.value }) + }) + } + }) + data.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + }) + } + return list + }} + /> + + + { + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: "100100", + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + if (dataState && dataState.length > 0) { + let obj: any = {} + console.log('dataState', dataState); + + dataState.forEach((item: any) => { + if (item.APPROVALROUTE_STATE === 2000) { + obj = item + } + }) + let personTotal: number = obj.APPROVALSTAFF_ID.split(',').length || 0 + if (personTotal > 0) { + let STAFFIDList: number[] = obj.APPROVALSTAFF_ID.split(',') + let STAFFNAMEList: string[] = obj.APPROVALSTAFF_NAME.split(',') + let list: any = [] + for (let i = 0; i < personTotal; i++) { + list.push({ label: STAFFNAMEList[i], value: STAFFIDList[i] }) + } + return list + } + } + }} + /> + + + + + { + setShowAddShopModal(true) + }}> + 新增商品 + + ] + }} + /> + + + + + {/* 新增商品的悬浮框 */} + { + modalShopFormRef.current?.validateFields().then(async (res: any) => { + let oldData: any = shopData && shopData.length > 0 ? JSON.parse(JSON.stringify(shopData)) : [] + let newList: any = [] + // 判断当前的里面有没有一样的 + if (oldData && oldData.length > 0) { + oldData.forEach((item: any, index: number) => { + if (item.ADDTIME === res.ADDTIME) { + newList.push(res) + } else { + newList.push(item) + } + }) + } else { + newList.push(res) + } + + setShopData(newList) + setShowAddShopModal(false) + setCommodityList([]) + setCustomClassList([]) + setCurrentRow(undefined) + }) + }} + onCancel={() => { + setShowAddShopModal(false) + setCommodityList([]) + setCustomClassList([]) + setCurrentRow(undefined) + }} + > + + +
商品基本信息
+ + + + + + + + + + { + const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) + const list: any = [] + if (data && data.length > 0) { + data.forEach((item: any) => { + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + list.push({ label: subItem.label, value: subItem.value }) + }) + } + }) + data.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + }) + } + return list + }} + rules={[ + { + required: true, + message: '请选择服务区', + }, + ]} + fieldProps={{ + onChange: async (e: any) => { + console.log('e', e) + if (e) { + setSelectSERVERPARTID(e) + await handleGetCommodity(e) + if (selectBUSINESSTYPE) { + await handleGetCustomClassList(e) + } + } else { + setSelectSERVERPARTID(undefined) + setCommodityList([]) + setCustomClassList([]) + } + } + }} + /> + + + { + if (e) { + setSelectBUSINESSTYPE(e) + if (selectSERVERPARTID) { + await handleGetCustomClassList(e) + } + } else { + setSelectBUSINESSTYPE(undefined) + } + } + }} + /> + + + { + return treeView + }} + fieldProps={{ + treeDefaultExpandAll: true + }} + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商品状态信息
+ + + + + + + + + + + + + + + + + + + + + + +
商品价格信息
+ + + + + + + + + + + + + + + + + + + + + +
商品进销信息
+ + + + + + + + + + + +
+
+
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(ProductChangeInfoApproval); diff --git a/src/pages/reports/productControl/ProductApprovalProcess/index.tsx b/src/pages/reports/productControl/ProductApprovalProcess/index.tsx new file mode 100644 index 0000000..567c245 --- /dev/null +++ b/src/pages/reports/productControl/ProductApprovalProcess/index.tsx @@ -0,0 +1,228 @@ +// 商品审批流程 +import { connect } from "umi"; +import type { CurrentUser } from "umi"; +import type { ConnectState } from "@/models/connect"; +import React, { useEffect, useRef, useState } from "react"; +import ProCard from "@ant-design/pro-card"; +import { MenuFoldOutlined } from "@ant-design/icons"; +import type { FormInstance } from "antd"; +import { Button, message, Space, Spin, Tree } from "antd"; +import useRequest from "@ahooksjs/use-request"; +import { getServerpartTree } from "@/services/options"; +import type { ActionType } from "@ant-design/pro-table"; +import ProTable from "@ant-design/pro-table"; +import ReactHTMLTableToExcel from "react-html-table-to-excel"; +import LeftSelectTree from "@/pages/reports/settlementAccount/component/leftSelectTree"; +import PageTitleBox from "@/components/PageTitleBox"; +import { handleGetExamineList } from "@/pages/examine/examineList/service"; +import { handleGetAPPROVALROUTEList } from "@/pages/Setting/serviceConfig/service"; + + +const ProductApprovalProcess: React.FC<{ currentUser: CurrentUser }> = (props) => { + const { currentUser } = props + const actionRef = useRef(); + const formRef = useRef(); + const [reqDetailList, setReqDetailList] = useState(); // 合计项数据源 + const [printOut, setPrintOut] = useState(); // 打印数据的内容 + // 审批类型数据 + const [searchTypeData, setSearchTypeData] = useState() + // 当前业务审批的枚举 + const [currentExamine, setCurrentExamine] = useState() + // 判断当前用户是否有发起按钮 + const [currentShowInitiate, setCurrentShowInitiate] = useState(false) + + useEffect(async () => { + await handleChangeType("6-100100") + }, []) + + const columns: any = [ + { + dataIndex: 'searchType', + title: '审批类型', + width: 200, + ellipsis: true, + align: 'center', + hideInTable: true, + valueEnum: { + "0": "全部", + "6-100100": "新增商品流程", + "6-100200": "商品调价流程", + "6-100210": "信息修改流程" + }, + initialValue: "6-100100", + }, + { + dataIndex: 'BusinessProcess_StateSearch', + title: '流程状态', + width: 200, + ellipsis: true, + align: 'center', + hideInTable: true, + valueEnum: { + "0": "全部", + "2000": "待审核", + "2010,2020,2030,2040,2050,2060,2070,2080,2090": "审核中", + "9000": "已审结" + }, + }, + { + dataIndex: 'BusinessProcess_Name', + title: '业务名称', + width: 300, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Serverpart_Name', + title: '服务区名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ServerpartShop_Name', + title: '门店名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ApproveStaff_Name', + title: '待审核人', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StateText', + title: '待审核环节', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Accept_Code', + title: '业务类别', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_EndDate', + title: '办结时间', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StartDate', + title: '流程开始', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + ] + + // 修改审批类型 + const handleChangeType = async (type: string) => { + // 查出当前类型里面的流程数据 + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: type + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + console.log('fdsjkafjslk', dataState); + setSearchTypeData(dataState) + + // 业务状态的枚举 + let statusObj: any = {} + if (dataState && dataState.length > 0) { + dataState.forEach((item: any) => { + statusObj[item.APPROVALROUTE_STATE] = item.APPROVALROUTE_NAME + }) + } + setCurrentExamine(statusObj) + } + + return ( +
{ + // 打印报表 + if (!reqDetailList || reqDetailList.length === 0) return; + setPrintOut(el); + }} > + +
+
+ } // 列表表头 + search={{ span: 6 }} + request={async (params) => { + + const req: any = { + QueryType: 0, + SearchParameter: { + Operation_Type: 6, + Accept_Code: params?.searchType === "0" ? '' : params?.searchType, + BusinessProcess_StateSearch: params?.BusinessProcess_StateSearch === 0 ? '' : params?.BusinessProcess_StateSearch + }, + PageIndex: 1, + PageSize: 999999 + } + const data = await handleGetExamineList(req) + console.log('data', data) + if (data.data && data.data.length > 0) { + data.data.forEach((item: any) => { + if (item.BusinessProcess_State === 2000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State > 2000 && item.BusinessProcess_State < 9000) { + item.BusinessProcess_StateText = "审核中" + } else if (item.BusinessProcess_State = 9000) { + item.BusinessProcess_StateText = "已审结" + } + }) + + + return { data: data.data, success: true, total: data.data.length } + } + return { data: [], success: true } + }} + toolbar={{ + actions: [ + ] + }} + /> +
+
+
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(ProductApprovalProcess); diff --git a/src/pages/reports/productControl/ProductApprovalProcess/service.ts b/src/pages/reports/productControl/ProductApprovalProcess/service.ts new file mode 100644 index 0000000..fc5b19f --- /dev/null +++ b/src/pages/reports/productControl/ProductApprovalProcess/service.ts @@ -0,0 +1,82 @@ +// 获取商户应收账款列表 +import request from '@/utils/request'; + +// 创建服务区商品审批流程 +export async function handleCreateCommodityProInst(params?: any) { + const data = await request('/BusinessProcess/CreateCommodityProInst', { + method: 'POST', + data: { + ...params, + requestEncryption: true + }, + }) + + if (data.Result_Code !== 100) { + return data + } + return data; +} + +// 审核服务区商品审批流程 +export async function handleApproveCommodityProInst(params?: any) { + const data = await request('/BusinessProcess/ApproveCommodityProInst', { + method: 'POST', + data: { + ...params, + requestEncryption: true + }, + }) + + if (data.Result_Code !== 100) { + return data; + } + return data; +} + +// 驳回服务区商品审批流程 +export async function handleRejectCommodityProInst(params?: any) { + const data = await request('/BusinessProcess/RejectCommodityProInst', { + method: 'POST', + data: { + ...params, + requestEncryption: true + }, + }) + + if (data.Result_Code !== 100) { + return data; + } + return data; +} + +// 审批流程详情 +export async function handleGetBUSINESSAPPROVALDetail(params?: any) { + const data = await request('/BusinessProcess/GetBUSINESSAPPROVALDetail', { + method: 'GET', + params: { + ...params, + + }, + }) + + if (data.Result_Code !== 100) { + return data; + } + return data; +} + +// 获取审批流程里面的商品 +export async function handleGetCOMMODITYRUNNINGList(params?: any) { + const data = await request('/Commodity/GetCOMMODITY_RUNNINGList', { + method: 'POST', + data: { + ...params, + requestEncryption: true + }, + }) + + if (data.Result_Code !== 100) { + return data; + } + return data; +} \ No newline at end of file diff --git a/src/pages/reports/productControl/ProductChangeInfoApproval/index.tsx b/src/pages/reports/productControl/ProductChangeInfoApproval/index.tsx new file mode 100644 index 0000000..62845d7 --- /dev/null +++ b/src/pages/reports/productControl/ProductChangeInfoApproval/index.tsx @@ -0,0 +1,1349 @@ +// 商品信息修改审批 +// 新增商品审批 +import { connect } from "umi"; +import type { CurrentUser } from "umi"; +import type { ConnectState } from "@/models/connect"; +import React, { useRef, useState } from "react"; +import type { FormInstance } from "antd"; +import { Button, Col, message, Modal, Popconfirm, Row, Space, Spin, Tree } from "antd"; +import type { ActionType } from "@ant-design/pro-table"; +import ProTable from "@ant-design/pro-table"; +import PageTitleBox from "@/components/PageTitleBox"; +import { handleGetExamineList } from "@/pages/examine/examineList/service"; +import ProForm, { ProFormDateTimePicker, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form"; +import { getFieldEnum, getFieldEnumTree, getServerpartTree } from "@/services/options"; +import { handleGetAPPROVALROUTEList } from "@/pages/Setting/serviceConfig/service"; +import { handleGetCommodityList, handleGetNestingCOMMODITYTYPETree, handleGetServerpartShopTrade } from "../commodityInfo/service"; +import { handleGetUSERDEFINEDTYPEList } from "../userDefinedType/service"; +import useRequest from "@ahooksjs/use-request"; +import moment from 'moment' +import { handleApproveCommodityProInst, handleCreateCommodityProInst, handleRejectCommodityProInst } from "../ProductApprovalProcess/service"; +import session from "@/utils/session"; + +const ProductChangeInfoApproval: React.FC<{ currentUser: CurrentUser }> = (props) => { + const { currentUser } = props + const downloadBtnRef = useRef() + const actionRef = useRef(); + const formRef = useRef(); + const modalFormRef = useRef(); + const modalShopFormRef = useRef(); + const modalApproveFormRef = useRef(); + + const ServerpartIdsList = session.get('ServerpartIdsList') + // 新增商品申请 + const [showApplyFor, setShowApplyFor] = useState(false); + // 显示新增商品的悬浮框 + const [showAddShopModal, setShowAddShopModal] = useState(false); + // 选择的当前商品行 + const [currentRow, setCurrentRow] = useState() + // 商品列表数据 + const [shopData, setShopData] = useState() + const [selectSERVERPARTID, setSelectSERVERPARTID] = useState() + // 商品业态的搜索框内容 + const [commodityList, setCommodityList] = useState([]) + const [selectBUSINESSTYPE, setSelectBUSINESSTYPE] = useState() + const [customClassList, setCustomClassList] = useState() + const [treeView, setTreeView] = useState() + // 审批的悬浮框 + const [approveModal, setApproveModal] = useState(false); + // 点击审批的行数据 + const [approveCurrentRow, setApproveCurrentRow] = useState() + // 下一个审批流程 + const [nextApproval, setNextApproval] = useState() + // 下一审批流程的审批人 + const [nextApprovalPerson, setNextApprovalPerson] = useState() + // 审批的加载效果 + const [addApprovalLoading, setAddApprovalLoading] = useState(false); + // 审批还是驳回 1 审批 2 驳回 + const [ApprovalType, setApprovaType] = useState(0) + // 选中的行数据 + const [selectRowList, setSelectRowList] = useState() + // 选中的行 + const [selectedOrderRowKeys, setSelectedOrderRowKeys] = useState() + // 编辑选中的商品的modal + const [editShopModal, setEditShopModal] = useState(false); + // 选中需要编辑的行 + const [editSelectRow, setEditSelectRow] = useState() + // 新增申请的加载效果 + const [handleAddLoading, setHandleAddLoading] = useState(false); + + // 加载服务区树 + const { loading: treeLoading, data: treeViews } = useRequest(async () => { + const req = { + PROVINCE_CODE: currentUser?.ProvinceCode, + COMMODITYTYPE_VALID: 1, + ShowCode: true + } + const data = await handleGetNestingCOMMODITYTYPETree(req) + setTreeView(data) + return data + }) + + const { loading: CommodityLoading, data: CommodityData } = useRequest(async () => { + const data = await getFieldEnumTree({ FieldExplainField: 'CommodityTypeIds' }) + const obj: any = {} + if (data && data.length > 0) { + data.forEach((item: any) => { + obj[item.value] = item.label + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + obj[subItem.value] = subItem.label + if (subItem.children && subItem.children.length > 0) { + subItem.children.forEach((thirdItem: any) => { + obj[thirdItem.value] = thirdItem.label + }) + } + }) + } + }) + } + return obj + }) + + const columns: any = [ + { + dataIndex: 'BusinessProcess_StateSearch', + title: '流程状态', + width: 200, + ellipsis: true, + align: 'center', + hideInTable: true, + valueEnum: { + "0": "全部", + "2000": "待审核", + "2010,2020,2030,2040,2050,2060,2070,2080,2090": "审核中", + "9000": "已审结" + }, + }, + { + dataIndex: 'BusinessProcess_Name', + title: '业务名称', + width: 300, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Serverpart_Name', + title: '服务区名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ServerpartShop_Name', + title: '门店名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ApproveStaff_Name', + title: '待审核人', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StateText', + title: '待审核环节', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Accept_Code', + title: '业务类别', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_EndDate', + title: '办结时间', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StartDate', + title: '流程开始', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + align: 'center', + hideInSearch: true, + width: 120, + fixed: "right", + ellipsis: true, + render: (_, record) => { + return ( + record?.ApproveStaff_ID === currentUser?.ID && record?.BusinessProcess_State !== 9000 + ? + + { + setApprovaType(1) + setApproveCurrentRow(record) + setApproveModal(true) + }} + > + 审批 + + { + setApprovaType(2) + setApproveCurrentRow(record) + setApproveModal(true) + }}> + 驳回 + + : "" + + ); + }, + }, + ] + + const modalColumns: any = [ + { + title: "序号", + width: 70, + dataIndex: "index", + valueType: "index", + align: 'center', + ellipsis: true, + }, + { + title: "名称", + width: 300, + dataIndex: "COMMODITY_NAME", + ellipsis: true, + align: 'center', + }, + { + title: "条码", + width: 150, + dataIndex: "COMMODITY_BARCODE", + ellipsis: true, + align: 'center', + }, + { + title: "零售价", + width: 150, + dataIndex: "COMMODITY_RETAILPRICE", + ellipsis: true, + align: 'center', + }, + { + title: "规格", + width: 150, + dataIndex: "COMMODITY_RULE", + ellipsis: true, + align: 'center', + }, + { + title: "单位", + width: 150, + dataIndex: "COMMODITY_UNIT", + ellipsis: true, + align: 'center', + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + align: 'center', + hideInSearch: true, + width: 120, + fixed: "right", + ellipsis: true, + render: (_, record) => { + return ( + + { + let obj: any = {} + if (shopData && shopData.length > 0) { + obj = shopData.filter((item: any) => item.COMMODITY_ID === record?.COMMODITY_ID)[0] + } + console.log('shopData', shopData); + console.log('obj', obj); + + setEditSelectRow(obj) + setEditShopModal(true) + }} + > + 编辑 + + { + console.log('record', record); + let oldData: any = JSON.parse(JSON.stringify(shopData)) + let list: any = [] + oldData.forEach((item: any) => { + if (item.ADDTIME !== record?.ADDTIME) { + list.push(item) + } + }) + setShopData(list) + }} + > + 删除 + + + ); + }, + }, + ] + + // 选择商品的表格结构 + const selectShopColumns: any = [ + { + title:
序号
, + width: 70, + dataIndex: 'index', + hideInSearch: true, + valueType: 'index' + }, + { + title:
服务区
, + width: 150, + ellipsis: true, + align: 'center', + dataIndex: 'SERVERPART_NAME', + hideInSearch: true, + valueType: "select", + valueEnum: ServerpartIdsList + }, + { + title:
商品业态
, + width: 120, + ellipsis: true, + dataIndex: 'BUSINESSTYPE', + align: 'center', + hideInSearch: true, + valueType: 'select', + request: async () => { + return await getFieldEnum({ FieldExplainField: 'BUSINESSTYPE', sessionName: 'SHOPTRADE', notformate: true }) + + } + }, + { + title:
商品类型
, + width: 120, + ellipsis: true, + dataIndex: 'COMMODITY_TYPE', + align: 'center', + hideInSearch: true, + valueEnum: CommodityData + }, + { + title:
商品名称
, + width: 200, + ellipsis: true, + align: 'left', + dataIndex: 'COMMODITY_NAME', + hideInSearch: true, + }, + { + title:
商品条码
, + width: 150, + ellipsis: true, + align: 'left', + dataIndex: 'COMMODITY_BARCODE', + hideInSearch: true, + }, + { + title:
零售价
, + width: 70, + ellipsis: true, + align: 'right', + dataIndex: 'COMMODITY_RETAILPRICE', + hideInSearch: true, + }, + { + title:
进货价
, + width: 70, + ellipsis: true, + align: 'right', + dataIndex: 'COMMODITY_PURCHASEPRICE', + hideInSearch: true, + }, + { + title:
商品单位
, + width: 80, + ellipsis: true, + align: 'right', + dataIndex: 'COMMODITY_UNIT', + hideInSearch: true, + }, + { + title:
状态
, + width: 100, + ellipsis: true, + dataIndex: 'COMMODITY_STATE', + hideInSearch: true, + align: 'center', + valueType: 'select', + valueEnum: { 0: { text: '无效', status: 'error' }, 1: { text: '有效', status: 'success' }, 2: { text: '不可选', status: 'default' } }, + }, + { + title:
审核时间
, + width: 150, + align: 'center', + ellipsis: true, + dataIndex: 'OPERATE_DATE', + hideInSearch: true, + } + ] + + // 拿到对应的商品业态 + const handleGetCommodity = async (id: any) => { + const req: any = { + ProvinceCode: currentUser?.ProvinceCode, + ServerpartId: id + } + const data = await handleGetServerpartShopTrade(req) + console.log('data', data) + setCommodityList(data) + } + + // 请求自定义类的选择列表 + const handleGetCustomClassList = async (id: any) => { + const req: any = { + SearchParameter: { + USERDEFINEDTYPE_STATE: 1, + SERVERPART_ID: id, + BUSINESSTYPE: selectBUSINESSTYPE + }, + PageIndex: 1, + PageSize: 999999, + pageSize: 999999, + } + const data = await handleGetUSERDEFINEDTYPEList(req) + if (data && data.length > 0) { + const list: any = [] + data.forEach((item: any) => { + list.push({ label: item.USERDEFINEDTYPE_NAME, value: item.USERDEFINEDTYPE_ID }) + }) + setCustomClassList(list) + } + console.log('data', data) + } + + + + return ( +
+
+
+ } // 列表表头 + search={{ span: 6 }} + request={async (params) => { + const req: any = { + QueryType: 0, + SearchParameter: { + Operation_Type: 6, + Accept_Code: "6-100210", + BusinessProcess_StateSearch: params?.BusinessProcess_StateSearch === 0 ? '' : params?.BusinessProcess_StateSearch + }, + PageIndex: 1, + PageSize: 999999 + } + const data = await handleGetExamineList(req) + console.log('data', data) + if (data.data && data.data.length > 0) { + data.data.forEach((item: any) => { + if (item.BusinessProcess_State === 1000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State === 2000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State > 2000 && item.BusinessProcess_State < 9000) { + item.BusinessProcess_StateText = "审核中" + } else if (item.BusinessProcess_State = 9000) { + item.BusinessProcess_StateText = "已审结" + } + }) + + + return { data: data.data, success: true, total: data.data.length } + } + return { data: [], success: true } + }} + toolbar={{ + actions: [ + + ] + }} + /> +
+
+ + {/* 审批的悬浮框 */} + { + setApproveCurrentRow(undefined) + setApproveModal(false) + setApprovaType(0) + }} + onOk={() => { + modalApproveFormRef?.current?.validateFields().then(() => { + modalApproveFormRef?.current?.submit() + }) + }} + > + { + console.log('approveCurrentRowapproveCurrentRowapproveCurrentRow', approveCurrentRow); + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: "100210", + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + console.log('dataStatedataStatedataState', dataState); + let obj: any = {} + let currentIndex: number = 0 + if (dataState && dataState.length > 0) { + dataState.forEach((item: any, index: number) => { + if (item.APPROVALROUTE_STATE === approveCurrentRow.BusinessProcess_State) { + obj = item + currentIndex = index + } + }) + } + if (obj) { + // 审批的时候 拿到当前状态 去找下一个状态 + if (ApprovalType === 1) { + // 拿到当前状态的信息 判断下一状态 是不是结束了 结束了 就不显示 下一结算审批人 不是结束 就拿到下一流程的审批人 + setNextApproval(obj.NEXT_STATE) + let nextObj: any = currentIndex + 1 <= dataState.length ? dataState[currentIndex + 1] : {} + if (nextObj) { + let personTotal: number = nextObj.APPROVALSTAFF_ID.split(',').length || 0 + if (personTotal > 0) { + let STAFFIDList: number[] = nextObj.APPROVALSTAFF_ID.split(',') + let STAFFNAMEList: string[] = nextObj.APPROVALSTAFF_NAME.split(',') + let list: any = [] + for (let i = 0; i < personTotal; i++) { + list.push({ label: STAFFNAMEList[i], value: STAFFIDList[i] }) + } + setNextApprovalPerson(list) + } + } + } else { + // 驳回的话 去找历史状态 + if (dataState && dataState.length > 0) { + let list: any = [] + dataState.forEach((item: any, index: number) => { + if (obj.APPROVALROUTE_STATE > item.APPROVALROUTE_STATE) { + list.push({ label: item.APPROVALROUTE_NAME, value: item.APPROVALROUTE_STATE }) + } + }) + setNextApprovalPerson(list) + } + + } + + } + return {} + }} + onFinish={async (res) => { + setAddApprovalLoading(true) + let data: any = {} + + if (ApprovalType === 1) { + // 审批 + const req: any = { + businessApprovalId: approveCurrentRow?.BusinessApproval_ID, + UserId: currentUser?.ID, + ApproveInfo: res.ApproveInfo, + nextApproveStaffId: res.nextApproveStaffId || "", + nextApproveState: nextApproval || "" + } + + data = await handleApproveCommodityProInst(req) + } else { + // 驳回 + const req: any = { + businessApprovalId: approveCurrentRow?.BusinessApproval_ID, + UserId: currentUser?.ID, + RejectInfo: res.ApproveInfo, + nextApproveState: res.nextApproveState || "" + } + console.log('reqreqreqreq', req); + + data = await handleRejectCommodityProInst(req) + } + setAddApprovalLoading(false) + console.log('datadatadata', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + setApproveCurrentRow(undefined) + setApproveModal(false) + setNextApproval(null) + setNextApprovalPerson(null) + setApprovaType(0) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + + }} + > + { + ApprovalType === 1 ? + + { + nextApproval === 9000 ? '' : + + + + + } + + + + : ApprovalType === 2 ? + + + + + + + + + : "" + } + + + + {/* 新增申请的悬浮框 */} + { + setShowApplyFor(false) + setCurrentRow(undefined) + setShopData([]) + setSelectRowList([]) + setSelectedOrderRowKeys([]) + }} + onOk={() => { + formRef?.current?.validateFields().then(() => { + modalFormRef?.current?.submit() + }) + + }} + > + { + if (shopData && shopData.length > 0) { + + } else { + message.error('请选择要修改的商品!') + return + } + setHandleAddLoading(true) + const req: any = { + ProinstName: res.reasonForApplication, + UserId: currentUser?.ID, + OperateType: "100210", + ServerpartId: res.ServerpartId, + NextApproveStaffId: res.NextApproveStaffId, + NextApproveState: 2000, + CommodityRunningList: shopData + } + console.log('reqreq', req); + + const data = await handleCreateCommodityProInst(req) + setHandleAddLoading(false) + console.log('dsaidjaskda', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + setShowApplyFor(false) + setCurrentRow(undefined) + actionRef.current?.reload() + setShopData([]) + setSelectRowList([]) + setSelectedOrderRowKeys([]) + } else { + message.error(data.Result_Desc) + } + + }} + > + + + + + + { + const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) + const list: any = [] + if (data && data.length > 0) { + data.forEach((item: any) => { + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + list.push({ label: subItem.label, value: subItem.value }) + }) + } + }) + data.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + }) + } + return list + }} + /> + + + { + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: "100210", + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + if (dataState && dataState.length > 0) { + let obj: any = {} + console.log('dataState', dataState); + + dataState.forEach((item: any) => { + if (item.APPROVALROUTE_STATE === 2000) { + obj = item + } + }) + let personTotal: number = obj.APPROVALSTAFF_ID.split(',').length || 0 + if (personTotal > 0) { + let STAFFIDList: number[] = obj.APPROVALSTAFF_ID.split(',') + let STAFFNAMEList: string[] = obj.APPROVALSTAFF_NAME.split(',') + let list: any = [] + for (let i = 0; i < personTotal; i++) { + list.push({ label: STAFFNAMEList[i], value: STAFFIDList[i] }) + } + return list + } + } + }} + /> + + + + + { + // 判断服务区是否已选择 + const values = modalFormRef.current?.getFieldsValue(); + if (!values?.ServerpartId) { + message.error("请先选择服务区!"); + return; + } + setShowAddShopModal(true); + }}> + 选择商品 + + ] + }} + /> + + + + + {/* 选择商品 */} + { + setShowAddShopModal(false) + setShopData(selectRowList) + console.log('selectRowListselectRowList', selectRowList); + + }} + onCancel={() => { + setShowAddShopModal(false) + }} + > + { + let formRes = modalFormRef.current?.getFieldsValue() + const req: any = { + SearchType: 3, + ProvinceCode: currentUser?.ProvinceCode, + // CommodityTypeId: currenMenu, + CommodityState: 1, + ServerpartID: formRes?.ServerpartId, + PageIndex: 1, + PageSize: 999999, + SortStr: "OPERATE_DATE desc" + // PageSize: 20 + } + const data = await handleGetCommodityList(req) + console.log('shdasidh', data); + if (data.List && data.List.length > 0) { + return { data: data.List, success: true, total: data.TotalCount } + } + return { data: [], success: true } + }} + columns={selectShopColumns} + rowSelection={{ + type: 'checkbox', + selectedRowKeys: selectedOrderRowKeys, + onChange: (selectedRowKeys: any, selectedRows: any) => { + setSelectRowList(selectedRows) + setSelectedOrderRowKeys(selectedRowKeys) + }, + }} + /> + + + + + {/* 编辑商品的悬浮框 */} + { + modalShopFormRef.current?.validateFields().then(async (res: any) => { + let oldData: any = shopData && shopData.length > 0 ? JSON.parse(JSON.stringify(shopData)) : [] + let newList: any = [] + // 判断当前的里面有没有一样的 + if (oldData && oldData.length > 0) { + oldData.forEach((item: any, index: number) => { + if (item.ADDTIME === res.ADDTIME) { + newList.push({ + ...item, + ...res + }) + } else { + newList.push(item) + } + }) + } else { + newList.push(res) + } + + setShopData(newList) + setEditSelectRow(undefined) + setEditShopModal(false) + }) + }} + onCancel={() => { + setEditSelectRow(undefined) + setEditShopModal(false) + }} + > + + +
商品基本信息
+ + + + + + + + + + { + const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) + const list: any = [] + if (data && data.length > 0) { + data.forEach((item: any) => { + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + list.push({ label: subItem.label, value: subItem.value }) + }) + } + }) + data.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + }) + } + return list + }} + rules={[ + { + required: true, + message: '请选择服务区', + }, + ]} + fieldProps={{ + onChange: async (e: any) => { + console.log('e', e) + if (e) { + setSelectSERVERPARTID(e) + await handleGetCommodity(e) + if (selectBUSINESSTYPE) { + await handleGetCustomClassList(e) + } + } else { + setSelectSERVERPARTID(undefined) + setCommodityList([]) + setCustomClassList([]) + } + } + }} + /> + + + { + if (e) { + setSelectBUSINESSTYPE(e) + if (selectSERVERPARTID) { + await handleGetCustomClassList(e) + } + } else { + setSelectBUSINESSTYPE(undefined) + } + } + }} + /> + + + { + return treeView + }} + fieldProps={{ + treeDefaultExpandAll: true + }} + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商品状态信息
+ + + + + + + + + + + + + + + + + + + + + + +
商品价格信息
+ + + + + + + + + + + + + + + + + + + + + +
商品进销信息
+ + + + + + + + + + + +
+
+
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(ProductChangeInfoApproval); diff --git a/src/pages/reports/productControl/ProductChangePriceApproval/index.tsx b/src/pages/reports/productControl/ProductChangePriceApproval/index.tsx new file mode 100644 index 0000000..8a41c78 --- /dev/null +++ b/src/pages/reports/productControl/ProductChangePriceApproval/index.tsx @@ -0,0 +1,904 @@ +// 商品调价审批 +// 新增商品审批 +import { connect } from "umi"; +import type { CurrentUser } from "umi"; +import type { ConnectState } from "@/models/connect"; +import React, { useRef, useState } from "react"; +import type { FormInstance } from "antd"; +import { Button, Col, Input, message, Modal, Popconfirm, Row, Space, Spin, Tree } from "antd"; +import type { ActionType } from "@ant-design/pro-table"; +import ProTable from "@ant-design/pro-table"; +import PageTitleBox from "@/components/PageTitleBox"; +import { handleGetExamineList } from "@/pages/examine/examineList/service"; +import ProForm, { ProFormDateTimePicker, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form"; +import { getFieldEnum, getFieldEnumTree, getServerpartTree } from "@/services/options"; +import { handleGetAPPROVALROUTEList } from "@/pages/Setting/serviceConfig/service"; +import { handleGetCommodityList, handleGetNestingCOMMODITYTYPETree, handleGetServerpartShopTrade } from "../commodityInfo/service"; +import { handleGetUSERDEFINEDTYPEList } from "../userDefinedType/service"; +import useRequest from "@ahooksjs/use-request"; +import moment from 'moment' +import { handleApproveCommodityProInst, handleCreateCommodityProInst, handleRejectCommodityProInst } from "../ProductApprovalProcess/service"; +import session from "@/utils/session"; + +const ProductChangePriceApproval: React.FC<{ currentUser: CurrentUser }> = (props) => { + const { currentUser } = props + const downloadBtnRef = useRef() + const actionRef = useRef(); + const formRef = useRef(); + const modalFormRef = useRef(); + const modalShopFormRef = useRef(); + const modalApproveFormRef = useRef(); + const ServerpartIdsList = session.get('ServerpartIdsList') + + // 新增商品申请 + const [showApplyFor, setShowApplyFor] = useState(false); + const [showApplyForLoading, setShowApplyForLoading] = useState(false); + // 显示新增商品的悬浮框 + const [showAddShopModal, setShowAddShopModal] = useState(false); + // 选择的当前商品行 + const [currentRow, setCurrentRow] = useState() + // 商品列表数据 + const [shopData, setShopData] = useState() + // 审批的悬浮框 + const [approveModal, setApproveModal] = useState(false); + // 点击审批的行数据 + const [approveCurrentRow, setApproveCurrentRow] = useState() + // 下一个审批流程 + const [nextApproval, setNextApproval] = useState() + // 下一审批流程的审批人 + const [nextApprovalPerson, setNextApprovalPerson] = useState() + // 选中的行数据 + const [selectRowList, setSelectRowList] = useState() + // 选中的行 + const [selectedOrderRowKeys, setSelectedOrderRowKeys] = useState() + // 审批还是驳回 1 审批 2 驳回 + const [ApprovalType, setApprovaType] = useState(0) + // 新增申请的加载效果 + const [addApprovalLoading, setAddApprovalLoading] = useState(false); + + const { loading: CommodityLoading, data: CommodityData } = useRequest(async () => { + const data = await getFieldEnumTree({ FieldExplainField: 'CommodityTypeIds' }) + const obj: any = {} + if (data && data.length > 0) { + data.forEach((item: any) => { + obj[item.value] = item.label + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + obj[subItem.value] = subItem.label + if (subItem.children && subItem.children.length > 0) { + subItem.children.forEach((thirdItem: any) => { + obj[thirdItem.value] = thirdItem.label + }) + } + }) + } + }) + } + return obj + }) + + const columns: any = [ + { + dataIndex: 'BusinessProcess_StateSearch', + title: '流程状态', + width: 200, + ellipsis: true, + align: 'center', + hideInTable: true, + valueEnum: { + "0": "全部", + "2000": "待审核", + "2010,2020,2030,2040,2050,2060,2070,2080,2090": "审核中", + "9000": "已审结" + }, + }, + { + dataIndex: 'BusinessProcess_Name', + title: '业务名称', + width: 300, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Serverpart_Name', + title: '服务区名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ServerpartShop_Name', + title: '门店名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ApproveStaff_Name', + title: '待审核人', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StateText', + title: '待审核环节', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'Accept_Code', + title: '业务类别', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_EndDate', + title: '办结时间', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'BusinessProcess_StartDate', + title: '流程开始', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + align: 'center', + hideInSearch: true, + width: 120, + fixed: "right", + ellipsis: true, + render: (_, record) => { + return ( + record?.ApproveStaff_ID === currentUser?.ID && record?.BusinessProcess_State !== 9000 + ? + + { + setApprovaType(1) + setApproveCurrentRow(record) + setApproveModal(true) + }} + > + 审批 + + { + setApprovaType(2) + setApproveCurrentRow(record) + setApproveModal(true) + }}> + 驳回 + + : "" + ); + }, + }, + ] + + const modalColumns: any = [ + { + title: "序号", + width: 70, + dataIndex: "index", + valueType: "index", + align: 'center', + ellipsis: true, + }, + { + title: "名称", + width: 300, + dataIndex: "COMMODITY_NAME", + ellipsis: true, + align: 'center', + }, + { + title: "条码", + width: 150, + dataIndex: "COMMODITY_BARCODE", + ellipsis: true, + align: 'center', + }, + { + title: "原价", + width: 150, + dataIndex: "COMMODITY_CURRPRICE", + ellipsis: true, + align: 'center', + }, + { + title: "现价", + width: 150, + dataIndex: "newPrice", + ellipsis: true, + align: 'center', + render: (_, record) => { + return { + let oldData: any = JSON.parse(JSON.stringify(shopData)) + let list: any = [] + oldData.forEach((item: any) => { + if (item.COMMODITY_ID === record?.COMMODITY_ID) { + item.newPrice = e.target.value + } + list.push(item) + }) + setShopData(list) + }} /> + } + }, + { + title: "单位", + width: 150, + dataIndex: "COMMODITY_UNIT", + ellipsis: true, + align: 'center', + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + align: 'center', + hideInSearch: true, + width: 120, + fixed: "right", + ellipsis: true, + render: (_, record) => { + return ( + + + { + console.log('record', record); + let oldData: any = JSON.parse(JSON.stringify(shopData)) + let list: any = [] + let rowKeyList: number[] = [] + oldData.forEach((item: any) => { + if (item.COMMODITY_ID !== record?.COMMODITY_ID) { + list.push(item) + rowKeyList.push(item.COMMODITY_ID) + } + }) + setShopData(list) + setSelectRowList(list) + setSelectedOrderRowKeys(rowKeyList) + }} + > + 删除 + + + ); + }, + }, + ] + + // 选择商品的表格结构 + const selectShopColumns: any = [ + { + title:
序号
, + width: 70, + dataIndex: 'index', + hideInSearch: true, + valueType: 'index' + }, + { + title:
服务区
, + width: 150, + ellipsis: true, + align: 'center', + dataIndex: 'SERVERPART_NAME', + hideInSearch: true, + valueType: "select", + valueEnum: ServerpartIdsList + }, + { + title:
商品业态
, + width: 120, + ellipsis: true, + dataIndex: 'BUSINESSTYPE', + align: 'center', + hideInSearch: true, + valueType: 'select', + request: async () => { + return await getFieldEnum({ FieldExplainField: 'BUSINESSTYPE', sessionName: 'SHOPTRADE', notformate: true }) + + } + }, + { + title:
商品类型
, + width: 120, + ellipsis: true, + dataIndex: 'COMMODITY_TYPE', + align: 'center', + hideInSearch: true, + valueEnum: CommodityData + }, + { + title:
商品名称
, + width: 200, + ellipsis: true, + align: 'left', + dataIndex: 'COMMODITY_NAME', + hideInSearch: true, + }, + { + title:
商品条码
, + width: 150, + ellipsis: true, + align: 'left', + dataIndex: 'COMMODITY_BARCODE', + hideInSearch: true, + }, + { + title:
零售价
, + width: 70, + ellipsis: true, + align: 'right', + dataIndex: 'COMMODITY_RETAILPRICE', + hideInSearch: true, + }, + { + title:
进货价
, + width: 70, + ellipsis: true, + align: 'right', + dataIndex: 'COMMODITY_PURCHASEPRICE', + hideInSearch: true, + }, + { + title:
商品单位
, + width: 80, + ellipsis: true, + align: 'right', + dataIndex: 'COMMODITY_UNIT', + hideInSearch: true, + }, + { + title:
状态
, + width: 100, + ellipsis: true, + dataIndex: 'COMMODITY_STATE', + hideInSearch: true, + align: 'center', + valueType: 'select', + valueEnum: { 0: { text: '无效', status: 'error' }, 1: { text: '有效', status: 'success' }, 2: { text: '不可选', status: 'default' } }, + }, + { + title:
审核时间
, + width: 150, + align: 'center', + ellipsis: true, + dataIndex: 'OPERATE_DATE', + hideInSearch: true, + } + ] + + + + return ( +
+
+
+ } // 列表表头 + search={{ span: 6 }} + request={async (params) => { + const req: any = { + QueryType: 0, + SearchParameter: { + Operation_Type: 6, + Accept_Code: "6-100200", + BusinessProcess_StateSearch: params?.BusinessProcess_StateSearch === 0 ? '' : params?.BusinessProcess_StateSearch + }, + PageIndex: 1, + PageSize: 999999 + } + const data = await handleGetExamineList(req) + console.log('data', data) + if (data.data && data.data.length > 0) { + data.data.forEach((item: any) => { + if (item.BusinessProcess_State === 1000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State === 2000) { + item.BusinessProcess_StateText = "待审核" + } else if (item.BusinessProcess_State > 2000 && item.BusinessProcess_State < 9000) { + item.BusinessProcess_StateText = "审核中" + } else if (item.BusinessProcess_State = 9000) { + item.BusinessProcess_StateText = "已审结" + } + }) + + + return { data: data.data, success: true, total: data.data.length } + } + return { data: [], success: true } + }} + toolbar={{ + actions: [ + + ] + }} + /> +
+
+ + {/* 审批的悬浮框 */} + { + setApproveCurrentRow(undefined) + setApproveModal(false) + setApprovaType(0) + }} + onOk={() => { + modalApproveFormRef?.current?.validateFields().then(() => { + modalApproveFormRef?.current?.submit() + }) + }} + > + { + console.log('approveCurrentRowapproveCurrentRowapproveCurrentRow', approveCurrentRow); + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: "100200", + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + console.log('dataStatedataStatedataState', dataState); + let obj: any = {} + let currentIndex: number = 0 + if (dataState && dataState.length > 0) { + dataState.forEach((item: any, index: number) => { + if (item.APPROVALROUTE_STATE === approveCurrentRow.BusinessProcess_State) { + obj = item + currentIndex = index + } + }) + } + if (obj) { + // 审批的时候 拿到当前状态 去找下一个状态 + if (ApprovalType === 1) { + // 拿到当前状态的信息 判断下一状态 是不是结束了 结束了 就不显示 下一结算审批人 不是结束 就拿到下一流程的审批人 + setNextApproval(obj.NEXT_STATE) + let nextObj: any = currentIndex + 1 <= dataState.length ? dataState[currentIndex + 1] : {} + if (nextObj) { + let personTotal: number = nextObj.APPROVALSTAFF_ID.split(',').length || 0 + if (personTotal > 0) { + let STAFFIDList: number[] = nextObj.APPROVALSTAFF_ID.split(',') + let STAFFNAMEList: string[] = nextObj.APPROVALSTAFF_NAME.split(',') + let list: any = [] + for (let i = 0; i < personTotal; i++) { + list.push({ label: STAFFNAMEList[i], value: STAFFIDList[i] }) + } + setNextApprovalPerson(list) + } + } + } else { + // 驳回的话 去找历史状态 + if (dataState && dataState.length > 0) { + let list: any = [] + dataState.forEach((item: any, index: number) => { + if (obj.APPROVALROUTE_STATE > item.APPROVALROUTE_STATE) { + list.push({ label: item.APPROVALROUTE_NAME, value: item.APPROVALROUTE_STATE }) + } + }) + setNextApprovalPerson(list) + } + + } + + } + return {} + }} + onFinish={async (res) => { + setAddApprovalLoading(true) + let data: any = {} + + if (ApprovalType === 1) { + // 审批 + const req: any = { + businessApprovalId: approveCurrentRow?.BusinessApproval_ID, + UserId: currentUser?.ID, + ApproveInfo: res.ApproveInfo, + nextApproveStaffId: res.nextApproveStaffId || "", + nextApproveState: nextApproval || "" + } + + data = await handleApproveCommodityProInst(req) + } else { + // 驳回 + const req: any = { + businessApprovalId: approveCurrentRow?.BusinessApproval_ID, + UserId: currentUser?.ID, + RejectInfo: res.ApproveInfo, + nextApproveState: res.nextApproveState || "" + } + console.log('reqreqreqreq', req); + + data = await handleRejectCommodityProInst(req) + } + setAddApprovalLoading(false) + console.log('datadatadata', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + setApproveCurrentRow(undefined) + setApproveModal(false) + setNextApproval(null) + setNextApprovalPerson(null) + setApprovaType(0) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + + }} + > + { + ApprovalType === 1 ? + + { + nextApproval === 9000 ? '' : + + + + + } + + + + : ApprovalType === 2 ? + + + + + + + + + : "" + } + + + + {/* 新增申请的悬浮框 */} + { + setShowApplyFor(false) + setCurrentRow(undefined) + setSelectRowList([]) + setSelectedOrderRowKeys([]) + setShopData([]) + }} + confirmLoading={showApplyForLoading} + onOk={() => { + // 判断表格里面的现价 是不是都已经输入了 + let allRight: boolean = true + console.log('shopData', shopData); + + if (shopData && shopData.length > 0) { + shopData.forEach((item: any) => { + if (!item.newPrice) { + allRight = false + } + }) + } + if (!allRight) { + message.error("请先完善表格数据!") + return + } + + formRef?.current?.validateFields().then(() => { + modalFormRef?.current?.submit() + }) + + }} + > + { + setShowApplyForLoading(true) + let list: any = [] + if (shopData && shopData.length > 0) { + shopData.forEach((item: any) => { + let obj: any = JSON.parse(JSON.stringify(item)) + let oldPrice = JSON.parse(JSON.stringify(obj.COMMODITY_RETAILPRICE)) + obj.COMMODITY_ORIPRICE = oldPrice + obj.COMMODITY_RETAILPRICE = item.newPrice + obj.COMMODITY_CURRPRICE = item.newPrice + list.push(obj) + }) + } + + + const req: any = { + ProinstName: res.reasonForApplication, + UserId: currentUser?.ID, + OperateType: "100200", + ServerpartId: res.ServerpartId, + NextApproveStaffId: res.NextApproveStaffId, + NextApproveState: 2000, + CommodityRunningList: list + } + console.log('req', req); + + const data = await handleCreateCommodityProInst(req) + setShowApplyForLoading(false) + console.log('dsaidjaskda', data); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + setShowApplyFor(false) + setCurrentRow(undefined) + actionRef.current?.reload() + setSelectRowList([]) + setSelectedOrderRowKeys([]) + setShopData([]) + } else { + message.error(data.Result_Desc) + } + + }} + > + + + + + + { + const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) + const list: any = [] + if (data && data.length > 0) { + data.forEach((item: any) => { + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + list.push({ label: subItem.label, value: subItem.value }) + }) + } + }) + data.forEach((item: any) => { + list.push({ label: item.label, value: item.value }) + }) + } + return list + }} + /> + + + { + const reqState: any = { + SearchParameter: { + APPROVALROUTE_STATES: "", + APPROVALROUTE_VALID: 1, + OPERATION_TYPES: "100200", + }, + PageIndex: 1, + PageSize: 999999 + } + const dataState = await handleGetAPPROVALROUTEList(reqState) + if (dataState && dataState.length > 0) { + let obj: any = {} + console.log('dataState', dataState); + + dataState.forEach((item: any) => { + if (item.APPROVALROUTE_STATE === 2000) { + obj = item + } + }) + let personTotal: number = obj.APPROVALSTAFF_ID.split(',').length || 0 + if (personTotal > 0) { + let STAFFIDList: number[] = obj.APPROVALSTAFF_ID.split(',') + let STAFFNAMEList: string[] = obj.APPROVALSTAFF_NAME.split(',') + let list: any = [] + for (let i = 0; i < personTotal; i++) { + list.push({ label: STAFFNAMEList[i], value: STAFFIDList[i] }) + } + return list + } + } + }} + /> + + + + + { + // 判断服务区是否已选择 + const values = modalFormRef.current?.getFieldsValue(); + if (!values?.ServerpartId) { + message.error("请先选择服务区!"); + return; + } + setShowAddShopModal(true); + }}> + 选择商品 + + ] + }} + /> + + + + + {/* 选择商品的悬浮框 */} + { + setShowAddShopModal(false) + setShopData(selectRowList) + }} + onCancel={() => { + setShowAddShopModal(false) + }} + > + { + let formRes = modalFormRef.current?.getFieldsValue() + const req: any = { + SearchType: 3, + ProvinceCode: currentUser?.ProvinceCode, + // CommodityTypeId: currenMenu, + CommodityState: 1, + ServerpartID: formRes?.ServerpartId, + PageIndex: 1, + PageSize: 999999, + SortStr: "OPERATE_DATE desc" + // PageSize: 20 + } + const data = await handleGetCommodityList(req) + console.log('shdasidh', data); + if (data.List && data.List.length > 0) { + return { data: data.List, success: true, total: data.TotalCount } + } + return { data: [], success: true } + }} + columns={selectShopColumns} + rowSelection={{ + type: 'checkbox', + selectedRowKeys: selectedOrderRowKeys, + onChange: (selectedRowKeys: any, selectedRows: any) => { + console.log('selectedRowKeysselectedRowKeys', selectedRowKeys); + console.log('selectedRowsselectedRowsselectedRows', selectedRows); + + setSelectRowList(selectedRows) + setSelectedOrderRowKeys(selectedRowKeys) + }, + }} + /> + +
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(ProductChangePriceApproval); diff --git a/src/pages/travelMember/scenicSpotConfig/index.tsx b/src/pages/travelMember/scenicSpotConfig/index.tsx new file mode 100644 index 0000000..74b638c --- /dev/null +++ b/src/pages/travelMember/scenicSpotConfig/index.tsx @@ -0,0 +1,670 @@ +// 景区信息配置 +import React, { useRef, useState, Suspense } from 'react'; +import moment from 'moment'; // 时间相关引用,没有使用可以删除 +import numeral from "numeral"; // 数字相关引用,没有使用可以删除 +import { connect } from 'umi'; + +import useRequest from '@ahooksjs/use-request'; // 请求数据的引用 +import Draggable from 'react-draggable'; +import SubMenu from "antd/lib/menu/SubMenu"; +import ProTable from '@ant-design/pro-table'; +import ProDescriptions from '@ant-design/pro-descriptions'; +import ProForm, { ProFormDatePicker, ProFormDateTimePicker, ProFormDigit, ProFormMoney, ProFormSelect, ProFormText, ProFormTextArea, ProFormUploadButton } from '@ant-design/pro-form'; +import { MenuFoldOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; +import { PageContainer } from '@ant-design/pro-layout'; +import { Button, Col, Drawer, message, Row, Popconfirm, Space, Image, Modal, Form, Switch, Upload, Tooltip, Descriptions, TreeSelect } from 'antd'; + +import type { CurrentUser } from "umi"; +import type { ConnectState } from '@/models/connect'; +import type { ActionType, ProColumns } from '@ant-design/pro-table'; +import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; +import type { FormInstance } from 'antd'; + +import { getFieldEnumTree, getFieldEnumName } from "@/services/options"; // 枚举的引用,没有使用可以删除 +import PageTitleBox from "@/components/PageTitleBox"; +import { handeDeleteSCENICAREA, handeGetSCENICAREAList, handeSynchroSCENICAREA } from '../service'; +import session from '@/utils/session'; +import { deletePicture, uploadPicture } from '@/services/picture'; + + +const beforeUpload = (file: any) => { + const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; + if (!isJpgOrPng) { + message.error('请上传JPEG、jpg、png格式的图片文件!'); + } + const isLt2M = file.size / 1024 / 1024 < 5; + if (!isLt2M) { + message.error('图片大小不超过 5MB!'); + } + return isJpgOrPng && isLt2M; +} + +const scenicSpotConfig: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => { + const { currentUser } = props + const { confirm } = Modal; + const actionRef = useRef(); + const formRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [showDetail, setShowDetail] = useState(); + const [modalVisible, handleModalVisible] = useState(); + const [confirmLoading, handleConfirmLoading] = useState(false) // 弹出框的内容表单是否在提交 + const [searchParams, setSearchParams] = useState(); + + // 弹出框拖动效果 + const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 + const [disabled, setDraggleDisabled] = useState() // 是否拖动 + const draggleRef = React.createRef() + + 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), + }); + }; + + // 景区类型的枚举 + let SCENICAREATYPEObj = session.get('SCENICAREATYPEObj') + let SCENICAREATYPEList = session.get('SCENICAREATYPEList') + // 景区状态的枚举 + let BUSINESSSTATEObj = session.get('BUSINESSSTATEObj') + let BUSINESSSTATEList = session.get('BUSINESSSTATEList') + + + // 文件列表 + const [fileList, setFileList] = useState([]) + const [imagePreviewVisible, setImagePreviewVisible] = useState(false) // 预览图片 + + + // 定义列表字段内容 + const columns: any = [ + { + dataIndex: 'SCENICAREA_NAME', + title: '景区名称', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + hideInDescriptions: true, + fixed: "left", + }, + { + dataIndex: 'SCENICAREA_TYPE', + title: '景区类型', + width: 120, + ellipsis: true, + align: 'center', + valueType: "select", + valueEnum: SCENICAREATYPEObj + }, + { + dataIndex: 'SCENICAREA_LOCATION', + title: '景区位置', + width: 200, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_FACILITY', + title: '景区设施', + width: 150, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_INFO', + title: '景区简介', + width: 300, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_OPENHOURS', + title: '开放时间', + width: 180, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'TICKET_PRICE', + title: '门票价格', + width: 120, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_LEVEL', + title: '景区等级', + width: 120, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_SCORE', + title: '景区评分', + width: 120, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_EVALUATENUM', + title: '评价条数', + width: 120, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_PHONE', + title: '联系电话', + width: 150, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'SCENICAREA_STATE', + title: '景区状态', + width: 120, + ellipsis: true, + valueType: 'select', + align: 'center', + valueEnum: BUSINESSSTATEObj, + initialValue: "1000" + }, + { + dataIndex: 'OPERATE_DATE', + title: '修改时间', + width: 180, + ellipsis: true, + align: 'center', + hideInSearch: true, + render: (_, record) => { + return record?.OPERATE_DATE ? moment(record?.OPERATE_DATE).format('YYYY-MM-DD HH:mm:ss') : "-" + } + }, + { + dataIndex: 'option', + title: '操作', + width: 120, + ellipsis: true, + valueType: 'option', + hideInSearch: true, + align: 'center', + fixed: "right", + render: (_, record) => { + return ( + + { + let imgList: any = [] + if (record?.ImageList && record?.ImageList.length > 0) { + record?.ImageList.forEach((item: any) => { + let obj = JSON.parse(JSON.stringify(item)) + obj.url = obj.ImageUrl + obj.name = obj.ImageName + obj.uid = item.ImageId + obj.status = 'done' + imgList.push(obj) + }) + } + setCurrentRow({ + ...record, + SCENICAREA_Image: imgList + }); + setFileList(imgList); + handleModalVisible(true); + }} + > + 编辑 + + { + await handelDelete(record.SCENICAREA_ID); + }} + > + 删除 + + + ); + }, + }, + ]; + + // 预览上传后的图片 + const handlePreview = async () => { + setFileList(fileList) + setImagePreviewVisible(true) + }; + const handleChangePreview = (val: any) => { + setImagePreviewVisible(val) + } + + const handelDelete = async (scenicareaid: number) => { + const result = await handeDeleteSCENICAREA({ SCENICAREAId: scenicareaid }); + + if (result.Result_Code !== 100) { + message.error(`${result.Result_Desc}` || `${result.Result_Code}:删除失败`); + } else { + message.success('删除成功!'); + actionRef.current?.reload() + } + }; + + const handleAddUpdate = async (res: any) => { + + let req: any = {} + let imgList: any = [] + if (fileList && fileList.length > 0) { + fileList.forEach((item: any) => { + imgList.push({ + ImageName: item.name, + ImageUrl: item.url + }) + }) + } + + if (currentRow?.USERDEFINEDTYPE_ID) { + req = { + ...currentRow, + ...res, + // ImageList: imgList, + PROVINCE_CODE: currentUser?.ProvinceCode, + STAFF_ID: currentUser?.ID, + STAFF_NAME: currentUser?.Name, + OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'), + } + } else { + req = { + ...res, + // ImageList: imgList, + PROVINCE_CODE: currentUser?.ProvinceCode, + STAFF_ID: currentUser?.ID, + STAFF_NAME: currentUser?.Name, + OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'), + } + } + const data = await handeSynchroSCENICAREA(req) + console.log('datadatadatadata', data); + + handleConfirmLoading(false) + if (data.Result_Code === 100) { + if (res.SCENICAREA_Image && res.SCENICAREA_Image.length > 0) { + const formData = new FormData(); + res.SCENICAREA_Image.forEach((file: any) => { + formData.append('files[]', file.originFileObj); + formData.append('ImageName', typeof file !== 'string' ? file?.name : ''); + }); + formData.append('TableId', data.Result_Data.SCENICAREA_ID); + formData.append('TableType', '1305'); + + console.log('formData', formData); + await uploadPicture(formData) + } + message.success("新增成功!") + setCurrentRow(undefined) + formRef?.current?.resetFields() + handleModalVisible(false) + actionRef.current?.reload() + setFileList([]) + } else { + message.error(data.Result_Desc) + } + }; + + return ( +
+ { + return `${record?.SCENICAREA_ID}` + }} + formRef={formRef} + headerTitle={} // 列表表头 + actionRef={actionRef} + search={{ span: 6, labelWidth: 'auto' }} + bordered + // 请求数据 + request={async (params, sorter) => { + const req = { + searchParameter: { + PROVINCE_CODES: currentUser?.ProvinceCode, + SCENICAREA_TYPES: params?.SCENICAREA_TYPE, + SCENICAREA_STATES: params?.SCENICAREA_STATE, + }, + PageIndex: 1, + PageSize: 999999, + } + const data = await handeGetSCENICAREAList(req); + console.log('datadatadatadatadata', data); + if (data.List && data.List.length > 0) { + return { data: data.List, success: true, total: data.TotalCount } + } + return { data: [], success: true } + }} + columns={columns} + toolbar={{ + actions: [ + // 新增按钮 + , + ], + }} + /> + + + {/* 图片预览组件 */} + {fileList && fileList.length > 0 &&
+ { + handleChangePreview(vis) + } + }}> + { + fileList.map((n) => ) + } + +
} + + { + if (disabled) { + setDraggleDisabled(false) + } + }} + onMouseOut={() => { + setDraggleDisabled(true) + }} + + onFocus={() => { }} + onBlur={() => { }} + > + {currentRow ? '更新景区信息' : '新建景区信息'} +
+ } + destroyOnClose={true} + width={900} + visible={modalVisible} + confirmLoading={confirmLoading} + afterClose={() => { + formRef.current?.resetFields(); + setCurrentRow(undefined); + }} + onCancel={() => { + handleConfirmLoading(false) + handleModalVisible(false) + setFileList([]) + }} + + onOk={async () => { // 提交框内的数据 + formRef?.current?.validateFields().then(() => { + handleConfirmLoading(true) + formRef?.current?.submit() + }) + }} + modalRender={(modal) => { + return onDraggaleStart(event, uiData)} + > +
{modal}
+
+ }} + > + { + let newValue = { ...values }; + if (currentRow) { + // 编辑数据 + newValue = { ...values, SCENICAREA_ID: currentRow.SCENICAREA_ID }; + } + // 如果有开关,要把开关的代码写进去 + await handleAddUpdate(newValue); + + handleConfirmLoading(false) + handleModalVisible(false); + }} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + console.log('info', info); + console.log('fileList', fileList); + if (info.file.status === 'removed') { + const index = fileList.findIndex(n => n.uid === info.file.uid); + confirm({ + title: '确认删除该文件吗?', + icon: , + async onOk() { + if (info.file.ImageId) { + const deleteLoading = message.loading('正在删除...') + const success = await deletePicture(info.file?.ImagePath, info.file?.uid, '', '5000') + deleteLoading() + + if (success) { + const files = [...fileList] + files.splice(index, 1) + setFileList(files) + message.success("删除成功") + actionRef.current?.reload() + } + else { + message.error("删除失败") + } + } else { + const files = [...fileList]; + files.splice(index, 1); + setFileList(files); + } + }, + onCancel() { + }, + }); + } else { + setFileList(info.fileList) + } + } + }} + /> + + + + + + + + + + + + ); +}; +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(scenicSpotConfig); diff --git a/src/pages/travelMember/service.ts b/src/pages/travelMember/service.ts index 0ab835a..c679d50 100644 --- a/src/pages/travelMember/service.ts +++ b/src/pages/travelMember/service.ts @@ -402,4 +402,41 @@ export async function handeDeleteMALLCOMMENT(params: any) { return [] } return data +} + + +// 获得景区列表 +export async function handeGetSCENICAREAList(params: any) { + const data = await requestEncryption(`/WisdomServerpart/GetSCENICAREAList`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data.Result_Data +} + +// 同步景区列表 +export async function handeSynchroSCENICAREA(params: any) { + const data = await requestEncryption(`/WisdomServerpart/SynchroSCENICAREA`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data +} + +// 删除景区 +export async function handeDeleteSCENICAREA(params: any) { + const data = await requestEncryption(`/WisdomServerpart/DeleteSCENICAREA`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data } \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index 24d9d1a..6b8c80f 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -8,6 +8,7 @@ import moment from 'moment'; import session from './session'; import type { CurrentUser } from '@/models/user'; import { SynchroBEHAVIORRECORD } from '@/services/user'; +import { encryptAES } from './handleAes'; const codeMessage: Record = { 200: '服务器成功返回请求的数据。', @@ -146,7 +147,12 @@ request.interceptors.request.use((url, opt: any) => { } } - + if (options && options.data && options.data.requestEncryption) { + options.data = { + name: "", + value: encryptAES(JSON.stringify(options.data)) + } + } } return { // url: url.indexOf('handler_ajax.ashx')>-1 ?`https://user.eshangtech.com${url}`: `http://47.96.233.105/EShangApiMain${url}`,