Commit 7e6a30a8 authored by 前端-彭佳文's avatar 前端-彭佳文

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

物料bug fix See merge request linkseeks-design/pro-platform!863
parents f04cb3da efa39827
......@@ -43,7 +43,7 @@ function useGetDetailCommon<T extends GetProductGoodsGetGoodsProcessDetailRespon
name: intl.formatMessage({ id: 'material.unitConversion.title', defaultMessage: '单位换算' })
},
{
key: 'contact',
key: 'contactInfo',
name: intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })
},
{
......
......@@ -85,15 +85,11 @@ export const fetchUnit = async (name?: string) => {
}
}
export const fetchUserPage = async () => {
try {
const Data:any={ current:1, status: '1', pageSize: 9999 }
const { data, code } = await getMemberUserPage(Data);
if (code === 1000) {
return data.data;
}
return EMPTY_ARRAY
} catch {
return EMPTY_ARRAY
export const fetchUserPage=async (params)=> {
try{
const { data } = await getMemberUserPage(params)
return data
}
catch { return EMPTY_ARRAY}
}
......@@ -10,8 +10,22 @@ interface Iprops {
const Files: React.FC<Iprops> & { isFieldComponent: boolean } = (props: Iprops) => {
// console.log()
const { value } = props
const onDownload=(file:any)=>{
const xhr=new XMLHttpRequest()
xhr.open('GEt',file.url,true)
xhr.responseType='blob'
xhr.onload=function(e){
const url=window.URL.createObjectURL(xhr.response)
const a=document.createElement('a')
a.href=url
a.download=file.name
a.click()
}
xhr.send()
}
return (
<a href={value?.url || ''}>{value?.name || ''} </a>
<a onClick={()=>{onDownload(value)}}>{value?.name || ''} </a>
)
}
......
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState,useRef } from 'react';
import AnchorPage from '@/components/AnchorPage';
import NiceForm from '@/components/NiceForm';
import { createFormActions, FormEffectHooks, FormPath, ISchema, Schema } from '@formily/antd';
import { Button, Cascader, message } from 'antd'
import { LinkOutlined } from '@ant-design/icons'
import { getSchema, propsCardSchema } from './schema/add';
import FormilyUploadFiles from '@/components/UploadFiles/FormilyUploadFiles';
import styles from './add.less';
......@@ -12,9 +13,9 @@ import UploadFileTip from '../components/uploadFileTip';
import FormilyUploadEnclosure from '../components/formilyUploadEnclosure';
import UploadFiles from '@/components/UploadFiles/UploadFiles';
import FileItem from '../components/fileItem';
import { fetchBrand, fetchCategoryData, fetchTreeData, fetchUnit, useAsyncCascader, fetchUserPage, fetchMemberUserGet } from '../common/useGetTableSearchData';
import RequisitionerTable from './components/requisitionerTable'
import { fetchBrand, fetchCategoryData, fetchTreeData, fetchUnit, useAsyncCascader, fetchUserPage } from '../common/useGetTableSearchData';
import { getProductCustomerGetCustomerCategoryById, postProductGoodsSaveOrUpdateGoods } from '@/services/ProductV2Api';
// import {getMemberUserPage} from '@/services/MemberV2Api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { usePageStatus } from '@/hooks/usePageStatus';
import useInitialValue, { Options } from './useInitialValue';
......@@ -42,6 +43,9 @@ const MaterialAdd: React.FC<IProps> = (props) => {
const { location: { state, query }, match } = props;
const isAdd = lastTypeParams === '/add' && !id;
const isEdit = lastTypeParams === '/edit' && id;
const isedtails = lastTypeParams === '/detail' && id;
// const isDetail = !isAdd && !isEdit;
const { loading, formatInitialValue } = useInitialValue({ id: id, query, state });
......@@ -54,6 +58,13 @@ const MaterialAdd: React.FC<IProps> = (props) => {
// 需要注意的是 这个需要跟 setSchema 一同使用
const [hasProperties, setHasProperties] = useState(false);
const RequisRef = useRef<any>({}) // 请购人
/*联系人选择*/
const handleOrder = () => {
RequisRef.current.setVisible(true)
}
const RequisitionerBtn = <div className='connectBtn' onClick={handleOrder}><LinkOutlined style={{ marginRight: 4 }} />{intl.formatMessage({ id: 'purchaseRequisition.xuanze', defaultMessage: '选择' })}</div>
useEffect(() => {
if (query?.type === 'sourceData') {
formActions.setFieldState('sourceListCard', (state) => {
......@@ -311,7 +322,7 @@ const MaterialAdd: React.FC<IProps> = (props) => {
},
(
hasProperties ? ({
key: 'props',
key: 'type',
name: intl.formatMessage({ id: 'material.props.title', defaultMessage: '属性信息' })
}) : null
),
......@@ -407,6 +418,7 @@ const MaterialAdd: React.FC<IProps> = (props) => {
customizeFileItemRender: customizeFileItemRender,
...createDescriptionElement(),
handleSearchUnit,
Requisitioner:Boolean(isedtails)?'':RequisitionerBtn
}}
effects={($, actions) => {
useAsyncCascader('category', fetchCategoryData)
......@@ -414,31 +426,14 @@ const MaterialAdd: React.FC<IProps> = (props) => {
useAsyncCascader('materialGroup', fetchTreeData);
useAsyncSelect('unitId', fetchUnit, ["name", "id"])
useAsyncSelect('unitConversions', fetchUnit, ["name", "id"])
useAsyncSelect('chargeUserId', fetchUserPage, ["name", "userId"])
// useAsyncSelect('chargeUserId', fetchUserPage, ["name", "userId"])
$('onFormMount').subscribe(() => {
if (isEdit) {
formActions.setFieldState('code', (state) => {
FormPath.setIn(state, 'editable', false);
})
}
}
})
$('onFieldInputChange', 'chargeUserId').subscribe((fieldState) => {
formActions.setFieldState('contactMemberName', (state) => {
FormPath.setIn(state, 'value', fieldState.values[1]?.name);
})
formActions.setFieldState('chargeName', (state) => {
FormPath.setIn(state, 'value', fieldState.values[1]?.name);
})
formActions.setFieldState('contactMemberPhone', (state) => {
FormPath.setIn(state, 'value', fieldState.values[1]?.phone);
})
formActions.setFieldState('chargeAccount', (state) => {
FormPath.setIn(state, 'value', fieldState.values[1]?.account);
})
formActions.setFieldState('chargeRoleName', (state) => {
FormPath.setIn(state, 'value', fieldState.values[1]?.roleName);
})
})
$('onFieldValueChange', 'category').subscribe((fieldState) => {
if (!fieldState.value || fieldState.value.length === 0) {
setSchema(
......@@ -453,10 +448,7 @@ const MaterialAdd: React.FC<IProps> = (props) => {
getProductCustomerGetCustomerCategoryById({ id: categoryId })
.then((data) => {
const { customerAttributeList } = data.data;
if (customerAttributeList?.length === 0) {
setSchema(
getSchema(null)
)
if (customerAttributeList?.length === 0) {
setHasProperties(false);
return;
}
......@@ -516,6 +508,7 @@ const MaterialAdd: React.FC<IProps> = (props) => {
}}
/>
<Prompt when={unsaved} message={intl.formatMessage({ id: 'common.tip.save.confirm' }, { default: '您还有未保存的内容,是否确定要离开?' })} />
<RequisitionerTable currentRef={RequisRef} schemaAction={formActions} />
</AnchorPage>
)
......
import React, { useEffect } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchUserPage} from '../../../common/useGetTableSearchData';
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { RequisitiColumns } from '../../constant'
import { useIntl } from 'umi'
export interface MemberModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?(),
productRef?: any,
}
const RequisitionerTable: React.FC<MemberModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({ type, customKey: 'userId' })
const intl = useIntl()
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
useEffect(() => {
if (visible) {
const memberId = schemaAction.getFieldValue('requisitionerId')
rowSelectionCtl.setSelectedRowKeys([memberId])
}
}, [visible])
const handleConfirm = () => {
const rowItem = rowSelectionCtl.selectRow[0]
/*当前选择的会员全部信息*/
console.log(rowItem, 'row')
if (rowItem) {
schemaAction.setFieldValue('contactMemberName', rowItem.name)
schemaAction.setFieldValue('chargeUserId', rowItem.userId)
schemaAction.setFieldValue('chargeName', rowItem.name)
schemaAction.setFieldValue('contactMemberPhone', rowItem.phone)
schemaAction.setFieldValue('chargeAccount', rowItem.account)
schemaAction.setFieldValue('chargeRoleName', rowItem.roleName)
}
confirmModal && confirmModal()
setVisible(false)
}
return (
<ModalTable
modalTitle="选择联系人"
columns={RequisitiColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={(params) => fetchUserPage({...params})}
rowSelection={rowSelection}
modalType='requisitSchema'
tableProps={{
rowKey: 'userId'
}}
{...restProps}
/>
)
}
RequisitionerTable.defaultProps = {}
export default RequisitionerTable
export const RequisitiColumns: any[] = [
{
title: "姓名",
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: "手机号",
dataIndex: 'phone',
align: 'center',
key: 'phone',
},
{
title: "所属机构",
dataIndex: 'orgName',
align: 'center',
key: 'orgName',
},
{
title: "职位",
dataIndex: 'jobTitle',
align: 'center',
key: 'jobTitle',
},
]
import { useState } from 'react'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
export const useModalTable = (options?) => {
const [visible, setVisible] = useState(false)
const [rowSelection, rowSelectionCtl] = useRowSelectionTable(options)
return {
visible,
setVisible,
rowSelection,
rowSelectionCtl
}
}
\ No newline at end of file
......@@ -285,7 +285,7 @@ export const getSchema = (schema: ISchema | null): ISchema => {
type: 'object',
"x-component": 'MellowCard',
"x-component-props": {
id: 'test123456789',
id: 'contactInfo',
title: intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })
},
properties: {
......@@ -306,21 +306,20 @@ export const getSchema = (schema: ISchema | null): ISchema => {
}
},
properties: {
chargeUserId: {
chargeName: {
title: intl.formatMessage({ id: 'material.chargeName', defaultMessage: '负责人' }),
type: 'string',
enum: [],
'x-component-props': {
addonAfter:"{{Requisitioner}}",
showSearch: true,
},
description: `{{desc()}}`,
'x-rules':[
{
required: true,
message: intl.formatMessage({ id: 'material.chargeName.required', defaultMessage: '请输入' })
}]
},
chargeName: {
chargeUserId: {
title: intl.formatMessage({ id: 'material.chargeUserId', defaultMessage: '负责人用户id' }),
type: "string",
display: false,
......
......@@ -110,15 +110,15 @@ const Detail = () => {
<CustomizeColumn
id="unitConversion"
data={unitInfoList}
title={intl.formatMessage({ id: 'material.unitInfoList.title', defaultMessage: '单位换算' })}
title={intl.formatMessage({ id: 'material.unitConversion.title', defaultMessage: '单位换算' })}
column={2}
/>
</Space>
<Space>
<CustomizeColumn
id="contactInfoList"
id="contactInfo"
data={contactInfoList}
title={intl.formatMessage({ id: 'material.contactInfoList.title', defaultMessage: '联系信息' })}
title={intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })}
column={2}
/>
</Space>
......
......@@ -105,15 +105,15 @@ const Detail = () => {
<CustomizeColumn
id="unitConversion"
data={unitInfoList}
title={intl.formatMessage({ id: 'material.unitInfoList.title', defaultMessage: '单位换算' })}
title={intl.formatMessage({ id: 'material.unitConversion.title', defaultMessage: '单位换算' })}
column={2}
/>
</Space>
<Space>
<CustomizeColumn
id="contactInfoList"
data={contactInfoList}
title={intl.formatMessage({ id: 'material.contactInfoList.title', defaultMessage: '联系信息' })}
id="contactInfo"
data={contactInfoList}
title={intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })}
column={2}
/>
</Space>
......
......@@ -113,7 +113,7 @@ const Detail = () => {
</Space>
<Space>
<CustomizeColumn
id="contact"
id="contactInfo"
data={contactInfoList}
title={intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })}
column={2}
......
......@@ -122,7 +122,7 @@ const Detail = () => {
</Space>
<Space>
<CustomizeColumn
id="contact"
id="contactInfo"
data={contactInfoList}
title={intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })}
column={2}
......
......@@ -77,8 +77,8 @@ const Detail = () => {
style={{ marginBottom: '16px' }}
/>
<CustomizeColumn
id="contact"
data={contactInfoList}
id="contactInfo"
data={contactInfoList}
title={intl.formatMessage({ id: 'material.contact.title', defaultMessage: '联系信息' })}
column={2}
style={{ marginBottom: '16px' }}
......
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