From a834ccd8dfef154b3164b83104a6cbd4837f81b3 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 23 Jun 2026 09:43:07 +0800
Subject: [PATCH] feat(system): 添加国家运费配置功能
---
src/main/java/cc/mrbird/febs/mall/service/IMallCountryDeliveryService.java | 24 +++
src/main/java/cc/mrbird/febs/mall/entity/MallCountryDelivery.java | 33 ++++
src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java | 21 ++
src/main/java/cc/mrbird/febs/mall/controller/dependentStation/ApiMallOrderController.java | 11 +
src/main/java/cc/mrbird/febs/mall/controller/ViewSystemController.java | 6
src/main/resources/templates/febs/views/modules/system/countryDeliveryList.html | 176 ++++++++++++++++++++++
src/main/java/cc/mrbird/febs/mall/dto/CountryDeliveryDto.java | 36 ++++
src/main/java/cc/mrbird/febs/mall/mapper/MallCountryDeliveryMapper.java | 12 +
sql/mall_country_delivery.sql | 40 +++++
src/main/java/cc/mrbird/febs/mall/service/impl/MallCountryDeliveryServiceImpl.java | 92 +++++++++++
src/main/resources/mapper/modules/MallCountryDeliveryMapper.xml | 19 ++
11 files changed, 470 insertions(+), 0 deletions(-)
diff --git a/sql/mall_country_delivery.sql b/sql/mall_country_delivery.sql
new file mode 100644
index 0000000..5a66763
--- /dev/null
+++ b/sql/mall_country_delivery.sql
@@ -0,0 +1,40 @@
+-- ============================================================
+-- 国家运费配置表
+-- ============================================================
+DROP TABLE IF EXISTS mall_country_delivery;
+CREATE TABLE mall_country_delivery (
+ ID BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键',
+ REVISION INT DEFAULT 1 COMMENT '乐观锁',
+ CREATED_BY VARCHAR(32) DEFAULT 'system' COMMENT '创建人',
+ CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ UPDATED_BY VARCHAR(32) DEFAULT 'system' COMMENT '更新人',
+ UPDATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ COUNTRY_CODE VARCHAR(10) NOT NULL COMMENT '国家编码(ISO 3166-1,如 CN/US/JP)',
+ COUNTRY_NAME VARCHAR(64) NOT NULL COMMENT '国家名称(中文)',
+ SHIPPING_FEE DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '运费(元)',
+ STATUS INT DEFAULT 1 COMMENT '状态:1-启用,0-禁用',
+ REMARK VARCHAR(255) COMMENT '备注',
+ PRIMARY KEY (ID),
+ UNIQUE KEY uk_country_code (COUNTRY_CODE)
+) COMMENT = '国家运费配置表';
+
+-- ----------------------------
+-- 默认数据
+-- ----------------------------
+INSERT INTO mall_country_delivery (COUNTRY_CODE, COUNTRY_NAME, SHIPPING_FEE, STATUS, REMARK) VALUES
+('CN', '中国', 0.00, 1, '国内免运费'),
+('US', '美国', 59.00, 1, NULL),
+('JP', '日本', 35.00, 1, NULL),
+('KR', '韩国', 30.00, 1, NULL),
+('GB', '英国', 50.00, 1, NULL),
+('DE', '德国', 50.00, 1, NULL),
+('FR', '法国', 50.00, 1, NULL),
+('AU', '澳大利亚', 55.00, 1, NULL),
+('CA', '加拿大', 55.00, 1, NULL),
+('SG', '新加坡', 28.00, 1, NULL);
+
+-- ============================================================
+-- 菜单注册 SQL(通过后台菜单管理页面操作,或直接执行)
+-- ============================================================
+-- INSERT INTO t_menu (MENU_NAME, URL, PERMS, ICON, TYPE, PARENT_ID, ORDER_NUM, CREATED_TIME)
+-- VALUES ('国家运费设置', 'modules/system/countryDeliveryList', 'countryDelivery:view', 'layui-icon-template-1', 0, {系统设置菜单ID}, 13, NOW());
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
index 6e9323a..e3cbbf9 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
@@ -8,6 +8,7 @@
import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.mall.service.ICommonService;
+import cc.mrbird.febs.mall.service.IMallCountryDeliveryService;
import cc.mrbird.febs.mall.service.ISystemService;
import cc.mrbird.febs.pay.model.HeaderDto;
import cc.mrbird.febs.pay.service.WxFaPiaoService;
@@ -23,6 +24,8 @@
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -50,6 +53,7 @@
private final ICommonService commonService;
private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
private final WxFaPiaoService wxFaPiaoService;
+ private final IMallCountryDeliveryService countryDeliveryService;
@PostMapping(value = "/bonusSystemSetting")
public FebsResponse bonusSystemSetting(@RequestBody Map<String, Object> map) {
@@ -125,6 +129,23 @@
return new FebsResponse().success().message("保存成功");
}
+ @GetMapping(value = "/countryDeliveryList")
+ public FebsResponse countryDeliveryList() {
+ return countryDeliveryService.list();
+ }
+
+ @PostMapping(value = "/countryDeliverySave")
+ @ControllerEndpoint(operation = "保存国家运费配置")
+ public FebsResponse countryDeliverySave(@Validated CountryDeliveryDto dto) {
+ return countryDeliveryService.saveOrUpdate(dto);
+ }
+
+ @GetMapping(value = "/countryDeliveryDelete/{id}")
+ @ControllerEndpoint(operation = "删除国家运费配置")
+ public FebsResponse countryDeliveryDelete(@PathVariable Long id) {
+ return countryDeliveryService.delete(id);
+ }
+
@PostMapping(value = "/agentAmountSetSetting")
public FebsResponse agentAmountSetSetting(AdminAgentAmountDto adminAgentAmountDto) {
DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/ViewSystemController.java b/src/main/java/cc/mrbird/febs/mall/controller/ViewSystemController.java
index 38e29b6..15838e8 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/ViewSystemController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/ViewSystemController.java
@@ -176,4 +176,10 @@
model.addAttribute("salesService", dto);
return FebsUtil.view("modules/system/salesService");
}
+
+ @GetMapping("countryDeliveryList")
+ @RequiresPermissions("countryDelivery:view")
+ public String countryDeliveryList() {
+ return FebsUtil.view("modules/system/countryDeliveryList");
+ }
}
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/dependentStation/ApiMallOrderController.java b/src/main/java/cc/mrbird/febs/mall/controller/dependentStation/ApiMallOrderController.java
index 6eb09d3..ed595da 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/dependentStation/ApiMallOrderController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/dependentStation/ApiMallOrderController.java
@@ -6,6 +6,7 @@
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.MallOrderInfo;
import cc.mrbird.febs.mall.service.IApiMallOrderInfoService;
+import cc.mrbird.febs.mall.service.IMallCountryDeliveryService;
import cc.mrbird.febs.mall.vo.ApiOrderPayVo;
import cc.mrbird.febs.mall.vo.OrderDetailVo;
import cc.mrbird.febs.mall.vo.OrderListVo;
@@ -40,6 +41,7 @@
private final IApiMallOrderInfoService mallOrderInfoService;
private final IXcxPayService iXcxPayService;
private final LwPayService lwPayService;
+ private final IMallCountryDeliveryService countryDeliveryService;
@ApiOperation(value = "创建订单--验证是否允许创建", notes = "创建订单--验证是否允许创建")
@PostMapping(value = "/createOrderVerify")
@@ -254,4 +256,13 @@
return "redirect:/pages/payResult?orderNo=" + orderId + "&code=" + returncode;
}
+ @ApiOperation(value = "根据国家编码查询运费", notes = "根据国家编码查询对应运费")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "success")
+ })
+ @GetMapping(value = "/getShippingFee")
+ public FebsResponse getShippingFee(@RequestParam String countryCode) {
+ return countryDeliveryService.getShippingFeeByCountryCode(countryCode);
+ }
+
}
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/CountryDeliveryDto.java b/src/main/java/cc/mrbird/febs/mall/dto/CountryDeliveryDto.java
new file mode 100644
index 0000000..8210f8a
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/dto/CountryDeliveryDto.java
@@ -0,0 +1,36 @@
+package cc.mrbird.febs.mall.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * 国家运费配置 DTO
+ *
+ * @author auto-generated
+ */
+@Data
+public class CountryDeliveryDto {
+
+ private Long id;
+
+ /** 国家编码 */
+ @NotBlank(message = "国家编码不能为空")
+ private String countryCode;
+
+ /** 国家名称 */
+ @NotBlank(message = "国家名称不能为空")
+ private String countryName;
+
+ /** 运费 */
+ @NotNull(message = "运费不能为空")
+ private BigDecimal shippingFee;
+
+ /** 状态 */
+ private Integer status;
+
+ /** 备注 */
+ private String remark;
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallCountryDelivery.java b/src/main/java/cc/mrbird/febs/mall/entity/MallCountryDelivery.java
new file mode 100644
index 0000000..71238fa
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/entity/MallCountryDelivery.java
@@ -0,0 +1,33 @@
+package cc.mrbird.febs.mall.entity;
+
+import cc.mrbird.febs.common.entity.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 国家运费配置表
+ *
+ * @author auto-generated
+ * @date 2026-06-22
+ */
+@Data
+@TableName("mall_country_delivery")
+public class MallCountryDelivery extends BaseEntity {
+
+ /** 国家编码(如 CN, US, JP) */
+ private String countryCode;
+
+ /** 国家名称(中文) */
+ private String countryName;
+
+ /** 运费(元) */
+ private BigDecimal shippingFee;
+
+ /** 状态:1-启用,0-禁用 */
+ private Integer status;
+
+ /** 备注 */
+ private String remark;
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/MallCountryDeliveryMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/MallCountryDeliveryMapper.java
new file mode 100644
index 0000000..bbd96e7
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/mapper/MallCountryDeliveryMapper.java
@@ -0,0 +1,12 @@
+package cc.mrbird.febs.mall.mapper;
+
+import cc.mrbird.febs.mall.entity.MallCountryDelivery;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 国家运费配置 Mapper
+ *
+ * @author auto-generated
+ */
+public interface MallCountryDeliveryMapper extends BaseMapper<MallCountryDelivery> {
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/service/IMallCountryDeliveryService.java b/src/main/java/cc/mrbird/febs/mall/service/IMallCountryDeliveryService.java
new file mode 100644
index 0000000..59ba084
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/service/IMallCountryDeliveryService.java
@@ -0,0 +1,24 @@
+package cc.mrbird.febs.mall.service;
+
+import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.mall.dto.CountryDeliveryDto;
+
+/**
+ * 国家运费配置 Service 接口
+ *
+ * @author auto-generated
+ */
+public interface IMallCountryDeliveryService {
+
+ /** 列表查询 */
+ FebsResponse list();
+
+ /** 新增/更新 */
+ FebsResponse saveOrUpdate(CountryDeliveryDto dto);
+
+ /** 删除 */
+ FebsResponse delete(Long id);
+
+ /** 根据国家编码查询运费 */
+ FebsResponse getShippingFeeByCountryCode(String countryCode);
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MallCountryDeliveryServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MallCountryDeliveryServiceImpl.java
new file mode 100644
index 0000000..0ee3bd1
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MallCountryDeliveryServiceImpl.java
@@ -0,0 +1,92 @@
+package cc.mrbird.febs.mall.service.impl;
+
+import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.mall.dto.CountryDeliveryDto;
+import cc.mrbird.febs.mall.entity.MallCountryDelivery;
+import cc.mrbird.febs.mall.mapper.MallCountryDeliveryMapper;
+import cc.mrbird.febs.mall.service.IMallCountryDeliveryService;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 国家运费配置 Service 实现
+ *
+ * @author auto-generated
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class MallCountryDeliveryServiceImpl implements IMallCountryDeliveryService {
+
+ private final MallCountryDeliveryMapper mallCountryDeliveryMapper;
+
+ @Override
+ public FebsResponse list() {
+ List<MallCountryDelivery> list = mallCountryDeliveryMapper.selectList(
+ Wrappers.lambdaQuery(MallCountryDelivery.class)
+ .orderByAsc(MallCountryDelivery::getCountryCode)
+ );
+ return new FebsResponse().success().data(list);
+ }
+
+ @Override
+ public FebsResponse saveOrUpdate(CountryDeliveryDto dto) {
+ MallCountryDelivery entity = new MallCountryDelivery();
+ entity.setCountryCode(dto.getCountryCode().toUpperCase());
+ entity.setCountryName(dto.getCountryName());
+ entity.setShippingFee(dto.getShippingFee());
+ entity.setStatus(dto.getStatus() != null ? dto.getStatus() : 1);
+ entity.setRemark(dto.getRemark());
+
+ if (dto.getId() != null) {
+ // 更新
+ entity.setId(dto.getId());
+ mallCountryDeliveryMapper.updateById(entity);
+ log.info("更新国家运费配置: countryCode={}, fee={}", entity.getCountryCode(), entity.getShippingFee());
+ } else {
+ // 新增前检查编码是否重复
+ MallCountryDelivery exist = mallCountryDeliveryMapper.selectOne(
+ Wrappers.lambdaQuery(MallCountryDelivery.class)
+ .eq(MallCountryDelivery::getCountryCode, entity.getCountryCode())
+ );
+ if (exist != null) {
+ return new FebsResponse().fail().message("国家编码 " + entity.getCountryCode() + " 已存在");
+ }
+ mallCountryDeliveryMapper.insert(entity);
+ log.info("新增国家运费配置: countryCode={}, fee={}", entity.getCountryCode(), entity.getShippingFee());
+ }
+ return new FebsResponse().success().message("保存成功");
+ }
+
+ @Override
+ public FebsResponse delete(Long id) {
+ mallCountryDeliveryMapper.deleteById(id);
+ return new FebsResponse().success().message("删除成功");
+ }
+
+ @Override
+ public FebsResponse getShippingFeeByCountryCode(String countryCode) {
+ if (StrUtil.isBlank(countryCode)) {
+ return new FebsResponse().fail().message("国家编码不能为空");
+ }
+
+ MallCountryDelivery delivery = mallCountryDeliveryMapper.selectOne(
+ Wrappers.lambdaQuery(MallCountryDelivery.class)
+ .eq(MallCountryDelivery::getCountryCode, countryCode.toUpperCase())
+ .eq(MallCountryDelivery::getStatus, 1)
+ );
+
+ if (delivery == null) {
+ // 没有配置则返回默认运费 0(可根据业务调整)
+ return new FebsResponse().success().data(BigDecimal.ZERO);
+ }
+
+ return new FebsResponse().success().data(delivery.getShippingFee());
+ }
+}
diff --git a/src/main/resources/mapper/modules/MallCountryDeliveryMapper.xml b/src/main/resources/mapper/modules/MallCountryDeliveryMapper.xml
new file mode 100644
index 0000000..516ff3a
--- /dev/null
+++ b/src/main/resources/mapper/modules/MallCountryDeliveryMapper.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cc.mrbird.febs.mall.mapper.MallCountryDeliveryMapper">
+
+ <resultMap id="BaseResultMap" type="cc.mrbird.febs.mall.entity.MallCountryDelivery">
+ <id column="ID" jdbcType="BIGINT" property="id"/>
+ <result column="REVISION" jdbcType="INTEGER" property="revision"/>
+ <result column="CREATED_BY" jdbcType="VARCHAR" property="createdBy"/>
+ <result column="CREATED_TIME" jdbcType="TIMESTAMP" property="createdTime"/>
+ <result column="UPDATED_BY" jdbcType="VARCHAR" property="updatedBy"/>
+ <result column="UPDATED_TIME" jdbcType="TIMESTAMP" property="updatedTime"/>
+ <result column="COUNTRY_CODE" jdbcType="VARCHAR" property="countryCode"/>
+ <result column="COUNTRY_NAME" jdbcType="VARCHAR" property="countryName"/>
+ <result column="SHIPPING_FEE" jdbcType="DECIMAL" property="shippingFee"/>
+ <result column="STATUS" jdbcType="INTEGER" property="status"/>
+ <result column="REMARK" jdbcType="VARCHAR" property="remark"/>
+ </resultMap>
+
+</mapper>
diff --git a/src/main/resources/templates/febs/views/modules/system/countryDeliveryList.html b/src/main/resources/templates/febs/views/modules/system/countryDeliveryList.html
new file mode 100644
index 0000000..1464fee
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/system/countryDeliveryList.html
@@ -0,0 +1,176 @@
+<div class="layui-fluid layui-anim febs-anim" id="country-delivery-list" lay-title="国家运费设置">
+ <div class="layui-row febs-container">
+ <div class="layui-col-md12">
+ <div class="layui-card">
+ <div class="layui-card-body febs-table-full">
+ <form class="layui-form layui-table-form" lay-filter="country-delivery-table-form">
+ <div class="layui-row">
+ <div class="layui-col-md10">
+ <div class="layui-form-item">
+ <button class="layui-btn layui-btn-normal" type="button" id="add-btn">
+ <i class="layui-icon"></i> 新增
+ </button>
+ </div>
+ </div>
+ <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
+ <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
+ <i class="layui-icon"></i>
+ </div>
+ </div>
+ </div>
+ </form>
+ <table lay-filter="countryDeliveryTable" lay-data="{id: 'countryDeliveryTable'}"></table>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+<!-- 表格操作栏 -->
+<script type="text/html" id="country-delivery-option">
+ <a lay-event="edit"><i class="layui-icon febs-edit-area febs-blue"></i></a>
+ <a lay-event="del"><i class="layui-icon febs-edit-area febs-red"></i></a>
+</script>
+<style>
+ .layui-form-label { width: 120px; }
+ .layui-form-item .layui-input-block { margin-left: 150px; }
+</style>
+<script data-th-inline="none" type="text/javascript">
+ layui.use(['jquery', 'form', 'table', 'febs'], function () {
+ var $ = layui.jquery,
+ febs = layui.febs,
+ form = layui.form,
+ table = layui.table,
+ layer = layui.layer,
+ $view = $('#country-delivery-list'),
+ $reset = $view.find('#reset'),
+ $addBtn = $view.find('#add-btn'),
+ tableIns;
+
+ form.render();
+ initTable();
+
+ // 表格操作
+ table.on('tool(countryDeliveryTable)', function (obj) {
+ var data = obj.data,
+ layEvent = obj.event;
+ if (layEvent === 'edit') {
+ openEditModal(data);
+ } else if (layEvent === 'del') {
+ layer.confirm('确定删除该国家的运费配置吗?', function (index) {
+ febs.get(ctx + 'admin/system/countryDeliveryDelete/' + data.id, {}, function () {
+ layer.close(index);
+ febs.alert.success('删除成功');
+ tableIns.reload();
+ });
+ });
+ }
+ });
+
+ // 新增按钮
+ $addBtn.on('click', function () {
+ openEditModal(null);
+ });
+
+ // 刷新按钮
+ $reset.on('click', function () {
+ tableIns.reload();
+ });
+
+ // 初始化表格
+ function initTable() {
+ tableIns = febs.table.init({
+ elem: $view.find('table'),
+ id: 'countryDeliveryTable',
+ url: ctx + 'admin/system/countryDeliveryList',
+ cols: [[
+ {field: 'countryCode', title: '国家编码', width: 120, align: 'center'},
+ {field: 'countryName', title: '国家名称', width: 150, align: 'center'},
+ {field: 'shippingFee', title: '运费(元)', width: 120, align: 'center'},
+ {field: 'status', title: '状态', width: 80, align: 'center',
+ templet: function (d) {
+ return d.status === 1 ? '<span class="layui-badge layui-bg-green">启用</span>'
+ : '<span class="layui-badge">禁用</span>';
+ }
+ },
+ {field: 'remark', title: '备注', minWidth: 150, align: 'left'},
+ {title: '操作', templet: '#country-delivery-option', width: 120, align: 'center'}
+ ]]
+ });
+ }
+
+ // 打开编辑弹窗
+ function openEditModal(data) {
+ var title = data ? '编辑国家运费' : '新增国家运费';
+ var html = '<div style="padding:20px 25px 0 0;">' +
+ '<form class="layui-form" lay-filter="country-delivery-form">' +
+ (data ? '<div class="layui-form-item febs-hide"><label class="layui-form-label">ID</label><div class="layui-input-block"><input type="text" name="id" value="' + data.id + '"></div></div>' : '') +
+ ' <div class="layui-form-item">' +
+ ' <label class="layui-form-label febs-form-item-require">国家编码</label>' +
+ ' <div class="layui-input-block">' +
+ ' <input type="text" name="countryCode" class="layui-input" ' + (data ? 'value="' + data.countryCode + '"' : 'placeholder="如 CN, US, JP"') + ' lay-verify="required">' +
+ ' <div class="layui-form-mid layui-word-aux">ISO国家编码,如CN/US/JP</div>' +
+ ' </div>' +
+ ' </div>' +
+ ' <div class="layui-form-item">' +
+ ' <label class="layui-form-label febs-form-item-require">国家名称</label>' +
+ ' <div class="layui-input-block">' +
+ ' <input type="text" name="countryName" class="layui-input" ' + (data ? 'value="' + (data.countryName || '') + '"' : 'placeholder="中文名称"') + ' lay-verify="required">' +
+ ' </div>' +
+ ' </div>' +
+ ' <div class="layui-form-item">' +
+ ' <label class="layui-form-label febs-form-item-require">运费(元)</label>' +
+ ' <div class="layui-input-block">' +
+ ' <input type="number" name="shippingFee" class="layui-input" ' + (data ? 'value="' + data.shippingFee + '"' : 'placeholder="运费金额"') + ' lay-verify="required|number">' +
+ ' </div>' +
+ ' </div>' +
+ ' <div class="layui-form-item">' +
+ ' <label class="layui-form-label">状态</label>' +
+ ' <div class="layui-input-block">' +
+ ' <input type="radio" name="status" value="1" title="启用" ' + (!data || data.status === 1 ? 'checked' : '') + '>' +
+ ' <input type="radio" name="status" value="0" title="禁用" ' + (data && data.status === 0 ? 'checked' : '') + '>' +
+ ' </div>' +
+ ' </div>' +
+ ' <div class="layui-form-item">' +
+ ' <label class="layui-form-label">备注</label>' +
+ ' <div class="layui-input-block">' +
+ ' <input type="text" name="remark" class="layui-input" ' + (data && data.remark ? 'value="' + data.remark + '"' : '') + '>' +
+ ' </div>' +
+ ' </div>' +
+ '</form></div>';
+
+ var layerIndex = layer.open({
+ type: 1,
+ title: title,
+ area: ['500px', '420px'],
+ content: html,
+ btn: ['保存', '取消'],
+ yes: function (index, layero) {
+ var formObj = $(layero).find('form');
+ var fieldData = {};
+ formObj.find('input[name]').each(function () {
+ var name = $(this).attr('name');
+ var type = $(this).attr('type');
+ if (type === 'radio' && !$(this).prop('checked')) return;
+ if (type !== 'radio') {
+ fieldData[name] = $(this).val();
+ } else {
+ fieldData[name] = $(this).val();
+ }
+ });
+ // radio
+ var statusVal = formObj.find('input[name="status"]:checked').val();
+ fieldData.status = statusVal;
+
+ febs.post(ctx + 'admin/system/countryDeliverySave', fieldData, function (res) {
+ layer.close(index);
+ febs.alert.success('保存成功');
+ tableIns.reload();
+ });
+ },
+ btn2: function () {
+ layer.closeAll();
+ }
+ });
+ }
+ });
+</script>
--
Gitblit v1.9.1