Commit b6e61238 authored by 前端-甘科's avatar 前端-甘科

Merge branch '220518-feat' into 'v2-220518'

新增规则引擎各类型列表/调整流程引擎-请购单规则/新增规则引擎配置 See merge request linkseeks-design/pro-platform!639
parents 2d4f711e bb13e5d3
...@@ -18,5 +18,6 @@ module.exports = [ ...@@ -18,5 +18,6 @@ module.exports = [
{ name: 'MessageV2', token: '7fc4a903c8ce9318fe925b1d95a39a42d7df4ba8d88df2b1260b714e24ab0db8', categoryIds: [0], }, // 消息中心v2 { name: 'MessageV2', token: '7fc4a903c8ce9318fe925b1d95a39a42d7df4ba8d88df2b1260b714e24ab0db8', categoryIds: [0], }, // 消息中心v2
{ name: 'MarketingV2', token: '0b705237f97ac68774bfcbbcbeaaf2a8f2c9381c42f6d5d0eaee219ef041701b', categoryIds: [0], }, // 营销能力 { name: 'MarketingV2', token: '0b705237f97ac68774bfcbbcbeaaf2a8f2c9381c42f6d5d0eaee219ef041701b', categoryIds: [0], }, // 营销能力
{ name: 'AfterServiceV2', token: '906dfe7bb2cb64b40c45cd9ccc8e7bab09003779e8103be2c7bd11a1ba9dcbb9', categoryIds: [0], }, // 售后能力V2 { name: 'AfterServiceV2', token: '906dfe7bb2cb64b40c45cd9ccc8e7bab09003779e8103be2c7bd11a1ba9dcbb9', categoryIds: [0], }, // 售后能力V2
{ name: 'ManageV2', token: 'b4a98fa71fa56ff34161166e714621810455c790e64f407f8788ef69cdafe234', categoryIds: [0] }, // 平台后台v2 // 平台后台v2 { name: 'ManageV2', token: '9ed658e616fbc3d317fdbbbaeb16c2f21613903f13787745c460358c41a438ae', categoryIds: [0] }, // 平台后台v2
{ name: 'RuleEngineV2', token: '4fb3cff10950aa9c237a6797e01a8ca4c9f339004efca915ecef5f96989c2519', categoryIds: [0] }, // 规则引擎服务v2
] ]
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react' ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
import { Select, SelectProps } from 'antd' import { Select, SelectProps } from 'antd'
export interface PropsType<VT> extends SelectProps<VT> { export interface PropsType<VT> extends SelectProps<VT> {
requestApi: Function requestApi?: Function
params?: Object params?: Object
labelKey?: string labelKey?: string
valueKey?: string valueKey?: string
......
...@@ -5,7 +5,7 @@ export const formItemLayout = { ...@@ -5,7 +5,7 @@ export const formItemLayout = {
export enum STATUS { export enum STATUS {
Effective = 1, // 有效 Effective = 1, // 有效
invalid = 2, // 无效 invalid = 0, // 无效
} }
/** /**
......
...@@ -9,12 +9,12 @@ import BaseInfo from '@/components/BaseInfo/BaseInfo' ...@@ -9,12 +9,12 @@ import BaseInfo from '@/components/BaseInfo/BaseInfo'
import { Button, Form, Input, Radio, Checkbox } from 'antd' import { Button, Form, Input, Radio, Checkbox } from 'antd'
import { SaveOutlined } from '@ant-design/icons' import { SaveOutlined } from '@ant-design/icons'
import AuthButton from '@/components/AuthButton' import AuthButton from '@/components/AuthButton'
import { postOrderDeliveryNoticeOrderSrmCreate, getOrderDeliveryNoticeOrderDetail, postOrderDeliveryNoticeOrderUpdate } from '@/services/OrderNewV2Api'
import usePrompt from '@/hooks/usePrompt' import usePrompt from '@/hooks/usePrompt'
import FormProgress, { HandleType } from '@/components/FormProgress' import FormProgress, { HandleType } from '@/components/FormProgress'
import { validatorByte } from '@/utils/regExp' import { validatorByte } from '@/utils/regExp'
import { buyingRequisitionTypeOptions } from '../../../../constants/buyingRequisitionProcess' import { buyingRequisitionTypeOptions } from '../../../../constants/buyingRequisitionProcess'
import RadioBlock from '../RadioBlock' import RadioBlock from '../RadioBlock'
import { getPurchaseRequisitionProcessBaseList, postPurchaseRequisitionProcessSave, postPurchaseRequisitionProcessUpdate, getPurchaseRequisitionProcessGet } from '@/services/PurchaseV2Api'
enum TYPE { enum TYPE {
ADD = 'add', ADD = 'add',
...@@ -41,17 +41,22 @@ const processOptionsMock = [ ...@@ -41,17 +41,22 @@ const processOptionsMock = [
{ value: 3, label: '请购单流程-2级', detail: '1.1.待审核请购单(一级) - 2.待审核请购单(二级) - 3.待提交请购单', type: '请购单流程' }, { value: 3, label: '请购单流程-2级', detail: '1.1.待审核请购单(一级) - 2.待审核请购单(二级) - 3.待提交请购单', type: '请购单流程' },
] ]
const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnCode, title, type }) => { const AddEditContent: React.FC<PropsType> = ({ id: processId, btnCode, title, type }) => {
const [form] = Form.useForm() const [form] = Form.useForm()
const { renderPrompt, handleLeave } = usePrompt() const { renderPrompt, handleLeave } = usePrompt()
const [loading, setLoading] = useState<boolean>(false) const [loading, setLoading] = useState<boolean>(false)
const [processBaseList, setProcessBaseList] = useState<any[]>([])
const progressRef = useRef<HandleType>() const progressRef = useRef<HandleType>()
const handleSubmit = () => { const handleSubmit = () => {
form.validateFields().then((values) => { form.validateFields().then((values) => {
const params: any = {} const params: any = {
const requestApi = id ? postOrderDeliveryNoticeOrderUpdate : postOrderDeliveryNoticeOrderSrmCreate processId,
...values,
allPurchaseRequisition: true // 请购单类型,默认为包含所有请购单
}
const requestApi = processId ? postPurchaseRequisitionProcessUpdate : postPurchaseRequisitionProcessSave
setLoading(true) setLoading(true)
requestApi(params).then(({ code, data }) => { requestApi(params).then(({ code, data }) => {
if (code === 1000) { if (code === 1000) {
...@@ -63,17 +68,34 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC ...@@ -63,17 +68,34 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC
}) })
}) })
} }
// getPurchaseRequisitionProcessBaseList
const getProcessBaseList = async () => {
const { code, data } = await getPurchaseRequisitionProcessBaseList();
if (code === 1000) {
setProcessBaseList(data)
}
}
const getDetail = async () => { const getDetail = async () => {
if (id) { if (processId) {
const { code, data } = await getOrderDeliveryNoticeOrderDetail({ id }); const { code, data } = await getPurchaseRequisitionProcessGet({ processId });
if (code === 1000) { if (code === 1000) {
form.setFieldsValue({
name: data.name,
baseProcessId: data.baseProcessId,
allPurchaseRequisition: [buyingRequisitionTypeOptions[0].value] // 请购单类型,默认为包含所有请购单
})
progressRef.current.render(form)
} }
} }
} }
useEffect(() => { useEffect(() => {
getDetail() const getData = async () => {
await getProcessBaseList()
getDetail()
}
getData()
}, []) }, [])
return ( return (
...@@ -83,7 +105,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC ...@@ -83,7 +105,7 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC
anchors={anchors} anchors={anchors}
extra={ extra={
<AuthButton btnCode={btnCode}> <AuthButton btnCode={btnCode}>
{ type !== TYPE.VIEW && <Button icon={<SaveOutlined />} loading={loading} onClick={handleSubmit} type='primary'>保存</Button> } {type !== TYPE.VIEW && <Button icon={<SaveOutlined />} loading={loading} onClick={handleSubmit} type='primary'>保存</Button>}
</AuthButton> </AuthButton>
} }
> >
...@@ -111,17 +133,16 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC ...@@ -111,17 +133,16 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC
</BaseInfo> </BaseInfo>
<BaseInfo cols={1} className='mt-16' title={anchors[1].name} id={anchors[1].key}> <BaseInfo cols={1} className='mt-16' title={anchors[1].name} id={anchors[1].key}>
<Form.Item <Form.Item
name='process' name='baseProcessId'
rules={[ rules={[
{ required: true, message: `请选择流程` } { required: true, message: `请选择流程` }
]} ]}
initialValue={processOptionsMock[0].value}
> >
<Radio.Group style={{ width: '100%' }} disabled={type === TYPE.VIEW}> <Radio.Group style={{ width: '100%' }} disabled={type === TYPE.VIEW}>
{ {
processOptionsMock.map(item => ( processBaseList.map(item => (
<RadioBlock <RadioBlock
key={item.value} key={item.baseProcessId}
options={item} options={item}
/> />
)) ))
...@@ -131,13 +152,13 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC ...@@ -131,13 +152,13 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC
</BaseInfo> </BaseInfo>
<BaseInfo cols={1} className='mt-16' title={anchors[2].name} id={anchors[2].key}> <BaseInfo cols={1} className='mt-16' title={anchors[2].name} id={anchors[2].key}>
<Form.Item <Form.Item
name='buyingRequisitionType' name='allPurchaseRequisition'
initialValue={[buyingRequisitionTypeOptions[0].value]} initialValue={[buyingRequisitionTypeOptions[0].value]}
rules={[ rules={[
{ required: true, message: `请选择请购类型` } { required: true, message: `请选择请购类型` }
]} ]}
> >
<Checkbox.Group disabled={type === TYPE.VIEW} options={buyingRequisitionTypeOptions}/> <Checkbox.Group disabled options={buyingRequisitionTypeOptions} />
</Form.Item> </Form.Item>
</BaseInfo> </BaseInfo>
</Form> </Form>
...@@ -146,4 +167,4 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC ...@@ -146,4 +167,4 @@ const DeliveryNoticeManagementAwaitSRMDetails: React.FC<PropsType> = ({ id, btnC
) )
} }
export default DeliveryNoticeManagementAwaitSRMDetails export default AddEditContent
...@@ -8,22 +8,22 @@ import styles from './index.less' ...@@ -8,22 +8,22 @@ import styles from './index.less'
type PropsType = { type PropsType = {
options: { options: {
label: string, processName: string,
value: string | number, baseProcessId: string | number,
detail?: string, description?: string,
type?: string processTypeName?: string
} }
} }
const RadioBlock: React.FC<PropsType> = ({ options }) => { const RadioBlock: React.FC<PropsType> = ({ options }) => {
return ( return (
<Radio className={styles.radioBlock} value={options.value}> <Radio className={styles.radioBlock} value={options.baseProcessId}>
<div> <div>
<div className={styles.label}>{options.label}</div> <div className={styles.label}>{options.processName}</div>
<div className={styles.detail}>{options.detail}</div> <div className={styles.detail}>{options.description}</div>
</div> </div>
<div className={styles.tag}><span>{options.type}</span></div> <div className={styles.tag}><span>{options.processTypeName}</span></div>
</Radio> </Radio>
) )
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
import React, { useMemo, useRef } from 'react' import React, { useMemo, useRef } from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Button, Card, Space, Switch } from 'antd' import { Button, Card, Modal, Space, Switch } from 'antd'
import StandardTable from '@/components/StandardTable' import StandardTable from '@/components/StandardTable'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch' import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const' import { FORM_FILTER_PATH } from '@/formSchema/const'
import { schema } from './schema' import { schema } from './schema'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { history, useIntl } from 'umi'
import { history } from 'umi'
import { PlusOutlined } from '@ant-design/icons' import { PlusOutlined } from '@ant-design/icons'
import StatusSwitch from '@/components/StatusSwitch' import StatusSwitch from '@/components/StatusSwitch'
import { getPurchaseRequisitionProcessDelete, getPurchaseRequisitionProcessPage, postPurchaseRequisitionProcessUpdateStatus } from '@/services/PurchaseV2Api'
const BuyingRequisitionProcess: React.FC = () => { const BuyingRequisitionProcess: React.FC = () => {
const intl = useIntl()
const ref = useRef<any>({}) const ref = useRef<any>({})
const formActions = createFormActions() const formActions = createFormActions()
...@@ -45,14 +46,26 @@ const BuyingRequisitionProcess: React.FC = () => { ...@@ -45,14 +46,26 @@ const BuyingRequisitionProcess: React.FC = () => {
'删除': 'buyingRequisitionProcess.delete', '删除': 'buyingRequisitionProcess.delete',
} }
const buttonGroup = { const buttonGroup = {
'修改': true, '修改': record.status === 0,
'查看': true, '查看': true,
'删除': true, '删除': record.status === 0,
} }
const operationHandler = { const operationHandler = {
'修改': () => { history.push(`/memberCenter/systemSetting/processManagement/buyingRequisitionProcess/edit?id=${record.id}`) }, '修改': () => { history.push(`/memberCenter/systemSetting/processManagement/buyingRequisitionProcess/edit?id=${record.processId}`) },
'查看': () => { history.push(`/memberCenter/systemSetting/processManagement/buyingRequisitionProcess/detail?id=${record.id}`) }, '查看': () => { history.push(`/memberCenter/systemSetting/processManagement/buyingRequisitionProcess/detail?id=${record.processId}`) },
'删除': () => {} '删除': () => {
Modal.confirm({
content: intl.formatMessage({ id: 'common.tip.save.confirm' }),
okText: intl.formatMessage({ id: 'common.button.confirm' }),
cancelText: intl.formatMessage({ id: 'common.button.cancel' }),
onOk: async () => {
const { code } = await getPurchaseRequisitionProcessDelete({ processId: record.processId })
if (code === 1000) {
ref.current.reload()
}
}
})
}
} }
return ( return (
<TableOperation <TableOperation
...@@ -63,13 +76,19 @@ const BuyingRequisitionProcess: React.FC = () => { ...@@ -63,13 +76,19 @@ const BuyingRequisitionProcess: React.FC = () => {
) )
} }
const handleModify = (record) => { const handleStatus = async ({ processId }, status: number) => {
const res = await postPurchaseRequisitionProcessUpdateStatus({
processId,
status
})
if (res.code === 1000) {
ref.current.reload()
}
} }
const fetchData = (params: any) => { const fetchData = (params: any) => {
return new Promise((resolve) => { return new Promise((resolve) => {
getOrderDeliveryNoticeOrderVendorPage({ getPurchaseRequisitionProcessPage({
...params, ...params,
}).then(({ code, data }) => { }).then(({ code, data }) => {
if (code === 1000) { if (code === 1000) {
...@@ -83,12 +102,12 @@ const BuyingRequisitionProcess: React.FC = () => { ...@@ -83,12 +102,12 @@ const BuyingRequisitionProcess: React.FC = () => {
{ title: '流程规则ID', dataIndex: 'processId', key: 'processId' }, { title: '流程规则ID', dataIndex: 'processId', key: 'processId' },
{ {
title: '流程规则名称', title: '流程规则名称',
dataIndex: 'processRuleName', dataIndex: 'name',
key: 'processRuleName', key: 'name',
width: 160, width: 160,
ellipsis: true, ellipsis: true,
render: (text: unknown, record: any) => ( render: (text: unknown, record: any) => (
<EyePreview url={`/memberCenter/systemSetting/processManagement/buyingRequisitionProcess/detail?id=${record.id}`}>{text}</EyePreview> <EyePreview url={`/memberCenter/systemSetting/processManagement/buyingRequisitionProcess/detail?id=${record.processId}`}>{text}</EyePreview>
) )
}, },
{ title: '流程名称', dataIndex: 'processName', key: 'processName' }, { title: '流程名称', dataIndex: 'processName', key: 'processName' },
...@@ -97,14 +116,7 @@ const BuyingRequisitionProcess: React.FC = () => { ...@@ -97,14 +116,7 @@ const BuyingRequisitionProcess: React.FC = () => {
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
render: (text: string, record: any) => ( render: (text: string, record: any) => (
// <AuthButton btnCode='buyingRequisitionProcess.state' > <Switch checked={!!text} onChange={() => handleStatus(record, !!text ? 0 : 1)} />
// <StatusSwitch
// fieldNames="status"
// handleConfirm={() => handleModify(record)}
// record={record}
// />
// </AuthButton>
<Switch />
) )
}, },
{ title: '操作时间', dataIndex: 'createTime', key: 'createTime' }, { title: '操作时间', dataIndex: 'createTime', key: 'createTime' },
...@@ -121,7 +133,7 @@ const BuyingRequisitionProcess: React.FC = () => { ...@@ -121,7 +133,7 @@ const BuyingRequisitionProcess: React.FC = () => {
<StandardTable <StandardTable
currentRef={ref} currentRef={ref}
columns={columns} columns={columns}
tableProps={{ rowKey: 'id', }} tableProps={{ rowKey: 'processId' }}
fetchTableData={(params: any) => fetchData(params)} fetchTableData={(params: any) => fetchData(params)}
controlRender={ controlRender={
<NiceForm <NiceForm
......
...@@ -5,16 +5,19 @@ ...@@ -5,16 +5,19 @@
import React from 'react' import React from 'react'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getPurchaseRequisitionProcessEnginePage } from '@/services/PurchaseV2Api'
import CommonTable from '../component/CommonTable' import CommonTable from '../component/CommonTable'
import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns'; import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns';
import { history } from 'umi'
const MaterialManageRule: React.FC = () => { const MaterialManageRule: React.FC = () => {
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const btnAuthOfOperationTextMap = { '配置': 'buyingRequisitionRule.config' } const btnAuthOfOperationTextMap = { '配置': 'buyingRequisitionRule.config' }
const buttonGroup = { '配置': true } const buttonGroup = { '配置': true }
const operationHandler = { '配置': () => { } } const operationHandler = { '配置': () => {
history.push(`/memberCenter/systemSetting/ruleEng/ruleEngConfig?type=BUYING_REQUISITION&processId=${record.processId}`)
}}
return ( return (
<TableOperation <TableOperation
buttonTextFieldMap={buttonGroup} buttonTextFieldMap={buttonGroup}
...@@ -38,13 +41,13 @@ const MaterialManageRule: React.FC = () => { ...@@ -38,13 +41,13 @@ const MaterialManageRule: React.FC = () => {
// 操作 // 操作
{ {
...column_operation, ...column_operation,
render: (record) => renderOptionButton(record) render: (_, record) => renderOptionButton(record)
} }
] ]
return ( return (
<CommonTable <CommonTable
fetchApi={getOrderDeliveryNoticeOrderVendorPage} fetchApi={getPurchaseRequisitionProcessEnginePage}
columns={columns} columns={columns}
/> />
) )
......
...@@ -12,8 +12,8 @@ export const column_name = name ...@@ -12,8 +12,8 @@ export const column_name = name
/** 流程规则类型 */ /** 流程规则类型 */
export const column_processRuleType: ColumnType<any> = { export const column_processRuleType: ColumnType<any> = {
title: '流程规则类型', title: '流程规则类型',
key: 'processRuleType', key: 'processTypeName',
dataIndex: 'processRuleType', dataIndex: 'processTypeName',
} }
/** 流程名称 */ /** 流程名称 */
......
...@@ -25,7 +25,7 @@ type PropsType = { ...@@ -25,7 +25,7 @@ type PropsType = {
} }
const CommonTable: React.FC<PropsType> = (props) => { const CommonTable: React.FC<PropsType> = (props) => {
const { schema = tableFormSchema, fetchApi, fetchParams = {}, columns, searchKey = 'name', rowKey = 'id' } = props const { schema = tableFormSchema, fetchApi, fetchParams = {}, columns, searchKey = 'name', rowKey = 'processId' } = props
const ref = useRef<any>({}) const ref = useRef<any>({})
const formActions = createFormActions() const formActions = createFormActions()
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React from 'react' import React from 'react'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getContractRuleEngineCoordinationPage } from '@/services/ContractV2Api'
import CommonTable from '../component/CommonTable' import CommonTable from '../component/CommonTable'
import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns'; import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns';
import { history } from 'umi' import { history } from 'umi'
...@@ -15,7 +15,9 @@ const ContractCoordinationRule: React.FC = () => { ...@@ -15,7 +15,9 @@ const ContractCoordinationRule: React.FC = () => {
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const btnAuthOfOperationTextMap = { '配置': 'contractCoordinationRule.config' } const btnAuthOfOperationTextMap = { '配置': 'contractCoordinationRule.config' }
const buttonGroup = { '配置': true } const buttonGroup = { '配置': true }
const operationHandler = { '配置': () => { history.push('/memberCenter/systemSetting/ruleEng/ruleEngConfig') } } const operationHandler = { '配置': () => {
history.push(`/memberCenter/systemSetting/ruleEng/ruleEngConfig?type=CONTRACT_COORDINATION&processId=${record.processId}`)
}}
return ( return (
<TableOperation <TableOperation
buttonTextFieldMap={buttonGroup} buttonTextFieldMap={buttonGroup}
...@@ -42,13 +44,13 @@ const ContractCoordinationRule: React.FC = () => { ...@@ -42,13 +44,13 @@ const ContractCoordinationRule: React.FC = () => {
// 操作 // 操作
{ {
...column_operation, ...column_operation,
render: (record) => renderOptionButton(record) render: (_, record) => renderOptionButton(record)
} }
] ]
return ( return (
<CommonTable <CommonTable
fetchApi={getOrderDeliveryNoticeOrderVendorPage} fetchApi={getContractRuleEngineCoordinationPage}
columns={columns} columns={columns}
/> />
) )
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React from 'react' import React from 'react'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getContractRuleEngineProcessPage } from '@/services/ContractV2Api'
import CommonTable from '../component/CommonTable' import CommonTable from '../component/CommonTable'
import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns'; import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns';
import { history } from 'umi' import { history } from 'umi'
...@@ -15,7 +15,9 @@ const ContractManageRule: React.FC = () => { ...@@ -15,7 +15,9 @@ const ContractManageRule: React.FC = () => {
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const btnAuthOfOperationTextMap = { '配置': 'contractManageRule.config' } const btnAuthOfOperationTextMap = { '配置': 'contractManageRule.config' }
const buttonGroup = { '配置': true } const buttonGroup = { '配置': true }
const operationHandler = { '配置': () => { history.push('/memberCenter/systemSetting/ruleEng/ruleEngConfig') } } const operationHandler = { '配置': () => {
history.push(`/memberCenter/systemSetting/ruleEng/ruleEngConfig?type=CONTRACT_MANAGE&processId=${record.processId}`)
}}
return ( return (
<TableOperation <TableOperation
buttonTextFieldMap={buttonGroup} buttonTextFieldMap={buttonGroup}
...@@ -42,13 +44,13 @@ const ContractManageRule: React.FC = () => { ...@@ -42,13 +44,13 @@ const ContractManageRule: React.FC = () => {
// 操作 // 操作
{ {
...column_operation, ...column_operation,
render: (record) => renderOptionButton(record) render: (_, record) => renderOptionButton(record)
} }
] ]
return ( return (
<CommonTable <CommonTable
fetchApi={getOrderDeliveryNoticeOrderVendorPage} fetchApi={getContractRuleEngineProcessPage}
columns={columns} columns={columns}
/> />
) )
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React from 'react' import React from 'react'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getProductMaterialProcessEnginePage } from '@/services/ProductV2Api'
import CommonTable from '../component/CommonTable' import CommonTable from '../component/CommonTable'
import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns'; import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns';
import { history } from 'umi' import { history } from 'umi'
...@@ -15,7 +15,9 @@ const BuyingRequisitionRule: React.FC = () => { ...@@ -15,7 +15,9 @@ const BuyingRequisitionRule: React.FC = () => {
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const btnAuthOfOperationTextMap = { '配置': 'materialManageRule.config' } const btnAuthOfOperationTextMap = { '配置': 'materialManageRule.config' }
const buttonGroup = { '配置': true } const buttonGroup = { '配置': true }
const operationHandler = { '配置': () => { history.push('/memberCenter/systemSetting/ruleEng/ruleEngConfig') } } const operationHandler = { '配置': () => {
history.push(`/memberCenter/systemSetting/ruleEng/ruleEngConfig?type=MATERIAL_MANAGE&processId=${record.processId}`)
}}
return ( return (
<TableOperation <TableOperation
buttonTextFieldMap={buttonGroup} buttonTextFieldMap={buttonGroup}
...@@ -42,13 +44,13 @@ const BuyingRequisitionRule: React.FC = () => { ...@@ -42,13 +44,13 @@ const BuyingRequisitionRule: React.FC = () => {
// 操作 // 操作
{ {
...column_operation, ...column_operation,
render: (record) => renderOptionButton(record) render: (_, record) => renderOptionButton(record)
} }
] ]
return ( return (
<CommonTable <CommonTable
fetchApi={getOrderDeliveryNoticeOrderVendorPage} fetchApi={getProductMaterialProcessEnginePage}
columns={columns} columns={columns}
/> />
) )
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React from 'react' import React from 'react'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getOrderPurchaseProcessEnginePage } from '@/services/OrderNewV2Api'
import CommonTable from '../component/CommonTable' import CommonTable from '../component/CommonTable'
import { column_id, column_name, column_processRuleType, column_processName, column_status, column_createTime, column_operation } from '../columns'; import { column_id, column_name, column_processRuleType, column_processName, column_status, column_createTime, column_operation } from '../columns';
import { history } from 'umi' import { history } from 'umi'
...@@ -15,7 +15,9 @@ const PurchaseProcessRule: React.FC = () => { ...@@ -15,7 +15,9 @@ const PurchaseProcessRule: React.FC = () => {
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const btnAuthOfOperationTextMap = { '配置': 'purchaseProcessRule.config' } const btnAuthOfOperationTextMap = { '配置': 'purchaseProcessRule.config' }
const buttonGroup = { '配置': true } const buttonGroup = { '配置': true }
const operationHandler = { '配置': () => { history.push('/memberCenter/systemSetting/ruleEng/ruleEngConfig') } } const operationHandler = { '配置': () => {
history.push(`/memberCenter/systemSetting/ruleEng/ruleEngConfig?type=PURCHASE_PROCESS&processId=${record.processId}`)
}}
return ( return (
<TableOperation <TableOperation
buttonTextFieldMap={buttonGroup} buttonTextFieldMap={buttonGroup}
...@@ -44,13 +46,13 @@ const PurchaseProcessRule: React.FC = () => { ...@@ -44,13 +46,13 @@ const PurchaseProcessRule: React.FC = () => {
// 操作 // 操作
{ {
...column_operation, ...column_operation,
render: (record) => renderOptionButton(record) render: (_, record) => renderOptionButton(record)
} }
] ]
return ( return (
<CommonTable <CommonTable
fetchApi={getOrderDeliveryNoticeOrderVendorPage} fetchApi={getOrderPurchaseProcessEnginePage}
columns={columns} columns={columns}
/> />
) )
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React from 'react' import React from 'react'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getSettleAccountsApplyAmountProcessEffectiveStatus } from '@/services/SettleV2Api'
import CommonTable from '../component/CommonTable' import CommonTable from '../component/CommonTable'
import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns'; import { column_id, column_name, column_processName, column_status, column_createTime, column_operation } from '../columns';
import { history } from 'umi' import { history } from 'umi'
...@@ -15,7 +15,9 @@ const RequestFundsManageRule: React.FC = () => { ...@@ -15,7 +15,9 @@ const RequestFundsManageRule: React.FC = () => {
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const btnAuthOfOperationTextMap = { '配置': 'requestFundsManageRule.config' } const btnAuthOfOperationTextMap = { '配置': 'requestFundsManageRule.config' }
const buttonGroup = { '配置': true } const buttonGroup = { '配置': true }
const operationHandler = { '配置': () => { history.push('/memberCenter/systemSetting/ruleEng/ruleEngConfig') } } const operationHandler = { '配置': () => {
history.push(`/memberCenter/systemSetting/ruleEng/ruleEngConfig?type=REQUEST_FUNDS_MANAGE&processId=${record.processId}`)
}}
return ( return (
<TableOperation <TableOperation
buttonTextFieldMap={buttonGroup} buttonTextFieldMap={buttonGroup}
...@@ -42,13 +44,13 @@ const RequestFundsManageRule: React.FC = () => { ...@@ -42,13 +44,13 @@ const RequestFundsManageRule: React.FC = () => {
// 操作 // 操作
{ {
...column_operation, ...column_operation,
render: (record) => renderOptionButton(record) render: (_, record) => renderOptionButton(record)
} }
] ]
return ( return (
<CommonTable <CommonTable
fetchApi={getOrderDeliveryNoticeOrderVendorPage} fetchApi={getSettleAccountsApplyAmountProcessEffectiveStatus}
columns={columns} columns={columns}
/> />
) )
......
import React, { useRef, useState, useCallback, forwardRef, memo } from 'react' import React, { useRef, useState, useCallback, forwardRef, memo, useEffect, useImperativeHandle } from 'react'
import { Form } from 'antd' import { Tree } from 'antd'
import StandardTable from '@/components/StandardTable'
import { ColumnType } from 'antd/lib/table'
import NiceForm from '@/components/NiceForm'
import { createFormActions } from '@formily/antd'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import { schema } from './schema'
import CommonDrawer from '../CommonDrawer' import CommonDrawer from '../CommonDrawer'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getProductPlatformGetCategoryTree } from '@/services/ProductV2Api'
interface PropsType { interface PropsType {
onOk?: () => void onOk?: (values: any) => void
fieldCode?: string
selectCache?: any[]
} }
const ConfigDrawer = (props: PropsType, ref) => { const CategoryDrawer = (props: PropsType, ref) => {
const [form] = Form.useForm() const { onOk, fieldCode, selectCache } = props
const formActions = createFormActions()
const { onOk } = props
const tableRef = useRef<any>({}) const [categoryTree, setCategoryTree] = useState<any[]>([])
const [checkedKeys, setCheckedKeys] = useState<any[]>([])
const drawRef = useRef<any>()
const handleOk = useCallback(() => { const handleOk = useCallback(() => {
form.validateFields().then((values) => { onOk?.(checkedKeys.map(item => ({ id: item.id, value: item[fieldCode] })))
onOk?.() }, [checkedKeys])
})
}, [])
const handleShow = useCallback((params: Object) => { const handleShow = useCallback((params: Object) => {
}, []) }, [])
const fetchData = (params: any) => { const getCategoryTree = async () => {
return new Promise((resolve) => { const { code, data } = await getProductPlatformGetCategoryTree()
getOrderDeliveryNoticeOrderVendorPage(params).then(({ code, data }) => { if (code === 1000) {
if (code === 1000) { setCategoryTree(data)
resolve(data) }
}
const _onCheck = (checked: string[], e: any) => {
const newChecks = e.checkedNodes.flatMap(item => !!item.children.length ? [] : [item])
setCheckedKeys(newChecks)
}
const checkAbleCategoryTree = () => {
const newTree = JSON.parse(JSON.stringify(categoryTree))
function delTree(tree, delItem) {
if (delItem) {
if (delItem.children.length) {
delItem.children.forEach(item => {
delTree(tree, item)
})
} else {
if(selectCache.includes(delItem.id)) {
delItem.disableCheckbox = true
}
} }
}) }
}
newTree.forEach(item => {
delTree(newTree, item)
}) })
return newTree
} }
const columns: ColumnType<any>[] = [ useImperativeHandle(ref, () => ({
{ show(flag: boolean, params = {}, data) {
title: '通知单号', drawRef?.current?.show(flag, params)
dataIndex: 'noticeNo', if (data) {
key: 'noticeNo', setCheckedKeys(data?.selectData || [])
width: 160, }
}, },
{ title: '通知单摘要', dataIndex: 'digest', key: 'digest' }, setKeys(keys: any[]) {
{ title: '送货日期', dataIndex: 'deliveryTime', key: 'deliveryTime' }, setCheckedKeys(keys)
{ title: '采购会员', dataIndex: 'memberName', key: 'memberName' }, }
{ title: '单据时间', dataIndex: 'createTime', key: 'createTime' }, }))
]
useEffect(() => {
getCategoryTree()
}, [])
return ( return (
<CommonDrawer <CommonDrawer
ref={ref} ref={drawRef}
title='编辑' title='选择品类'
width={400} width={600}
onOk={handleOk} onOk={handleOk}
onCancel={() => {}}
onShow={handleShow} onShow={handleShow}
destroyOnClose
> >
<StandardTable <Tree
currentRef={tableRef} checkable={true}
columns={columns} onCheck={_onCheck}
tableProps={{ rowKey: 'id', }} treeData={checkAbleCategoryTree()}
fetchTableData={(params: unknown) => fetchData(params)} blockNode={true}
controlRender={ checkedKeys={checkedKeys.map(item => item.id)}
<NiceForm fieldNames={{ key: 'id' }}
actions={formActions}
onSubmit={values => ref.current.reload(values)}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'noticeNo',
FORM_FILTER_PATH,
)
}}
schema={schema}
/>
}
/> />
</CommonDrawer> </CommonDrawer>
) )
} }
export default memo(forwardRef(ConfigDrawer)) export default memo(forwardRef(CategoryDrawer))
import { ISchema } from '@formily/antd'
import { FORM_FILTER_PATH } from '@/formSchema/const'
export const schema: ISchema = {
type: 'object',
properties: {
mageLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
className: 'useMegaStart'
},
properties: {
noticeNo: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
allowClear: true,
placeholder: '请输入通知单号查询'
},
},
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
justifyContent: 'flex-start'
},
colStyle: {
marginRight: 20,
},
},
properties: {
digest: {
type: 'string',
'x-component-props': {
allowClear: true,
placeholder: '通知单摘要'
}
},
'[startDate, endDate]': {
type: 'daterange',
'x-component-props': {
allowClear: true,
placeholder: ['送货开始日期', '送货结束日期'],
},
},
memberName: {
type: 'string',
'x-component-props': {
allowClear: true,
placeholder: '采购会员'
}
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
}
}
}
}
}
}
...@@ -3,7 +3,7 @@ import { Drawer, Space, Button, DrawerProps } from 'antd' ...@@ -3,7 +3,7 @@ import { Drawer, Space, Button, DrawerProps } from 'antd'
import styles from './index.less' import styles from './index.less'
export type HandleType = { export type HandleType = {
show: (flag?: boolean, params?: Object) => void; show: (flag?: boolean, params?: any) => void;
} }
interface PropsType extends DrawerProps { interface PropsType extends DrawerProps {
...@@ -12,23 +12,24 @@ interface PropsType extends DrawerProps { ...@@ -12,23 +12,24 @@ interface PropsType extends DrawerProps {
onCancel?: () => void onCancel?: () => void
cancelText?: string cancelText?: string
children?: React.ReactNode children?: React.ReactNode
onShow?: (params: Object) => void onShow?: (params: any, flag?: boolean) => void
specialFooter?: React.ReactNode specialFooter?: React.ReactNode
confirmLoading?: boolean
} }
const CommonDrawer = (props: PropsType, ref: any) => { const CommonDrawer = (props: PropsType, ref: any) => {
const { onOk, onCancel, onShow, okText = '确定', cancelText = '取消', specialFooter, children, ...rest } = props const { onOk, onCancel, onShow, okText = '确定', cancelText = '取消', specialFooter, children, confirmLoading, ...rest } = props
const [visible, setVisible] = useState<boolean>(false) const [visible, setVisible] = useState<boolean>(false)
console.log('confirmLoading', confirmLoading)
const _onCancel = () => { const _onCancel = () => {
setVisible(false) setVisible(false)
onCancel?.() onCancel?.()
} }
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
show(flag = true, params = {}) { show(flag, params = {}) {
setVisible(flag) setVisible(flag)
onShow?.(params) onShow?.(params, flag)
} }
})) }))
...@@ -43,7 +44,7 @@ const CommonDrawer = (props: PropsType, ref: any) => { ...@@ -43,7 +44,7 @@ const CommonDrawer = (props: PropsType, ref: any) => {
<div style={{ textAlign: 'right' }}> <div style={{ textAlign: 'right' }}>
<Space size={12} > <Space size={12} >
{ onCancel && <Button onClick={_onCancel}>{cancelText}</Button> } { onCancel && <Button onClick={_onCancel}>{cancelText}</Button> }
{ onOk && <Button type="primary" onClick={onOk}>{okText}</Button> } { onOk && <Button type="primary" onClick={onOk} loading={confirmLoading}>{okText}</Button> }
</Space> </Space>
</div> </div>
</div> </div>
......
import React from 'react'
interface PropsType {
onChange?: (val: any) => void
value?: any
valueType?: 'string' | 'number' | 'array'
children?: React.ReactNode
}
const CommonValue = (props: PropsType) => {
const { onChange, value, children, valueType = 'string' } = props
const _handleValue = (val) => {
if (Array.isArray(val)) {
return val
}
return [{ value: val }]
}
const _onChange = (val) => {
const newValue = _handleValue(val)
onChange?.(newValue)
}
return (
<div>
{
children && React.Children.map(children, (child: any) => {
return React.cloneElement(child, {
value: valueType === 'array' ? value : value?.value,
onChange: _onChange
});
})
}
</div>
)
}
export default CommonValue
import React, { useState, forwardRef, memo, useCallback } from 'react' import React, { useState, forwardRef, memo, useCallback, useRef } from 'react'
import { Form } from 'antd' import { Form } from 'antd'
import CommonDrawer from '../CommonDrawer' import CommonDrawer from '../CommonDrawer'
import ProcessRules from '../ProcessRules' import ProcessRules from '../ProcessRules'
import { getRuleEngineProcessRuleConfigGetProcessRuleConfig, postRuleEngineConfigBatchSaveOrUpdate } from '@/services/RuleEngineV2Api'
interface PropsType { interface PropsType {
onChange?: () => void onChange?: () => void
...@@ -11,17 +12,62 @@ const ConfigDrawer = (props: PropsType, ref) => { ...@@ -11,17 +12,62 @@ const ConfigDrawer = (props: PropsType, ref) => {
const [form] = Form.useForm() const [form] = Form.useForm()
const { onChange } = props const { onChange } = props
const [filedTypeOptions, setFiledTypeOptions] = useState<any[]>([])
const [loading, setLoading] = useState<boolean>(false)
const paramsRef = useRef<any>({})
// 获取字段类型下拉数据
const getFiledTypeData = async (params: any) => {
const { code, data } = await getRuleEngineProcessRuleConfigGetProcessRuleConfig(params)
if (code === 1000) {
// Select组件options参数字段不支持驼峰法,这里处理一下
const newData = data.map(({ selectContent, ...rest }) => ({ ...rest, select_content: selectContent }))
setFiledTypeOptions(newData)
}
}
const handleOk = useCallback(() => { const handleOk = useCallback(() => {
form.validateFields().then((values) => { form.validateFields().then((values) => {
onChange?.() const { id, ruleEngineConfigFieldRelations } = values
const params = {
...paramsRef.current,
id,
ruleEngineConfigFieldRelations: ruleEngineConfigFieldRelations?.map(item => {
let temp = item.ruleEngineConfigFields || []
let ruleEngineConfigFields: any[] = temp?.filter(i => !['', undefined, null].includes(i.value))
return {
...item,
ruleEngineConfigFields: ruleEngineConfigFields.length ? ruleEngineConfigFields : undefined
}
})
}
console.log('params', params)
setLoading(true)
postRuleEngineConfigBatchSaveOrUpdate(params).then(({ code }) => {
if (code === 1000) {
onChange?.()
ref.current.show(false)
}
}).finally(() => {
setLoading(false)
})
}) })
}, []) }, [loading])
const handleCancel = useCallback(() => { const handleCancel = useCallback(() => {
onChange?.() onChange?.()
}, []) }, [])
const handleShow = useCallback((params: Object) => { const handleShow = useCallback(async ({ process, formData }: any, flag: boolean) => {
if (flag) {
form.resetFields()
paramsRef.current = process
await getFiledTypeData({ processId: process?.processId, processStep: process?.processStep })
console.log('formData', formData)
formData && form.setFieldsValue(formData)
}
}, []) }, [])
return ( return (
...@@ -32,8 +78,13 @@ const ConfigDrawer = (props: PropsType, ref) => { ...@@ -32,8 +78,13 @@ const ConfigDrawer = (props: PropsType, ref) => {
onOk={handleOk} onOk={handleOk}
onCancel={handleCancel} onCancel={handleCancel}
onShow={handleShow} onShow={handleShow}
confirmLoading={loading}
destroyOnClose
> >
<ProcessRules form={form}/> <ProcessRules
form={form}
filedTypeOptions={filedTypeOptions}
/>
</CommonDrawer> </CommonDrawer>
) )
} }
......
...@@ -4,7 +4,8 @@ import styles from './index.less' ...@@ -4,7 +4,8 @@ import styles from './index.less'
export type FlowChartOptionsType = { export type FlowChartOptionsType = {
label: string, label: string,
value: string | number value: string | number,
other?: any
} }
export type RefHandleType = { export type RefHandleType = {
...@@ -14,7 +15,8 @@ export type RefHandleType = { ...@@ -14,7 +15,8 @@ export type RefHandleType = {
type PropsType = { type PropsType = {
children?: React.ReactNode children?: React.ReactNode
options?: FlowChartOptionsType[] options?: FlowChartOptionsType[]
onChange?: (value: string | number) => void onChange?: (value: string | number, item?: any) => void
fieldNames?: { label?: string, value?: string }
} }
type ItemPropsType = { type ItemPropsType = {
...@@ -25,12 +27,12 @@ type ItemPropsType = { ...@@ -25,12 +27,12 @@ type ItemPropsType = {
value?: string | number value?: string | number
} }
const FlowChart = ({ children, options, onChange }: PropsType, ref) => { const FlowChart = ({ children, options, onChange, fieldNames = { label: 'label', value: 'value' } }: PropsType, ref) => {
const [activeValue, setActiveValue] = useState<string | number>() const [activeValue, setActiveValue] = useState<string | number>()
const onItemChange = (value: string | number) => { const onItemChange = (value: string | number, item?: any) => {
setActiveValue(value) setActiveValue(value)
onChange?.(value) onChange?.(value, item)
} }
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
...@@ -46,18 +48,18 @@ const FlowChart = ({ children, options, onChange }: PropsType, ref) => { ...@@ -46,18 +48,18 @@ const FlowChart = ({ children, options, onChange }: PropsType, ref) => {
options ? options ?
options.map(item => ( options.map(item => (
<FlowChartItem <FlowChartItem
key={item.value} key={item[fieldNames.value]}
active={item.value === activeValue} active={item[fieldNames.value] === activeValue}
onClick={() => { onItemChange(item.value) }} onClick={() => { onItemChange?.(item[fieldNames.value], item) }}
> >
{item.label} {item[fieldNames.label]}
</FlowChartItem> </FlowChartItem>
)) ))
: :
children && React.Children.map(children, (child: any) => { children && React.Children.map(children, (child: any) => {
return React.cloneElement(child, { return React.cloneElement(child, {
active: child.props.value === activeValue, active: child.props.value === activeValue,
onClick: (value) => { onItemChange(value) } onClick: (value) => { onItemChange?.(value) }
}); });
}) })
} }
...@@ -72,7 +74,7 @@ const FlowChartItem = ({ children, type = 'step', active, onClick, value }: Item ...@@ -72,7 +74,7 @@ const FlowChartItem = ({ children, type = 'step', active, onClick, value }: Item
<div className={styles['item-box']}> <div className={styles['item-box']}>
<div <div
className={cs(styles[type], active && styles['active'])} className={cs(styles[type], active && styles['active'])}
onClick={() => onClick(value)} onClick={() => onClick?.(value)}
> >
{children} {children}
</div> </div>
......
import React, { useRef, useState, useCallback, forwardRef, memo, useImperativeHandle } from 'react' import React, { useRef, useState, useCallback, forwardRef, memo, useImperativeHandle } from 'react'
import { Form } from 'antd' import { Cascader, Form, Tabs, Table, Checkbox } from 'antd'
import StandardTable from '@/components/StandardTable' import StandardTable from '@/components/StandardTable'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
...@@ -8,37 +8,44 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte ...@@ -8,37 +8,44 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte
import { FORM_FILTER_PATH } from '@/formSchema/const' import { FORM_FILTER_PATH } from '@/formSchema/const'
import { schema } from './schema' import { schema } from './schema'
import CommonDrawer, { HandleType } from '../CommonDrawer' import CommonDrawer, { HandleType } from '../CommonDrawer'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getProductGoodsGetDoesNotFreezeGoodsList } from '@/services/ProductV2Api'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { fetchBrand, fetchCategoryData, fetchTreeData, useAsyncCascader } from '../../effects'
export type RefHandleType = { export type RefHandleType = {
show: (flag?: boolean, params?: Object) => void show: (flag?: boolean, params?: any, data?: any) => void
setRows: (rows: any[]) => void; setRows: (rows: any[]) => void;
} }
interface PropsType { interface PropsType {
onOk?: (rows: any[], rowKeys: any[]) => void onOk?: (rows: any[], rowKeys: any[]) => void
onQueryAll?: (value?: any) => void
fieldCode?: string
selectCache?: any[]
} }
const MaterialDrawer = (props: PropsType, ref) => { const MaterialDrawer = (props: PropsType, ref) => {
const formActions = createFormActions() const formActions = createFormActions()
const { onOk } = props const { onOk, onQueryAll, fieldCode = 'code', selectCache } = props
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]) const [selectedRowKeys, setSelectedRowKeys] = useState<any>([])
const [selectedRows, setSelectedRows] = useState<any>([]) const [selectedRows, setSelectedRows] = useState<any>([])
const [isQueryAll, setIsQueryAll] = useState<boolean>(false)
const tableRef = useRef<any>({}) const tableRef = useRef<any>({})
const drawRef = useRef<HandleType>() const drawRef = useRef<HandleType>()
const handleOk = useCallback(() => { const handleOk = useCallback(() => {
onOk?.(selectedRows, selectedRowKeys) onQueryAll?.(isQueryAll)
}, [selectedRows, selectedRowKeys]) onOk?.(selectedRows.map(item => ({ id: item.id, value: item[fieldCode] })) , selectedRowKeys)
}, [selectedRows, selectedRowKeys, isQueryAll])
const handleShow = useCallback((params: Object) => { const handleShow = useCallback((params: Object) => {
}, []) }, [])
const fetchData = (params: any) => { const fetchData = (params: any) => {
return new Promise((resolve) => { return new Promise((resolve) => {
getOrderDeliveryNoticeOrderVendorPage(params).then(({ code, data }) => { getProductGoodsGetDoesNotFreezeGoodsList(params).then(({ code, data }) => {
if (code === 1000) { if (code === 1000) {
resolve(data) resolve(data)
} }
...@@ -47,20 +54,14 @@ const MaterialDrawer = (props: PropsType, ref) => { ...@@ -47,20 +54,14 @@ const MaterialDrawer = (props: PropsType, ref) => {
} }
const handleSelectChange = (record, selected, selectedRow, nativeEvent) => { const handleSelectChange = (record, selected, selectedRow, nativeEvent) => {
let childArr = [...selectedRowKeys]; let childArr = [...selectedRowKeys]
let childRowArr = [...selectedRows] let childRowArr = [...selectedRows]
if (selected) { if (selected) {
childArr.push(record.id); childArr.push(record.id)
childRowArr.push(record); childRowArr.push(record)
} else { } else {
childArr.splice( childArr.splice(childArr.findIndex((item) => item === record.id), 1)
childArr.findIndex((item) => item === record.id), childRowArr.splice(childRowArr.findIndex((item) => item.id === record.id), 1)
1
);
childRowArr.splice(
childRowArr.findIndex((item) => item.id === record.id),
1
);
} }
setSelectedRowKeys(childArr) setSelectedRowKeys(childArr)
setSelectedRows(childRowArr) setSelectedRows(childRowArr)
...@@ -88,9 +89,21 @@ const MaterialDrawer = (props: PropsType, ref) => { ...@@ -88,9 +89,21 @@ const MaterialDrawer = (props: PropsType, ref) => {
setSelectedRows(childRowArr); setSelectedRows(childRowArr);
} }
const onSelectAllMaterial = (checked: boolean) => {
setIsQueryAll(checked)
setSelectedRows([])
setSelectedRowKeys([])
}
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
show(flag = true, params = {}) { show(flag: boolean, params = {}, data: any) {
drawRef?.current?.show(flag, params) drawRef?.current?.show(flag, params)
if (data) {
setSelectedRows(data?.selectData || [])
const selectKeys = data?.selectData?.map(item => item.id) || []
setSelectedRowKeys(selectKeys)
setIsQueryAll(data?.isQueryAll || false)
}
}, },
setRows(rows: any[]) { setRows(rows: any[]) {
const rowKeys = rows.map(item => item.id) const rowKeys = rows.map(item => item.id)
...@@ -100,16 +113,18 @@ const MaterialDrawer = (props: PropsType, ref) => { ...@@ -100,16 +113,18 @@ const MaterialDrawer = (props: PropsType, ref) => {
})) }))
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ { title: 'ID', dataIndex: 'id', key: 'id', },
title: '通知单号', { title: '物料编号', dataIndex: fieldCode, key: fieldCode }
dataIndex: 'noticeNo', ]
key: 'noticeNo',
width: 160, const columns2: ColumnType<any>[] = [
}, { title: 'ID', dataIndex: 'id', key: 'id' },
{ title: '通知单摘要', dataIndex: 'digest', key: 'digest' }, { title: '物料编号', dataIndex: 'code', key: 'code', width: 120 },
{ title: '送货日期', dataIndex: 'deliveryTime', key: 'deliveryTime' }, { title: '物料名称', dataIndex: 'name', key: 'name' },
{ title: '采购会员', dataIndex: 'memberName', key: 'memberName' }, { title: '物料组', dataIndex: ['materialGroup', 'name'], key: 'materialGroup' },
{ title: '单据时间', dataIndex: 'createTime', key: 'createTime' }, { title: '规格型号', dataIndex: 'type', key: 'type' },
{ title: '品类', dataIndex: ['customerCategory', 'name'], key: 'customerCategory' },
{ title: '品牌', dataIndex: ['brand', 'name'], key: 'brand' },
] ]
return ( return (
...@@ -119,34 +134,61 @@ const MaterialDrawer = (props: PropsType, ref) => { ...@@ -119,34 +134,61 @@ const MaterialDrawer = (props: PropsType, ref) => {
width={1000} width={1000}
onOk={handleOk} onOk={handleOk}
onShow={handleShow} onShow={handleShow}
onCancel={() => { }} onCancel={() => {}}
destroyOnClose
> >
<StandardTable <div style={{ position: 'relative', top: 90 }}>
currentRef={tableRef} <Checkbox
columns={columns} checked={isQueryAll}
tableProps={{ rowKey: 'id', }} onChange={(e) => onSelectAllMaterial(e.target.checked)}
fetchTableData={(params: unknown) => fetchData(params)} >
rowSelection={{ 所有物料
selectedRowKeys: selectedRowKeys, </Checkbox>
onSelect: handleSelectChange, </div>
onSelectAll: handleSelectAll, <Tabs defaultActiveKey='1' onChange={() => {}}>
}} <Tabs.TabPane tab='可选择' key='1'>
controlRender={ {
<NiceForm !isQueryAll && (
actions={formActions} <StandardTable
onSubmit={values => tableRef.current.reload(values)} currentRef={tableRef}
effects={($, actions) => { columns={columns2}
useStateFilterSearchLinkageEffect( tableProps={{ rowKey: 'id' }}
$, fetchTableData={(params: any) => fetchData(params)}
actions, rowSelection={{
'noticeNo', selectedRowKeys: selectedRowKeys,
FORM_FILTER_PATH, onSelect: handleSelectChange,
) onSelectAll: handleSelectAll,
}} getCheckboxProps: (record: any) => ({
schema={schema} disabled: selectCache.includes(record.id)
})
}}
controlRender={
<NiceForm
actions={formActions}
onSubmit={values => tableRef.current.reload(values)}
components={{ Cascader }}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'code', FORM_FILTER_PATH);
useAsyncCascader('materialGroupId', fetchTreeData)
useAsyncCascader('categoryId', fetchCategoryData)
useAsyncSelect('brandId', fetchBrand, ["name", "id"])
}}
schema={schema}
/>
}
/>
)
}
</Tabs.TabPane>
<Tabs.TabPane tab={`已选择(${selectedRows.length})`} key='2'>
<Table
rowKey='id'
dataSource={selectedRows}
columns={columns}
pagination={null}
/> />
} </Tabs.TabPane>
/> </Tabs>
</CommonDrawer> </CommonDrawer>
) )
} }
......
import { ISchema } from '@formily/antd' import { ISchema } from '@formily/antd'
import { FORM_FILTER_PATH } from '@/formSchema/const' import { FORM_FILTER_PATH } from '@/formSchema/const'
import { getIntl } from 'umi'
const intl = getIntl()
export const schema: ISchema = { export const schema: ISchema = {
type: 'object', type: 'object',
...@@ -11,16 +14,16 @@ export const schema: ISchema = { ...@@ -11,16 +14,16 @@ export const schema: ISchema = {
topLayout: { topLayout: {
type: 'object', type: 'object',
'x-component': 'mega-layout', 'x-component': 'mega-layout',
'x-component-props': { // 'x-component-props': {
className: 'useMegaStart' // className: 'useMegaStart'
}, // },
properties: { properties: {
noticeNo: { code: {
type: 'string', type: 'string',
'x-component': 'Search', 'x-component': 'Search',
'x-component-props': { 'x-component-props': {
allowClear: true, allowClear: true,
placeholder: '请输入通知单号查询' placeholder: '物料编号'
}, },
}, },
}, },
...@@ -38,25 +41,49 @@ export const schema: ISchema = { ...@@ -38,25 +41,49 @@ export const schema: ISchema = {
}, },
}, },
properties: { properties: {
digest: { name: {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
allowClear: true, allowClear: true,
placeholder: '通知单摘要' placeholder: '物料名称'
} }
}, },
'[startDate, endDate]': { type: {
type: 'daterange', type: 'string',
'x-component-props': { "x-component-props": {
placeholder: '规格型号'
}
},
materialGroupId: {
type: 'string',
enum: [],
'x-component': 'Cascader',
"x-component-props": {
placeholder: intl.formatMessage({ id: 'material.group.title', defaultMessage: '物料组'}),
allowClear: true, allowClear: true,
placeholder: ['送货开始日期', '送货结束日期'], style: {
}, width: 150
},
showSearch: true,
fieldNames: { label: 'title', value: 'id', children: 'children' },
}
}, },
memberName: { categoryId: {
type: 'string', type: 'string',
'x-component': 'Cascader',
'x-component-props': { 'x-component-props': {
placeholder: intl.formatMessage({ id: 'material.category', defaultMessage: '品类' }),
allowClear: true, allowClear: true,
placeholder: '采购会员' style: { width: 150 },
showSearch: true,
fieldNames: { label: 'title', value: 'id', children: 'children' },
}
},
brandId: {
type: 'string',
'x-component-props': {
placeholder: intl.formatMessage({ id: 'material.brand', defaultMessage: '品牌' }),
style: { width: 150 },
} }
}, },
submit: { submit: {
......
...@@ -11,20 +11,37 @@ ...@@ -11,20 +11,37 @@
} }
.rule-wrap { .rule-wrap {
position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
width: 368px; width: 368px;
height: 32px; height: 32px;
margin-bottom: 16px; margin-bottom: 16px;
padding: 0 4px; padding: 0 4px;
border: 1px solid #F5F6F7;
border-radius: 4px; border-radius: 4px;
color: #252D37; color: #252D37;
font-size: 14px; font-size: 14px;
background-color: #F5F6F7; background-color: #F5F6F7;
cursor: pointer; cursor: pointer;
.rule-delete {
display: none;
align-items: center;
justify-content: center;
position: absolute;
right: 8px;
top: 8px;
width: 16px;
height: 16px;
cursor: pointer;
}
&:hover { &:hover {
border: 1px solid #00A98F; border: 1px solid #00A98F;
.rule-delete {
display: flex;
}
} }
:global { :global {
......
import React, { useRef, useState, useCallback, forwardRef, memo, useImperativeHandle } from 'react' import React, { useRef, forwardRef, memo } from 'react'
import StandardTable from '@/components/StandardTable' import StandardTable from '@/components/StandardTable'
import { ColumnType } from 'antd/lib/table' import { ColumnType } from 'antd/lib/table'
import CommonDrawer, { HandleType } from '../CommonDrawer' import CommonDrawer from '../CommonDrawer'
import { getOrderDeliveryNoticeOrderVendorPage } from '@/services/OrderNewV2Api' import { getMemberUserPageByRoleId } from '@/services/MemberV2Api'
interface PropsType { interface PropsType {
onOk?: (rows: any[], rowKeys: any[]) => void onOk?: (rows: any[], rowKeys: any[]) => void
} }
const SeeUserDrawer = (props: PropsType, ref) => { const SeeUserDrawer = (props: PropsType, ref) => {
const tableRef = useRef<any>({})
const roleIdRef = useRef<any>()
const fetchData = (params: any) => { const fetchData = (params: any) => {
console.log('roleIdRef.current', roleIdRef.current)
return new Promise((resolve) => { return new Promise((resolve) => {
getOrderDeliveryNoticeOrderVendorPage(params).then(({ code, data }) => { if (roleIdRef.current) {
if (code === 1000) { getMemberUserPageByRoleId({ ...params, roleId: roleIdRef.current }).then(({ code, data }) => {
resolve(data) if (code === 1000) {
} resolve(data)
}) }
})
} else {
resolve({ total: 0, data: [] })
}
}) })
} }
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ { title: '序号', dataIndex: 'number', key: 'number', render: (text, record, index) => index },
title: '通知单号', { title: '姓名', dataIndex: 'name', key: 'name' },
dataIndex: 'noticeNo', { title: '手机号码', dataIndex: 'phone', key: 'phone' },
key: 'noticeNo', { title: '所属机构', dataIndex: 'orgName', key: 'orgName' },
width: 160, { title: '职位', dataIndex: 'jobTitle', key: 'jobTitle' },
},
{ title: '通知单摘要', dataIndex: 'digest', key: 'digest' },
{ title: '送货日期', dataIndex: 'deliveryTime', key: 'deliveryTime' },
{ title: '采购会员', dataIndex: 'memberName', key: 'memberName' },
{ title: '单据时间', dataIndex: 'createTime', key: 'createTime' },
] ]
return ( return (
<CommonDrawer <CommonDrawer
ref={ref} ref={ref}
title='用户列表' title='用户列表'
width={1000} width={800}
footer={null} footer={null}
onShow={(params: any) => {
roleIdRef.current = params?.roleId
}}
destroyOnClose={true}
> >
<StandardTable <StandardTable
ref={tableRef}
columns={columns} columns={columns}
tableProps={{ rowKey: 'id', }} tableProps={{ rowKey: 'userId' }}
fetchTableData={(params: any) => fetchData(params)} fetchTableData={(params: any) => fetchData(params)}
/> />
</CommonDrawer> </CommonDrawer>
......
import React, { useState, memo, useCallback, useRef, useEffect } from 'react' import React, { useState, memo, useCallback, useRef, useEffect } from 'react'
import { HandleType } from '../CommonDrawer' import CategoryDrawer from '../CategoryDrawer'
import MaterialDrawer, { RefHandleType } from '../MaterialDrawer'
import WrapSelect from '../WrapSelect' import WrapSelect from '../WrapSelect'
interface PropsType { interface PropsType {
onChange?: (data: any[]) => void onChange?: (data: any) => void
onValueChange?: (data: any[]) => void
value?: any value?: any
fieldCode?: string
selectCache?: any[]
} }
const SelectMaterial = (props: PropsType) => { const SelectMaterial = (props: PropsType) => {
const { onChange, value } = props const { onChange, value, fieldCode = 'title', onValueChange, ...rest } = props
const [selectData, setSelectData] = useState<any[]>([]) const [selectData, setSelectData] = useState<any[]>([])
const ref = useRef<RefHandleType>() const ref = useRef<any>()
const handleOk = useCallback((rows: any[]) => { const handleOk = useCallback((keys: any[]) => {
onChange?.(rows) // 直接处理为JSON字符串
setSelectData(rows) onChange?.(JSON.stringify(keys))
onValueChange?.(keys)
setSelectData(keys)
ref?.current?.show(false) ref?.current?.show(false)
}, []) }, [])
const onItemDelete = (id: string | number) => { const onItemDelete = (id: string | number) => {
const newSelectData = selectData.filter(item => item.id !== id) const newSelectData = selectData.filter(item => item.id !== id)
// 直接处理为JSON字符串
onChange?.(JSON.stringify(newSelectData))
onValueChange?.(newSelectData)
setSelectData(newSelectData) setSelectData(newSelectData)
ref?.current?.setRows(newSelectData) ref?.current?.setKeys(newSelectData)
} }
useEffect(() => { useEffect(() => {
if (value) { if (value) {
setSelectData(value) // JSON字符串转为原数据
const keys = JSON.parse(value)
setSelectData(keys)
onValueChange?.(keys)
} }
}, []) }, [value])
return ( return (
<> <>
<WrapSelect <WrapSelect
onIconClick={() => { ref?.current?.show() }} onIconClick={() => { ref?.current?.show(true, {}, { selectData }) }}
onItemDelete={onItemDelete} onItemDelete={onItemDelete}
data={selectData} data={selectData}
labelKey='memberName' labelKey='value'
/> />
<MaterialDrawer <CategoryDrawer
ref={ref} ref={ref}
onOk={handleOk} onOk={handleOk}
fieldCode={fieldCode}
{...rest}
/> />
</> </>
......
...@@ -3,45 +3,72 @@ import MaterialDrawer, { RefHandleType } from '../MaterialDrawer' ...@@ -3,45 +3,72 @@ import MaterialDrawer, { RefHandleType } from '../MaterialDrawer'
import WrapSelect from '../WrapSelect' import WrapSelect from '../WrapSelect'
interface PropsType { interface PropsType {
onChange?: (data: any[]) => void onChange?: (data: any) => void
onValueChange?: (data: any[]) => void
value?: any value?: any
fieldCode?: string
onQueryAll?: (value?: any) => void
selectCache?: any[]
isAll?: boolean
} }
const SelectMaterial = (props: PropsType) => { const SelectMaterial = (props: PropsType) => {
const { onChange, value } = props const { onChange, value, fieldCode = 'code', onQueryAll, onValueChange, isAll, ...rest } = props
const [selectData, setSelectData] = useState<any[]>([]) const [selectData, setSelectData] = useState<any[]>([])
const [isQueryAll, setIsQueryAll] = useState<boolean>(false)
const ref = useRef<RefHandleType>() const ref = useRef<RefHandleType>()
const handleOk = useCallback((rows: any[]) => { const handleOk = useCallback((rows: any[]) => {
onChange?.(rows) // 直接处理为JSON字符串
onChange?.(JSON.stringify(rows))
onValueChange?.(rows)
setSelectData(rows) setSelectData(rows)
ref?.current?.show(false) ref?.current?.show(false)
}, []) }, [])
const onItemDelete = (id: string | number) => { const onItemDelete = (id: string | number) => {
const newSelectData = selectData.filter(item => item.id !== id) const newSelectData = selectData.filter(item => item.id !== id)
// 直接处理为JSON字符串
onChange?.(JSON.stringify(newSelectData))
onValueChange?.(newSelectData)
setSelectData(newSelectData) setSelectData(newSelectData)
ref?.current?.setRows(newSelectData) ref?.current?.setRows(newSelectData)
} }
const _onQueryAll = (val: boolean) => {
setIsQueryAll(val)
onQueryAll?.(val)
}
useEffect(() => { useEffect(() => {
if (value) { if (value) {
setSelectData(value) // JSON字符串转为原数据
const rows = JSON.parse(value)
setSelectData(rows)
onValueChange?.(rows)
} }
}, []) }, [value])
useEffect(() => {
setIsQueryAll(isAll)
}, [isAll])
return ( return (
<> <>
<WrapSelect <WrapSelect
onIconClick={() => { ref?.current?.show() }} onIconClick={() => { ref?.current?.show(true, {}, { selectData, isQueryAll }) }}
onItemDelete={onItemDelete} onItemDelete={onItemDelete}
data={selectData} data={selectData}
labelKey='memberName' labelKey='value'
placeholder={isQueryAll ? '所有物料' : '请选择'}
/> />
<MaterialDrawer <MaterialDrawer
ref={ref} ref={ref}
onOk={handleOk} onOk={handleOk}
fieldCode={fieldCode}
onQueryAll={_onQueryAll}
{...rest}
/> />
</> </>
......
...@@ -6,14 +6,15 @@ import { HandleType } from '../CommonDrawer' ...@@ -6,14 +6,15 @@ import { HandleType } from '../CommonDrawer'
import SeeUserDrawer from '../SeeUserDrawer' import SeeUserDrawer from '../SeeUserDrawer'
const SelectRoles = (props: any) => { const SelectRoles = (props: any) => {
const { onChange, ...rest } = props const { onChange, onValueChange, ...rest } = props
const valueRef = useRef<any>() const roleIdRef = useRef<any>(rest?.value)
const drawRef = useRef<HandleType>() const drawRef = useRef<HandleType>()
const _onChange = (value) => { const _onChange = (id) => {
valueRef.current.ref = value roleIdRef.current = id
onChange?.(value) onChange?.(id)
onValueChange?.(id)
} }
return ( return (
...@@ -22,9 +23,6 @@ const SelectRoles = (props: any) => { ...@@ -22,9 +23,6 @@ const SelectRoles = (props: any) => {
<Col style={{ flex: 1 }}> <Col style={{ flex: 1 }}>
<FetchSelect <FetchSelect
style={{ width: '100%' }} style={{ width: '100%' }}
labelKey='memberName'
valueKey='id'
requestApi={getOrderDeliveryNoticeOrderVendorPage}
onChange={_onChange} onChange={_onChange}
{...rest} {...rest}
/> />
...@@ -32,13 +30,15 @@ const SelectRoles = (props: any) => { ...@@ -32,13 +30,15 @@ const SelectRoles = (props: any) => {
<Col> <Col>
<Button <Button
style={{ marginRight: 0 }} style={{ marginRight: 0 }}
onClick={() => { drawRef?.current?.show() }} onClick={() => { drawRef?.current?.show(true, { roleId: roleIdRef.current }) }}
> >
查看用户 查看用户
</Button> </Button>
</Col> </Col>
</Row> </Row>
<SeeUserDrawer ref={drawRef}/> <SeeUserDrawer
ref={drawRef}
/>
</> </>
) )
......
import React from 'react'
import { DatePicker } from 'antd'
import moment from 'moment'
const StringDatePicker = (props: any) => {
const { onChange, value, ...rest } = props
const _onChange = (date: any, dateString: string) => {
onChange?.(dateString)
}
return (
<DatePicker
style={{ width: '100%' }}
placeholder="请选择"
{...rest}
value={moment(value)}
onChange={_onChange}
/>
)
}
export default StringDatePicker
...@@ -10,10 +10,11 @@ interface PropsType { ...@@ -10,10 +10,11 @@ interface PropsType {
data?: any[] data?: any[]
labelKey?: string labelKey?: string
valueKey?: string valueKey?: string
placeholder?: string
} }
const WrapSelect = (props: PropsType) => { const WrapSelect = (props: PropsType) => {
const { onIconClick, onItemClick, onItemDelete, data = [], labelKey = 'name', valueKey='id' } = props const { onIconClick, onItemClick, onItemDelete, data = [], labelKey = 'name', valueKey='id', placeholder = '请选择' } = props
return ( return (
<div className={styles['wrap-select']}> <div className={styles['wrap-select']}>
...@@ -46,7 +47,7 @@ const WrapSelect = (props: PropsType) => { ...@@ -46,7 +47,7 @@ const WrapSelect = (props: PropsType) => {
} }
</> </>
: :
<div className={styles['content-placeholder']}>请选择</div> <div className={styles['content-placeholder']}>{placeholder}</div>
} }
<div className={styles['icon-box']} onClick={() => onIconClick?.()}> <div className={styles['icon-box']} onClick={() => onIconClick?.()}>
<LinkOutlined style={{ fontSize: 16, color: '#FFF' }} /> <LinkOutlined style={{ fontSize: 16, color: '#FFF' }} />
......
/** 字段类型 */
export enum Filed_Type {
STRING = 1, // 字符
NUMBER = 2, // 数字
DATE = 3, // 日期
}
/** 选择弹窗类型 */
export enum Select_Content_Type {
SelectMaterial = 1, // 选择物料
SelectCategory = 2, // 选择品类
}
/**
* EQUAL 1 等于
*
* UNEQUAL 2 不等于
*
* GREATER_THAN 3 大于
*
* GREATER_THAN_EQUAL 4 大于等于
*
* LESS_THAN 5 小于
*
* LESS_THAN_EQUAL 6 小于等于
*
* INCLUDED 7 包含
*
* NOT_INCLUDED 8 不包含
*
* ALL 9 所有
*/
export enum CONDITION_VALUE {
EQUAL = 1, // 等于
UNEQUAL = 2, // 不等于
GREATER_THAN = 3, // 大于
GREATER_THAN_EQUAL = 4, // 大于等于
LESS_THAN = 5, // 小于
LESS_THAN_EQUAL = 6, // 小于等于
INCLUDED = 7, // 包含
NOT_INCLUDED = 8, // 不包含
// ALL = 9, // 所有
}
export const conditionOptions = {
[Filed_Type.STRING]: [
{ label: '是', value: CONDITION_VALUE.EQUAL },
{ label: '不是', value: CONDITION_VALUE.UNEQUAL },
{ label: '包含', value: CONDITION_VALUE.INCLUDED },
{ label: '不包含', value: CONDITION_VALUE.NOT_INCLUDED },
// { label: '所有', value: CONDITION_VALUE.ALL },
],
[Filed_Type.NUMBER]: [
{ label: '>', value: CONDITION_VALUE.GREATER_THAN },
{ label: '<', value: CONDITION_VALUE.LESS_THAN },
{ label: '=', value: CONDITION_VALUE.EQUAL },
{ label: '>=', value: CONDITION_VALUE.GREATER_THAN_EQUAL },
{ label: '<=', value: CONDITION_VALUE.LESS_THAN_EQUAL },
{ label: '!=', value: CONDITION_VALUE.UNEQUAL },
],
[Filed_Type.DATE]: [
{ label: '是', value: CONDITION_VALUE.EQUAL },
{ label: '不是', value: CONDITION_VALUE.UNEQUAL },
{ label: '在之前', value: CONDITION_VALUE.LESS_THAN },
{ label: '在之后', value: CONDITION_VALUE.GREATER_THAN },
]
}
export const interrelationOptions = [
{ label: '并且', value: 1 },
{ label: '或者', value: 2 },
]
export enum RULE_TYPE {
MATERIAL_MANAGE = 'MATERIAL_MANAGE', // 物料管理
BUYING_REQUISITION = 'BUYING_REQUISITION', // 请购单
PURCHASE_PROCESS = 'PURCHASE_PROCESS', // 采购流程
CONTRACT_MANAGE = 'CONTRACT_MANAGE', // 合同管理
CONTRACT_COORDINATION = 'CONTRACT_COORDINATION', // 合同协同
REQUEST_FUNDS_MANAGE = 'REQUEST_FUNDS_MANAGE' // 请款单管理
}
/**
* 物料管理 1 等于
*
* 采购单流程 2 不等于
*
* 合同管理 3 大于
*
* 合同协同 4 大于等于
*
* 请购单流程 5 小于
*
* 请款单管理 6 小于等于
*/
export enum RULE_ENR_TYPE {
MATERIAL_MANAGE = 1, // 物料管理
PURCHASE_PROCESS = 2, // 采购单流程
CONTRACT_MANAGE = 3, // 合同管理
CONTRACT_COORDINATION = 4, // 合同协同
BUYING_REQUISITION = 5, // 请购单流程
REQUEST_FUNDS_MANAGE = 6, // 请款单管理
}
import { getProductCustomerGetCustomerCategoryTree, getProductMaterialGroupTree, getProductSelectGetSelectBrand } from "@/services/ProductV2Api"
import { createFormActions, FormEffectHooks, FormPath } from "@formily/antd"
const { onFormMount$ } = FormEffectHooks
const EMPTY_ARRAY = []
export const EMPTY = {
totalCount: 0,
data: [],
}
export const useAsyncCascader = async (name, service: () => Promise<any[]>) => {
const { setFieldState } = createFormActions()
onFormMount$().subscribe(() => {
service().then(res => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-component-props.options', res)
})
}).catch(err => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-component-props.options', [])
})
})
})
}
export const fetchTreeData = async () => {
try {
const { data, code } = await getProductMaterialGroupTree({ rootNodeId: '0' });
if (code === 1000) {
return data;
}
return EMPTY_ARRAY
} catch {
return EMPTY_ARRAY
}
}
export const fetchCategoryData = async () => {
try {
const { data, code } = await getProductCustomerGetCustomerCategoryTree();
if (code === 1000) {
return data;
}
return EMPTY_ARRAY
} catch {
return EMPTY_ARRAY
}
}
export const fetchBrand = async () => {
try {
const { data, code } = await getProductSelectGetSelectBrand();
if (code === 1000) {
return data;
}
return EMPTY_ARRAY
} catch {
return EMPTY_ARRAY
}
}
...@@ -2,34 +2,87 @@ ...@@ -2,34 +2,87 @@
* 系统能力 - 规则引擎 - 规则引擎配置 * 系统能力 - 规则引擎 - 规则引擎配置
* @author: Crayon * @author: Crayon
*/ */
import React, { useEffect, useRef, useCallback } from 'react' import React, { useEffect, useRef, useCallback, useState } from 'react'
import AnchorPage from '@/components/AnchorPage' import AnchorPage from '@/components/AnchorPage'
import { history } from 'umi' import { history, useLocation } from 'umi'
import usePrompt from '@/hooks/usePrompt' import FlowChart, { RefHandleType } from './components/FlowChart'
import FlowChart, { FlowChartOptionsType, RefHandleType } from './components/FlowChart'
import ConfigDrawer from './components/ConfigDrawer' import ConfigDrawer from './components/ConfigDrawer'
import { HandleType } from './components/CommonDrawer' import { HandleType } from './components/CommonDrawer'
import { Spin } from 'antd'
import { getProductMaterialProcessEngineGet } from '@/services/ProductV2Api'
import { getOrderPurchaseProcessEngineGet } from '@/services/OrderNewV2Api'
import { getPurchaseRequisitionProcessEngineGet } from '@/services/PurchaseV2Api'
import { getContractRuleEngineCoordinationProcess, getContractRuleEngineProcess } from '@/services/ContractV2Api'
import { getSettleAccountsApplyAmountProcessGet } from '@/services/SettleV2Api'
import { getRuleEngineConfigGetRuleEngineInfo } from '@/services/RuleEngineV2Api'
import { RULE_ENR_TYPE, RULE_TYPE } from './constant'
type RuleType = 'MATERIAL_MANAGE' | 'BUYING_REQUISITION' | 'PURCHASE_PROCESS' | 'CONTRACT_MANAGE' | 'CONTRACT_COORDINATION' | 'REQUEST_FUNDS_MANAGE'
const getFetchDetailApi = async (type: RuleType, params: any) => {
switch (type) {
case RULE_TYPE.MATERIAL_MANAGE:
return await getProductMaterialProcessEngineGet(params) // 查询物料流程规则引擎详情
case RULE_TYPE.BUYING_REQUISITION:
return await getPurchaseRequisitionProcessEngineGet(params) // 查询请购单管理规则引擎详情
case RULE_TYPE.PURCHASE_PROCESS:
return await getOrderPurchaseProcessEngineGet(params) // 查询采购流程规则引擎详情
case RULE_TYPE.CONTRACT_MANAGE:
return await getContractRuleEngineProcess(params) // 查询合同管理规则引擎详情
case RULE_TYPE.CONTRACT_COORDINATION:
return await getContractRuleEngineCoordinationProcess(params) // 查询合同协同规则引擎详情
case RULE_TYPE.REQUEST_FUNDS_MANAGE:
return await getSettleAccountsApplyAmountProcessGet(params) // 查询请款单管理规则引擎详情
default:
return { code: 1102, data: null }
}
}
const RuleEngConfig: React.FC = () => { const RuleEngConfig: React.FC = () => {
const location: any = useLocation();
const { type, processId } = location?.query
const [flowOptions, setFlowOptions] = useState<any[]>()
const [spinning, setSpinning] = useState<boolean>(false)
const flowRef = useRef<RefHandleType>() const flowRef = useRef<RefHandleType>()
const drawRef = useRef<HandleType>() const drawRef = useRef<HandleType>()
const options: FlowChartOptionsType[] = [ const getProcessEngineDetail = async () => {
{ label: '提交审核', value: 1 }, if (type && processId) {
{ label: '审核 (一级)', value: 2 }, setSpinning(true)
{ label: '审核 (二级)', value: 3 }, const { code, data } = await getFetchDetailApi(type, { processId })
] if (code === 1000) {
const newOptions = data.responses.map(item => ({
processStepName: item.taskName,
processStep: item.taskStep,
processId: data.processKey,
processName: data.processName
}))
setFlowOptions(newOptions)
setSpinning(false)
}
}
}
const handleDrawer = useCallback(() => { const handleDrawer = useCallback(() => {
flowRef?.current?.setActive('') flowRef?.current?.setActive('')
drawRef?.current?.show(false)
}, []) }, [])
const onFlowChartChange = useCallback((value: string | number) => { const onFlowChartChange = useCallback(async (processStep: string, optionItem: any) => {
drawRef?.current?.show(true, { id: value }) setSpinning(true)
const { code, data } = await getRuleEngineConfigGetRuleEngineInfo({ processId: optionItem.processId, processStep })
setSpinning(false)
if (code === 1000) {
const params = { process: { ...optionItem, type: RULE_ENR_TYPE[type] }, formData: data }
drawRef?.current?.show(true, params)
}
}, []) }, [])
useEffect(() => { useEffect(() => {
getProcessEngineDetail()
}, []) }, [])
return ( return (
...@@ -38,15 +91,18 @@ const RuleEngConfig: React.FC = () => { ...@@ -38,15 +91,18 @@ const RuleEngConfig: React.FC = () => {
onBack={() => history.goBack()} onBack={() => history.goBack()}
anchors={[]} anchors={[]}
> >
<FlowChart <Spin spinning={spinning}>
ref={flowRef} <FlowChart
options={options} ref={flowRef}
onChange={onFlowChartChange} options={flowOptions}
/> onChange={onFlowChartChange}
<ConfigDrawer fieldNames={{ label: 'processStepName', value: 'processStep' }}
ref={drawRef} />
onChange={handleDrawer} <ConfigDrawer
/> ref={drawRef}
onChange={handleDrawer}
/>
</Spin>
</AnchorPage> </AnchorPage>
) )
} }
......
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