Commit 83c48928 authored by GuanHua's avatar GuanHua
parents be61f948 217f86b5
......@@ -161,7 +161,7 @@ const ClassProperty: React.FC<{}> = () => {
const syncIds = syncTreeActions.getSelectKeys()
if(syncIds.length) {
// @ts-ignore
PublicApi.postProductCustomerSyncCategory({idList: syncIds.concat(syncTreeActions.getExpandedKeys()[0])}).then(res => {
PublicApi.postProductCustomerSyncCategory({idList: Array.from(new Set([...syncIds, ...syncTreeActions.getExpandedKeys()]))}).then(res => {
resetMenu()
syncTreeActions.setSelectKeys([])
setResetSearch(true)
......
......@@ -53,7 +53,8 @@ const AddProducts: React.FC<{}> = (props) => {
selectCategoryId,
clearPartData,
setTabClickItem,
setSelectedGoods
setSelectedGoods,
setProductPriceType
} = ProductStore
useEffect(() => {
......@@ -89,6 +90,7 @@ const AddProducts: React.FC<{}> = (props) => {
afterService: data.afterService
})
setProductName(data?.name)
setProductPriceType(data?.priceType)
const attributeRes = await PublicApi.getProductCustomerGetCustomerCategoryById({ id: data?.customerCategory?.id + '' })
setAttributeLists(attributeRes.data?.customerAttributeList)
// 预先设置选择货品
......
import React, { useEffect, useRef } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import { history } from 'umi'
import { Form, Radio, Input } from 'antd'
import { store } from '@/store'
......@@ -25,14 +25,18 @@ const OtherForm: React.FC<Iprops> = (props) => {
const otherFormRef = useRef()
const flagRef = useRef<boolean>(false)
const [otherForm] = Form.useForm()
const { getOtherFormParamsByEdit, selectCategoryId } = ProductStore
const { getOtherFormParamsByEdit, selectCategoryId, productPriceType, productInfoByEdit } = ProductStore
const [disabledInvoice, setDisabledInvoice] = useState(false)
const { id } = history.location.query
useEffect(()=>{
//传入ref给父级
onRef(otherFormRef)
if(history.location.query?.id)
if(id){
otherForm.setFieldsValue(getOtherFormParamsByEdit)
}
}, [])
useEffect(() => {
......@@ -44,6 +48,15 @@ const OtherForm: React.FC<Iprops> = (props) => {
}
}, [selectCategoryId])
useEffect(() => {
if(productPriceType === 3) {
otherForm.setFieldsValue({"isInvoice": false})
setDisabledInvoice(true)
} else {
setDisabledInvoice(false)
}
}, [productPriceType])
return (<>
<Form
{...layout}
......@@ -62,7 +75,7 @@ const OtherForm: React.FC<Iprops> = (props) => {
message: "请选择是否提供发票"
}]}
>
<Radio.Group size="small">
<Radio.Group size="small" disabled={disabledInvoice}>
<Radio.Button value={true} style={{ width: 100, textAlign: 'center' }}></Radio.Button>
<Radio.Button value={false} style={{ width: 100, textAlign: 'center' }}></Radio.Button>
</Radio.Group>
......
......@@ -241,7 +241,13 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
/* 构建表格列和data */
const constructedCallback = () => {
let _col = [];
let col_productName = { title: '商品名称', dataIndex: '商品名称', key: '商品名称' }
let col_productName = {
title: '商品名称',
dataIndex: '商品名称',
key: '商品名称',
width: "30%",
// ellipsis: true,
}
_col.push(col_productName)
let _priceAttribute = productSelectAttribute.filter(_item=>_item.isPrice)
......
import React, { useState, useEffect, useRef } from 'react'
import {history} from 'umi'
import { Form, Select, Checkbox, Tabs, Input, DatePicker } from 'antd'
import { Form, Select, Checkbox, Tabs, Input, DatePicker, Row, Col } from 'antd'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
......@@ -27,18 +27,18 @@ const { RangePicker } = DatePicker
let paramsArray = [];
const ProductAttributeForm: React.FC<Iprops> = (props) => {
const ProductAttributeForm: React.FC<Iprops> = (props) => {
const { attributesData, onRef } = props
const [isClearFormAndDataInEdit, setIsClearFormAndDataInEdit] = useState<boolean>(false) // 编辑情况下 是否要清空商品属性表单数据和页面全局数据
const productAttributeFormRef = useRef()
const [attributeForm] = Form.useForm()
const { ProductStore } = store
const {
const {
attributeLists,
setProductSelectAttribute,
getProductAttributeFormParamsByEdit,
productInfoByEdit,
clearProductDetailsUnitPriceAndPicListInEdit
getProductAttributeFormParamsByEdit,
productInfoByEdit,
clearProductDetailsUnitPriceAndPicListInEdit
} = ProductStore
useEffect(()=>{
......@@ -69,7 +69,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
attributeForm.resetFields()
}
}, [attributeLists])
/**
* @description 表单项改变转换数据格式,仅限“select单选、checkbox多选、输入”三类控件的改变
* @param {Number, Array, e} value type为1:数字id,type为2:数组id,type为3:事件对象
......@@ -181,7 +181,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
</Form.Item>
}
{
attrItem.type === 2 && ( attrItem.isDate ?
attrItem.type === 2 && ( attrItem.isDate ?
<Form.Item
label={attrItem.name}
name={attrItem.id}
......@@ -190,9 +190,9 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
message: '此项为必填项'
}]}
>
<RangePicker
<RangePicker
disabled={_isDisabled}
onChange={(v)=>onChange(v, attrItem)}
onChange={(v)=>onChange(v, attrItem)}
format="YYYY-MM-DD"
/>
</Form.Item>
......@@ -206,14 +206,19 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
}]}
>
<Checkbox.Group
onChange={(v)=>onChange(v, attrItem)}
onChange={(v)=>onChange(v, attrItem)}
disabled={_isDisabled}
style={{width: "100%"}}
>
{
attrItem?.customerAttributeValueList.length > 0 && attrItem.customerAttributeValueList.map((item: any, index: string) => (
<Checkbox key={item.id} value={item.id}>{item.value}</Checkbox>
))
}
<Row>
{
attrItem?.customerAttributeValueList.length > 0 && attrItem.customerAttributeValueList.map((item: any, index: string) => (
<Col span={6} key={item.id}>
<Checkbox value={item.id}>{item.value}</Checkbox>
</Col>
))
}
</Row>
</Checkbox.Group>
</Form.Item>
)
......@@ -271,4 +276,4 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
</>)
}
export default observer(ProductAttributeForm)
\ No newline at end of file
export default observer(ProductAttributeForm)
......@@ -107,9 +107,9 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{
record.receivingTimes >= 1 && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
record.receivingTimes >= 1 || PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
}
</>
}
......
import React, { useRef, useEffect, useMemo } from 'react'
import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd'
import addressSchema from './schema'
import './index.less'
import { PublicApi } from '@/services/api'
export interface InvoiceModalProps {
mode: 'add' | 'edit' | 'preview' | 'default',
currentRef?: any,
formInitValue?: any,
reload?()
}
const schemaActions = createFormActions()
const modelTitle = {
'add': '新增发票',
'edit': "编辑发票",
'preview': '查看发票'
}
const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
// 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault
}
const resetForm = () => {
schemaActions.reset({validate: false})
}
const handleConfirm = () => {
if (mode === 'preview') {
props.currentRef.current.setVisible(false)
return ;
}
schemaActions.submit()
}
const handleSubmit = async (value) => {
const params = {
...value,
isDefault: value.isDefault ? 1 : 0
}
const fn = mode === 'edit' ? PublicApi.postSettleAccountsInvoiceMessageUpdate : PublicApi.postSettleAccountsInvoiceMessageAdd
await fn(params)
resetForm()
props.currentRef.current.setVisible(false)
props.reload && props.reload()
}
return (
<ModalForm
modalTitle={modelTitle[mode]}
previewPlaceholder=" "
confirm={handleConfirm}
cancel={resetForm}
value={selfInitValue}
editable={mode !== 'preview'}
effects={($, { setFieldState }) => {
$('onFormMount').subscribe(() => {
})
}}
currentRef={props.currentRef}
actions={schemaActions}
schema={addressSchema}
onSubmit={handleSubmit}
/>
)
}
InvoiceModal.defaultProps = {}
export default InvoiceModal
import React, { useRef, useEffect, useMemo } from 'react'
import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd'
import addressSchema from './schema'
import './index.less'
import { PublicApi } from '@/services/api'
export interface InvoiceModalProps {
mode: 'add' | 'edit' | 'preview' | 'default',
currentRef?: any,
formInitValue?: any,
reload?()
}
const schemaActions = createFormActions()
const modelTitle = {
'add': '新增发票',
'edit': "编辑发票",
'preview': '查看发票'
}
const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
// 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault
}
const resetForm = () => {
schemaActions.reset({validate: false})
}
const handleConfirm = () => {
if (mode === 'preview') {
props.currentRef.current.setVisible(false)
return ;
}
schemaActions.submit()
}
const handleSubmit = async (value) => {
const params = {
...value,
isDefault: value?.isDefault ? 1 : 0
}
const fn = mode === 'edit' ? PublicApi.postSettleAccountsInvoiceMessageUpdate : PublicApi.postSettleAccountsInvoiceMessageAdd
await fn(params)
resetForm()
props.currentRef.current.setVisible(false)
props.reload && props.reload()
}
return (
<ModalForm
modalTitle={modelTitle[mode]}
previewPlaceholder=" "
confirm={handleConfirm}
cancel={resetForm}
value={selfInitValue}
editable={mode !== 'preview'}
effects={($, { setFieldState }) => {
$('onFormMount').subscribe(() => {
})
}}
currentRef={props.currentRef}
actions={schemaActions}
schema={addressSchema}
onSubmit={handleSubmit}
modalProps={{
destroyOnClose: true
}}
/>
)
}
InvoiceModal.defaultProps = {}
export default InvoiceModal
......@@ -61,7 +61,7 @@ const SimpleElectronModal:React.FC<SimpleElectronModalProps> = (props) => {
signatureState.current = null
setVisible(false)
schemaAction.setFieldValue("signatureLogId", res.data.signatureLogId)
message.success("操作成功")
// message.success("操作成功")
}
}, 2000)
}
......
......@@ -156,9 +156,8 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
)
const { productAddButton, productRef, productColumns, productComponents, ...sectionProps } = useProductTable(addSchemaAction)
let timerSignature = null
// 页面进入时, 当前所处的下单模式
useEffect(() => {
if (id) {
setFormLoading(true)
......@@ -185,7 +184,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
}
return () => {
clearInterval(timerSignature)
timerSignature = null
}
}, [])
const handleSubmit = async (value) => {
let _orderProductRequests = JSON.parse(JSON.stringify(value.orderProductRequests))
let processEnum = value['processEnum']
......@@ -194,6 +199,15 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
let electronicContractId = value['electronicContractId']
if(processEnum === 24 && usingElectronicContracts && !signatureLogId) {
setBtnLoading(true)
// 监听 是否完成签合同 提交订单
timerSignature = setInterval(() => {
let __signatureLogId = addSchemaAction.getFieldValue("signatureLogId")
if(__signatureLogId) {
clearInterval(timerSignature)
timerSignature = null
addSchemaAction.submit()
}
}, 1000)
// 生成并签署合同
if(electronicContractId) {
fetchOrderApi.createContract({
......@@ -213,7 +227,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
orderModel: value['orderModel'],
deliveryAddresId: value['deliveryAddresId']["id"],
}).then(_data => {
setBtnLoading(false)
// setBtnLoading(false)
if(_data?.contractName) {
addSchemaAction.setFieldState("usingElectronicContracts", state => {
state.props["x-component-props"].contract = { contractTemplateId: electronicContractId, ..._data, }
......@@ -260,9 +274,8 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
...omit(value.deliveryAddresId, ['id']),
// 冗余发票信息
theInvoiceId: value.theInvoiceId ? value.theInvoiceId.id : undefined,
// theInvoiceId: typeof value.theInvoiceId === 'object' ? value.theInvoiceId.id : value.theInvoiceId,
// 去掉该冗余字段的传递, 只做详情展示
// theInvoiceInfo: (value.typeof value.theInvoiceId === 'object' ? value.theInvoiceId : null
// theInvoiceInfo: value.theInvoiceInfo
}
// 校验是否选择支付渠道/支付比例
......@@ -297,10 +310,11 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error('请填写商品采购数量')
}
// // 校验简单电子合同必选
// if(processEnum === 24 && !usingElectronicContracts){
// throw new Error('此订单必须签署电子合同')
// }
// 使用发票即校验发票id
console.log(params, 'params')
if(params.needTheInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
// logistics render字段字符串化
params.orderProductRequests = params.orderProductRequests.map(item => {
let logistics: any = { ...item.logistics, render: item.logistics?.render ? JSON.stringify(item.logistics.render) : '' };
......@@ -518,6 +532,20 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
// 选择某种类型时, 需显示对应的订单类型
ctx.setFieldValue('type', orderTypeLabel[value - 4]) // -4 获得对应的数组下标, 由于id是固定的
// 需要发票变动或者发票id变动,调用订单更新接口传入发票id
$('onFieldInputChange', 'theInvoiceId, needTheInvoice').subscribe(state => {
if(pageStatus === PageStatus.EDIT) {
addSchemaAction.submit((values) => PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: state.value.id,
needTheInvoice: Number(values.needTheInvoice),
id,
}, { ctlType: "none" }))
}
})
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
......
This diff is collapsed.
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