地址修改
This commit is contained in:
@ -208,7 +208,7 @@ public class OrderController {
|
||||
modelAndView.addObject("orderId", orderId);
|
||||
modelAndView.addObject("type", type);
|
||||
modelAndView.addObject("order", order);
|
||||
modelAndView.addObject("logistics", order.getLogistics());
|
||||
modelAndView.addObject("logistics", order.getLogistics() == null ? "[]" : order.getLogistics());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ public class OrderController {
|
||||
modelAndView.addObject("orderId", orderId);
|
||||
modelAndView.addObject("type", type);
|
||||
modelAndView.addObject("order", order);
|
||||
modelAndView.addObject("logistics", order.getLogistics());
|
||||
modelAndView.addObject("logistics", order.getLogistics() == null ? "[]" : order.getLogistics());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
@ -7,4 +7,6 @@ public class GoodsDeDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private Integer num;
|
||||
private Long specId;
|
||||
private String spec;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#开发环境
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.0.142:3306/wisdo?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://192.168.0.145:3306/wisdo?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
# url: jdbc:mysql://146.56.198.32:3306/wisdo?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
username: yshop
|
||||
# username: root
|
||||
|
@ -20,29 +20,35 @@
|
||||
<script>
|
||||
let layer = null
|
||||
layui.use(['layer'], function () {
|
||||
layer = layui.layer
|
||||
layer = layui.layer;
|
||||
});
|
||||
<%--if("${logistics}"){--%>
|
||||
// }
|
||||
</script>
|
||||
</head>
|
||||
<body style="background-color: white">
|
||||
<div id="root"></div>
|
||||
<script type="text/babel">
|
||||
// let __logistics = []
|
||||
const __logistics = ${logistics};
|
||||
const orderId = ${orderId};
|
||||
const orderAddress = "${order.orderAddress}";
|
||||
const __orderAddress = "${order.orderAddress}";
|
||||
const __logisticsName = "${order.logisticsName}";
|
||||
const type = ${type};
|
||||
const {useState} = React
|
||||
const App = () => {
|
||||
const [logisticsName, setLogisticsName] = useState(__logisticsName)
|
||||
const [orderAddress, setOrderAddress] = useState(__orderAddress)
|
||||
const [logistics, setLogistics] = useState(__logistics)
|
||||
return <div className="p-4">
|
||||
<form>
|
||||
<div className="layui-form-item">
|
||||
<label htmlFor="orderAddress" className="layui-form-label w-24">收货地址</label>
|
||||
<div className="layui-input-block">
|
||||
<input type="text" id="orderAddress" name="orderAddress" readOnly value={orderAddress}
|
||||
|
||||
<input type="text" id="orderAddress" name="orderAddress" value={orderAddress}
|
||||
onInput={ev => {
|
||||
setOrderAddress(ev.target.value)
|
||||
}}
|
||||
placeholder="请输入收货地址" autoComplete="off" className="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
@ -78,13 +84,15 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>规格</th>
|
||||
<th>数量</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
pack.goods.map((goods, idx) => <tr key={goods.id}>
|
||||
pack.goods.map((goods, idx) => <tr key={goods.id + "" + goods.specId}>
|
||||
<td>{goods.name}</td>
|
||||
<td>{goods.spec}</td>
|
||||
<td>{goods.num}</td>
|
||||
</tr>
|
||||
)
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body style="background-color: white">
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/babel">
|
||||
const {useState} = React
|
||||
@ -52,6 +52,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>规格</th>
|
||||
<th>数量</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@ -60,24 +61,27 @@
|
||||
{
|
||||
goodsList.filter(el => el.goodsNum > 0).map(goods => <tr key={goods.id}>
|
||||
<td>{goods.goodsName}</td>
|
||||
<td>{goods?.wisdGoodsSpec?.specName ?? ""}</td>
|
||||
<td>{goods.goodsNum}</td>
|
||||
<td>
|
||||
<button className="layui-btn layui-btn-xs" onClick={() => {
|
||||
// TODO: STEP1: 将商品添加到 packages 中
|
||||
const _packages = [...packages]
|
||||
const goodsInPackageIndex = _packages[activePackage].goods.findIndex(el => el.id === goods.id)
|
||||
const goodsInPackageIndex = _packages[activePackage].goods.findIndex(el => el.id === goods.id && goods.wisdGoodsSpec.id === el.specId)
|
||||
if (goodsInPackageIndex !== -1) {
|
||||
_packages[activePackage].goods[goodsInPackageIndex].num += 1
|
||||
} else {
|
||||
_packages[activePackage].goods.push({
|
||||
id: goods.id,
|
||||
specId: goods.wisdGoodsSpec.id,
|
||||
name: goods.goodsName,
|
||||
spec: goods?.wisdGoodsSpec?.specName ?? "",
|
||||
num: 1
|
||||
})
|
||||
}
|
||||
setPackages(_packages)
|
||||
const _goodsList = [...goodsList]
|
||||
_goodsList.find(el => el.id === goods.id).goodsNum -= 1
|
||||
_goodsList.find(el => el.id === goods.id && el.wisdGoodsSpec.id === goods.wisdGoodsSpec.id).goodsNum -= 1
|
||||
|
||||
setGoodsList(_goodsList)
|
||||
}}>
|
||||
@ -120,13 +124,13 @@
|
||||
// TODO: WHY
|
||||
setTimeout(() => {
|
||||
setActivePackage(state => state - 1)
|
||||
}, 0)
|
||||
}, 100)
|
||||
}
|
||||
setPackages(state => state.filter(el => pack.id !== el.id))
|
||||
// TODO: 删除该包裹中所有商品
|
||||
const _goodsList = [...goodsList]
|
||||
for (const p of pack.goods) {
|
||||
_goodsList.find(g => g.id === p.id).goodsNum += p.num
|
||||
_goodsList.find(g => g.id === p.id && g.wisdGoodsSpec.id === p.specId).goodsNum += p.num
|
||||
}
|
||||
setGoodsList(_goodsList)
|
||||
|
||||
@ -154,6 +158,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>规格</th>
|
||||
<th>数量</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@ -162,6 +167,7 @@
|
||||
{
|
||||
pack.goods.map((goods, idx) => <tr key={goods.id}>
|
||||
<td>{goods.name}</td>
|
||||
<td>{goods.spec}</td>
|
||||
<td>{goods.num}</td>
|
||||
<td>
|
||||
<button className="layui-btn layui-btn-xs" type="button"
|
||||
@ -175,7 +181,7 @@
|
||||
})))
|
||||
// TODO: goodsList 中数量 +1
|
||||
const _goodsList = [...goodsList]
|
||||
_goodsList.find(el => el.id === _packages[index].goods[idx].id).goodsNum += 1
|
||||
_goodsList.find(el => el.id === _packages[index].goods[idx].id && el.wisdGoodsSpec.id === _packages[index].goods[idx].specId).goodsNum += 1
|
||||
setGoodsList(_goodsList)
|
||||
}}>移除
|
||||
</button>
|
||||
|
@ -30,7 +30,7 @@
|
||||
const __logistics = ${logistics};
|
||||
const type = ${type};
|
||||
const orderId = ${orderId};
|
||||
const orderAddress = ${order.pendingApprovalOrderAddress};
|
||||
const orderAddress = "${order.pendingApprovalOrderAddress}";
|
||||
const {useState} = React
|
||||
const App = () => {
|
||||
const [logistics, setLogistics] = useState(__logistics)
|
||||
@ -65,13 +65,15 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>规格</th>
|
||||
<th>数量</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
pack.goods.map((goods) => <tr key={goods.id}>
|
||||
pack.goods.map((goods) => <tr key={goods.id + "" + goods.specId}>
|
||||
<td>{goods.name}</td>
|
||||
<td>{goods.spec}</td>
|
||||
<td>{goods.num}</td>
|
||||
</tr>
|
||||
)
|
||||
@ -81,7 +83,7 @@
|
||||
</div>
|
||||
</div>)}
|
||||
<div className="flex justify-center">
|
||||
<button type="button" onClick={() => {
|
||||
<button type="button" className="layui-btn layui-btn-primary mt-2" onClick={() => {
|
||||
const formData = {
|
||||
orderId,
|
||||
type: 1,
|
||||
|
Reference in New Issue
Block a user