提交附加费配置功能
This commit is contained in:
+12
@@ -50,6 +50,18 @@ public class BmsRegionController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取国家下拉选项列表(仅启用状态)
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
BmsRegion query = new BmsRegion();
|
||||
query.setStatus("0");
|
||||
List<BmsRegion> list = regionService.selectRegionList(query);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出区域列表
|
||||
*/
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.ruoyi.web.controller.price;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
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.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.price.domain.PrcSurcharge;
|
||||
import com.ruoyi.price.service.IPrcSurchargeService;
|
||||
|
||||
/**
|
||||
* 附加费配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/surcharge")
|
||||
public class SurchargeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPrcSurchargeService surchargeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrcSurcharge surcharge)
|
||||
{
|
||||
startPage();
|
||||
List<PrcSurcharge> list = surchargeService.selectPrcSurchargeList(surcharge);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:query')")
|
||||
@GetMapping("/{scId}")
|
||||
public AjaxResult getInfo(@PathVariable Long scId)
|
||||
{
|
||||
return success(surchargeService.selectPrcSurchargeById(scId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:add')")
|
||||
@Log(title = "附加费配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody PrcSurcharge surcharge)
|
||||
{
|
||||
surcharge.setCreateBy(getUsername());
|
||||
return toAjax(surchargeService.insertPrcSurcharge(surcharge));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:edit')")
|
||||
@Log(title = "附加费配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody PrcSurcharge surcharge)
|
||||
{
|
||||
surcharge.setUpdateBy(getUsername());
|
||||
return toAjax(surchargeService.updatePrcSurcharge(surcharge));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:remove')")
|
||||
@Log(title = "附加费配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{scIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] scIds)
|
||||
{
|
||||
return toAjax(surchargeService.deletePrcSurchargeByIds(scIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 附加费配置 prc_surcharge
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class PrcSurcharge extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 附加费配置ID */
|
||||
private Long scId;
|
||||
/** 附加费名称 */
|
||||
private String scName;
|
||||
/** 费用类型(字典 bms_fee_type) */
|
||||
private String feeType;
|
||||
/** 计费方式 FIXED固定金额/WEIGHT按重量/RATE按比例 */
|
||||
private String chargeType;
|
||||
/** 计费数值 */
|
||||
private BigDecimal chargeValue;
|
||||
/** 币种 */
|
||||
private String currency;
|
||||
/** 取值方式(字典 bms_round_mode)UP/DOWN/HALF_UP */
|
||||
private String roundMode;
|
||||
/** 状态码 on/of */
|
||||
private String ssCode;
|
||||
/** 适用国家ISO2(空=全部) */
|
||||
private String countryCode;
|
||||
/** 备注 */
|
||||
private String scNote;
|
||||
/** 租户ID */
|
||||
private Long tmsId;
|
||||
|
||||
public Long getScId() { return scId; }
|
||||
public void setScId(Long scId) { this.scId = scId; }
|
||||
public String getScName() { return scName; }
|
||||
public void setScName(String scName) { this.scName = scName; }
|
||||
public String getFeeType() { return feeType; }
|
||||
public void setFeeType(String feeType) { this.feeType = feeType; }
|
||||
public String getChargeType() { return chargeType; }
|
||||
public void setChargeType(String chargeType) { this.chargeType = chargeType; }
|
||||
public BigDecimal getChargeValue() { return chargeValue; }
|
||||
public void setChargeValue(BigDecimal chargeValue) { this.chargeValue = chargeValue; }
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
public String getRoundMode() { return roundMode; }
|
||||
public void setRoundMode(String roundMode) { this.roundMode = roundMode; }
|
||||
public String getSsCode() { return ssCode; }
|
||||
public void setSsCode(String ssCode) { this.ssCode = ssCode; }
|
||||
public String getCountryCode() { return countryCode; }
|
||||
public void setCountryCode(String countryCode) { this.countryCode = countryCode; }
|
||||
public String getScNote() { return scNote; }
|
||||
public void setScNote(String scNote) { this.scNote = scNote; }
|
||||
public Long getTmsId() { return tmsId; }
|
||||
public void setTmsId(Long tmsId) { this.tmsId = tmsId; }
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("scId", getScId())
|
||||
.append("scName", getScName())
|
||||
.append("feeType", getFeeType())
|
||||
.append("chargeType", getChargeType())
|
||||
.append("chargeValue", getChargeValue())
|
||||
.append("currency", getCurrency())
|
||||
.append("roundMode", getRoundMode())
|
||||
.append("ssCode", getSsCode())
|
||||
.append("countryCode", getCountryCode())
|
||||
.append("scNote", getScNote())
|
||||
.append("tmsId", getTmsId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.price.domain.PrcSurcharge;
|
||||
|
||||
/**
|
||||
* 附加费配置 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface PrcSurchargeMapper
|
||||
{
|
||||
public PrcSurcharge selectPrcSurchargeById(Long scId);
|
||||
|
||||
public List<PrcSurcharge> selectPrcSurchargeList(PrcSurcharge surcharge);
|
||||
|
||||
public int insertPrcSurcharge(PrcSurcharge surcharge);
|
||||
|
||||
public int updatePrcSurcharge(PrcSurcharge surcharge);
|
||||
|
||||
public int deletePrcSurchargeByIds(Long[] scIds);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.price.domain.PrcSurcharge;
|
||||
|
||||
/**
|
||||
* 附加费配置 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface IPrcSurchargeService
|
||||
{
|
||||
public PrcSurcharge selectPrcSurchargeById(Long scId);
|
||||
|
||||
public List<PrcSurcharge> selectPrcSurchargeList(PrcSurcharge surcharge);
|
||||
|
||||
public int insertPrcSurcharge(PrcSurcharge surcharge);
|
||||
|
||||
public int updatePrcSurcharge(PrcSurcharge surcharge);
|
||||
|
||||
public int deletePrcSurchargeByIds(Long[] scIds);
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.ruoyi.price.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.price.domain.PrcSurcharge;
|
||||
import com.ruoyi.price.mapper.PrcSurchargeMapper;
|
||||
import com.ruoyi.price.service.IPrcSurchargeService;
|
||||
|
||||
/**
|
||||
* 附加费配置 服务层实现
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
{
|
||||
@Autowired
|
||||
private PrcSurchargeMapper surchargeMapper;
|
||||
|
||||
@Override
|
||||
public PrcSurcharge selectPrcSurchargeById(Long scId)
|
||||
{
|
||||
return surchargeMapper.selectPrcSurchargeById(scId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcSurcharge> selectPrcSurchargeList(PrcSurcharge surcharge)
|
||||
{
|
||||
return surchargeMapper.selectPrcSurchargeList(surcharge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertPrcSurcharge(PrcSurcharge surcharge)
|
||||
{
|
||||
validate(surcharge);
|
||||
if (StringUtils.isEmpty(surcharge.getSsCode()))
|
||||
{
|
||||
surcharge.setSsCode("on");
|
||||
}
|
||||
if (StringUtils.isEmpty(surcharge.getFeeType()))
|
||||
{
|
||||
surcharge.setFeeType("SURCHARGE");
|
||||
}
|
||||
if (StringUtils.isEmpty(surcharge.getRoundMode()))
|
||||
{
|
||||
surcharge.setRoundMode("HALF_UP");
|
||||
}
|
||||
return surchargeMapper.insertPrcSurcharge(surcharge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updatePrcSurcharge(PrcSurcharge surcharge)
|
||||
{
|
||||
validate(surcharge);
|
||||
return surchargeMapper.updatePrcSurcharge(surcharge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deletePrcSurchargeByIds(Long[] scIds)
|
||||
{
|
||||
return surchargeMapper.deletePrcSurchargeByIds(scIds);
|
||||
}
|
||||
|
||||
private void validate(PrcSurcharge surcharge)
|
||||
{
|
||||
if (StringUtils.isEmpty(surcharge.getScName()))
|
||||
{
|
||||
throw new ServiceException("附加费名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(surcharge.getChargeType()))
|
||||
{
|
||||
throw new ServiceException("计费方式不能为空");
|
||||
}
|
||||
if (surcharge.getChargeValue() == null)
|
||||
{
|
||||
throw new ServiceException("计费数值不能为空");
|
||||
}
|
||||
if (surcharge.getChargeValue().compareTo(java.math.BigDecimal.ZERO) < 0)
|
||||
{
|
||||
throw new ServiceException("计费数值不能为负数");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?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="com.ruoyi.price.mapper.PrcSurchargeMapper">
|
||||
|
||||
<resultMap type="PrcSurcharge" id="PrcSurchargeResult">
|
||||
<id property="scId" column="sc_id" />
|
||||
<result property="scName" column="sc_name" />
|
||||
<result property="feeType" column="fee_type" />
|
||||
<result property="chargeType" column="charge_type" />
|
||||
<result property="chargeValue" column="charge_value" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="ssCode" column="ss_code" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="scNote" column="sc_note" />
|
||||
<result property="tmsId" column="tms_id" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="created_at" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="updated_at" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcSurchargeVo">
|
||||
select sc_id, sc_name, fee_type, charge_type, charge_value, currency, round_mode, ss_code,
|
||||
country_code, sc_note, tms_id, created_by, created_at, updated_by, updated_at
|
||||
from prc_surcharge
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcSurchargeById" parameterType="Long" resultMap="PrcSurchargeResult">
|
||||
<include refid="selectPrcSurchargeVo"/>
|
||||
where sc_id = #{scId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcSurchargeList" parameterType="PrcSurcharge" resultMap="PrcSurchargeResult">
|
||||
<include refid="selectPrcSurchargeVo"/>
|
||||
<where>
|
||||
<if test="scName != null and scName != ''">
|
||||
AND sc_name like concat('%', #{scName}, '%')
|
||||
</if>
|
||||
<if test="feeType != null and feeType != ''">
|
||||
AND fee_type = #{feeType}
|
||||
</if>
|
||||
<if test="chargeType != null and chargeType != ''">
|
||||
AND charge_type = #{chargeType}
|
||||
</if>
|
||||
<if test="roundMode != null and roundMode != ''">
|
||||
AND round_mode = #{roundMode}
|
||||
</if>
|
||||
<if test="ssCode != null and ssCode != ''">
|
||||
AND ss_code = #{ssCode}
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
AND country_code = #{countryCode}
|
||||
</if>
|
||||
<if test="tmsId != null">
|
||||
AND tms_id = #{tmsId}
|
||||
</if>
|
||||
</where>
|
||||
order by sc_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcSurcharge" parameterType="PrcSurcharge" useGeneratedKeys="true" keyProperty="scId">
|
||||
insert into prc_surcharge (
|
||||
<if test="scName != null and scName != ''">sc_name,</if>
|
||||
<if test="feeType != null and feeType != ''">fee_type,</if>
|
||||
<if test="chargeType != null and chargeType != ''">charge_type,</if>
|
||||
<if test="chargeValue != null">charge_value,</if>
|
||||
<if test="currency != null and currency != ''">currency,</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode,</if>
|
||||
<if test="ssCode != null and ssCode != ''">ss_code,</if>
|
||||
<if test="countryCode != null">country_code,</if>
|
||||
<if test="scNote != null">sc_note,</if>
|
||||
<if test="tmsId != null">tms_id,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
created_at
|
||||
) values (
|
||||
<if test="scName != null and scName != ''">#{scName},</if>
|
||||
<if test="feeType != null and feeType != ''">#{feeType},</if>
|
||||
<if test="chargeType != null and chargeType != ''">#{chargeType},</if>
|
||||
<if test="chargeValue != null">#{chargeValue},</if>
|
||||
<if test="currency != null and currency != ''">#{currency},</if>
|
||||
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
|
||||
<if test="ssCode != null and ssCode != ''">#{ssCode},</if>
|
||||
<if test="countryCode != null">#{countryCode},</if>
|
||||
<if test="scNote != null">#{scNote},</if>
|
||||
<if test="tmsId != null">#{tmsId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrcSurcharge" parameterType="PrcSurcharge">
|
||||
update prc_surcharge
|
||||
<set>
|
||||
<if test="scName != null and scName != ''">sc_name = #{scName},</if>
|
||||
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
|
||||
<if test="chargeType != null and chargeType != ''">charge_type = #{chargeType},</if>
|
||||
<if test="chargeValue != null">charge_value = #{chargeValue},</if>
|
||||
<if test="currency != null and currency != ''">currency = #{currency},</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode = #{roundMode},</if>
|
||||
<if test="ssCode != null and ssCode != ''">ss_code = #{ssCode},</if>
|
||||
country_code = #{countryCode},
|
||||
<if test="scNote != null">sc_note = #{scNote},</if>
|
||||
<if test="tmsId != null">tms_id = #{tmsId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
updated_at = sysdate()
|
||||
</set>
|
||||
where sc_id = #{scId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrcSurchargeByIds" parameterType="Long">
|
||||
delete from prc_surcharge where sc_id in
|
||||
<foreach item="scId" collection="array" open="(" separator="," close=")">
|
||||
#{scId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
-- ----------------------------
|
||||
-- BMS 计费字典:计费方式 / 币种
|
||||
-- charset: utf8mb4
|
||||
-- 幂等:dict_type 唯一键 + WHERE NOT EXISTS,可重复执行
|
||||
-- 默认值:计费方式 = FIXED(固定金额),币种 = CNY(人民币)
|
||||
-- ----------------------------
|
||||
|
||||
-- 1) 字典类型
|
||||
INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
|
||||
SELECT '计费方式', 'bms_charge_type', '0', 'admin', sysdate(), '计费方式 FIXED固定金额/WEIGHT按重量/RATE按比例'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE dict_type = 'bms_charge_type');
|
||||
|
||||
INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
|
||||
SELECT '币种', 'bms_currency', '0', 'admin', sysdate(), '计费币种'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE dict_type = 'bms_currency');
|
||||
|
||||
-- 2) 计费方式字典数据(默认 FIXED 固定金额)
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 1, '固定金额(每票)', 'FIXED', 'bms_charge_type', 'Y', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_charge_type' AND dict_value = 'FIXED');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 2, '按重量(每KG)', 'WEIGHT', 'bms_charge_type', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_charge_type' AND dict_value = 'WEIGHT');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 3, '按比例(%)', 'RATE', 'bms_charge_type', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_charge_type' AND dict_value = 'RATE');
|
||||
|
||||
-- 3) 币种字典数据(默认 CNY 人民币)
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 1, '人民币', 'CNY', 'bms_currency', 'Y', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_currency' AND dict_value = 'CNY');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 2, '美元', 'USD', 'bms_currency', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_currency' AND dict_value = 'USD');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 3, '欧元', 'EUR', 'bms_currency', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_currency' AND dict_value = 'EUR');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 4, '英镑', 'GBP', 'bms_currency', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_currency' AND dict_value = 'GBP');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 5, '日元', 'JPY', 'bms_currency', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_currency' AND dict_value = 'JPY');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 6, '港币', 'HKD', 'bms_currency', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_currency' AND dict_value = 'HKD');
|
||||
|
||||
-- 4) 幂等修正默认值(数据已存在时强制对齐)
|
||||
UPDATE sys_dict_data SET is_default = 'N' WHERE dict_type = 'bms_charge_type' AND dict_value <> 'FIXED';
|
||||
UPDATE sys_dict_data SET is_default = 'Y' WHERE dict_type = 'bms_charge_type' AND dict_value = 'FIXED';
|
||||
UPDATE sys_dict_data SET is_default = 'N' WHERE dict_type = 'bms_currency' AND dict_value <> 'CNY';
|
||||
UPDATE sys_dict_data SET is_default = 'Y' WHERE dict_type = 'bms_currency' AND dict_value = 'CNY';
|
||||
@@ -0,0 +1,47 @@
|
||||
-- ----------------------------
|
||||
-- BMS 计费字典:取值方式 / 费用类型
|
||||
-- charset: utf8mb4
|
||||
-- 幂等:dict_type 唯一键 + WHERE NOT EXISTS,可重复执行
|
||||
-- 默认值:费用类型 = SURCHARGE(附加费),取值方式 = HALF_UP(四舍五入)
|
||||
-- ----------------------------
|
||||
|
||||
-- 1) 字典类型
|
||||
INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
|
||||
SELECT '取值方式', 'bms_round_mode', '0', 'admin', sysdate(), '计费金额取值方式'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE dict_type = 'bms_round_mode');
|
||||
|
||||
INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, remark)
|
||||
SELECT '费用类型', 'bms_fee_type', '0', 'admin', sysdate(), '计费费用类型'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE dict_type = 'bms_fee_type');
|
||||
|
||||
-- 2) 取值方式字典数据(默认 HALF_UP 四舍五入)
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 1, '向上取值', 'UP', 'bms_round_mode', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_round_mode' AND dict_value = 'UP');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 2, '向下取整', 'DOWN', 'bms_round_mode', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_round_mode' AND dict_value = 'DOWN');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 3, '四舍五入', 'HALF_UP', 'bms_round_mode', 'Y', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_round_mode' AND dict_value = 'HALF_UP');
|
||||
|
||||
-- 3) 费用类型字典数据(默认 SURCHARGE 附加费)
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 1, '基础运费', 'BASIC_FREIGHT', 'bms_fee_type', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_fee_type' AND dict_value = 'BASIC_FREIGHT');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 2, '挂号费', 'REGISTRATION_FEE', 'bms_fee_type', 'N', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_fee_type' AND dict_value = 'REGISTRATION_FEE');
|
||||
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, is_default, status, create_by, create_time, remark)
|
||||
SELECT 3, '附加费', 'SURCHARGE', 'bms_fee_type', 'Y', '0', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_fee_type' AND dict_value = 'SURCHARGE');
|
||||
|
||||
-- 4) 幂等修正默认值(数据已存在时强制对齐,保证重复执行后默认值仍正确)
|
||||
UPDATE sys_dict_data SET is_default = 'N' WHERE dict_type = 'bms_round_mode' AND dict_value <> 'HALF_UP';
|
||||
UPDATE sys_dict_data SET is_default = 'Y' WHERE dict_type = 'bms_round_mode' AND dict_value = 'HALF_UP';
|
||||
UPDATE sys_dict_data SET is_default = 'N' WHERE dict_type = 'bms_fee_type' AND dict_value <> 'SURCHARGE';
|
||||
UPDATE sys_dict_data SET is_default = 'Y' WHERE dict_type = 'bms_fee_type' AND dict_value = 'SURCHARGE';
|
||||
@@ -0,0 +1,55 @@
|
||||
-- ----------------------------
|
||||
-- BMS price basic: surcharge config (附加费配置)
|
||||
-- charset: utf8mb4
|
||||
-- menu_id: 2115-2119
|
||||
-- ----------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS prc_surcharge (
|
||||
sc_id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '附加费配置ID',
|
||||
sc_name VARCHAR(100) NOT NULL COMMENT '附加费名称',
|
||||
fee_type VARCHAR(30) NOT NULL DEFAULT 'SURCHARGE' COMMENT '费用类型(字典bms_fee_type)',
|
||||
charge_type VARCHAR(20) NOT NULL COMMENT '计费方式 FIXED固定金额/WEIGHT按重量/RATE按比例',
|
||||
charge_value DECIMAL(18,6) NOT NULL COMMENT '计费数值',
|
||||
currency CHAR(3) NOT NULL DEFAULT 'CNY' COMMENT '币种',
|
||||
round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
ss_code VARCHAR(20) NOT NULL DEFAULT 'on' COMMENT '状态 on/of',
|
||||
country_code CHAR(2) DEFAULT NULL COMMENT '适用国家ISO2(空=全部)',
|
||||
sc_note VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
tms_id BIGINT(20) DEFAULT NULL COMMENT '租户ID',
|
||||
created_by VARCHAR(64) DEFAULT '' COMMENT '创建人',
|
||||
created_at DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
updated_by VARCHAR(64) DEFAULT '' COMMENT '更新人',
|
||||
updated_at DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (sc_id),
|
||||
INDEX idx_sc_ss_code (ss_code),
|
||||
INDEX idx_sc_country (country_code),
|
||||
INDEX idx_sc_tms_id (tms_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='附加费配置';
|
||||
|
||||
-- menus 2115-2119
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2115, N'附加费配置', 2100, 3, 'surcharge', 'price/basic/surcharge/index', '', 'PriceSurcharge', 1, 0, 'C', '0', '0', 'price:surcharge:list', 'money', 'admin', sysdate(), N'附加费配置菜单'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2115);
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2116, N'附加费查询', 2115, 1, '', NULL, '', '', 1, 0, 'F', '0', '0', 'price:surcharge:query', '#', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2116);
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2117, N'附加费新增', 2115, 2, '', NULL, '', '', 1, 0, 'F', '0', '0', 'price:surcharge:add', '#', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2117);
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2118, N'附加费修改', 2115, 3, '', NULL, '', '', 1, 0, 'F', '0', '0', 'price:surcharge:edit', '#', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2118);
|
||||
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2119, N'附加费删除', 2115, 4, '', NULL, '', '', 1, 0, 'F', '0', '0', 'price:surcharge:remove', '#', 'admin', sysdate(), ''
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2119);
|
||||
|
||||
-- role_id=1 grants
|
||||
INSERT INTO sys_role_menu (role_id, menu_id) SELECT 1, 2115 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2115);
|
||||
INSERT INTO sys_role_menu (role_id, menu_id) SELECT 1, 2116 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2116);
|
||||
INSERT INTO sys_role_menu (role_id, menu_id) SELECT 1, 2117 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2117);
|
||||
INSERT INTO sys_role_menu (role_id, menu_id) SELECT 1, 2118 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2118);
|
||||
INSERT INTO sys_role_menu (role_id, menu_id) SELECT 1, 2119 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND menu_id = 2119);
|
||||
@@ -9,6 +9,14 @@ export function listRegion(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 查询国家下拉选项列表(仅启用)
|
||||
export function listRegionOptions() {
|
||||
return request({
|
||||
url: '/data/region/optionselect',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询区域详细
|
||||
export function getRegion(regionId) {
|
||||
return request({
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// ========== 附加费配置 ==========
|
||||
|
||||
/** 查询附加费配置列表 */
|
||||
export function listSurcharge(query) {
|
||||
return request({
|
||||
url: '/price/surcharge/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询附加费配置详细 */
|
||||
export function getSurcharge(scId) {
|
||||
return request({
|
||||
url: '/price/surcharge/' + scId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/** 新增附加费配置 */
|
||||
export function addSurcharge(data) {
|
||||
return request({
|
||||
url: '/price/surcharge',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改附加费配置 */
|
||||
export function updateSurcharge(data) {
|
||||
return request({
|
||||
url: '/price/surcharge',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除附加费配置 */
|
||||
export function delSurcharge(scIds) {
|
||||
return request({
|
||||
url: '/price/surcharge/' + scIds,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<basic-table
|
||||
ref="tableRef"
|
||||
:columns="columns"
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="scId"
|
||||
>
|
||||
<template #toolbar="{ selection, ids }">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['price:surcharge:add']"
|
||||
>新建附加费</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="selection.length !== 1"
|
||||
@click="handleUpdate(selection[0])"
|
||||
v-hasPermi="['price:surcharge:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="!selection.length"
|
||||
@click="handleDelete(ids)"
|
||||
v-hasPermi="['price:surcharge:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<template #col-ssCode="{ row }">
|
||||
<el-tag :type="(row.ssCode || '').toLowerCase() === 'on' ? 'success' : 'warning'" size="small">
|
||||
{{ (row.ssCode || '').toLowerCase() === 'on' ? '有效' : '停用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-chargeType="{ row }">
|
||||
<el-tag type="primary" size="small" effect="plain">{{ chargeTypeLabel(row.chargeType) }}</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-chargeValue="{ row }">
|
||||
<span class="charge-value">{{ formatChargeValue(row) }}</span>
|
||||
</template>
|
||||
|
||||
<template #col-countryCode="{ row }">
|
||||
<span>{{ countryLabel(row.countryCode) }}</span>
|
||||
</template>
|
||||
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:surcharge:edit']">编辑</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(row.scId)" v-hasPermi="['price:surcharge:remove']">删除</el-button>
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<el-dialog :title="title" v-model="open" width="640px" append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="附加费名称" prop="scName">
|
||||
<el-input v-model="form.scName" placeholder="如 燃油附加费" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="费用类型" prop="feeType">
|
||||
<el-select v-model="form.feeType" placeholder="请选择" style="width: 100%" disabled>
|
||||
<el-option v-for="d in bms_fee_type" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计费方式" prop="chargeType">
|
||||
<el-select v-model="form.chargeType" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="c in bms_charge_type" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计费数值" prop="chargeValue">
|
||||
<el-input-number v-model="form.chargeValue" :min="0" :precision="6" :step="1" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="币种" prop="currency">
|
||||
<el-select v-model="form.currency" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="c in bms_currency" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="取值方式" prop="roundMode">
|
||||
<el-select v-model="form.roundMode" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="d in bms_round_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="适用国家" prop="countryCode">
|
||||
<el-select v-model="form.countryCode" placeholder="全部国家" clearable filterable style="width: 100%">
|
||||
<el-option label="全部国家" value="" />
|
||||
<el-option v-for="r in regionOptions" :key="r.countryCode2" :label="regionLabel(r)" :value="r.countryCode2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="ssCode">
|
||||
<el-radio-group v-model="form.ssCode">
|
||||
<el-radio value="on">有效</el-radio>
|
||||
<el-radio value="of">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注" prop="scNote">
|
||||
<el-input v-model="form.scNote" type="textarea" :rows="2" placeholder="请输入备注" maxlength="500" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="open = false">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSurcharge">
|
||||
import { listSurcharge, getSurcharge, addSurcharge, updateSurcharge, delSurcharge } from '@/api/price/surcharge'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_fee_type, bms_round_mode, bms_charge_type, bms_currency } = useDict('bms_fee_type', 'bms_round_mode', 'bms_charge_type', 'bms_currency')
|
||||
|
||||
const tableRef = ref()
|
||||
const open = ref(false)
|
||||
const title = ref('')
|
||||
const regionOptions = ref([])
|
||||
|
||||
const columns = [
|
||||
{ label: 'scId', prop: 'scId', align: 'center', width: 80 },
|
||||
{ label: '附加费名称', prop: 'scName', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'feeType', align: 'center', width: 110, dict: 'bms_fee_type' },
|
||||
{ label: '计费方式', prop: 'chargeType', align: 'center', width: 130 },
|
||||
{ label: '计费数值', prop: 'chargeValue', align: 'center', width: 140 },
|
||||
{ label: '取值方式', prop: 'roundMode', align: 'center', width: 110, dict: 'bms_round_mode' },
|
||||
{ label: '适用国家', prop: 'countryCode', align: 'center', minWidth: 120, showOverflowTooltip: true },
|
||||
{ label: '状态', prop: 'ssCode', align: 'center', width: 80 },
|
||||
{ label: '备注', prop: 'scNote', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true },
|
||||
{ label: '操作', prop: 'action', align: 'center', width: 150, fixed: 'right', showInToolbar: false }
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '附加费名称', prop: 'scName', component: 'input', placeholder: '请输入名称', width: '200px' },
|
||||
{
|
||||
label: '计费方式',
|
||||
prop: 'chargeType',
|
||||
component: 'select',
|
||||
dict: 'bms_charge_type',
|
||||
placeholder: '计费方式',
|
||||
width: '150px'
|
||||
},
|
||||
{ label: '取值方式', prop: 'roundMode', component: 'select', dict: 'bms_round_mode', placeholder: '取值方式', width: '150px' },
|
||||
{
|
||||
label: '状态',
|
||||
prop: 'ssCode',
|
||||
component: 'select',
|
||||
options: [
|
||||
{ label: '有效', value: 'on' },
|
||||
{ label: '停用', value: 'of' }
|
||||
],
|
||||
placeholder: '状态',
|
||||
width: '120px'
|
||||
}
|
||||
]
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
rules: {
|
||||
scName: [{ required: true, message: '附加费名称不能为空', trigger: 'blur' }],
|
||||
feeType: [{ required: true, message: '请选择费用类型', trigger: 'change' }],
|
||||
chargeType: [{ required: true, message: '请选择计费方式', trigger: 'change' }],
|
||||
chargeValue: [{ required: true, message: '计费数值不能为空', trigger: 'blur' }],
|
||||
roundMode: [{ required: true, message: '请选择取值方式', trigger: 'change' }]
|
||||
}
|
||||
})
|
||||
const { form, rules } = toRefs(data)
|
||||
|
||||
function queryList(params) {
|
||||
return listSurcharge(params)
|
||||
}
|
||||
|
||||
function chargeTypeLabel(val) {
|
||||
const found = bms_charge_type.value.find(c => c.value === val)
|
||||
return found ? found.label : (val || '-')
|
||||
}
|
||||
|
||||
function regionLabel(r) {
|
||||
const cn = r.countryNameCn || r.countryNameEn || ''
|
||||
return cn ? `${r.flagEmoji || ''} ${cn} (${r.countryCode2})`.trim() : r.countryCode2
|
||||
}
|
||||
|
||||
function countryLabel(code) {
|
||||
if (!code) return '全部'
|
||||
const found = regionOptions.value.find(r => r.countryCode2 === code)
|
||||
return found ? (found.countryNameCn || found.countryNameEn || code) : code
|
||||
}
|
||||
|
||||
function loadRegionOptions() {
|
||||
listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadRegionOptions()
|
||||
})
|
||||
|
||||
function formatChargeValue(row) {
|
||||
if (row.chargeValue == null) return '-'
|
||||
const v = Number(row.chargeValue)
|
||||
if (row.chargeType === 'RATE') {
|
||||
return (v * 100).toFixed(2) + '%'
|
||||
}
|
||||
return v + ' ' + (row.currency || 'CNY')
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = {
|
||||
scId: undefined,
|
||||
scName: undefined,
|
||||
feeType: 'SURCHARGE',
|
||||
chargeType: 'FIXED',
|
||||
chargeValue: undefined,
|
||||
currency: 'CNY',
|
||||
roundMode: 'HALF_UP',
|
||||
ssCode: 'on',
|
||||
countryCode: undefined,
|
||||
scNote: undefined
|
||||
}
|
||||
proxy.resetForm('formRef')
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '新建附加费'
|
||||
}
|
||||
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
getSurcharge(row.scId).then(res => {
|
||||
const data = res.data || {}
|
||||
if (data.ssCode) data.ssCode = String(data.ssCode).toLowerCase()
|
||||
form.value = data
|
||||
open.value = true
|
||||
title.value = '修改附加费'
|
||||
})
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
proxy.$refs['formRef'].validate(valid => {
|
||||
if (!valid) return
|
||||
const payload = { ...form.value }
|
||||
if (!payload.countryCode) payload.countryCode = undefined
|
||||
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
|
||||
const req = payload.scId != null ? updateSurcharge(payload) : addSurcharge(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess(payload.scId != null ? '修改成功' : '新增成功')
|
||||
open.value = false
|
||||
tableRef.value.refresh()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function handleDelete(ids) {
|
||||
const idText = Array.isArray(ids) ? ids.join(',') : ids
|
||||
proxy.$modal.confirm('是否确认删除所选附加费配置?').then(() => {
|
||||
return delSurcharge(idText)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
tableRef.value.refresh()
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.charge-value {
|
||||
font-weight: 600;
|
||||
color: #d63031;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user