Commit ae8bf705 authored by 前端-许佳敏's avatar 前端-许佳敏
parents 2fb11c20 166098c3
import React from 'react';
import { Row, Col, Input } from 'antd';
import React, { useState, useEffect, useRef } from 'react';
import { Row, Col, Input, Button, Modal } from 'antd';
import { LinkOutlined } from '@ant-design/icons';
import styled from 'styled-components';
import cx from 'classnames';
import { StandardTable } from 'god';
import NiceForm from '@/components/NiceForm';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
const formActions = createFormActions();
const RowStyleLayout = styled(props => <div {...props} />)`
width: 100%;
.relevance {
border-color: #6b778c;
background-color: #6b778c;
}
`;
const data = [
{
key: '1',
role: '采购商',
businessType: '采购',
roleType: '服务消费',
memberType: '企业会员',
},
{
key: '2',
role: '供应商',
businessType: '商品供应',
roleType: '服务提供',
memberType: '企业会员',
},
];
// 模拟请求
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
const queryResult = data.find(v => v.key === params.keywords);
setTimeout(() => {
resolve({
code: 200,
message: '',
data: queryResult ? [queryResult] : data,
});
}, 1000);
});
};
const Relevance = props => {
const ref = useRef<any>({});
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([]);
const [visible, setVisible] = useState(false);
const propsParams = props.props['x-component-props'];
useEffect(() => {
console.log('props', propsParams);
}, []);
const handlePreview = () => {
setVisible(!visible);
};
const rowSelection = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {},
};
const handleSubmit = type => {
if (type === 'confirm') {
} else {
}
setVisible(false);
};
return (
<RowStyleLayout>
<Row>
<Col span={16}>123</Col>
<Col span={8}>456</Col>
<Col span={16}>
<Input disabled></Input>
</Col>
<Col span={8}>
<Button
type="primary"
className="relevance"
icon={<LinkOutlined />}
onClick={handlePreview}
>
关联
</Button>
</Col>
</Row>
<Modal
title={propsParams.modalTitle || ''}
visible={visible}
width={propsParams.modalWidth || ''}
destroyOnClose
onOk={() => handleSubmit('confirm')}
onCancel={() => handleSubmit('cancel')}
>
<StandardTable
columns={propsParams.modalColumns}
currentRef={ref}
tableProps={{ rowKey: 'key' }}
rowSelection={rowSelection}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
<NiceForm
actions={formActions}
onSubmit={values => ref.current.reload(values)}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'search',
FORM_FILTER_PATH,
);
}}
schema={propsParams.modalSchema}
/>
}
/>
</Modal>
</RowStyleLayout>
);
};
......
import React, { useState } from 'react';
import { Input, Space, Button } from 'antd';
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons';
import { useFieldState, FormPath } from '@formily/antd';
import { useFieldState, FormPath, FormEffectHooks } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
export interface SearchProps {
......
import { GetProductGoodsGetGoodsListResponseDetail, GetProductCommodityGetCommodityResponse } from '@/services';
export interface IBasicFormParam {
brandId: number;
brandName: string;
commodityAreaList: string[][];
customerCategoryId: number[];
name: string;
sellingPoint: string[];
slogan: string;
}
interface InnerAttributeValueList {
customerAttributeValueId: number;
value: string;
}
export interface IProductSelectAttribute {
attributeName: string;
customerAttributeId: number;
customerAttributeValueList: InnerAttributeValueList[]
isPrice: boolean;
}
export interface IProductModule {
productInfoByEdit: GetProductCommodityGetCommodityResponse;
attributeLists: any[];
productName: string;
productSelectAttribute: any[];
selectedGoods: any[];
productSelectAttribute: IProductSelectAttribute[]; //商品属性传输数据
selectedGoods: GetProductGoodsGetGoodsListResponseDetail[];
tableDataSource: any[];
priceAttributeParams: any[]; // 价格设置的传输数据
productAttributeAndImageParams: any[]; //价格属性包含图片的传输数据
areaOption: any[]; // 省市数据
setProductName(name: string):void;
setProductSelectAttribute(list: any[]):void;
setSelectedGoods(lists: any[]):void;
setTableDataSource(datas: any[]):void;
clearData(data: any[]):void;
setAttributeLists(lists: any[]): void;
setProductName(name: string): void;
setProductSelectAttribute(list: IProductSelectAttribute[]): void;
setSelectedGoods(lists: GetProductGoodsGetGoodsListResponseDetail[]): void;
setTableDataSource<T>(datas: T[]): void;
clearData(data: any[]): void;
setPriceAttributeParams<T>(datas: T[]): void;
setProductAttributeAndImageParams(datas: any[]): void;
setAreaOption(datas: any[]): void;
setProductInfoByEdit(data: GetProductCommodityGetCommodityResponse): void;
}
export interface ISiteModule {
siteId: number;
}
......@@ -220,18 +220,18 @@ const AddAtttribute: React.FC<{}> = () => {
<Col span={24}>
<Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>必填</Checkbox></Form.Item>
</Col>
<Col span={24}>
{/* <Col span={24}>
<Form.Item name="isImage" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>上传图片</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的属性值可以上传属性值的对应图片!">
<InfoCircleOutlined />
</Tooltip>
</Col>
<Col span={24}>
</Col> */}
{/* <Col span={24}>
<Form.Item name="isName" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>名称属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的属性值会将属性值添加到商品名称之后,中间以/区隔!">
<InfoCircleOutlined />
</Tooltip>
</Col>
</Col> */}
<Col span={24}>
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>价格属性</Checkbox></Form.Item>
<Tooltip title="勾选后对于此属性的每个属性值会在商品发布时按属性设置不同的价格!">
......
......@@ -140,7 +140,7 @@ const ClassProperty: React.FC<{}> = () => {
useEffect(()=>{
//@ts-ignore
treeForm.setFieldsValue({categoryKey: selectLinkRow && selectLinkRow.key, categoryName: selectLinkRow && selectLinkRow.name })
treeForm.setFieldsValue({category: {id: selectLinkRow && selectLinkRow.key}, categoryName: selectLinkRow && selectLinkRow.name })
}, [selectLinkRow])
const initGetCategoryTree = () => {
......@@ -341,7 +341,7 @@ const ClassProperty: React.FC<{}> = () => {
<Col span={14}>
<Form.Item
name='name'
label='品类名称'
label={<>品类名称&nbsp;&nbsp;</>}
rules={[
{
required: true,
......@@ -355,7 +355,7 @@ const ClassProperty: React.FC<{}> = () => {
<Col span={14}>
<Form.Item
name='type'
label='品类类型'
label={<>品类类型&nbsp;&nbsp;</>}
rules={[
{
required: true,
......@@ -398,7 +398,7 @@ const ClassProperty: React.FC<{}> = () => {
>
<Row>
<Col span={20}>
<Form.Item name='categoryKey' style={{display:'none'}}>
<Form.Item name={['category','id']} style={{display:'none'}}>
<Input disabled />
</Form.Item>
<Form.Item name='categoryName'>
......@@ -444,7 +444,7 @@ const ClassProperty: React.FC<{}> = () => {
{
//@ts-ignore
onSelect: (key: string, item: any) => {
// console.log(key, item);
console.log(key, item);
// @ts-ignore
setSelectLinkKeys(key);
setSelectLinkRow(item)
......
import React, { useState, useRef, useEffect, createContext } from 'react'
import { history } from 'umi';
import { Button, Card, Tabs } from 'antd'
import { Button, Card, Tabs, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
SaveOutlined,
......@@ -14,15 +14,37 @@ import PriceAttributeForm from './addProductsItem/priceAttributeForm'
import LogisticsForm from './addProductsItem/logisticsForm';
import OtherForm from './addProductsItem/otherForm';
import ProductImageForm from './addProductsItem/productImageForm';
import ProductDescForm from './addProductsItem/productDescForm';
import ProductDescFormOne from './addProductsItem/productDescFormOne';
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
import { PublicApi } from '@/services/api';
const { TabPane } = Tabs
const AddProducts: React.FC<{}> = (props) => {
const [isEnableCheck, setIsEnableCheck] = useState(true)
const [responseId, setReponseId] = useState<number>(null)
const [attributeList, setAttributeList] = useState<any[]>([])
let [formRefs, setFormRefs] = useState([]) //子form的ref数组
const { ProductStore } = store
const { productSelectAttribute, productAttributeAndImageParams, areaOption, setProductName, setAttributeLists, setProductInfoByEdit } = ProductStore
useEffect(()=>{
const { id } = history.location.query
if(id){
const makeRequest = async () => {
const productRes = await PublicApi.getProductCommodityGetCommodity({id: id})
const { data } = productRes
setProductInfoByEdit(data)
setProductName(data.name)
const attributeRes = await PublicApi.getProductCustomerGetCustomerCategoryById({ id: 47 + '' })
setAttributeLists(attributeRes.data?.customerAttributeList)
}
makeRequest()
}
}, [])
const onSave = () => {
console.log('点击保存')
......@@ -30,17 +52,78 @@ const AddProducts: React.FC<{}> = (props) => {
if(formRefs.length > 0){
try{
let data = formRefs.map(async __ => {
return ( await __.current.validateFields())
return (
await __.current.validateFields()
)
})
console.log(data)
// let vaild = data.every(__ => Boolean(__))
// return vaild ? data :vaild
console.log(data,'data')
Promise.all(data).then((values) => {
// 提交的数据进行处理
console.log(values, productSelectAttribute, productAttributeAndImageParams, '所有数据')
productSelectAttribute.length>0 && productSelectAttribute.map(_itme => {
delete _itme.attributeName
delete _itme.isPrice
})
if(productAttributeAndImageParams.length>0){
productAttributeAndImageParams.map(_item => {
if(_item.goodsCustomerAttributeList.length>0){
_item.goodsCustomerAttributeList.map(__item => {
delete __item.customerAttributeName
})
}
if(_item.commodityPic.length>0){
_item.commodityPic = _item.commodityPic.map(__item => {
return __item?.response?.data
})
}else{
return message.error("每项请至少上传一张商品图片!")
}
})
}
else{
return message.error("每项请至少上传一张商品图片!")
}
let _bacsicForm = {...values[0]}
_bacsicForm.customerCategoryId = _bacsicForm.customerCategoryId[_bacsicForm.customerCategoryId.length-1]
let _params = {..._bacsicForm, ...values[2], logistics: {...values[3]}, ...values[4], customerAttributeList: productSelectAttribute, unitPriceAndPicList: productAttributeAndImageParams}
_params.minOrder = Number(_params.minOrder)
_params.logistics.weight = Number(_params.logistics.weight)
// 处理地址
let _commodityAreaList:any = []
_params.commodityAreaList.length > 0 && _params.commodityAreaList.map(_itme => {
let _temp: any = {}
let pobj = areaOption.filter(_=>_.code===_itme[0])[0]
let cobj = pobj.areaResponses.filter(__=>__.code===_itme[1])[0]
_temp.provinceCode = pobj.code
_temp.provinceName = pobj.name,
_temp.cityCode = cobj.code,
_temp.cityName = cobj.name,
_commodityAreaList.push(_temp)
console.log(_itme, _temp, '地址的每一项')
})
_params.commodityAreaList = _commodityAreaList
console.log(_params,'_params')
PublicApi.postProductCommoditySaveOrUpdateCommodity(_params).then(res => {
console.log(res, 'res')
setIsEnableCheck(false)
//@ts-ignore
setReponseId(res.data)
})
}).catch(error => {
message.error("请完善表单必填项!")
console.log(error, '_error')
})
}catch(e){
console.log(e,'error')
}
}
}
const handleApplyCheck = () => {
PublicApi.postProductCommodityApplyCheckCommodity({id: responseId})
}
const callback = (key: any) => {
console.log(key)
}
......@@ -48,9 +131,9 @@ const AddProducts: React.FC<{}> = (props) => {
return (<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title="新建商品"
title={history.location.query.id?'编辑商品':'新建商品'}
extra={[
<Button key="2">直接提交审核</Button>,
<Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>直接提交审核</Button>,
<Button key="1" type="primary" icon={<SaveOutlined />} onClick={onSave}>
保存
</Button>,
......@@ -58,37 +141,37 @@ const AddProducts: React.FC<{}> = (props) => {
>
<Card>
<Tabs onChange={callback} type="card" defaultActiveKey="1">
<TabPane tab="基本信息" key="11">
<TabPane tab="基本信息" key="1">
<BasicInfoForm
onRef={(refs)=>setFormRefs([...formRefs, refs])}
onChangeAttributeList={(_lists: any)=>setAttributeList(_lists)} />
</TabPane>
<TabPane tab="选择货品" key="22">
<TabPane tab="选择货品" key="2">
<SelectGoodsForm />
</TabPane>
<TabPane tab="商品属性" key="33">
<TabPane tab="商品属性" key="3">
<ProductAttributeForm
onRef={(refs)=>setFormRefs([...formRefs, refs])}
attributesData={attributeList}
/>
</TabPane>
<TabPane tab="价格设置" key="44">
<TabPane tab="价格设置" key="4">
<PriceAttributeForm
onRef={(refs)=>setFormRefs([...formRefs, refs])}
/>
</TabPane>
<TabPane tab="商品图片" key="55" style={{ border: '1px solid rgba(223,225,230,1)' }}>
<TabPane tab="商品图片" key="5" style={{ border: '1px solid rgba(223,225,230,1)' }}>
<ProductImageForm />
</TabPane>
<TabPane tab="商品描述" key="66">
<ProductDescForm />
<TabPane tab="商品描述" key="6">
<ProductDescFormOne />
</TabPane>
<TabPane tab="物流信息" key="77">
<TabPane tab="物流信息" key="7">
<LogisticsForm
onRef={(refs)=>setFormRefs([...formRefs, refs])}
/>
</TabPane>
<TabPane tab="其他" key="88">
<TabPane tab="其他" key="8">
<OtherForm
onRef={(refs)=>setFormRefs([...formRefs, refs])}
/>
......@@ -98,4 +181,4 @@ const AddProducts: React.FC<{}> = (props) => {
</PageHeaderWrapper>)
}
export default AddProducts
\ No newline at end of file
export default observer(AddProducts)
\ No newline at end of file
......@@ -9,7 +9,7 @@ import styles from './index.less'
import { PublicApi } from '@/services/api';
import {
GetProductCustomerGetCustomerCategoryTreeResponse,
GetWarehouseAreaAllResponse
GetManageAreaAllResponse
} from '@/services';
import { inject, observer } from 'mobx-react'
......@@ -17,7 +17,6 @@ import { inject, observer } from 'mobx-react'
// import { IStore } from '@/store';
import { store } from '@/store'
const { Option } = Select
const layout = {
labelCol: {
......@@ -63,10 +62,11 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
const [brandData, setBrandData] = useState<any>([])
const [brandValue, setBrandValue] = useState(undefined)
const [customerCategoryTree, setCustomerCategoryTree] = useState<GetProductCustomerGetCustomerCategoryTreeResponse>()
const [proviceOptions, setProviceOptions] = useState<GetWarehouseAreaAllResponse>()
const [proviceOptions, setProviceOptions] = useState<GetManageAreaAllResponse>()
const [showCategory, setShowCategory] = useState(null)
const [areaParams, setAreaParams] = useState<AreaParams>()
const { ProductStore } = store
const { setAreaOption, productInfoByEdit, getBasicFormParamsByEdit, setAttributeLists, setProductName } = ProductStore
useEffect(() => {
// 获取品类树
......@@ -75,7 +75,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
setCustomerCategoryTree(res.data)
})
//获取省市区
PublicApi.getWarehouseAreaAll().then(res => {
PublicApi.getManageAreaAll().then(res => {
if (res.code === 1000) {
let arr = [...res.data] //裁去最后一级别
for (let index in arr) {
......@@ -86,16 +86,20 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
}
}
setProviceOptions(arr)
setAreaOption(arr)
}
})
//传入ref给父级
onRef(basicFormRef)
if(productInfoByEdit?.id){
console.log(productInfoByEdit,'productInfoByEdit')
handleBrandSearch(getBasicFormParamsByEdit.brandName)
onCustomerCategoryChange([45, 47])
}
}, [])
const onFinish = (values: any) => {
let params = {...values, commodityAreaList: areaParams, customerCategoryId: values?.customerCategoryId.pop()}
console.log('子保单值,', params)
}
// const onFinish = (values: any) => {
// console.log(values,'原values')
// }
const handleBrandSearch = (value: any) => { // end value
console.log(value, 'handleBrandSearch')
......@@ -120,15 +124,17 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
<Tag closable={closable} onClose={onClose} style={{ marginRight: 4, border: '1px solid #f0f0f0' }}>
{label}
</Tag>
)
)
}
const onCustomerCategoryChange = (value: any) => {
let seletCategoryId = value[1] || value[0]
if (value.length > 0) {
PublicApi.getProductCustomerGetCustomerCategoryById({ id: seletCategoryId }).then(res => {
onChangeAttributeList(res.data?.customerAttributeList)
setShowCategory(res.data.name)
const { data } = res
onChangeAttributeList(data?.customerAttributeList)
setShowCategory(data.name)
setAttributeLists(data?.customerAttributeList)
})
}
else
......@@ -149,11 +155,11 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
areaParams.cityCode = selected[1].code
}
setAreaParams(areaParams)
console.log(areaParams, 'area')
console.log(value, selected, areaParams, 'area')
}
const onChangeName = (value: any) => {
ProductStore.setProductName(value)
setProductName(value)
}
return (<>
......@@ -162,9 +168,10 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
form={basicForm}
name="basic-form"
labelAlign="left"
onFinish={onFinish}
// onFinish={onFinish}
colon={false}
ref={basicFormRef}
initialValues={productInfoByEdit?.id ? getBasicFormParamsByEdit : {}}
>
<Form.Item
name="customerCategoryId"
......@@ -187,6 +194,12 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
<Form.Item
name="brandId"
label="商品品牌"
rules={[
{
required: true,
message: '请选择商品品牌'
}
]}
>
<Select
showSearch
......@@ -277,11 +290,11 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
{...(index === 0 ? layout : layoutFormList)}
label={
field.key === 0 && <span>
<i style={{ color: 'red' }}>* </i>
归属地市&nbsp;
<Tooltip title="设置了归属地市后,此商品可根据地市进行筛选,未设置时默认为所有地市">
<QuestionCircleOutlined />
</Tooltip>
<i style={{ color: 'red' }}> * </i>
</span>
}
rules={[
......@@ -324,14 +337,14 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
>
{showCategory && <><span className="commonStatusValid"></span>{showCategory}</>}
</Form.Item>
<Form.Item {...tailLayout}>
{/* <Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit">
保存
</Button>
<Button className={styles.ml20}>
取消
</Button>
</Form.Item>
</Form.Item> */}
</Form>
</>)
}
......
.colBox{
background-color: #FAFBFC;
position: relative;
ul{
margin-bottom: 42px;
margin-top: 12px;
list-style: none;
padding: 0;
li{
padding-left: 24px;
height: 32px;
line-height: 32px;
color: #172B4D;
display: flex;
justify-content: space-between;
margin: 8px 0;
cursor: pointer;
// span{
// padding-top: 12px;
// padding-bottom: 12px;
// }
a{
color: #97A0AF;
float: right;
padding-right: 24px;
}
}
.actived-li{
box-sizing: border-box;
font-weight: bold;
border-left: 2px solid #00B37A;
}
.tipTitle{
height:20px;
font-size:12px;
font-weight:400;
color:rgba(151,160,175,0.8);
line-height:20px;
margin: 25px 0 20px 0;
padding-left: 24px;
}
}
.addBtn{
margin-top: 30px;
background-color: #F4F5F7;
width: 100%;
position: absolute;
bottom: 0;
}
}
\ No newline at end of file
import React, { useState, useEffect, useRef } from 'react'
import {history} from 'umi'
import { Button, Form, Select, Checkbox, Tooltip, Radio, Input, Table, Modal, Row, Col } from 'antd'
import { Button, Form, Select, Checkbox, Tooltip, Radio, Input, Table, Modal, Row, Col, InputNumber } from 'antd'
import { PublicApi } from '@/services/api'
import { GetLogisticsSelectListCompanyResponse, GetLogisticsSelectListShipperAddressResponse } from '@/services'
......@@ -49,6 +49,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
name="logistic-form"
labelAlign="left"
ref={logisticsFormRef}
colon={false}
>
<Form.Item
name="deliveryType"
......@@ -89,7 +90,10 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
rules={[
{
required: true,
message: '请填入重量'
type: 'number',
message: '请填入重量',
min: 0,
transform: (value) => Number(value)
},
]}
>
......
......@@ -40,6 +40,7 @@ const OtherForm: React.FC<Iprops> = (props) => {
name="other-form"
labelAlign="left"
ref={otherFormRef}
colon={false}
>
<Form.Item
name="isInvoice"
......
import React, { useState, useEffect, useRef, useContext, useCallback, useMemo } from 'react'
import {history} from 'umi'
import { Button, Form, Select, Checkbox, Tooltip, Radio, Input, Table, Modal, Row, Col } from 'antd'
import { Button, Form, Select, Checkbox, Tooltip, Radio, Input, Table, Modal, Row, Col, InputNumber } from 'antd'
import styles from './index.less'
import { PublicApi } from '@/services/api'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { EyeOutlined, QuestionCircleOutlined, SettingOutlined, PlusOutlined, MinusOutlined, ContactsFilled, CodeSandboxCircleFilled } from '@ant-design/icons'
import { EyeOutlined, QuestionCircleOutlined, SettingOutlined, PlusOutlined, MinusOutlined, } from '@ant-design/icons'
import { inject, observer } from 'mobx-react'
// import { IProductModule } from '@/module/productModule'
// import { IStore } from '@/store';
import { store } from '@/store'
import ProductDescForm from './productDescForm'
import { Effects } from 'bizcharts'
const layout = {
labelCol: {
......@@ -54,33 +50,21 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const [colums, setColumns] = useState<ColumnType<any>[]>()
const { ProductStore } = store
const { productName, selectedGoods, productSelectAttribute, tableDataSource, setTableDataSource, clearData } = ProductStore
const { productName, selectedGoods, productSelectAttribute, tableDataSource, setTableDataSource, clearData, setPriceAttributeParams } = ProductStore
_tableDataSource = useMemo(() =>tableDataSource, [tableDataSource]) // 保持最新值
useEffect(()=>{
console.log('000')
//传入ref给父级
onRef(priceFormRef) //初始化或组件卸载先置空_tableDataSource和tableDataSource
// clearData([])
// _tableDataSource = []
return () => {
console.log(111)
// clearData([])
// _tableDataSource = []
console.log(_tableDataSource, tableDataSource, '组件卸载清空data')
}
onRef(priceFormRef)
},[])
useEffect(()=>{
console.log(222)
constructedCallback()
},[productName, selectedGoods, productSelectAttribute, planPrice])
// 构建表格列和data
/* 构建表格列和data */
const constructedCallback = () => {
console.log(productName,'name')
console.log(333)
let _col = [];
let col_productName = { title: '商品名称', dataIndex: '商品名称', key: '商品名称' }
_col.push(col_productName)
......@@ -174,14 +158,19 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
combineArray.map((_rowArr: any[], i: any) => { // _rowArr 属性值数组
let _tempObj: any = { 索引: i ,商品名称: productName }
console.log(_rowArr,'_rowArr')
Array.isArray(_rowArr) && _rowArr.map((__rowArr, index) => {
Array.isArray(_rowArr) ? _rowArr.map((__rowArr, index) => {
_tempObj[_attributeNameArr[index]] = __rowArr
})
_tempObj['对应货品'] = selectedGoods.length > 0 && selectedGoods[0].id
}) : _tempObj[_attributeNameArr[i]] = _rowArr
_tempObj['对应货品'] = selectedGoods.length > 0 ? selectedGoods[0].id : 0
_tempObj['单价'] = {}
_tableData.push(_tempObj)
console.log(_rowArr,'_tempObj')
})
}else{ // length不存在,默认只有商品名称一行
let _tempObj: any = { 索引: 0 ,商品名称: productName }
_tempObj['对应货品'] = selectedGoods.length > 0 ? selectedGoods[0].id : 0
_tempObj['单价'] = {}
_tableData.push(_tempObj)
}
console.log(_tableData, '_tableData')
_tableDataSource = _tableData
......@@ -194,22 +183,28 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
constructedPrarams()
},[combineAttributeArray, attributeObjArr, attributeValObjArr, setPriceModal, tableDataSource])
// 生成传输数据
/* 生成传输数据 */
const constructedPrarams = () => {
let _paramsArray: any[] = [];
console.log('生成传输数据', combineAttributeArray, attributeObjArr, attributeValObjArr)
Array.isArray(combineAttributeArray) && combineAttributeArray.map((item, index)=>{ // 当属性减少的时候 这个combine数组还是之前的
let _tempArr: any = [], _tempObj: any = {}
Array.isArray(item) && item.map((_item, _index)=>{
console.log('生成传输数据', combineAttributeArray, attributeObjArr, attributeValObjArr, tableDataSource)
Array.isArray(combineAttributeArray) ? combineAttributeArray.map((item, index)=>{ // 非数组情况下默认无组合 从table数据中获取 // 当属性减少的时候 这个combine数组还是之前的
let _tempArr: any = []
Array.isArray(item) ? item.map((_item, _index)=>{
let _tempObject: any = {};
_tempObject.customerAttributeId = attributeObjArr[_index].customerAttributeId
_tempObject.customerAttributeName = attributeObjArr[_index].attributeName
_tempObject.customerAttributeValueId = attributeValObjArr[_index].find(__item=>__item.value===item[_index]).customerAttributeValueId
_tempObject.value = item[_index]
_tempArr.push(_tempObject)
}) : _tempArr.push({
customerAttributeId: attributeObjArr[0].customerAttributeId,
customerAttributeName: attributeObjArr[0].attributeName,
customerAttributeValueId: attributeValObjArr[0][0].customerAttributeValueId,
value: item.toString()
})
_paramsArray.push({goodsId: _tableDataSource[index] && _tableDataSource[index]['对应货品'], goodsCustomerAttributeList: _tempArr, unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价']}) /*带上货品id 带上单价*/
})
_paramsArray.push({goodsId: _tableDataSource[index] ? _tableDataSource[index]['对应货品'] : 0, goodsCustomerAttributeList: _tempArr, unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价']}) /*带上货品id 带上单价*/
}) : _paramsArray.push({goodsId: _tableDataSource[0] ? _tableDataSource[0]['对应货品'] : 0, goodsCustomerAttributeList: [], unitPrice: _tableDataSource[0]&&_tableDataSource[0]['单价']}) /*带上货品id 带上单价*/
setPriceAttributeParams(_paramsArray)
console.log(_paramsArray,'params')
}
......@@ -313,8 +308,10 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}
}
const handleUnitChange = (value:any) => {
const handleUnitChange = (value:any, option: any) => {
console.log(value, option,'change value')
setUnitValue(value)
priceForm.setFieldsValue({unitName: option.children})
}
return (<>
......@@ -324,6 +321,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
name="price-form"
labelAlign="left"
ref={priceFormRef}
colon={false}
>
<Form.Item
name="unitId"
......@@ -350,7 +348,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
showArrow={false}
filterOption={false}
onSearch={handleUnitSearch}
onChange={handleUnitChange}
onChange={(value,option)=>handleUnitChange(value, option)}
notFoundContent={null}
style={{width:'100%'}}
>
......@@ -358,6 +356,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
</Select>
</Form.Item>
<Form.Item
name="unitName"
style={{display:'none'}}
label="单位名称"
initialValue=""
>
<Input disabled={true} />
</Form.Item>
<Form.Item
name="minOrder"
label={
<span>
......@@ -369,7 +375,10 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}
rules={[{
required: true,
message: '请输入最小起订数'
type: 'number',
message: '请输入最小起订数',
min: 0,
transform: (value) => Number(value)
}]}
>
<Input placeholder="请输入最小起订数" />
......@@ -411,6 +420,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
message: '请选择会员折扣'
}]}
valuePropName="checked"
initialValue={false}
>
<Checkbox>允许使用会员折扣价购买</Checkbox>
</Form.Item>
......
......@@ -4,8 +4,6 @@ import { Button, Form, Select, Checkbox, Tabs, Input } from 'antd'
import styles from './index.less'
import { inject, observer } from 'mobx-react'
// import { IProductModule } from '@/module/productModule'
// import { IStore } from '@/store';
import { store } from '@/store'
const layout = {
......@@ -39,16 +37,14 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
const productAttributeFormRef = useRef()
const [attributeForm] = Form.useForm()
const { ProductStore } = store
const [paramsData, setParamsData] = useState<any>()
const { setProductSelectAttribute, getProductAttributeFormParamsByEdit, productInfoByEdit } = ProductStore
useEffect(()=>{
//传入ref给父级
onRef(productAttributeFormRef)
}, [])
const onFinish = (values) => {
console.log(values)
console.log(values, 'values')
}
/**
......@@ -85,13 +81,18 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
})
}
paramsArray.push(params)
console.log(paramsArray,'paramsArray')
let resultParams = Object.values(paramsArray.reduce((item, next)=>{
let _resultParams = Object.values(paramsArray.reduce((item, next)=>{
item[next.customerAttributeId] = next;
return item
},{}))
console.log(resultParams,'result', paramsArray) // 最终传输数据
ProductStore.setProductSelectAttribute(resultParams)
//遍历 排空
let resultParams = _resultParams.filter((_item: any)=>_item.customerAttributeValueList.length!=0)
console.log(resultParams,'resultParams') // 最终传输数据
setProductSelectAttribute(resultParams)
}
const renderTabPanchildren = (attrItem: any) => {
......@@ -164,6 +165,8 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
labelAlign="left"
onFinish={onFinish}
ref={productAttributeFormRef}
colon={false}
initialValues={productInfoByEdit?.id ? getProductAttributeFormParamsByEdit : {}}
>
<Tabs defaultActiveKey="1" tabPosition="left">
{
......
import React, { useState, useEffect } from 'react'
import {history} from 'umi'
import { Button, Form, Select, Checkbox, Tooltip, Radio, Input, Table, Modal, Row, Col } from 'antd'
import styles from '../index.less'
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons'
export interface Iprops {
}
const ProductDescForm: React.FC<Iprops> = (props) => {
return (<>
<div className={styles.descriptBox}>
<p>文字区域</p>
<div className={styles.bottomBtn}>
<Button icon={<PlusOutlined />}>添加文字</Button>
</div>
</div>
<div className={styles.descriptBox}>
<p>视频区域</p>
<div className={styles.bottomBtn}>
<Button icon={<DeleteOutlined />}>删除</Button>
<Button icon={<PlusOutlined />}>添加素材</Button>
</div>
</div>
<div className={styles.descriptBox}>
<p>图片区域</p>
<div className={styles.bottomBtn}>
<Button icon={<DeleteOutlined />}>删除</Button>
<Button icon={<PlusOutlined />}>添加素材</Button>
</div>
</div>
</>)
}
export default ProductDescForm
\ No newline at end of file
import React, { useState, useEffect } from 'react'
import {history} from 'umi'
import { Button, Form, Select, Checkbox, message, Upload, Input, Table, Modal, Row, Col } from 'antd'
import styles from '../index.less'
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons'
import { PublicApi } from '@/services/api'
export interface Iprops {
}
const ProductDescFormOne: React.FC<Iprops> = (props) => {
const [fileImageList, sefileImageList] = useState<any>([
// {
// uid: '-1',
// name: 'image.png',
// status: 'done',
// url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
// },
// {
// uid: '-2',
// name: 'image.png',
// status: 'done',
// url: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
// },
])
useEffect(()=>{
// PublicApi
}, [])
const uploadProps = {
name: 'file',
action: '/imgapi/file/file/upload',
showUploadList: false,
data: { fileType: 2 },
headers: {
authorization: 'authorization-text',
},
onChange(info) {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList, 'image files');
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`);
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败`);
}
},
}
return (<>
<div className={styles.descriptBox}>
<p className={styles.pVideo}>视频区域<br />(数量限一个)</p>
<div className={styles.rightBtn}>
<Button icon={<PlusOutlined />} />
<Button icon={<DeleteOutlined />} />
</div>
</div>
<div className={styles.descriptBox}>
<p>图片区域</p>
<div className={styles.rightBtn}>
<Button icon={<PlusOutlined />} />
<Button icon={<DeleteOutlined />} />
</div>
</div>
<div className={styles.descriptBox}>
<p>图片区域</p>
<div className={styles.rightBtn}>
<Button icon={<PlusOutlined />} />
<Button icon={<DeleteOutlined />} />
</div>
</div>
<div className={styles.descriptBox}>
<p className={styles.middleAddBtn}>
<Upload {...uploadProps}>
<Button type="text">
<PlusOutlined />
</Button>
<br/>
<span>添加图片区域</span>
</Upload>
</p>
</div>
</>)
}
export default ProductDescFormOne
\ No newline at end of file
......@@ -6,10 +6,9 @@ import { PublicApi } from '@/services/api'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { EyeOutlined } from '@ant-design/icons'
import { GetProductGoodsGetGoodsListResponseDetail } from '@/services';
import { inject, observer } from 'mobx-react'
// import { IProductModule } from '@/module/productModule'
// import { IStore } from '@/store';
import { store } from '@/store'
const layout = {
......@@ -28,7 +27,7 @@ export interface Iprops {
const SelectGoodsForm: React.FC<Iprops> = (props) => {
const [selectGoodsForm] = Form.useForm()
const [showSelectGoods, setIsSelectGoods] = useState(false)
const [selectGoodsRow, setSelectGoodsRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectGoodsRow, setSelectGoodsRow] = useState<GetProductGoodsGetGoodsListResponseDetail[]>([]) // 模态框选择的行数据
const [selectedGoodsRowKeys, setSelectedGoodsRowKeys] = useState<Array<number>>([])
const { ProductStore } = store
......@@ -104,6 +103,7 @@ const SelectGoodsForm: React.FC<Iprops> = (props) => {
form={selectGoodsForm}
name="select-goods"
labelAlign="left"
colon={false}
>
<Form.Item
label="是否选择货品"
......
......@@ -91,17 +91,37 @@
.descript-box{
position: relative;
margin: 24px;
width: 790px;
margin: 24px auto;
border:1px solid rgba(235,236,240,1);
text-align: center;
color:rgba(151,160,175,1);
height: 128px;
.bottom-btn{
p{
height: 128px;
line-height: 128px;
}
.pVideo, .middleAddBtn{
height: 44px;
line-height: 1.5;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
}
.right-btn{
position: absolute;
top: 0;
right: 0;
bottom: 0;
Button{
margin-left: 16px;
display: block;
width:36px;
height:36px;
background:rgba(250,251,252,1);
border-color: #ebecf0;
border-radius: 0px;
border-top: none;
border-right: none;
}
}
}
......@@ -134,6 +154,10 @@
height:104px;
margin-right: 16px;
border:1px solid rgba(235,236,240,1);
.pic{
width: 100%;
height: 100%;
}
}
}
.pruduct-status{
......
......@@ -157,9 +157,9 @@ const Products: React.FC<{}> = () => {
else if (record.status === 2)
component = (<><span className="commonStatusModify"></span>待审核</>)
else if (record.status === 3)
component = (<><span className="commonStatusValid"></span>审核通过</>)
component = (<><span className="commonStatusValid"></span>审核通过</>)
else if (record.status === 4)
component = (<><span className="commonStatusInvalid">审核通过</span></>)
component = (<><span className="commonStatusInvalid">审核通过</span></>)
else if (record.status === 5)
component = (<span style={{ color: '#00B37A', padding: '2px 5px', background: 'rgba(235,247,242,1)', borderRadius: '4px' }}>已上架</span>)
else if (record.status === 6)
......@@ -176,11 +176,11 @@ const Products: React.FC<{}> = () => {
value: 2,
},
{
text: '审核通过',
text: '审核通过',
value: 3,
},
{
text: '审核通过',
text: '审核通过',
value: 4,
},
{
......@@ -215,9 +215,9 @@ const Products: React.FC<{}> = () => {
<Menu.Item>
{record.status === 1 ? <Button type='link' onClick={()=>clickSubmitCheck(record)}>提交审核</Button> : ''}
</Menu.Item>
{(record.status === 3 || record.status === 6) ? <Menu.Item><Button type='link' onClick={() => clickUp(1)}>上架</Button></Menu.Item> : ''}
{(record.status === 4 || record.status === 6) ? <Menu.Item><Button type='link' onClick={() => clickUp(1)}>上架</Button></Menu.Item> : ''}
{record.status === 5 ? <Menu.Item><Button type='link' onClick={() => clickUp(0)}>下架</Button></Menu.Item> : ''}
{record.status === 4 ? <Menu.Item><Button type='link'>修改</Button></Menu.Item> : ''}
{record.status === 3 ? <Menu.Item><Button type='link' onClick={() => clickModify(record.id)}>修改</Button></Menu.Item> : ''}
<Menu.Item>
<Button type='link' onClick={()=>clickCopy(record)}>复制</Button>
</Menu.Item>
......@@ -250,6 +250,10 @@ const Products: React.FC<{}> = () => {
history.push(`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`)
}
const clickModify = (id: number) => {
history.push(`/memberCenter/commodityAbility/commodity/products/addProducts?id=${id}`)
}
const confirm = () => {
console.log('confirm')
}
......@@ -427,6 +431,8 @@ const Products: React.FC<{}> = () => {
const { id } = record;
if(id)
PublicApi.postProductCommodityApplyCheckCommodity({id: id})
//@ts-ignore
ref.current.reload(restObj)
}
const handleMenuClick = (e: any) => {
......
......@@ -3,7 +3,7 @@ import { usePageStatus } from '@/hooks/usePageStatus';
import { history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { createFormActions } from '@formily/antd';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { Button, Card } from 'antd';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
......@@ -12,9 +12,149 @@ import { PublicApi } from '@/services/api';
const addSchemaAction = createFormActions();
const { onFieldValueChange$ } = FormEffectHooks;
const AddBills: React.FC<{}> = (props: any) => {
const ref = useRef({});
const [warehouseList, setWarehouseList] = useState<any>([]);
const [relevance, setRelevance] = useState(1);
// 订单
const orderColumns = [
{
title: '订单号',
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
},
{
title: '订单商品摘要',
align: 'center',
dataIndex: 'invoicesAbstract',
key: 'invoicesAbstract',
},
{
title: '会员名称',
align: 'center',
dataIndex: 'memberName',
key: 'memberName',
},
{
title: '下单时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
},
{
title: '订单类型',
align: 'center',
dataIndex: 'orderType',
key: 'orderType',
},
{
title: '订单状态',
align: 'center',
dataIndex: 'state',
key: 'state',
},
];
// 生成通知单列表
const productionColumns = [
{
title: '通知单号',
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
},
{
title: '通知单摘要',
align: 'center',
dataIndex: 'invoicesAbstract',
key: 'invoicesAbstract',
},
{
title: '加工企业名称',
align: 'center',
dataIndex: 'memberName',
key: 'memberName',
},
{
title: '单据时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
},
{
title: '申请单状态',
align: 'center',
dataIndex: 'state',
key: 'state',
},
];
// 售后订单列表
const afterSaleColumns = [
{
title: '申请单号',
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
},
{
title: '申请单摘要',
align: 'center',
dataIndex: 'invoicesAbstract',
key: 'invoicesAbstract',
},
{
title: '会员名称',
align: 'center',
dataIndex: 'memberName',
key: 'memberName',
},
{
title: '单据时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
},
{
title: '申请单状态',
align: 'center',
dataIndex: 'state',
key: 'state',
},
];
const [modalColumns, setModalColumns] = useState(orderColumns);
const tableColumns = [
{ dataIndex: 'id', title: 'ID' },
{
dataIndex: 'no',
title: '货号',
render: (text, record) => <span>{text}</span>,
},
{ dataIndex: 'pname', title: '货品名称' },
{ dataIndex: 'size', title: '规格/型号' },
{ dataIndex: 'type', title: '品类' },
{ dataIndex: 'brand', title: '品牌' },
{ dataIndex: 'unit', title: '单位' },
{ dataIndex: 'name', title: '商品名称' },
{ dataIndex: 'univalence', title: '单价' },
{ dataIndex: 'numberr', title: '单据数量' },
{ dataIndex: 'price', title: '金额' },
{
dataIndex: 'ctl',
title: '操作',
render: (text, record) => (
<Button type="link" onClick={() => handleDeleteTable(record.id)}>
删除
</Button>
),
},
];
// useEffect(() => {
// PublicApi.getWarehouseWarehouseList({
......@@ -29,6 +169,8 @@ const AddBills: React.FC<{}> = (props: any) => {
// });
// }, []);
const handleDeleteTable = id => {};
const handleSubmit = value => {
if (usePageStatus().pageStatus === 0)
return PublicApi.postWarehouseInvoicesAdd({ ...value }).then(res => {
......@@ -74,9 +216,28 @@ const AddBills: React.FC<{}> = (props: any) => {
>
<Card>
<NiceForm
expressionScope={{
tableColumns,
}}
effects={$ => {
$('onFieldValueChange', 'relevanceInvoices').subscribe(state => {
setRelevance(state.value);
setModalColumns(
state.value === 1
? orderColumns
: state.value === 2 || state.value === 3
? afterSaleColumns
: productionColumns,
);
});
}}
onSubmit={handleSubmit}
actions={addSchemaAction}
schema={getBillsDetailSchema(warehouseList)}
schema={getBillsDetailSchema({
warehouseList,
relevance,
modalColumns,
})}
/>
</Card>
</PageHeaderWrapper>
......
......@@ -13,7 +13,6 @@ import { FORM_FILTER_PATH } from '@/formSchema/const';
import { billsSchema } from './schema';
import UploadModal from '@/components/UploadModal';
import { PublicApi } from '@/services/api';
import style from './index.less';
const formActions = createFormActions();
......
......@@ -109,7 +109,7 @@ const billsType: React.FC<{}> = () => {
</Button>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => console.log('...')}
onConfirm={() => handleDelete(record)}
onCancel={() => console.log('...')}
okText="是"
cancelText="否"
......@@ -128,6 +128,12 @@ const billsType: React.FC<{}> = () => {
console.log('执行状态修改', record);
};
const handleDelete = record => {
PublicApi.postWarehouseInvoicesTypeDelete({
id: record.id,
}).then(res => {});
};
return (
<PageHeaderWrapper>
<Card>
......
......@@ -108,8 +108,7 @@ const WareHouse: React.FC<{}> = () => {
</Button>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => console.log('...')}
onCancel={() => console.log('...')}
onConfirm={() => handleDelete(record)}
okText="是"
cancelText="否"
>
......@@ -127,6 +126,14 @@ const WareHouse: React.FC<{}> = () => {
console.log('执行状态修改', record);
};
const handleDelete = record => {
PublicApi.getWarehouseInvoicesDetailsList({
invoicesId: record.id,
}).then(res => {
// if(res.data.)
});
};
return (
<PageHeaderWrapper>
<Card>
......
import {action, computed, observable, runInAction} from 'mobx'
import { IProductModule } from '@/module/productModule'; // mobx要用到的数据类型
import { IProductModule, IProductSelectAttribute, IBasicFormParam } from '@/module/productModule'; // mobx要用到的数据类型
import { GetProductGoodsGetGoodsListResponseDetail, GetProductCommodityGetCommodityResponse } from '@/services';
class ProductStore implements IProductModule {
@observable public attributeLists: any[] = [];
@observable public productName: string = "";
@observable public productSelectAttribute: any[] = [];
@observable public selectedGoods: any[] = [];
@observable public productSelectAttribute: IProductSelectAttribute[] = [];
@observable public selectedGoods: GetProductGoodsGetGoodsListResponseDetail[] = [];
@observable public tableDataSource: any[] = [];
@observable public priceAttributeParams: any[] = [];
@observable public productAttributeAndImageParams: any[] = [];
@observable public areaOption: any[] = [];
@observable public productInfoByEdit: GetProductCommodityGetCommodityResponse; // id属性可以作为判断是否是编辑状态的依据
@computed
public get getBasicFormParamsByEdit(): IBasicFormParam {
return {
brandId: this.productInfoByEdit?.brand?.id,
brandName: this.productInfoByEdit?.brand?.name,
name: this.productInfoByEdit?.name,
slogan: this.productInfoByEdit?.slogan,
sellingPoint: this.productInfoByEdit?.sellingPoint,
commodityAreaList: this.productInfoByEdit?.commodityAreaList.map(item => [item.provinceCode, item.cityCode]),
customerCategoryId: [45, 47]
}
}
@computed
public get getProductAttributeFormParamsByEdit(): any {
let attributeArr = this.productInfoByEdit.commodityAttributeList.map(item => item.customerAttribute)
let attributeValueArr = this.productInfoByEdit.commodityAttributeList.map(item => item.customerAttributeValueList)
let attributeIdArr = attributeArr.map(item => item.id)
let attributeValueIdArr = attributeValueArr.map(item => item.map(_item => _item.id))
let tempObj = {}
attributeIdArr.map((item, index) => {
if(attributeValueIdArr[index].length>1){
tempObj[item] = attributeValueIdArr[index]
}else{
tempObj[item] = attributeValueIdArr[index][0]
}
})
return tempObj
}
/** 定义动作区块,外部调用,改变对应的状态 **/
// 可以改变存的testText值
@action.bound
public setAttributeLists(lists: any[]) {
this.attributeLists = lists;
}
@action.bound
public setProductName(name: string) {
this.productName = name;
}
......@@ -20,12 +61,12 @@ class ProductStore implements IProductModule {
}
@action.bound
public setSelectedGoods(list: any[]) {
public setSelectedGoods(list: GetProductGoodsGetGoodsListResponseDetail[]) {
this.selectedGoods = list;
}
@action.bound
public setTableDataSource(datas: any[]) {
public setTableDataSource<T>(datas: T[]) {
console.log(datas, 'innerBox')
this.tableDataSource = datas;
}
......@@ -34,6 +75,26 @@ class ProductStore implements IProductModule {
public clearData(data: any[]) {
this.tableDataSource = data;
}
@action.bound
public setPriceAttributeParams<T>(datas: T[]) {
this.priceAttributeParams = datas
}
@action.bound
public setProductAttributeAndImageParams(datas: any[]) {
this.productAttributeAndImageParams = datas
}
@action.bound
public setAreaOption(datas: any[]) {
this.areaOption = datas
}
@action.bound
public setProductInfoByEdit(data: GetProductCommodityGetCommodityResponse) {
this.productInfoByEdit = data
}
}
......
import {action, computed, observable, runInAction} from 'mobx'
import { ISiteModule } from '@/module/siteModule';
class SiteStore implements ISiteModule {
@observable public siteId: number = 255;
}
export default SiteStore
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