From f8539751a2e8cd3e1eda51e4de08351a743a3dce Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Sat, 9 Mar 2024 09:46:05 +0800 Subject: [PATCH] z --- config/proxy.js | 4 +- config/routes.js | 7 + src/app.jsx | 8 + .../goods/goodsattributeprice/index.jsx | 370 ++++++++++++++++++ .../goods/goodsattributeprice/service.js | 41 ++ .../goods/goodsbom/components/CreateBom.jsx | 16 +- .../components/goodstechnologymaken.jsx | 18 +- src/pages/database/goods/newgoods/index.jsx | 22 +- 8 files changed, 478 insertions(+), 8 deletions(-) create mode 100644 src/pages/database/goods/goodsattributeprice/index.jsx create mode 100644 src/pages/database/goods/goodsattributeprice/service.js diff --git a/config/proxy.js b/config/proxy.js index fc94b84..3a7b741 100644 --- a/config/proxy.js +++ b/config/proxy.js @@ -9,7 +9,7 @@ export default { dev: { '/kitchbase/': { - target: 'http://localhost:5009/', + target: 'http://192.168.1.19:5006/', changeOrigin: true, secure: false, //关闭证书验证 pathRewrite: { @@ -17,7 +17,7 @@ }, }, '/kitchorder/': { - target: 'http://localhost:5007', + target: 'http://192.168.1.19:5007', changeOrigin: true, secure: false, //关闭证书验证 pathRewrite: { diff --git a/config/routes.js b/config/routes.js index 00c10e6..540620f 100644 --- a/config/routes.js +++ b/config/routes.js @@ -172,6 +172,13 @@ export default [ component: './database/goods/goodstechnology', access: 'k7', }, + { + name: '商品属性配置', + icon: 'smile', + path: '/database/goods/goodsattributeprice', + component: './database/goods/goodsattributeprice', + access: 'k7', + }, ] }, ], diff --git a/src/app.jsx b/src/app.jsx index 8cbc297..efc6ad3 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -244,6 +244,14 @@ export async function getInitialState() { component: './database/goods/newgoods', access: 'k10', }, + { + code: 'newgoods', + name: '商品属性配置', + icon: 'smile', + path: '/database/goods/goodsattributeprice', + component: './database/goods/goodsattributeprice', + access: 'k10', + }, ] }, ] diff --git a/src/pages/database/goods/goodsattributeprice/index.jsx b/src/pages/database/goods/goodsattributeprice/index.jsx new file mode 100644 index 0000000..6404e95 --- /dev/null +++ b/src/pages/database/goods/goodsattributeprice/index.jsx @@ -0,0 +1,370 @@ +import { PlusOutlined,ArrowLeftOutlined } from '@ant-design/icons'; +import { Button, message, Input, Form, Popconfirm,Radio,InputNumber,Card,Tag } from 'antd'; +import React, { useState, useRef, useEffect } from 'react'; +import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; +import ProTable from '@ant-design/pro-table'; +import EditableProTable from '@ant-design/pro-table'; + +import { history } from 'umi'; +import ProDescriptions from '@ant-design/pro-descriptions'; +import { + getpage, + add, + update, + del, + getbygoodsidattribute +} from './service'; + + + +const goodsattribute = (props) => { + /** 新建/更新窗口的弹窗 */ + const [createModalVisible, handleModalVisible] = useState(false); + const [editableKeys, setEditableRowKeys] = useState([]); + /** 分布更新窗口的弹窗 */ + const [arttuename,setarttuename]=useState(""); + const [checkvalue, setCheckvalue] = useState([]); + const actionRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [selectedRowsState, setSelectedRows] = useState([]); + const [price, setprice] = useState(0); + const [goodsAttriburteData, setGoodsAttriburteData] = useState([]); + const [dataSource, setDataSource] = useState([]); + /** 国际化修改 */ + useEffect(() => { + + intDicData(); + }, []); + function intDicData() { + getbygoodsidattribute(props.location.query.values.id).then((r)=>{ + if(r.data && r.data.length>0){ + + setGoodsAttriburteData(r.data); + + } + + + }) + } + + /** + * 批量删除 + * + * @param selectedRows + */ + + const handleRemove = async (selectedRows) => { + const hide = message.loading('正在删除'); + if (!selectedRows) return true; + await del(selectedRows.map((row) => row.id)).then((r) => { + if (r.succeeded) { + message.success('删除成功'); + actionRef.current.reload(); + } else { + message.error(r.errors); + } + }); + hide(); + return true; + }; + + const columns = [ + { + title: '主键', + dataIndex: 'id', + hideInSearch: true, + hideInTable: true, + tip: '规则名称是唯一的 key', + render: (dom, entity) => { + return ( + { + setCurrentRow(entity); + setShowDetail(true); + }} + > + {dom} + + ); + }, + }, + { + title: '属性', + dataIndex: 'goodsattributeValue', + valueType: 'textarea', + ellipsis: true, + readonly: true, + }, + { + title: '价格', + dataIndex: 'price', + hideInSearch: true, + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (text, record, _, action) => [ + { + action?.startEditable?.(record.id); + }} + > + 更新 + , + { + await del([record.id]).then((r) => { + if (r.succeeded) { + message.success('删除成功'); + actionRef.current.reload(); + } else { + message.error(r.errors); + } + }); + }} + onCancel={() => {}} + > + 删除 + , + ], + }, + ]; +const onChangevalue =(data)=>{ + const { name, value } = data.target; + let names=""; + let updatedValues = [...checkvalue]; + for (let index = 0; index { + for (let index = 0; index < updatedValues.length; index++) { + var bs=item.goodsAttributeValueList.find(x=>x.goodsAttributeValuId==updatedValues[index])?.attributeValue + if(bs){ + names=names+bs; + if(index< updatedValues.length-1){ + names=names+"-" + } + } + } + item.goodsAttributeValueList.forEach(x=>{ + if(value==x.goodsAttributeValuId){ + x.check=true; + item.defalutvalue=value + } + }) + }) + setarttuename(names) + setCheckvalue(updatedValues) +} +const onpriceChange=(value)=>{ + setprice(value) +} +const onsubmit=()=>{ + var check=true; + if(checkvalue.length==0){ + check=false; + message.error("请选择属性"); + } + else if(price<=0){ + check=false; + message.error("价格不能小于0"); + } + if(check){ + var parm={goodsId:props.location.query.values.id,goodsattributeValueId:checkvalue.join(','),Price:price,goodsattributeValue:arttuename} + add(parm).then((r)=>{ + if (r.succeeded) { + message.success('保存成功'); + actionRef.current.reload(); + setCheckvalue([]); + setarttuename(""); + setprice(0) + var gg=goodsAttriburteData.map(x => { + x.goodsAttributeValueList.forEach(t=>{ + t.check=false; + x.defalutvalue="" + }) + return x + }) + setGoodsAttriburteData(gg) + } else { + message.error(r.errors); + } + }) + } + +} +const onresetsubmit=()=>{ + setCheckvalue([]); + setarttuename(""); + setprice(0) + var gg=goodsAttriburteData.map(x => { + x.goodsAttributeValueList.forEach(t=>{ + t.check=false; + x.defalutvalue="" + }) + return x + }) + setGoodsAttriburteData(gg) +} + return ( + <> + { + history.push({ + pathname: '/database/goods/newgoods', + }); + }}>返回], + breadcrumb: {}, + }}> + + *商品属性 + { + goodsAttriburteData==undefined || goodsAttriburteData.length ==0 ? (
当前商品分类还未配置属性点击跳转 { + history.push({ + pathname: '/database/goods/goodstypemanage', + + }); + // handleModalVisible(true); + // setCurrentRow(record); + }} + > + 添加属性 +
) :( + goodsAttriburteData.map((item, index) => { + return ( +
+
+ {item.attributeName} + + + { + item.goodsAttributeValueList.map((item, index)=>{ + return ( + {item.attributeValue} + ) + }) + } + + +
+
+ ); + }) + ) + } +
+ *价格: +
+ +
+ + + +
+ + +
+ { + var data = []; + params.goodsId=props.location.query.values.id + var total = 0; + await getpage(params).then((r) => { + data = r.data.data; + total = r.data.total; + }); + return { + data: data, + success: true, + total: total, + }; + }} + columns={columns} + onChange={setDataSource} + editable={{ + type: 'multiple', + editableKeys, + actionRender: (row, config, dom) => [dom.save, dom.cancel], + onSave: async (rowKey, data, row) => { + console.log(rowKey, data, row); + update(data).then((res)=>{ + if (res.succeeded) { + message.success('保存成功'); + actionRef.current.reload(); + } else { + message.error(r.errors); + } + }) + //onsubmit() + }, + + onChange: setEditableRowKeys, + }} + rowSelection={{ + onChange: (_, selectedRows) => { + setSelectedRows(selectedRows); + }, + }} + /> + {selectedRowsState?.length > 0 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + {/* + 服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.id, 0)} 万 + */} + + } + > + + {/* */} + + )} +
+ + ); +}; + +export default goodsattribute; diff --git a/src/pages/database/goods/goodsattributeprice/service.js b/src/pages/database/goods/goodsattributeprice/service.js new file mode 100644 index 0000000..e1a3b81 --- /dev/null +++ b/src/pages/database/goods/goodsattributeprice/service.js @@ -0,0 +1,41 @@ +import { request } from 'umi'; +import { getDataBaseUrl } from '@/global_data'; +/** 获取商品属性列表 sdsa GET /kitchen/api/rule */ +export async function getpage(data) { + return request(getDataBaseUrl()+`/api/goodsattributeprice/getpage`, { + method: 'POST', + data: data, + // params: { ...params }, + // ...(options || {}), + }); +} +export async function add(data) { + return request(getDataBaseUrl()+`/api/goodsattributeprice/add`, { + method: 'POST', + data: data, + // params: { ...params }, + // ...(options || {}), + }); +} +export async function update(data) { + return request(getDataBaseUrl()+`/api/goodsattributeprice/update`, { + method: 'POST', + data: data, + // params: { ...params }, + // ...(options || {}), + }); +} +export async function del(data) { + return request(getDataBaseUrl()+`/api/goodsattributeprice/delete?id=`+data, { + method: 'GET', + // params: { ...params }, + // ...(options || {}), + }); +} +export async function getbygoodsidattribute (data) { + return request(getDataBaseUrl()+`/api/goodsattribute/getbygoodsidattribute?id=`+data, { + method: 'Get', + // params: { ...params }, + // ...(options || {}), + }); +} \ No newline at end of file diff --git a/src/pages/database/goods/goodsbom/components/CreateBom.jsx b/src/pages/database/goods/goodsbom/components/CreateBom.jsx index 73442f9..07b8048 100644 --- a/src/pages/database/goods/goodsbom/components/CreateBom.jsx +++ b/src/pages/database/goods/goodsbom/components/CreateBom.jsx @@ -2,6 +2,7 @@ import React, { useState,useRef,useEffect } from 'react'; import { PlusOutlined,CheckOutlined} from '@ant-design/icons'; import { Modal, Form, Input, Button, Select,Radio,message,Tag,Divider,Space } from 'antd'; import { AddBomType,getbyidbomlist } from '../service'; +import { history } from 'umi'; import { EditableProTable, ProTable @@ -243,7 +244,20 @@ const GoodsbomFrom = (props) => { > *商品属性 { - props.goodsAttriburteData == undefined ? '' :( + props.goodsAttriburteData == undefined || props.goodsAttriburteData.length==0 ? (
当前商品分类还未配置属性点击跳转 { + history.push({ + pathname: '/database/goods/goodstypemanage', + + }); + // handleModalVisible(true); + // setCurrentRow(record); + }} + > + 添加属性 +
) :( props.goodsAttriburteData.map((item, index) => { return (
diff --git a/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx b/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx index 331b79b..9210ea0 100644 --- a/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx +++ b/src/pages/database/goods/goodstechnology/components/goodstechnologymaken.jsx @@ -3,6 +3,7 @@ import React, { useState, useRef, useEffect } from 'react'; import { CloseOutlined, DeleteOutlined, FormOutlined } from '@ant-design/icons'; import { ProCard } from '@ant-design/pro-Card'; import { BetaSchemaForm } from '@ant-design/pro-form'; +import { history } from 'umi'; import { getbyidgoods, GetGoodsTechnology, @@ -473,10 +474,23 @@ const goodstechnologymaken = (props) => { - +
商品属性
{ - goodsinfo.goodsAttributeList == undefined ? '' : ( + goodsinfo.goodsAttributeList == undefined || goodsinfo.goodsAttributeList == "" ? (
当前商品分类还未配置属性点击跳转 { + history.push({ + pathname: '/database/goods/goodstypemanage', + + }); + // handleModalVisible(true); + // setCurrentRow(record); + }} + > + 添加属性 +
) : ( goodsinfo.goodsAttributeList.map((item, index) => { return (
diff --git a/src/pages/database/goods/newgoods/index.jsx b/src/pages/database/goods/newgoods/index.jsx index a3b2368..3430b14 100644 --- a/src/pages/database/goods/newgoods/index.jsx +++ b/src/pages/database/goods/newgoods/index.jsx @@ -164,7 +164,7 @@ const GoodsManage = () => { // setCurrentRow(record); }} > - 商品配方设置 + 配方配置 , { // setCurrentRow(record); }} > - 商品工艺设置 + 工艺配置 , - + { + history.push({ + pathname: '/database/goods/goodsattributeprice', + query: { + isAdd: false, + values: record, + }, + }); + // handleModalVisible(true); + // setCurrentRow(record); + }} + > + 价格配置 + ,