Commit a394831e authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 2aa28f01 597a4fa1
...@@ -56,11 +56,18 @@ const Table: React.FC<Iprops> = (props: any) => { ...@@ -56,11 +56,18 @@ const Table: React.FC<Iprops> = (props: any) => {
/** 列表数据 */ /** 列表数据 */
const fetchData = (params?: any) => { const fetchData = (params?: any) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!Array.isArray(fetch)) {
fetch({ ...params }).then(res => { fetch({ ...params }).then(res => {
resolve(res.data) resolve(res.data)
}).catch(error => { }).catch(error => {
console.warn(error) console.warn(error)
}) })
return
}
resolve({
code: 1000,
data: fetch
})
}) })
} }
...@@ -119,7 +126,7 @@ const Table: React.FC<Iprops> = (props: any) => { ...@@ -119,7 +126,7 @@ const Table: React.FC<Iprops> = (props: any) => {
<StandardTable <StandardTable
currentRef={tableRef} currentRef={tableRef}
columns={columns} columns={columns}
tableProps={{ rowKew: 'id' }} tableProps={{ rowKey: 'id' }}
rowSelection={selectedRow && rowSelection} rowSelection={selectedRow && rowSelection}
fetchTableData={(params: any) => fetchData(params)} fetchTableData={(params: any) => fetchData(params)}
controlRender={ controlRender={
......
...@@ -109,10 +109,8 @@ const BasicInfo: React.FC<Iprops> = (props: any) => { ...@@ -109,10 +109,8 @@ const BasicInfo: React.FC<Iprops> = (props: any) => {
city[idx] = { citydata: res.data } city[idx] = { citydata: res.data }
setcity([...city]) setcity([...city])
} }
}) }).catch(() => {})
} }
}).catch(error => {
console.warn(error)
}) })
} else { } else {
...@@ -130,13 +128,11 @@ const BasicInfo: React.FC<Iprops> = (props: any) => { ...@@ -130,13 +128,11 @@ const BasicInfo: React.FC<Iprops> = (props: any) => {
}) })
setcity([...city]) setcity([...city])
} }
console.log(2)
setrequisitionFormAddress(result); setrequisitionFormAddress(result);
} }
/** 选择城市的时候下拉就调用方 */ /** 选择城市的时候下拉就调用方 */
const onDropdownVisibleChange = () => { const onDropdownVisibleChange = () => {
console.log(1)
return new Promise(reslove => reslove(code)).then((res: any) => { return new Promise(reslove => reslove(code)).then((res: any) => {
city.forEach((item: any) => { city.forEach((item: any) => {
item.citydata.filter(it => { item.citydata.filter(it => {
...@@ -148,8 +144,6 @@ const BasicInfo: React.FC<Iprops> = (props: any) => { ...@@ -148,8 +144,6 @@ const BasicInfo: React.FC<Iprops> = (props: any) => {
}) })
}) })
setcity([...city]) setcity([...city])
}).catch(error => {
console.warn(error)
}) })
} }
......
...@@ -182,6 +182,7 @@ const Material: React.FC<Iprops> = (props: any) => { ...@@ -182,6 +182,7 @@ const Material: React.FC<Iprops> = (props: any) => {
} }
}, [fetchdata]) }, [fetchdata])
return ( return (
<> <>
<Form <Form
...@@ -222,6 +223,7 @@ const Material: React.FC<Iprops> = (props: any) => { ...@@ -222,6 +223,7 @@ const Material: React.FC<Iprops> = (props: any) => {
{materielMode === 1 {materielMode === 1
&& ( && (
<AnchorModal <AnchorModal
dataSource={dataSource}
preview={isPreview} preview={isPreview}
edit={edit} edit={edit}
visible={flag} visible={flag}
......
...@@ -18,6 +18,8 @@ const layout: any = { ...@@ -18,6 +18,8 @@ const layout: any = {
}; };
interface AnchorModalProps { interface AnchorModalProps {
/** 列表数据 */
dataSource?: any[],
/** 显示隐藏 */ /** 显示隐藏 */
visible?: boolean, visible?: boolean,
/** 是否查看数据 */ /** 是否查看数据 */
...@@ -32,13 +34,14 @@ interface AnchorModalProps { ...@@ -32,13 +34,14 @@ interface AnchorModalProps {
const AnchorModal: React.FC<AnchorModalProps> = (props: any) => { const AnchorModal: React.FC<AnchorModalProps> = (props: any) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const { visible, preview, edit, onClose, onConfirm } = props; const { dataSource, visible, preview, edit, onClose, onConfirm } = props;
const [loading, setloading] = useState<boolean>(false); const [loading, setloading] = useState<boolean>(false);
const [searchVisible, setSearchVisible] = useState<boolean>(false) const [searchVisible, setSearchVisible] = useState<boolean>(false)
const [isSeleted, setIsSeleted] = useState<number>(1); const [isSeleted, setIsSeleted] = useState<number>(1);
const [category, setcategory] = useState([]); const [category, setcategory] = useState([]);
const [files, setFiles] = useState([]); const [files, setFiles] = useState([]);
const [product, setProduct] = useState<any>({}); const [product, setProduct] = useState<any>({});
const [ids, setIds] = useState<Array<number>[]>([])
const [menu] = useState([ const [menu] = useState([
{ id: 1, label: '基本信息' }, { id: 1, label: '基本信息' },
...@@ -99,7 +102,6 @@ const AnchorModal: React.FC<AnchorModalProps> = (props: any) => { ...@@ -99,7 +102,6 @@ const AnchorModal: React.FC<AnchorModalProps> = (props: any) => {
console.warn(error) console.warn(error)
}) })
}).then((data: any) => { }).then((data: any) => {
console.log(data)
setcategory(data) setcategory(data)
}) })
} }
...@@ -110,7 +112,6 @@ const AnchorModal: React.FC<AnchorModalProps> = (props: any) => { ...@@ -110,7 +112,6 @@ const AnchorModal: React.FC<AnchorModalProps> = (props: any) => {
setIsSeleted(1) setIsSeleted(1)
searchCategoryTree(null); searchCategoryTree(null);
if (!isEmpty(edit)) { if (!isEmpty(edit)) {
console.log(edit)
form.setFieldsValue({ form.setFieldsValue({
number: edit.number, number: edit.number,
name: edit.name, name: edit.name,
...@@ -122,11 +123,22 @@ const AnchorModal: React.FC<AnchorModalProps> = (props: any) => { ...@@ -122,11 +123,22 @@ const AnchorModal: React.FC<AnchorModalProps> = (props: any) => {
}) })
setFiles(edit.urls) setFiles(edit.urls)
} }
if (!isEmpty(dataSource)) {
const arr: Array<number>[] = []
dataSource.forEach(item => {
arr.push(item.goodsId)
});
setIds(arr)
}
}, [visible]); }, [visible]);
/** 选择货品点击 */ /** 选择货品点击 */
const confirm = (selectRowKeys: string[] | number[], selectRowRecord: any) => { const confirm = (selectRowKeys: string[] | number[], selectRowRecord: any) => {
const selectRow = selectRowRecord; const selectRow = selectRowRecord;
if (ids.includes(selectRow[0].id)) {
message.error('货品已存在,请勿重复选择!')
return
}
if (selectRow.length > 0) { if (selectRow.length > 0) {
const data: any = selectRow[0] const data: any = selectRow[0]
if (data.customerCategory.category) { if (data.customerCategory.category) {
......
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