Commit eb0b84ca authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

对接货品部分功能

parent 3f7fc261
......@@ -29,6 +29,7 @@
"@umijs/test": "^3.2.0",
"bizcharts": "^4.0.7",
"god": "^0.1.7",
"god-tool": "^2.2.0",
"lint-staged": "^10.0.7",
"mobx": "^5.15.4",
"mobx-react": "^6.2.2",
......
......@@ -140,18 +140,30 @@ const Attribute: React.FC<{}> = () => {
}}
formilyProps={{
layouts: {
order: 1
order: 1,
span: 4
},
ctx: {
inline: false,
schema: {
type: 'object',
properties: {
name: {
type: 'string',
'x-component-props': {
placeHolder: '属性名称'
megaLayout0: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
grid: true,
columns: 1,
},
'x-component': 'Search'
properties: {
name: {
type: 'string',
'x-component-props': {
placeholder: '属性名称',
},
'x-component': 'Search'
}
}
}
}
}
......
import React, { useState } from 'react';
import { Form, Input, Button, Select, Card, Tooltip } from 'antd'
import { Form, Input, Button, Select, Card, Tooltip, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { history } from 'umi';
import {
......@@ -7,6 +7,7 @@ import {
} from '@ant-design/icons'
import ReutrnEle from '@/components/ReturnEle';
import styles from './index.less'
import { getSelectBrandList, getSelectCustomerCategoryList, getSelectUniteList, updateGoods } from '@/services/commodity/goods';
const { Option } = Select;
const layout = {
......@@ -26,9 +27,70 @@ const tailLayout = {
const AddGoods = () => {
const [form] = Form.useForm();
const [brandData, setBrandData] = useState<any>([])
const [brandValue, setBrandValue] = useState(undefined)
const [classData, setClassData] = useState<any>([])
const [classValue, setClassValue] = useState(undefined)
const [unitData, setUnitData] = useState<any>([])
const [unitValue, setUnitValue] = useState(undefined)
const handleBrandSearch = (value:any) => { // end value
console.log(value, 'handleBrandSearch')
if (value) {
getSelectBrandList({name: value}).then(res=>{
if(res.code === 1000)
setBrandData(res.data)
})
} else {
setBrandData([])
}
}
const handleBrandChange = (value:any) => {
setBrandValue(value)
console.log(value, 'handleBrandChange')
// let obj = {...filterParams, brandId: value}
// setFilterParams(obj)
}
const handleClassSearch = (value:any) => {
console.log(value, 'handleClassSearch')
if (value) {
getSelectCustomerCategoryList({name: value}).then(res=>{
if(res.code === 1000)
setClassData(res.data)
})
} else {
setClassData([])
}
}
const handleClassChange = (value:any) => {
setClassValue(value)
// let obj = {...filterParams, customerCategoryId: value}
// setFilterParams(obj)
console.log(value, 'handleClassChange')
}
const handleUnitSearch = (value:any) => {
console.log(value, 'handleClassSearch')
if (value) {
getSelectUniteList({name: value}).then(res=>{
if(res.code === 1000)
setUnitData(res.data)
})
} else {
setUnitData([])
}
}
const handleUnitChange = (value:any) => {
setUnitValue(value)
// let obj = {...filterParams, customerCategoryId: value}
// setFilterParams(obj)
console.log(value, 'handleClassChange')
}
const onFinish = (values:any) => {
console.log(values);
updateGoods({...values}).then(res=>{
if(res.code===1000)
message.success(res.message)
})
};
return (<PageHeaderWrapper
......@@ -51,9 +113,13 @@ const AddGoods = () => {
required: true,
message: '请填入货号'
},
{
pattern: /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{1,20}$/,
message: '最长20个字符(由字母、数组、特殊字符组成)'
}
]}
>
<Input placeholder="最长20个字符(由字母、数组、特殊字符组成)" />
<Input placeholder="最长20个字符(由字母、数组、特殊字符组成)" maxLength={20} />
</Form.Item>
<Form.Item
name="name"
......@@ -65,10 +131,10 @@ const AddGoods = () => {
},
]}
>
<Input placeholder="最长40个字符、20个汉字" />
<Input placeholder="最长20个字符" maxLength={20} />
</Form.Item>
<Form.Item
name="specification"
name="type"
label="规格型号"
rules={[
{
......@@ -77,10 +143,10 @@ const AddGoods = () => {
},
]}
>
<Input placeholder="最长40个字符、20个汉字" />
<Input placeholder="最长20个字符" maxLength={20} />
</Form.Item>
<Form.Item
name="class"
name={['customerCategory', 'id']}
label="品类"
rules={[
{
......@@ -89,10 +155,24 @@ const AddGoods = () => {
},
]}
>
<Input placeholder="最长24个字符、12个汉字" />
{/* <Input placeholder="最长24个字符、12个汉字" /> */}
<Select
showSearch
placeholder="请填入品类"
value={classValue}
defaultActiveFirstOption={false}
showArrow={false}
filterOption={false}
onSearch={handleClassSearch}
onChange={handleClassChange}
notFoundContent={null}
style={{width:'100%'}}
>
{classData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
</Form.Item>
<Form.Item
name="brand"
name={['brand', 'id']}
label="品牌"
rules={[
{
......@@ -101,34 +181,54 @@ const AddGoods = () => {
},
]}
>
<Input placeholder="最长40个字符、20个汉字" />
{/* <Input placeholder="最长40个字符、20个汉字" /> */}
<Select
showSearch
placeholder="请填入品牌"
value={brandValue}
defaultActiveFirstOption={false}
showArrow={false}
filterOption={false}
onSearch={handleBrandSearch}
onChange={handleBrandChange}
notFoundContent={null}
style={{width:'100%'}}
>
{brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
</Form.Item>
<Form.Item
name="unit"
name="unitId"
label="单位"
rules={[
{
required: true,
message: '请选择单位'
// required: true,
// message: '请输入单位'
},
]}
>
<Select
placeholder="请选择单位"
allowClear
showSearch
placeholder="请输入单位"
value={unitValue}
defaultActiveFirstOption={false}
showArrow={false}
filterOption={false}
onSearch={handleUnitSearch}
onChange={handleUnitChange}
notFoundContent={null}
style={{width:'100%'}}
>
<Option value="g"></Option>
<Option value="kg">千克</Option>
<Option value="t"></Option>
{unitData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
</Form.Item>
<Form.Item
name="originPrice"
name="constPrice"
// label="成本价"
label={
<span>
成本价&nbsp;
<Tooltip title="这是一段描述?">
<Tooltip title="成本价即该商品销售时不能低于此价,如在商品发布时商品销售价低于成本价,则将触发风控预警。">
<QuestionCircleOutlined />
</Tooltip>
</span>
......@@ -146,7 +246,7 @@ const AddGoods = () => {
<Button type="primary" htmlType="submit">
保存
</Button>
<Button className={styles.ml20}>
<Button className={styles.ml20} onClick={()=>history.goBack()}>
取消
</Button>
</Form.Item>
......
This diff is collapsed.
......@@ -13,6 +13,7 @@ import { ColumnType } from 'antd/lib/table/interface'
import { IButtonFilter, IFormFilter } from 'god/dist/src/standard-table/TableController'
import styles from "./index.less"
import { getProductLists } from '@/services/commodity/products'
import moment from 'moment'
// 定义选择的行数据的类型
interface Item {
......@@ -160,17 +161,31 @@ const Products: React.FC<{}> = () => {
align: 'center',
key: 'unitName',
},
// 产品定价:1-现货价格,2-价格需要询价,3-积分兑换商品
{
title: '产品定价',
dataIndex: 'priceType',
key: 'priceType',
render: (text:any, reocrd:any)=>{
if(text===1)
return '现货价格'
else if(text===2)
return '价格需要询价'
else if(text===3)
return '积分兑换商品'
}
},
{
title: '价格',
dataIndex: 'price',
align: 'center',
key: 'price',
dataIndex: 'min',
key: 'min',
render: (text:any, reocrd:any)=>(<>{reocrd.min} ~ ¥{reocrd.max}</>)
},
{
title: '审核时间',
dataIndex: 'checkTime',
align: 'center',
key: 'checkTime',
dataIndex: 'applyTime',
key: 'applyTime',
render: (text:any, record:any)=>moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '审核状态',
......
declare namespace CommodityGoodsApi {
export interface innerCategory {
id: number;
name: string;
}
export interface innerBrand {
id: number;
name: string;
}
export interface GoodsItem {
id?: number;
code: string;
name: string;
type: string;
getCustomerCategory: innerCategory;
brand: innerBrand;
unitName: string;
costPrice: number;
batch: string;
}
export interface GoodsListsModel {
totalCount: number;
data: GoodsItem[];
}
export interface GoodsListsByQueryDTO {
current: number;
pageSize: number;
name?: string;
code?: string;
brandId?: number;
customerCategoryId?: number;
batch?: string;
}
// 查询
export interface GoodsInfoByQueryDTO {
id: number;
}
export interface GoodsInfoByUpdateDTO {
id?: number;
code: string;
name: string;
type: string;
customerCategoryId: number;
brandId: number;
unitId: number;
costPrice: number;
}
// 批量删除
export interface GoodsByBatchDeleteDTO {
idList: number[]
}
// 品牌 品类下拉筛选
export interface SelectCustomerCategoryModel {
data: innerCategory[];
}
export interface SelectCustomerCategoryByQueryDTO {
name: string;
}
export interface SelectBrandModel {
data: innerBrand[];
}
export interface SelectBrandByQueryDTO {
name: string;
}
// 新增 单位下拉
export interface SelectUniteByQueryDTO {
name: string;
}
export interface SelectUniteModel {
data: innerBrand[];
}
}
\ No newline at end of file
import request from '@/utils/request';
const prefix = '/product'
/**
* @description 查询货品信息
* @param {CommodityGoodsApi.GoodsInfoByQueryDTO} params
*/
export async function getGoodsDetail(params: CommodityGoodsApi.GoodsInfoByQueryDTO) {
return request<CommodityGoodsApi.GoodsItem>('/goods/getGoods', {
prefix,
params
})
}
/**
* @description 查询货品列表
* @param {CommodityGoodsApi.GoodsListsByQueryDTO} parmas
*/
export async function getGoodsLists(params: CommodityGoodsApi.GoodsListsByQueryDTO) {
return request<CommodityGoodsApi.GoodsListsModel>('/goods/getGoodsList', {
prefix,
params
})
}
/**
* @description 新增/修改货品
* @param {CommodityGoodsApi.GoodsInfoByUpdateDTO} params
*/
export async function updateGoods(params: CommodityGoodsApi.GoodsInfoByUpdateDTO) {
return request('/goods/saveOrUpdateGoods', {
prefix,
method: 'post',
data: params
})
}
/**
* @description 批量删除货品
* @param {CommodityGoodsApi.GoodsByBatchDeleteDTO} params
*/
export async function deleteBatchGoods(params: CommodityGoodsApi.GoodsByBatchDeleteDTO) {
return request('/brand/deleteBrand', {
prefix,
params
})
}
/**
* @description 获取下拉框品类数据
* @param {CommodityGoodsApi.SelectCustomerCategoryByQueryDTO} params
*/
export async function getSelectCustomerCategoryList(params: CommodityGoodsApi.SelectCustomerCategoryByQueryDTO) {
return request<CommodityGoodsApi.SelectCustomerCategoryModel>('/select/getSelectCustomerCategory', {
prefix,
params
})
}
/**
* @description 获取下拉框品牌数据
* @param {CommodityGoodsApi.SelectBrandByQueryDTO} params
*/
export async function getSelectBrandList(params: CommodityGoodsApi.SelectBrandByQueryDTO) {
return request<CommodityGoodsApi.SelectBrandModel>('/select/getSelectBrand', {
prefix,
params
})
}
/**
* @description 获取下拉框单位数据
* @param {CommodityGoodsApi.SelectUniteByQueryDTO} params
*/
export async function getSelectUniteList(params: CommodityGoodsApi.SelectUniteByQueryDTO) {
return request<CommodityGoodsApi.SelectUniteModel>('/select/getSelectCNUnit', {
prefix,
params
})
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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