Commit 68bd2350 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

feat: 新增采购流程规则配置

parent dde0dbbb
......@@ -42,7 +42,7 @@ const routeList = [
// rfqOfferRoute,
// logisticsRoutes,
// memberAbility,
// ruleSettingRoutes,
// ruleSettingRoutes,
// authConfig,
// commentRoutes,
// contentRoute,
......@@ -56,7 +56,7 @@ const routeList = [
// orderSystemRoutes,
// productionNoticeRoutes,
// exchangeManageRoutes,
// returnManageRoute,
// returnManageRoute,
// repairManageRoute,
]
......@@ -99,7 +99,7 @@ const router = [
// component: '@/pages/home',
// icon: 'BarChartOutlined'
// },
...routeList,
// ...routeList,
...asyncRoutes,
{
path: '/noAuth',
......
......@@ -48,6 +48,27 @@ const router = {
hidePageHeader: true
},
// 采购流程配置
{
path: '/ruleSettingManager/procurementRules',
name: 'procurementRules',
component: '@/pages/ruleSettingManage/procurementRules',
},
{
path: '/ruleSettingManager/procurementRules/addRule',
name: 'addProcurementRule',
component: '@/pages/ruleSettingManage/procurementRules/addRule',
hideInMenu: true,
hidePageHeader: true
},
{
path: '/ruleSettingManager/procurementRules/ruleDetails',
name: 'procurementRuleDetails',
component: '@/pages/ruleSettingManage/procurementRules/ruleDetails',
hideInMenu: true,
hidePageHeader: true
},
// 会员角色权限设置
{
path: '/ruleSettingManager/memberAuthManage',
......
......@@ -22,6 +22,9 @@ export interface PayPlatformPayConfig {
wayId?: any;
payType: number;
isPitchOn: number;
settlementWay: number;
settlementDays?: any;
settlementDate?: any;
}
export interface PayConfig {
......
......@@ -110,6 +110,9 @@ export default {
'menu.ruleSettingManager.transactionRules': '交易规则',
'menu.ruleSettingManager.addRule': '新建交易规则',
'menu.ruleSettingManager.ruleDetails': '交易规则详情',
'menu.ruleSettingManager.procurementRules': '采购流程规则',
'menu.ruleSettingManager.addProcurementRule': '新建采购流程规则',
'menu.ruleSettingManager.procurementRuleDetails': '采购流程规则详情',
'menu.ruleSettingManager.memberAuthManage': '会员角色权限设置',
'menu.ruleSettingManager.memberAuthManageDetail': '会员角色权限设置',
'menu.ruleSettingManager.platformSettlementStrategy': '平台结算策略配置',
......
import React, {useState} from 'react'
import { history } from 'umi'
import { Button, Card } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
SaveOutlined,
} from '@ant-design/icons'
import ReutrnEle from '@/components/ReturnEle';
import './index.less'
import { ruleDetailSchema } from './schema'
import { createFormActions } from '@formily/antd'
import { omit } from '@/utils'
import { PublicApi } from '@/services/api'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import RuleSetting from './components/RuleSetting'
const addSchemaAction = createFormActions()
const AddRule:React.FC<{}> = (props) => {
const [isDisabled, setIsDisabled] = useState<boolean>(false)
const {
id,
preview,
pageStatus
} = usePageStatus()
// 整体表单提交
const formSubmit = async (values) => {
setIsDisabled(true)
const params = omit(values, ['state'])
console.log(params, 'parmas')
// 切割memberId
let res: any = {}
if(pageStatus === PageStatus.EDIT){
res = await PublicApi.postManagePurchaseRuleConfigUpdate(params)
}else if(pageStatus === PageStatus.ADD){
res = await PublicApi.postManagePurchaseRuleConfigAdd(params)
}
if(res.code === 1000){
setIsDisabled(false)
history.goBack()
}
}
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title={pageStatus === PageStatus.PREVIEW ? '查看采购流程规则' : ( pageStatus === PageStatus.EDIT ? '编辑采购流程规则' : '新增采购流程规则' )}
className="addRule"
extra={[
<Button
key="1"
onClick={() => addSchemaAction.submit()}
type="primary"
icon={<SaveOutlined />}
disabled={isDisabled}
>
保存
</Button>,
]}
>
<Card className=''>
<RuleSetting addSchemaAction={addSchemaAction} schema={ruleDetailSchema} formSubmit={formSubmit}/>
</Card>
</PageHeaderWrapper>
)
}
export default AddRule
import React, { useState, useRef, useEffect } from 'react'
import styled from 'styled-components'
import { ISchemaFieldComponentProps, createFormActions, useFieldState } from '@formily/antd'
import { Row, Col, Tag } from 'antd'
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons'
import cx from 'classnames'
import { PublicApi } from '@/services/api'
import { findItemAndDelete } from '@/utils'
const SelectStyles = styled((props) => <div className='select-list' {...props}></div>)`
.select_style_border {
border: 1px solid #EEF0F3;
margin-top: 20px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 14px;
cursor: pointer;
line-height: 28px;
position:relative;
}
.select_style_border.active {
border: 1px solid #00B382;
}
.select_style_border.active::after {
content: '';
position: absolute;
width: 0;
height: 0;
border-bottom: 12px solid #00B37A;
border-left: 12px solid transparent;
bottom: 0;
right: 0;
z-index: 5;
}
`
enum ProcessTagColor {
'red',
'orange',
'purple',
'blue'
}
enum ProcessTagType {
'订单交易流程',
'售后换货流程',
'售后退货流程',
'售后维修流程'
}
const SelectProcesss = (props: ISchemaFieldComponentProps) => {
const [formInitValue, setFormInitValue] = useState<any>(null)
const [state, setFieldState] = useFieldState<any>({
dataSource: [],
showMore: false
})
const modalRef = useRef<any>({})
const { dataSource, showMore } = state
const { mutators, editable } = props
const value: number[] = props.value || []
useEffect(() => {
PublicApi.getOrderProcessRuleConfigList().then(res => {
setFieldState({
dataSource: res.data,
showMore
})
})
}, [])
const showDataSource = showMore ? dataSource : [...dataSource].splice(0, 3)
const handleCheck = (id) => {
// if (editable) {
// mutators.change(id)
// }
if (!editable) {
return false
}
if (value.includes(id)) {
const newValue = findItemAndDelete(value, id)
mutators.change(newValue)
} else {
mutators.change([...value, id])
}
}
const isChecked = (id) => {
return value.includes(id)
}
const toogleMore = () => {
setFieldState({
dataSource,
showMore: !showMore
})
}
const renderProcessType = (v: any) => {
return <Tag color={ProcessTagColor[v.type - 1]}>
{ProcessTagType[v.type - 1]}
</Tag>
}
return (
<div style={{ width: '100%' }}>
<SelectStyles>
{
showDataSource.map(v => <div key={v.id} onClick={() => handleCheck(v.id)} className={cx('select_style_border', isChecked(v.id) ? 'active' : '')}>
<div>
<Row style={{ color: '#303133' }}>
<Col>{v.name}</Col>
<Col style={{ marginLeft: 6 }}>
{
renderProcessType(v)
}
</Col>
</Row>
<div style={{ color: '#909399' }}>{v.explain}</div>
</div>
</div>)
}
</SelectStyles>
{dataSource.length > 3 &&
<div onClick={toogleMore} style={{ textAlign: 'center', cursor: 'pointer' }}>
显示更多{showMore ? <CaretDownOutlined /> : <CaretUpOutlined />}
</div>
}
</div>
)
}
SelectProcesss.defaultProps = {}
SelectProcesss.isFieldComponent = true;
export default SelectProcesss
\ No newline at end of file
import React, { useEffect } from 'react'
import { ISchemaFormActions, FormEffectHooks, IFormActions, ISchema } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
const { onFieldValueChange$ } = FormEffectHooks
export const createAddContractTemplateEffect = (context: ISchemaFormActions) => {
const fetchListContractTemplateAll = async () => {
const { data } = await PublicApi.getOrderSelectListContractTemplate()
context.setFieldState('contractTemplateId', state => {
state.contractTemplateLists = data
})
return data.map(v => ({
value: v.id,
label: v.name
}))
}
useAsyncSelect('contractTemplateId', fetchListContractTemplateAll)
}
export const useUnitPreview = (initValue, context) => {
useEffect(() => {
if (initValue) {
context.setFieldState('inventory', state => {
if (!state.props['x-props']) {
state.props['x-props'] = {}
}
state.props['x-props'].addonAfter = <div style={{marginLeft: 4}}>{initValue.unit}</div>
})
context.setFieldValue('itemNo', initValue.itemNo)
}
}, [initValue])
}
\ No newline at end of file
.addRule {
.ant-input-group-addon {
padding: 0;
border: none;
}
.connectBtn {
width: 80px;
height: 32px;
line-height: 32px;
background: #909399;
color: #fff;
text-align: center;
cursor: pointer;
}
}
\ No newline at end of file
import React, { ReactNode, useRef } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card } from 'antd'
import {
PlusOutlined,
PlayCircleOutlined,
PauseCircleOutlined,
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import moment from 'moment'
import EyePreview from '@/components/EyePreview';
import { PublicApi } from '@/services/api'
const ProcurementRules: React.FC<{}> = () => {
const ref = useRef<any>({})
const fetchData = (params: any) => {
if(!params?.name) delete params.name
return new Promise((resolve, reject) => {
PublicApi.getManagePurchaseRuleConfigList(params).then(res => {
const { data } = res
resolve(data)
})
})
}
const columns: ColumnType<any>[] = [
{
title: '流程规则ID',
dataIndex: 'id',
key: 'id',
},
{
title: '流程规则名称',
dataIndex: 'name',
key: 'name',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview
url={`/ruleSettingManager/procurementRules/ruleDetails?id=${record.id}`}
>
{text}
</EyePreview>
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
render: (text: any, record: any) => text && moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '状态',
dataIndex: 'state',
key: 'state',
render: (text: any, record: any) => {
let component: ReactNode = null
component = (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => confirm(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button
type="link"
style={record.state ? { color: '#00B37A' } : { color: 'red' }}>{record.state ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}</Button>
</Popconfirm>
)
return component
}
},
{
title: '操作',
dataIndex: 'option',
render: (text: any, record: any) => {
return (
<>
{
(record.state === 0) ? <>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => handelDelete(record)}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button type='link'>删除</Button>
</Popconfirm>
<Button type='link' onClick={()=>history.push(`/ruleSettingManager/procurementRules/addRule?id=${record.id}`)}>修改</Button>
</> : ''
}
</>
)
}
}
];
const confirm = (record: any) => {
PublicApi.postManagePurchaseRuleConfigStartOrStop({ id: record.id, state: record.state ? 0 : 1 }).then(res => {
ref.current.reload()
})
}
const cancel = () => {
console.log('cancel')
}
const handelDelete = (record: any) => {
PublicApi.postManagePurchaseRuleConfigDelete({ id: record.id }).then(res => {
if(res.code === 1000)
ref.current.reload()
})
}
return (
<Card>
<StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
layouts: {
order: 1,
span: 4,
},
ctx: {
inline: false,
schema: {
type: 'object',
properties: {
megaLayout0: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
grid: true,
columns: 2,
},
properties: {
name: {
type: 'string',
'x-component-props': {
placeholder: '规则名称',
},
'x-component': 'Search'
}
}
}
}
}
}
}}
formilyChilds={{
layouts: {
order: 0
},
children: (
<>
<Button type="primary" icon={<PlusOutlined />} onClick={() => history.push('/ruleSettingManager/procurementRules/addRule')}>
新建
</Button>
</>
)
}}
/>
</Card>
)
}
export default ProcurementRules
import React, {useState, useEffect} from 'react'
import { history } from 'umi'
import { Space, Card, Col, Row } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ReutrnEle from '@/components/ReturnEle'
import { PublicApi } from '@/services/api'
import LevelBrand from '@/pages/member/components/LevelBrand'
import { GetOrderTradingRulesBackgroundDetailsResponse, GetOrderTradingRulesBackgroundMemberResponse } from '@/services/OrderApi'
import { StandardTable } from 'god'
const RuleDetail:React.FC<{}> = (props) => {
const [membersList, setMembersList] = useState<GetOrderTradingRulesBackgroundMemberResponse>()
const [ruleDetails, setRuleDetails] = useState<GetOrderTradingRulesBackgroundDetailsResponse>()
const { id }: any = history.location.query
useEffect(() => {
// 获取规则详情
PublicApi.getManagePurchaseRuleConfigDetails({id, current: '1', pageSize: '10'}).then(res => {
const { data } = res
setRuleDetails(data)
})
}, [])
const fetchData = (params) => {
return new Promise((resolve, reject) => {
// 获取绑定的会员列表
PublicApi.getManagePurchaseMemberItemsList({id, ...params}).then(res => {
const { data } = res
resolve(data)
})
})
}
const tableColumns = [
{
dataIndex: 'memberId',
title: 'ID',
key: 'memberId'
},
{
dataIndex: 'name',
title: '会员名称',
key: 'name',
// render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview>
},
{
dataIndex: 'memberTypeName',
title: '会员类型',
key: 'memberTypeName'
},
{
dataIndex: 'roleName',
title: '会员角色',
key: 'roleName'
},
{
dataIndex: 'levelTag',
title: '会员等级',
key: 'levelTag',
render: (text, record) => <LevelBrand level={record.level} />
},
]
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title='查看详情'
>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="基本信息">
<Row>
<Col span={3}>
<p>流程规则名称:</p>
</Col>
<Col span={21}>
<p>{ruleDetails?.name}</p>
</Col>
<Col span={3}>
<p>状态:</p>
</Col>
<Col span={21}>
<p>{ruleDetails?.state ? '有效' : '无效'}</p>
</Col>
{/* <Col span={3}>
<p>交易流程名称:</p>
</Col>
<Col span={21}>
<p>
{
ruleDetails?.transactionProcesss.toString()
}
</p>
</Col> */}
</Row>
</Card>
</Space>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="适用会员">
<Row>
<Col span={3}>
<p>是否所有会员共用:</p>
</Col>
<Col span={21}>
<p>{ruleDetails?.isTacitlyApprove === 1 ? '是' : '否'}</p>
</Col>
</Row>
<StandardTable
columns={tableColumns}
fetchTableData={(params: any) => fetchData(params)}
/>
</Card>
</Space>
</PageHeaderWrapper>
)
}
export default RuleDetail
import React from 'react'
import { ISchema } from '@formily/antd';
import { padRequiredMessage } from '@/utils';
// 新增规则
export const ruleDetailSchema: ISchema = padRequiredMessage({
type: 'object',
properties: {
REPOSIT_TABS: {
type: 'object',
"x-component": "tab",
"x-component-props": {
type: 'card',
},
properties: {
"tab-1": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "基本信息"
},
"properties": {
MEGA_LAYOUT1: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
wrapperCol: 8,
labelAlign: 'left',
style: { height: '400px' }
},
properties: {
name: {
type: 'string',
required: true,
title: '规则名称',
"x-component-props": {
placeholder: '请输入规则名称'
},
"x-rules": [
{
limitByte: true,
maxByte: 48
}
]
},
processEnums: {
type: 'array:number',
title: '流程选择',
"x-component": 'SelectProcesss',
"x-mega-props": {
style: {
full: true
}
},
"x-component-props": {
dataSource: []
},
"x-rules": [
{
required: true,
message: '请选择流程配置'
}
],
},
}
}
}
},
"tab-2": {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
"tab": "适用会员"
},
properties: {
MEGA_LAYOUT3: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"isApplyMember ": {
"type": "radio",
enum: [
{ label: '所有会员(默认)', value: 1 },
{ label: '指定会员', value: 0 },
],
"title": "适用会员",
default: 1,
required: true,
"x-linkages": [
{
type: 'value:visible',
target: 'memberIds',
"condition": "{{!$value}}"
}
]
},
memberIds: {
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'MemberManageRoleId',
columns: "{{tableColumns}}",
prefix: "{{tableAddButton}}"
}
}
}
}
}
}
}
}
}
})
......@@ -12,6 +12,7 @@ import * as ReportApi from './reportApi';
import * as EnhanceApi from './enhanceApi';
import * as AfterServiceApi from './AfterServiceApi';
import * as PurchaseApi from './PurchaseApi';
import * as PlatformApi from './PlatformApi';
/**
* 可在这里写入自定义的接口
......@@ -36,4 +37,5 @@ export const PublicApi = {
...EnhanceApi,
...AfterServiceApi,
...PurchaseApi,
...PlatformApi,
}
......@@ -12,7 +12,9 @@ const tokenList = [
{ name: 'report', token: 'e709e5bd31eb2b84de468944b153a62a05afcc13f0ea880be7333b928c7c0620', categoryIds: [0]}, //报表服务
{ name: 'Purchase', token: '425043481f605f76064951c72d26c412e5ba1baf2d70158300f560ef58358f41', categoryIds: [0]}, //采购服务
{ name: 'enhance', token: '594a7e7ff17f6f40fb9fb726c1da9a3f282a926a8d386eb6cbfd668a3f75f251', categoryIds: [0] }, // 加工服务
{ name: 'AfterService', token: 'bac1c7ca2c63869ec87085b0b33e830fea19f707dea5763f1bf8f2dc5996bde8', categoryIds: [0] } // 售后服务
{ name: 'AfterService', token: 'bac1c7ca2c63869ec87085b0b33e830fea19f707dea5763f1bf8f2dc5996bde8', categoryIds: [0] }, // 售后服务
{ name: 'Platform', token: 'cadc3b13452c3ec67b5ef0c57063f12142e857a9eaa64669e80165adf42f5861', categoryIds: [0] } // 平台后台v2
]
const getConfigMap = (tokens) => tokens.map(v => ({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment