Commit 039b6024 authored by alwayOnlie's avatar alwayOnlie

删除小写文件

parent 8709a0e6
import React, { useRef, useState, useEffect, forwardRef } from 'react';
import { Button, Table, Input, Select, Popconfirm, Form, Typography, Modal, } from 'antd'
import {
PlusOutlined
} from '@ant-design/icons'
import { StandardTable } from 'god';
import styles from '../index.less'
import { goodcolumns } from '../Table'
import { PublicApi } from '@/services/api';
const { Option } = Select;
const { Text } = Typography;
const FormList = (props: any) => {
const { currentRef, Row, sourceType } = props;
const refs = useRef({});
/* 显示模态框 */
const [isModalVisible, setIsModalVisible] = useState(false);// 显示模态框
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([]) // 选中的
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [dataList, setData] = useState<Array<any>>([]) // 列表数据
/* 选中 */
const rowSelectionGood: any = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectedRowKeys(selectedRowKeys)
setSelectRow(selectedRows)
console.log(setSelectedRowKeys)
}
};
const [columnsTab, setcolumnsTab] = useState<any>([]);
/* 确定 */
const handleOk = () => {
console.log(dataList)
let dataArr = dataList.length != 0 ? dataList.concat(selectRow) : selectRow;
const hash = {}
let templateList = dataArr.reduceRight((item, next) => {
if (!hash[next.id]) hash[next.id] = true && item.push(next)
return item
}, [])
templateList.map((item: any, index: number) => {
item.rowId = index + 1
dataArr.push(item);
})
setData(templateList)
setIsModalVisible(false);
};
/* 获取商品 */
const getGoodsList = (params) => {
return new Promise(resolve => {
PublicApi.getProductGoodsGetGoodsList(params).then(res => {
if (res.code === 1000) {
console.log(res.data, 1231321)
resolve(res.data)
}
})
})
}
/* 删除 */
const handleDelete = (id) => {
const dataSource = [...dataList];
const RowKeys = [...selectedRowKeys]
let List = dataSource.filter((item) => item.id !== id);
const RowKeysList = RowKeys.filter(item => item !== id);
setData(List)
setSelectedRowKeys(RowKeysList)
};
/* 获取物料信息 */
const getList = () => {
let parmas: any = {
current: '1',
pageSize: '3',
}
let fn;
switch (sourceType) {
case '1':
parmas.id = Row.demandId;
parmas.memberId = Row.partyBMemberId;
parmas.memberRoleId = Row.partyBRoleId;
fn = PublicApi.getPurchaseQuotedPriceProductlistListContract
break;
case '2':
parmas.submitTenderId = Row.bidId;
fn = PublicApi.getPurchaseSubmitTenderMaterielGetSubmitTenderMaterielList
break;
case '3':
parmas.id = Row.viePriceId
fn = PublicApi.getPurchaseBiddingPrizeMaterielPage
break;
default:
break;
}
/* 过滤字段 */
const _filter = (sourceType: string, newObj: any, callBackArr: Array) => {
const key = callBackArr[sourceType]
if (!key) {
return '';
}
let callBlackString = '';
if (sourceType == '2') {
if (newObj.inviteTenderMateriel[key]) {
return newObj.inviteTenderMateriel[key]
} else {
return newObj[key]
}
}
callBlackString = newObj[key]
if (callBlackString == null) {
return '';
}
return callBlackString;
}
/* 处理数组 */
const _filterArr = (sourceType: string, newObj: any, callBackArr: Array) => {
let callBlackString = _filter(sourceType, newObj, callBackArr);
if (Object.getPrototypeOf(callBlackString) === Array.prototype) {
callBlackString = callBlackString[0]
}
return callBlackString
}
/* 处理布尔值 */
const _filterFalg = (sourceType: string, newObj: any, callBackArr: Array) => {
let callBlackString = _filter(sourceType, newObj, callBackArr);
console.log(callBlackString, 'callBlackString')
if (sourceType !== '1') {
callBlackString = callBlackString ? '1' : '0';
}
console.log(callBlackString)
return Number(callBlackString)
}
fn(parmas).then(res => {
if (res.code === 1000) {
let data = res.data.data.map((item, index) => {
return {
code: _filter(sourceType, item, ['', 'number', 'code', 'number']),// 物料编号
name: _filter(sourceType, item, ['', 'name', 'name', 'name']),//物料名称
type: _filter(sourceType, item, ['', 'model', 'type', 'model']),//物料规格
customerCategory: { // 品类
name: _filter(sourceType, item, ['', 'category', 'brandName', '']),
category: _filter(sourceType, item, ['', 'category', '', '']),
id: _filterArr(sourceType, item, ['', 'goodsId', 'categoryId', 'ids']),
},
brand: {
name: _filter(sourceType, item, ['', 'brand', 'categoryName', 'brand'])
}, // 品牌
unitName: _filter(sourceType, item, ['', 'unit', 'unitName', 'unitPrice']), //单位
purchaseCount: _filter(sourceType, item, ['', 'purchaseCount', 'count', 'purchaseCount']),// 数量
isHasTax: _filterFalg(sourceType, item, ['', 'isTax', 'isTax', 'isTax']),// 数量是否函税
taxRate: _filter(sourceType, item, ['', 'taxProbability', 'taxRate', 'taxRate']), //税率
price: _filter(sourceType, item, ['', 'taxUnitPrice', 'price', 'price']), //单价
bidCount: sourceType == '1' ? item.awardTaxProbability * item.purchaseCount / 100 : sourceType == '2' ? item.awardTenderRatio * item.inviteTenderMateriel.count / 100 : item.purchaseCount,
bidAmount: sourceType == '1' ? item.awardTaxProbability * item.purchaseCount / 100 * item.taxUnitPrice : sourceType == '2' ? item.awardTenderRatio * item.inviteTenderMateriel.count / 100 * item.price : item.price,
// productBrand
associatedType: _filter(sourceType, item, ['', '', '', '']),
associatedBrand: _filter(sourceType, item, ['', 'productAttributeJson', '', '']),
associatedDataId: _filter(sourceType, item, ['', 'productId', 'commoditySkuId']), // 关联商品id
associatedMaterielNo: _filter(sourceType, item, ['', 'number', 'commodityAttribute']), // 关联物料编号
associatedMaterielName: _filter(sourceType, item, ['', 'productName', 'commodityName']), // 关联商品名称
associatedGoods: _filter(sourceType, item, ['', 'productAttributeJson', 'commodityBrand']), //关联品牌
// associatedMaterielName: sourceType == '1' ? item.productName : sourceType == '2' ? item.commodityName : '',
// associatedGoods: sourceType == '1' ? item.productAttributeJson : sourceType == '2' ? item.commodityBrand : '',// 关联品牌
rowId: index,
}
})
setData(data)
}
}).catch(err => {
console.log(err)
})
}
useEffect(() => {
let columnsTab: any = [
{
title: '物料编号/名称', dataIndex: 'name', align: 'center',
render: (text, item) =>
<div>
<p>{item.code}</p>
<p>{text}</p>
</div>
},
{ title: '规格型号', dataIndex: 'type', align: 'center', },
{
title: '品类', dataIndex: 'customerCategory', align: 'center',
render: (text, item) =>
<span>{item.customerCategory.name ? item.customerCategory.name : item.customerCategory.category}</span>
},
{
title: '品牌', dataIndex: 'brand', align: 'center',
render: (text, item) =>
<span>{item.brand ? item.brand.name : ''}</span>
},
{ title: '单位', dataIndex: 'unitName', align: 'center', },
{
title: '采购数量',
dataIndex: 'purchaseCount',
key: 'purchaseCount',
align: 'center',
render: (text, record, index) =>
<Form.Item
name={`isHasTax${index}`}
rules={[{ required: true, message: '请选择' }]}
>
<Input
style={{
width: 120,
}}
placeholder=""
onChange={(e) => setInput(e, 'purchaseCount', index)}
defaultValue={text}
disabled={Object.keys(Row).length != 0 ? true : false}
/>
</Form.Item>
},
{
title: '含税', dataIndex: 'isHasTax', align: 'center',
render: (text, record, index) =>
<Form.Item
name={`isHasTax${index}`}
initialValue={text + index}
rules={[{ required: true, message: '请选择' }]}
>
<Select
style={{ width: 80 }}
defaultValue={text === 0 || text === 1 ? text.toString() : ''}
onChange={(e) => setInput(e, 'isHasTax', index)}
disabled={Object.keys(Row).length != 0 ? true : false}
>
<Option value="0" key={0}></Option>
<Option value="1" key={1}></Option>
</Select>
</Form.Item>
},
{
title: '税率', dataIndex: 'taxRate', align: 'center',
render: (text: any, record: any, index: number) =>
<Form.Item
name={`taxRate${index}`}
rules={[{ required: true, message: '请输入' }]}
>
<Input
style={{
width: 120,
}}
defaultValue={text}
onChange={(e) => setInput(e, 'taxRate', index)}
addonAfter="%"
disabled={Object.keys(Row).length != 0 ? true : false}
/>
</Form.Item>
},
{
title: '单价(含税)', dataIndex: 'price', align: 'center',
render: (text: any, record: any, index: number) =>
<Form.Item
name={`price${index}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<Input
style={{
width: 120,
}}
onChange={(e) => setInput(e, 'price', index)}
addonBefore="¥"
defaultValue={text}
disabled={Object.keys(Row).length != 0 ? true : false}
/>
</Form.Item>
},
{
title: '授标数量', dataIndex: 'bidCount', align: 'center',
render: (text, record, index) =>
<Form.Item
name={`bidCount${index}`}
rules={[{ required: true, message: '请输入' }]}
>
<Input
style={{
width: 120,
}}
onChange={(e) => setInput(e, 'bidCount', index)}
defaultValue={text ? text : ''}
disabled={Object.keys(Row).length != 0 ? true : false}
/>
</Form.Item>
},
{
title: '金额(含税)',
dataIndex: 'bidAmount',
key: 'bidAmount',
align: 'center',
render: (text: any, record: any) => <Text>{record.bidAmount}</Text>
},
];
if (dataList.length === 0) {
columnsTab.push(
{
title: '操作',
dataIndex: 'del',
align: 'center',
key: 'del',
render: (_, record, index) => {
return (
<Popconfirm title="确定要删除吗?" onConfirm={() => handleDelete(record.id)}>
<a>删除</a>
</Popconfirm>
)
}
}
)
}
setcolumnsTab(columnsTab);
}, [dataList])
useEffect(() => {
if (Object.keys(Row).length != 0) {
getList()
}
}, [Row])
/* 回调出来的数据 */
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
let list = [];
dataList.map(item => {
list.push({
id: 0,
materielNo: item.code,
materielName: item.name,
type: item.type,
category: item.customerCategory != null ? item.customerCategory.name : '',
brand: item.brand != null ? item.brand.name : '',
unit: item.unitName,
isHasTax: item.isHasTax,
taxRate: item.taxRate,
purchaseCount: item.purchaseCount,
price: Number(item.price),
bidCount: item.bidCount,
bidAmount: item.bidCount && item.price ? Number(item.bidCount) * Number(item.price) : '',
associatedMaterielName: Object.keys(Row).length === 0 ? '' : item.associatedMaterielName,
associatedGoods: Object.keys(Row).length === 0 ? '' : item.associatedGoods,
associatedDataId: Object.keys(Row).length === 0 ? '' : item.associatedDataId,
associatedMaterielNo: Object.keys(Row).length === 0 ? '' : item.associatedMaterielNo,
associatedType: Object.keys(Row).length === 0 ? '' : item.associatedType,
associatedCategory: Object.keys(Row).length === 0 ? '' : item.associatedCategory,
associatedBrand: Object.keys(Row).length === 0 ? '' : item.associatedBrand,
})
})
resolve({
state: true,
name: 'purchaseMaterielList',
data: { list }
})
})
}
})
const handleCancel = () => {
setIsModalVisible(false);
};
/* 下拉的子元素 */
const listItem = (record, index) => (
<div className={styles.listItem}>
<div className={styles.label}>
<p>关联</p>
<p>报价商品</p>
</div>
<div className={styles.text}>
<p>商品ID:{record.associatedDataId}</p>
<p>商品名称:{record.associatedMaterielName}</p>
</div>
<div className={styles.text}>
<p>规格:{record.associatedGoods}</p>
<p>品类:{record.associatedType}</p>
</div>
<div className={styles.text}>
<p>品牌:{record.associatedBrand}</p>
</div>
</div>
)
/* 设置值 */
const setInput = (e, name, idx) => {
let item: any = [...dataList];
console.log(dataList, name, idx)
switch (name) {
case 'isHasTax':
item[idx].isHasTax = e
break;
case 'taxRate':
item[idx].taxRate = e.target.value;
break;
case 'price':
item[idx].price = e.target.value;
break;
case 'bidCount':
item[idx].bidCount = e.target.value;
break;
case 'purchaseCount':
item[idx].purchaseCount = e.target.value;
break;
}
item[idx].bidAmount = item[idx].bidCount && item[idx].price ? Number(item[idx].bidCount) * Number(item[idx].price) : 0;
console.log(item)
setData(item)
}
const onExpand = expandedKeys => {
console.log(expandedKeys)
};
return (
<div className={styles.box}>
{
Object.keys(Row).length === 0 && <div style={{ paddingTop: 12, paddingBottom: 12, }} onClick={() => setIsModalVisible(true)}>
<Button block type='dashed'><PlusOutlined />选择采购物料</Button>
</div>
}
<Table
columns={columnsTab}
rowKey="rowId"
dataSource={dataList}
expandable={{
expandedRowRender: (record, index) => listItem(record, index),
}}
style={{
width: "100%"
}}
/>
{/* 模态框 */}
<Modal title="选择采购物料" width={900} visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
<StandardTable
tableProps={{
rowKey: 'id',
}}
columns={goodcolumns}
currentRef={refs}
rowSelection={rowSelectionGood}
fetchTableData={(params: any) => getGoodsList(params)}
/>
</Modal>
</div>
)
}
export default forwardRef(FormList)
import React, { useState, useEffect, forwardRef } from 'react';
import { Button, Select, Form, Checkbox, message, Upload } from 'antd'
import { PublicApi } from '@/services/api';
import styles from '../index.less'
import {
FileWordFilled,
} from '@ant-design/icons'
import { UPLOAD_TYPE } from '@/constants'
const ContractText = (props: any) => {
const { currentRef, memberId } = props;
const [TemplatePage, setTemplatePage] = useState<any>([]);
const [Templatel, setTemplatel] = useState<any>({});
const [checkNick, setCheckNick] = useState(true);
const [contractFlag, setcontractFlag] = useState<boolean>(false);
/* 第四个tab */
const onCheckboxChange = (e: { target: { checked: boolean } }) => {
setCheckNick(e.target.checked);
};
const getTemplate = (e) => {
PublicApi.getContractContractTemplateGet({ id: e }).then(res => {
setTemplatel(res.data)
})
}
/* 获取合同详情数据 */
const contractTemplate = () => {
let data: any = {
current: 1,
pageSize: 99
}
PublicApi.getContractContractTemplatePage(data).then(res => {
console.log(res);
let list = [];
res.data.data.find((item: any) => {
item.version != null ? item.version : '';
console.log(item.version)
if (item.state == 1) {
console.log(item,)
list.push({
label: item.name + item.version,
value: item.id,
id: item.id,
})
}
})
setTemplatePage(list)
}).catch(err => {
console.log(err)
})
}
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
let contractText = {
id: 0,
templateId: Templatel.id,
isUseElectronicContract: checkNick ? 1 : 0,
contractName: Templatel.name,
contractUrl: Templatel.fileUrl ? Templatel.fileUrl : Templatel.fileExampleUrl,
contractFlag: contractFlag,
}
resolve(contractText)
})
}
})
useEffect(() => {
contractTemplate();
}, [])
/* 生成电子合同 */
const generate = () => {
if (!Templatel.id) {
message.info('请先选择合同模版')
} else {
const param = {
contractTemplateId: Templatel.id,
memberId,
}
PublicApi.postContractSignatureContractCreate(param).then(res => {
console.log(res);
if (res.code == 1000) {
Templatel.name = res.data.contractName
Templatel.fileUrl = res.data.contractUrl
setTemplatel(Templatel)
setcontractFlag(true)
}
})
}
}
/**下载 */
const onDownload = () => {
window.location.href = `/api/contract/contractTemplate/downloadContract?contractName=${Templatel.fileName}&contractUrl=${Templatel.fileUrl}`
}
/**判断文件类型和大小 */
const beforeDocUpload = (file: any) => {
const isLt20M = file.size / 1024 / 1024 < 20;
if (!isLt20M) {
message.error('上传文件大小不超过 20M!');
}
return isLt20M;
}
// 上传回调
const handleChange = ({ fileList }) => {
if (fileList[0].response) {
if (fileList[0].response.code === 1000) {
Templatel.name = fileList[0].name
Templatel.fileName = fileList[0].name
Templatel.fileUrl = fileList[0].response.data
console.log(Templatel, '上传成功执行的')
setTemplatel({ ...Templatel })
}
}
}
return (
<div
style={{
width: '100%',
}}
>
<Form.Item label="合同模板" labelAlign="left" labelCol={{ span: 2 }}>
<Select
style={{ width: 600 }}
options={TemplatePage}
placeholder="请选择合同模板"
onChange={(e) => getTemplate(e)}
>
</Select>
{
checkNick && <Button type='link' onClick={() => generate()}>生成合同</Button>
}
</Form.Item>
{
Object.keys(Templatel).length != 0 &&
<Form.Item label="合同文本" labelAlign="left" labelCol={{ span: 2 }}>
<div className={styles.upload_item} style={{ width: 680 }}>
<div className={styles.upload_left} style={{ width: 600 }} onClick={() => onDownload()}>
<FileWordFilled />
<span>{Templatel.name}</span>
</div>
<Upload
action="/api/file/file/upload"
data={{ fileType: UPLOAD_TYPE }}
showUploadList={false}
beforeUpload={beforeDocUpload}
onChange={handleChange}
accept='.doc,.docx'
>
<div className={styles.uploadIconBtn}>
<Button type='link' >上传合同</Button>
</div>
</Upload>
</div>
</Form.Item>
}
<Form.Item label="电子合同" labelAlign="left" labelCol={{ span: 2 }}>
<Checkbox checked={checkNick} onChange={onCheckboxChange}>
使用电子合同
</Checkbox>
</Form.Item>
</div>
)
}
export default forwardRef(ContractText)
import React, { useState, useEffect, forwardRef } from 'react';
import { Button, Table, Input, Select, DatePicker, InputNumber } from 'antd'
import {
PlusOutlined
} from '@ant-design/icons'
import styles from '../index.less'
const { TextArea } = Input
const { Option } = Select;
import moment from 'moment';
const FormList = (props: any) => {
const { fromData, currentRef, fetchdata, Price } = props;
const [keys, setkeys] = useState<any>(); // 记录上次删除的
const [options, setoptions] = useState<any>([
{
value: 1,
disabled: true
}
])
const [PlanList, setPlanList] = useState<any>([
{
payNum: '1',
payStage: '',
expectPayTime: '',
payRatio: '',
payAmount: '',
payWay: '1',
payParam: '',
id: 0,
rowId: 1,
disabled: true
},
]);
/* 显示模态框 */
const tabcolumns: any = [
{
title: '付款次数', dataIndex: 'payNum', align: 'left',
render: (_, item, index) => {
return (
<Select
style={{ width: 200 }}
defaultValue={item.payNum}
options={options}
key='1'
onChange={(e) => onSelectChange(e, 'payNum', index)}
>
</Select>
)
}
},
{
title: '付款阶段', dataIndex: 'payStage', align: 'left',
render: (_, item, index) => <TextArea maxLength={150} rows={1} onChange={(e) => onSelectChange(e, 'payStage', index)} />
},
{
title: '预计付款时间', dataIndex: 'expectPayTime', align: 'left',
render: (_, item, index) => <DatePicker
style={{ width: '100%' }}
format="YYYY-MM-DD"
onChange={(e) => onSelectChange(e, 'expectPayTime', index)}
/>
},
{
title: '付款比例', dataIndex: 'payRatio', align: 'left',
render: (_, item, index) =>
<div className={styles.flex}>
<Input
style={{
width: 150,
}}
value={item.payRatio}
placeholder=""
onChange={(e) => onSelectChange(e, 'payRatio', index)}
/>
<span>%</span>
</div>
},
{
title: '付款金额', dataIndex: 'payAmount', align: 'left',
render: (_, item, index) =>
<div className={styles.flex}>
<span></span>
<Input
style={{
width: 130,
}}
placeholder=""
value={item.payAmount}
onChange={(e) => onSelectChange(e, 'payAmount', index)}
/>
</div>
},
{
title: '付款方式', dataIndex: 'payWay', align: 'left',
render: (_, item, index) =>
<div
className={styles.select}
>
<Select
style={{ width: 208 }}
onChange={(e) => onSelectChange(e, 'payWay', index)}
defaultValue={item.payWay}
>
<Option value="3" key={3}>现结</Option>
<Option value="1" key={1}>账期:</Option>
<Option value="2" key={2}>月结:</Option>
</Select>
{
item.payWay != 3 &&
<div className={styles.setBox}>
{/* payParam */}
<InputNumber placeholder='' onChange={(e) => onSelectChange(e, 'payParam', index)} width={60} max={31} />
<span>{item.payWay == 2 ? '号' : item.payWay == 1 ? '天' : ''}</span>
</div>
}
</div>
},
{
title: '操作',
dataIndex: '',
align: 'left',
key: 'x',
render: (_, item, index) => <a onClick={() => Delete(item, index)}>删除</a>,
},
];
/* 添加 */
const addtable = () => {
const data = [...PlanList];
if (keys) {
data.push(keys);
setkeys('');
} else {
data.push(
{
payNum: data.length + 1,
payStage: '',
expectPayTime: '',
payRatio: '',
payAmount: '',
payWay: '1',
payParam: '',
id: 0,
rowId: data.length + 1,
disabled: false,
},
)
}
let optionsData = data.map((item, index) => {
return {
value: item.payNum ? item.payNum : index + 1,
disabled: item.payNum ? true : false,
rowId: item.rowId,
}
})
console.log('optionsDataadd', data, optionsData, 'optionsList')
setPlanList(data)
setoptions(optionsData)
};
/* 删除 */
const Delete = (elm, idx) => {
const dataSource = [...PlanList];
let List = dataSource.filter((item, index) => index !== idx);
let optionsData = options.map((keys => {
if (elm.payNum == keys.value) {
keys.disabled = false;
}
return {
...keys
}
}))
setkeys(elm);
setPlanList(List)
setoptions(optionsData)
};
/* 选中设置值 */
const onSelectChange = (e, name, idx) => {
let item = [...PlanList];
switch (name) {
case 'payWay':
item[idx].payWay = e;
break;
case 'payNum':
item[idx].payNum = e;
break;
case 'expectPayTime':
item[idx].expectPayTime = moment(e).format('YYYY-MM-DD HH:mm:ss');
break;
case 'payStage':
item[idx].payStage = e.target.value;
break;
case 'payRatio':
item[idx].payRatio = e.target.value;
if (Price != 0) {
item[idx].payAmount = e.target.value / 100 * Price;
}
break;
case 'payAmount':
if (Price != 0) {
item[idx].payRatio = e.target.value / Price * 100;
}
item[idx].payAmount = e.target.value;
break;
case 'payParam':
item[idx].payParam = e;
break;
}
console.log(item[idx])
setPlanList(item)
}
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
PlanList.map(item => {
item.payNum = Number(item.payNum)
item.payRatio = Number(item.payRatio)
item.payAmount = Number(item.payAmount)
item.payWay = Number(item.payWay)
item.payParam = Number(item.payParam)
// 付款方式: 1 - 账期,2 - 月结,3 - 现结
item.payWayName = item.payWay == 1 ? '账期' : item.payWay == 2 ? '月结' : '现结'
})
resolve(PlanList)
})
}
})
return (
<div className="table">
<Table
columns={tabcolumns}
dataSource={PlanList}
rowKey="rowId"
style={{
width: "100%"
}}
pagination={false}
/>
<div style={{ background: '#F4F5F7' }} onClick={() => addtable()} >
<Button block type='dashed'><PlusOutlined />添加付款计划</Button>
</div>
</div>
)
}
export default forwardRef(FormList)
import React, { useRef, useState, useEffect, forwardRef } from 'react';
import { Button, Input, Select, DatePicker, Form, Drawer, message } from 'antd'
import {
LinkOutlined,
} from '@ant-design/icons'
import { StandardTable } from 'god';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import moment from 'moment';
import { purchaseSchema, userchema } from "../../schema"
import { PublicApi } from '@/services/api';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import Submit from '@/components/NiceForm/components/Submit'
import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { column, columnsList, columnsGetList, supplierColumns } from '../Table'
import { clearModalParams } from '@/utils';
import style from '../../../constants/styles.less'
const { Option } = Select;
const { RangePicker } = DatePicker;
const { Search } = Input
export interface IProps {
fetchdata: any,
currentRef: any,
Row: any
}
const Information = (props: any) => {
const { fetchdata, currentRef, Row, getrow, getmemberId, sourceType, getsourceType } = props;
const refs = useRef({});
/**
* @param {{visible}} 显示选择合同弹出
* @param {{rowSelection}} 单选的值
*/
const [visible, setvisible] = useState<boolean>(false);
const [rowSelection, RowCtl] = useRowSelectionTable({ customKey: 'id', type: 'radio' });
/**
* @param {{basicsVO}} 表单数据集合
* */
const [basicsVO, setbasicsVO] = useState<any>({
})
/**
* @param {{startTime,endTime}} 开始结束时间
* */
const [startTime, setstartTime] = useState('');
const [endTime, setendTime] = useState('');
const [attrValueForm] = Form.useForm();
/*标记是不是手工单子*/
const [Change, sethandleChange] = useState('1');
/* 是否是手工单 */
/* 控制是否禁用单据按钮 */
const [falg, setfalg] = useState<boolean>(false);
const [manual, setmanual] = useState<boolean>(false)
/* 显示弹出 */
const Choose = (sourceType?) => {
clearModalParams()
if (sourceType) {
let Data = basicsVO;
Data.sourceType = sourceType;
console.log(currentRef);
setbasicsVO(Data);
}
setvisible(!visible)
}
/* 选中的下拉框的值 */
const handleChange = (e) => {
basicsVO.sourceType = e;
sethandleChange(e)
setbasicsVO(basicsVO);
getsourceType(e)
}
/* 时间选中 */
const onChange = (value: any) => {
console.log(value)
let startTime = moment(Number(value[0])).format('YYYY-MM-DD HH:mm:ss')
let endTime = moment(Number(value[1])).format('YYYY-MM-DD HH:mm:ss')
setstartTime(startTime)
setendTime(endTime)
}
/* 获取合同编号 */
useEffect(() => {
PublicApi.getContractManageGetContractNo().then(res => {
console.log(res.data)
let basics: any = {}
if (res.code === 1000) {
basics.contractNo = res.data
console.log(basics)
setbasicsVO(basics)
}
})
}, [])
/* 获取传入组建的值 */
useEffect(() => {
console.log(Row.sourceId)
basicsVO.contractNo = basicsVO.contractNo ? basicsVO.contractNo : '';
basicsVO.sourceType = Row.sourceType ? Row.sourceType + '' : '1';
basicsVO.contractId = Row.contractId ? Row.contractId : 0;
basicsVO.partyBName = Row.partyBName ? Row.partyBName : '';
basicsVO.sourceNo = Row.sourceNo ? Row.sourceNo : '';
basicsVO.sourceId = Row.sourceId ? Row.sourceId : '';
basicsVO.totalAmount = Row.totalAmount ? Row.totalAmount : '';
basicsVO.partyBMemberId = sourceType === '1' ? Row.awardRoleId ? Row.awardMemberId : '' : Row.partyBMemberId;
basicsVO.partyBRoleId = sourceType === '1' ? Row.awardRoleId ? Row.awardRoleId : '' : Row.partyBRoleId;
console.log(Row, basicsVO)
setbasicsVO(basicsVO)
attrValueForm.setFieldsValue(basicsVO)
setfalg(Row.sourceNo ? true : false)
setmanual(Row.partyBName ? true : false)
}, [basicsVO])
/**
* @function fetchData 容需求发布
**/
const fetchData = (params: any) => {
ctx()
let fn;
switch (basicsVO.sourceType) {
case '1':
fn = PublicApi.getContractPurchaseInquiryPageToBeCreate
break;
case '2':
fn = PublicApi.getContractPurchaseInviteBidPageToBeCreate
break;
case '3':
fn = PublicApi.getContractPurchaseViePricePageToBeCreate
break;
case '4':
fn = PublicApi.postMemberManageLowerProviderPage
break;
default:
break;
}
return new Promise(resolve => {
fn({ ...params }, { ctlType: 'none' }).then(res => {
resolve(res.data)
}).catch(err => {
console.log(err)
})
})
}
/* 确认选中 */
const Confirm = () => {
if (basicsVO.sourceType == '4') {
setfalg(!falg)
basicsVO.partyBName = RowCtl.selectRow[0].name;
basicsVO.partyBMemberId = RowCtl.selectRow[0].memberId;
basicsVO.partyBRoleId = RowCtl.selectRow[0].roleId
basicsVO.sourceType = Change;
setfalg(true)
attrValueForm.setFieldsValue(basicsVO);
getmemberId(basicsVO.partyBMemberId)
} else {
let totalAmount, sourceId, partyBName, partyBMemberId, sourceNo, partyBRoleId;
const selectRow = RowCtl.selectRow[0];
// console.log(selectRow)
switch (basicsVO.sourceType) {
case '1':
totalAmount = selectRow.awardAmount;
sourceId = selectRow.demandId;
sourceNo = selectRow.demandNO;
partyBName = selectRow.awardName;
partyBMemberId = selectRow.awardMemberId;
partyBRoleId = selectRow.awardRoleId;
break;
case '2':
totalAmount = selectRow.bidWinnerAmount
sourceId = selectRow.bidId
partyBName = selectRow.bidWinnerName
sourceNo = selectRow.inviteBidNO
partyBMemberId = selectRow.bidWinnerMemberId
partyBRoleId = selectRow.bidWinnerRoleId;
break;
case '3':
totalAmount = selectRow.awardAmount
sourceId = selectRow.viePriceId
break;
default:
break;
}
basicsVO.totalAmount = totalAmount;
basicsVO.sourceId = sourceId;
basicsVO.partyBName = partyBName;
basicsVO.partyBMemberId = partyBMemberId;
basicsVO.sourceNo = sourceNo;
basicsVO.partyBRoleId = partyBRoleId;
setbasicsVO(basicsVO)
setmanual(true)
attrValueForm.setFieldsValue(basicsVO);
selectRow.partyBMemberId = selectRow.awardMemberId;
selectRow.partyBRoleId = selectRow.awardRoleId;
getmemberId(partyBMemberId)
getrow(selectRow)
}
Choose()
}
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
attrValueForm.validateFields().then(res => {
resolve({
state: true,
name: 'basic',
data: Object.assign(res, { id: 0, partyBRoleId: basicsVO.partyBRoleId, startTime, endTime, sourceId: basicsVO.sourceId, totalAmount: basicsVO.totalAmount, partyBMemberId: basicsVO.partyBMemberId, partyBName: basicsVO.partyBName, oldContractId: 0 }),
})
}).catch(error => {
if (error && error.errorFields) {
message.info('请输入基本资料必填内容')
}
})
})
}
})
/* 根据 sourceType 设置搜索内容 */
const ctx = () => {
if (basicsVO.sourceType == 1) {
let data = {
ctx: {
inline: false,
schema: purchaseSchema,
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'demandNO',
FORM_FILTER_PATH,
);
},
components: {
DateRangePickerUnix,
Submit
}
}
}
return data;
}
else {
let data = {
ctx: {
inline: false,
schema: userchema,
components: {
DateRangePickerUnix,
Submit
}
}
}
return data;
}
}
const rangeConfig = {
rules: [{ type: 'array' as const, required: true, message: ' 请选择开始或者结束时间' }],
};
return (
<div className={style.revise_info}>
<Form
form={attrValueForm}
name="edit_infomation"
layout="horizontal"
labelAlign="left"
colon={false}
autoComplete="off"
>
<Form.Item
label="合同编号"
labelAlign="left"
name="contractNo"
labelCol={{ span: 2 }}
wrapperCol={{ span: 8 }}
initialValue={basicsVO.contractNo}
rules={[
{
required: true,
message: '请输入合同编号',
},
]}
>
{/* disabled */}
<Input placeholder='请输入合同编号' />
</Form.Item>
<Form.Item
label="合同摘要"
labelAlign="left"
name="contractAbstract"
labelCol={{ span: 2 }}
wrapperCol={{ span: 8 }}
rules={[
{
required: true,
message: '请输入合同摘要',
},
]}
>
<Input placeholder='请输入合同摘要' />
</Form.Item>
<Form.Item
label="寻源类型"
labelAlign="left"
name="sourceType"
labelCol={{ span: 2 }}
wrapperCol={{ span: 8 }}
initialValue={basicsVO.sourceType}
rules={[
{
required: true,
message: '请选择寻源类型',
},
]}
>
<Select onChange={handleChange}
disabled={sourceType ? true : false}>
<Option value="1" >采购询价</Option>
<Option value="2" >采购招标</Option>
<Option value="3" >采购竞价</Option>
</Select>
</Form.Item>
<Form.Item
label="合同有效期"
labelAlign="left"
labelCol={{ span: 2 }}
wrapperCol={{ span: 8 }}
name="range-picker"
{...rangeConfig}
>
<RangePicker style={{ width: '100%' }} onChange={(e) => onChange(e)} />
</Form.Item>
<Form.Item
label="对应单据"
labelAlign="left"
labelCol={{ span: 2 }}
name="sourceNo"
initialValue={basicsVO.sourceNo ? basicsVO.sourceNo : ''}
wrapperCol={{ span: 8 }}
>
{
falg ?
<Input placeholder='最长60个字符,30个汉字' disabled />
:
<Search placeholder="最长60个字符,30个汉字" readOnly enterButton={<div onClick={() => Choose(basicsVO.sourceType == '4' ? Change : basicsVO.sourceType)} ><LinkOutlined /> 选择</div>} />
}
</Form.Item>
<Form.Item
label="授标会员"
labelAlign="left"
labelCol={{ span: 2 }}
name="partyBName"
initialValue={basicsVO.partyBName ? basicsVO.partyBName : ''}
wrapperCol={{ span: 8 }}
rules={[
{
required: true,
message: '请选择授标会员',
},
]}
>
{
manual ?
<Input placeholder='最长60个字符,30个汉字' disabled />
:
<Search placeholder="最长60个字符,30个汉字" readOnly enterButton={<div onClick={() => Choose('4')} ><LinkOutlined /> 选择</div>} />
}
</Form.Item>
<Form.Item
label="授标金额"
labelAlign="left"
labelCol={{ span: 2 }}
wrapperCol={{ span: 8 }}
>
<p>{basicsVO.totalAmount ? `¥${basicsVO.totalAmount}` : ''}</p>
</Form.Item>
</Form>
{/* 选择弹出内容 */}
<Drawer
visible={visible}
onClose={() => setvisible(!visible)}
title={basicsVO.sourceType == '1' ? '选择采购需求单' : basicsVO.sourceType == '2' ? '选择招标需求单' : basicsVO.sourceType == '3' ? '选择竞价需求单' : '选择会员'}
width={900}
footer={
<div
style={{
textAlign: 'right',
}}
>
<Button onClick={() => setvisible(!visible)} style={{ marginRight: 8 }}>
取消
</Button>
<Button type="primary" onClick={() => Confirm()} >
确定
</Button>
</div>
}
destroyOnClose
>
<StandardTable
tableProps={{
rowKey: 'id',
}}
columns={basicsVO.sourceType == '1' ? column : basicsVO.sourceType == '2' ? columnsList : basicsVO.sourceType == '3' ? columnsGetList : supplierColumns}
currentRef={refs}
rowSelection={rowSelection}
fetchTableData={(params: any) => fetchData(params)}
formilyProps={ctx()}
/>
</Drawer>
</div>
)
}
export default forwardRef(Information)
......@@ -216,7 +216,7 @@ const Details = (props: any) => {
render: (text) => {
return (
<div>
{text}
{text}
</div>
)
}
......
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