Commit 48474681 by 张立顺

Merge branch 'v1.4.0' of http://192.168.3.233:8090/usedCarAuction/aus into v1.4.0

2 parents 4a31e134 b7a2537a
Showing 32 changed files with 698 additions and 195 deletions
...@@ -150,6 +150,8 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity, ...@@ -150,6 +150,8 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity,
* 活动分页统计查询(小驼峰·纯数字·支持条件+排序+新增字段) * 活动分页统计查询(小驼峰·纯数字·支持条件+排序+新增字段)
* 使用 JOIN 替代子查询,符合公司规范 * 使用 JOIN 替代子查询,符合公司规范
* 统计时排除已退回的优惠券(coupon_account.status = 4) * 统计时排除已退回的优惠券(coupon_account.status = 4)
*
* @param activityIdsByTemplate 根据模板ID反查出的活动ID列表,传空列表表示不过滤
*/ */
@Query(value = """ @Query(value = """
SELECT SELECT
...@@ -181,8 +183,9 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity, ...@@ -181,8 +183,9 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity,
AND (:searchKey IS NULL OR ca.activity_name LIKE CONCAT('%', :searchKey, '%') OR ca.activity_id LIKE CONCAT('%', :searchKey, '%')) AND (:searchKey IS NULL OR ca.activity_name LIKE CONCAT('%', :searchKey, '%') OR ca.activity_id LIKE CONCAT('%', :searchKey, '%'))
AND (:status IS NULL OR ca.status = :status) AND (:status IS NULL OR ca.status = :status)
AND (:activityType IS NULL OR ca.activity_type = :activityType) AND (:activityType IS NULL OR ca.activity_type = :activityType)
AND (:startTime IS NULL OR ca.create_time >= :startTime) AND (:startTime IS NULL OR ca.valid_end_time >= :startTime)
AND (:endTime IS NULL OR ca.create_time <= :endTime) AND (:endTime IS NULL OR ca.valid_start_time <= :endTime)
AND ('__ALL__' IN :activityIdsByTemplate OR ca.activity_id IN :activityIdsByTemplate)
GROUP BY ca.id, ca.activity_id, ca.activity_name, ca.valid_start_time, ca.valid_end_time, GROUP BY ca.id, ca.activity_id, ca.activity_name, ca.valid_start_time, ca.valid_end_time,
ca.activity_type, ca.target_type, ca.distribution_quantity, ca.status, ca.activity_type, ca.target_type, ca.distribution_quantity, ca.status,
ca.create_time, ca.send_notification, ca.remark, ca.update_time, ca.template_id ca.create_time, ca.send_notification, ca.remark, ca.update_time, ca.template_id
...@@ -209,8 +212,9 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity, ...@@ -209,8 +212,9 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity,
AND (:searchKey IS NULL OR ca.activity_name LIKE CONCAT('%', :searchKey, '%') OR ca.activity_id LIKE CONCAT('%', :searchKey, '%')) AND (:searchKey IS NULL OR ca.activity_name LIKE CONCAT('%', :searchKey, '%') OR ca.activity_id LIKE CONCAT('%', :searchKey, '%'))
AND (:status IS NULL OR ca.status = :status) AND (:status IS NULL OR ca.status = :status)
AND (:activityType IS NULL OR ca.activity_type = :activityType) AND (:activityType IS NULL OR ca.activity_type = :activityType)
AND (:startTime IS NULL OR ca.create_time >= :startTime) AND (:startTime IS NULL OR ca.valid_end_time >= :startTime)
AND (:endTime IS NULL OR ca.create_time <= :endTime) AND (:endTime IS NULL OR ca.valid_start_time <= :endTime)
AND ('__ALL__' IN :activityIdsByTemplate OR ca.activity_id IN :activityIdsByTemplate)
""", """,
nativeQuery = true) nativeQuery = true)
Page<CouponActivityStatDTO> pageActivityStat( Page<CouponActivityStatDTO> pageActivityStat(
...@@ -221,6 +225,7 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity, ...@@ -221,6 +225,7 @@ public interface CouponActivityRepository extends BaseRepository<CouponActivity,
@Param("endTime") LocalDateTime endTime, @Param("endTime") LocalDateTime endTime,
@Param("sortField") String sortField, @Param("sortField") String sortField,
@Param("sortOrder") String sortOrder, @Param("sortOrder") String sortOrder,
@Param("activityIdsByTemplate") List<String> activityIdsByTemplate,
Pageable pageable Pageable pageable
); );
......
...@@ -106,6 +106,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo ...@@ -106,6 +106,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo
* @param startTime 创建时间开始 * @param startTime 创建时间开始
* @param endTime 创建时间结束 * @param endTime 创建时间结束
* @param idList 记录主键 ID 列表(可选,为空则不按 ID 过滤) * @param idList 记录主键 ID 列表(可选,为空则不按 ID 过滤)
* @param couponTemplateId 优惠券模板唯一 ID(精准匹配)
* @param templateName 优惠券名称(模糊匹配)
* @param pageable 分页参数 * @param pageable 分页参数
* @return 发放记录分页数据 * @return 发放记录分页数据
*/ */
...@@ -116,7 +118,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo ...@@ -116,7 +118,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo
r.activityId, r.activityId,
r.activityName, r.activityName,
r.templateId, r.templateId,
r.templateName, temp.templateName,
temp.templateId,
r.couponId, r.couponId,
r.accountId, r.accountId,
a.accountName, a.accountName,
...@@ -140,14 +143,15 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo ...@@ -140,14 +143,15 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo
) )
FROM CouponDistributionRecord r FROM CouponDistributionRecord r
LEFT JOIN CouponAccount c ON r.couponId = c.couponId AND c.deleteFlag = 'N' LEFT JOIN CouponAccount c ON r.couponId = c.couponId AND c.deleteFlag = 'N'
LEFT JOIN CouponTemplate temp ON temp.id = c.templateId AND c.deleteFlag = 'N'
LEFT JOIN Account a ON r.accountId = a.accountId LEFT JOIN Account a ON r.accountId = a.accountId
LEFT JOIN CouponVerificationRecord v ON r.couponId = v.couponId AND v.deleteFlag = 'N' LEFT JOIN CouponVerificationRecord v ON r.couponId = v.couponId AND v.deleteFlag = 'N'
WHERE r.deleteFlag = 'N' WHERE r.deleteFlag = 'N'
AND (:keyword IS NULL OR :keyword = '' AND (:keyword IS NULL OR :keyword = ''
OR r.activityName LIKE %:keyword% OR r.activityName LIKE %:keyword%
OR r.activityId LIKE %:keyword%) OR r.activityId LIKE %:keyword%)
AND (:userInfo IS NULL OR :userInfo = '' AND (:userInfo IS NULL OR :userInfo = ''
OR a.accountName LIKE %:userInfo% OR a.accountName LIKE %:userInfo%
OR r.mobile LIKE %:userInfo%) OR r.mobile LIKE %:userInfo%)
AND (:couponStatus IS NULL OR c.status = :couponStatus) AND (:couponStatus IS NULL OR c.status = :couponStatus)
AND (:distributionType IS NULL OR r.distributionType = :distributionType) AND (:distributionType IS NULL OR r.distributionType = :distributionType)
...@@ -155,6 +159,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo ...@@ -155,6 +159,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo
AND (:startTime IS NULL OR r.distributionTime >= :startTime) AND (:startTime IS NULL OR r.distributionTime >= :startTime)
AND (:endTime IS NULL OR r.distributionTime <= :endTime) AND (:endTime IS NULL OR r.distributionTime <= :endTime)
AND (:idList IS NULL OR r.id IN :idList) AND (:idList IS NULL OR r.id IN :idList)
AND (:couponTemplateId IS NULL OR :couponTemplateId = '' OR temp.templateId = :couponTemplateId)
AND (:templateName IS NULL OR :templateName = '' OR temp.templateName LIKE %:templateName%)
""") """)
Page<CouponDistributionRecordDTO> findDistributionRecords( Page<CouponDistributionRecordDTO> findDistributionRecords(
@Param("keyword") String keyword, @Param("keyword") String keyword,
...@@ -165,6 +171,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo ...@@ -165,6 +171,8 @@ public interface CouponDistributionRecordRepository extends BaseRepository<Coupo
@Param("startTime") LocalDateTime startTime, @Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime, @Param("endTime") LocalDateTime endTime,
@Param("idList") List<Integer> idList, @Param("idList") List<Integer> idList,
@Param("couponTemplateId") String couponTemplateId,
@Param("templateName") String templateName,
Pageable pageable Pageable pageable
); );
......
...@@ -24,6 +24,7 @@ public class CouponDistributionRecordDTO implements Serializable { ...@@ -24,6 +24,7 @@ public class CouponDistributionRecordDTO implements Serializable {
private String activityName; private String activityName;
private Long templateId; private Long templateId;
private String templateName; private String templateName;
private String couponTemplateId;
private String couponId; private String couponId;
private Integer accountId; private Integer accountId;
private String accountName; private String accountName;
......
...@@ -476,11 +476,36 @@ public class CouponActivityService { ...@@ -476,11 +476,36 @@ public class CouponActivityService {
Integer activityType = typeObj instanceof Integer ? (Integer) typeObj : null; Integer activityType = typeObj instanceof Integer ? (Integer) typeObj : null;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<String> timeRange = (List<String>) pagination.getFilterValueOrElseNull("createTime"); List<String> timeRange = (List<String>) pagination.getFilterValueOrElseNull("validTime");
LocalDateTime[] parsedRange = parseTimeRange(timeRange); LocalDateTime[] parsedRange = parseTimeRange(timeRange);
LocalDateTime startTime = parsedRange[0]; LocalDateTime startTime = parsedRange[0];
LocalDateTime endTime = parsedRange[1]; LocalDateTime endTime = parsedRange[1];
// 提取优惠券模板ID参数,并反查关联的活动ID列表
String couponTemplateId = (String)pagination.getFilterValueOrElseNull("couponTemplateId");
// 根据模板ID反查活动ID列表
List<String> activityIdsByTemplate = Collections.singletonList("__ALL__"); // 默认不过滤
if (couponTemplateId != null) {
Optional<CouponTemplate> template = couponTemplateRepository.findByTemplateIdAndDeleteFlag(couponTemplateId, DeleteFlag.NOT_DELETED.getCode());
if (template.isEmpty()) {
return Page.empty();
}
Long templateId = template.get().getId();
Set<String> activityIdSet = new HashSet<>();
// 从活动阶梯表查询(自动触发类型活动)
List<CouponActivityPriceRange> priceRanges = priceRangeRepository.findByTemplateIdAndDeleteFlag(
templateId, DeleteFlag.NOT_DELETED.getCode());
priceRanges.forEach(pr -> activityIdSet.add(pr.getActivityId()));
// 从活动表查询(直接发放类型活动)
List<CouponActivity> directActivities = couponActivityRepository.findByTemplateIdAndDeleteFlag(
templateId, DeleteFlag.NOT_DELETED.getCode());
directActivities.forEach(a -> activityIdSet.add(a.getActivityId()));
if (activityIdSet.isEmpty()) {
return Page.empty();
}
activityIdsByTemplate = new ArrayList<>(activityIdSet);
}
// 2. 排序参数 // 2. 排序参数
String sortField = pagination.getSort() == null ? "createTime" : pagination.getSort(); String sortField = pagination.getSort() == null ? "createTime" : pagination.getSort();
String sortOrder = pagination.getOrder() == null ? "DESC" : pagination.getOrder(); String sortOrder = pagination.getOrder() == null ? "DESC" : pagination.getOrder();
...@@ -488,7 +513,7 @@ public class CouponActivityService { ...@@ -488,7 +513,7 @@ public class CouponActivityService {
// 3. 执行查询 // 3. 执行查询
Page<CouponActivityStatDTO> dtoPage = couponActivityRepository.pageActivityStat( Page<CouponActivityStatDTO> dtoPage = couponActivityRepository.pageActivityStat(
searchKey, status, activityType, startTime, endTime, searchKey, status, activityType, startTime, endTime,
sortField, sortOrder, pagination.getPageRequest() sortField, sortOrder, activityIdsByTemplate, pagination.getPageRequest()
); );
// 4. 一次遍历按类型分组 // 4. 一次遍历按类型分组
...@@ -786,6 +811,9 @@ public class CouponActivityService { ...@@ -786,6 +811,9 @@ public class CouponActivityService {
if (idList != null && idList.isEmpty()) { if (idList != null && idList.isEmpty()) {
idList = null; idList = null;
} }
// 提取优惠券模板查询参数
String couponTemplateId = (String) pagination.getFilterValueOrElseNull("couponTemplateId");
String templateName = (String) pagination.getFilterValueOrElseNull("templateName");
String sort = StrUtil.blankToDefault(pagination.getSort(), "distributionTime"); String sort = StrUtil.blankToDefault(pagination.getSort(), "distributionTime");
Sort.Direction direction = pagination.getSortDirection() == null ? Sort.Direction.DESC : pagination.getSortDirection(); Sort.Direction direction = pagination.getSortDirection() == null ? Sort.Direction.DESC : pagination.getSortDirection();
PageRequest base = pagination.getPageRequest(); PageRequest base = pagination.getPageRequest();
...@@ -800,6 +828,8 @@ public class CouponActivityService { ...@@ -800,6 +828,8 @@ public class CouponActivityService {
startTime, startTime,
endTime, endTime,
idList, idList,
couponTemplateId,
templateName,
pageable pageable
); );
......
...@@ -128,7 +128,7 @@ public class CouponTemplateService { ...@@ -128,7 +128,7 @@ public class CouponTemplateService {
} }
// 校验是否有启用中的活动关联了此模板 // 校验是否有启用中的活动关联了此模板
checkActiveActivityAssociations(template.getId()); // checkActiveActivityAssociations(template.getId());
// 校验阶梯规则 // 校验阶梯规则
validateTierRules(updateVO.getTierRules(), updateVO.getCouponType()); validateTierRules(updateVO.getTierRules(), updateVO.getCouponType());
......
...@@ -36,6 +36,9 @@ public class CouponDistributionRecordRespVO implements Serializable { ...@@ -36,6 +36,9 @@ public class CouponDistributionRecordRespVO implements Serializable {
@Schema(description = "优惠券名称") @Schema(description = "优惠券名称")
private String templateName; private String templateName;
@Schema(description = "优惠券模板唯一ID")
private String couponTemplateId;
@Schema(description = "优惠券实例 ID") @Schema(description = "优惠券实例 ID")
private String couponId; private String couponId;
......
...@@ -54,5 +54,8 @@ public class CouponPopupRespVO implements Serializable { ...@@ -54,5 +54,8 @@ public class CouponPopupRespVO implements Serializable {
@Schema(description = "发放来源/标签") @Schema(description = "发放来源/标签")
private String distributionSource; private String distributionSource;
@Schema(description = "抵扣类型 (1:抵扣车款;2:抵扣佣金)")
private Integer deductionType;
} }
} }
...@@ -35,7 +35,7 @@ public class CouponTemplateAddVO implements Serializable { ...@@ -35,7 +35,7 @@ public class CouponTemplateAddVO implements Serializable {
@Schema(description = "使用门槛(元,0 代表无门槛)", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "10000.00") @Schema(description = "使用门槛(元,0 代表无门槛)", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "10000.00")
@DecimalMin(value = "0", message = "门槛必须>=0") @DecimalMin(value = "0", message = "门槛必须>=0")
@DecimalMax(value = "9999999", message = "门槛必须<=9999999") @DecimalMax(value = "10000000", message = "门槛必须<=10000000")
private BigDecimal thresholdAmount; private BigDecimal thresholdAmount;
@Schema(description = "抵扣类型 (1:抵扣车款;2:抵扣佣金)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "抵扣类型 (1:抵扣车款;2:抵扣佣金)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
......
...@@ -39,7 +39,7 @@ public class CouponTemplateUpdateVO implements Serializable { ...@@ -39,7 +39,7 @@ public class CouponTemplateUpdateVO implements Serializable {
@Schema(description = "使用门槛(元,0 代表无门槛)", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "10000.00") @Schema(description = "使用门槛(元,0 代表无门槛)", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "10000.00")
@DecimalMin(value = "0", message = "门槛必须>=0") @DecimalMin(value = "0", message = "门槛必须>=0")
@DecimalMax(value = "9999999", message = "门槛必须<=9999999") @DecimalMax(value = "10000000", message = "门槛必须<=10000000")
private BigDecimal thresholdAmount; private BigDecimal thresholdAmount;
@Schema(description = "抵扣类型 (1:抵扣车款;2:抵扣佣金)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "抵扣类型 (1:抵扣车款;2:抵扣佣金)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
......
...@@ -6,8 +6,8 @@ PUBLISH_PATH = '/' ...@@ -6,8 +6,8 @@ PUBLISH_PATH = '/'
BASE_URL = '/ BASE_URL = '/
# 开发环境 # 开发环境
# VITE_API_BASE_URL = 'http://aus.test.glsx.com.cn/admin/rest' VITE_API_BASE_URL = 'http://aus.test.glsx.com.cn/admin/rest'
VITE_API_BASE_URL = 'http://192.168.1.69:6903/admin/rest' # VITE_API_BASE_URL = 'http://192.168.1.69:6903/admin/rest'
#VITE_TOKEN= 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbmlzdHJhdG9yIiwicmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJwYXNzd29yZCI6IiQyYSQxMCRlQ21jWmxPaFltVUxrNklibjR3RVgudjNpa0dzcnBpYjh0SlBlcGJ6NVl1SXFWbUpCVER4eSIsImlzcyI6ImF1c0FwcCIsImV4cCI6MTg0NTI4NTU3NiwiaWF0IjoxNzczMjg1NTc2LCJqdGkiOiIzMCIsImF1dGhvcml0aWVzIjpbIlJPTEVfU1VQRVIiXX0.q0Ou_W9goNWUgasZTULp4IDWlZhVHWbQ0jn49qdZeSw' #VITE_TOKEN= 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbmlzdHJhdG9yIiwicmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJwYXNzd29yZCI6IiQyYSQxMCRlQ21jWmxPaFltVUxrNklibjR3RVgudjNpa0dzcnBpYjh0SlBlcGJ6NVl1SXFWbUpCVER4eSIsImlzcyI6ImF1c0FwcCIsImV4cCI6MTg0NTI4NTU3NiwiaWF0IjoxNzczMjg1NTc2LCJqdGkiOiIzMCIsImF1dGhvcml0aWVzIjpbIlJPTEVfU1VQRVIiXX0.q0Ou_W9goNWUgasZTULp4IDWlZhVHWbQ0jn49qdZeSw'
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"dayjs": "^1.10.7", "dayjs": "^1.10.7",
"echarts": "^5.2.2", "echarts": "^5.2.2",
"glsk-oss-jssdk": "^1.0.7", "glsk-oss-jssdk": "^1.0.6",
"image-conversion": "^2.1.1", "image-conversion": "^2.1.1",
"ionicons": "^8.0.9", "ionicons": "^8.0.9",
"lib": "file:../lib", "lib": "file:../lib",
......
...@@ -45,8 +45,8 @@ importers: ...@@ -45,8 +45,8 @@ importers:
specifier: ^5.2.2 specifier: ^5.2.2
version: 5.6.0 version: 5.6.0
glsk-oss-jssdk: glsk-oss-jssdk:
specifier: ^1.0.7 specifier: ^1.0.6
version: 1.0.7 version: 1.0.6
image-conversion: image-conversion:
specifier: ^2.1.1 specifier: ^2.1.1
version: 2.1.1 version: 2.1.1
...@@ -1826,8 +1826,8 @@ packages: ...@@ -1826,8 +1826,8 @@ packages:
resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==}
engines: {node: '>=10'} engines: {node: '>=10'}
glsk-oss-jssdk@1.0.7: glsk-oss-jssdk@1.0.6:
resolution: {integrity: sha512-e5uQWWD+f8UJ/zE7F1qJi09YvSMhX3iAbglJuwOOstMv0aVulX8gA3tdn8zPruS0fxzqrcpE9BNhwnETuHbSpw==} resolution: {integrity: sha512-uifUcPNbb6Roas0Dlx6LRldHPwU1yQqJbQRldUaNB+e6stFvn9XrsewCueNDUty3cZw4NCg3yao2WVCUm3T2Og==}
good-listener@1.2.2: good-listener@1.2.2:
resolution: {integrity: sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==} resolution: {integrity: sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==}
...@@ -5014,7 +5014,7 @@ snapshots: ...@@ -5014,7 +5014,7 @@ snapshots:
merge2: 1.4.1 merge2: 1.4.1
slash: 3.0.0 slash: 3.0.0
glsk-oss-jssdk@1.0.7: glsk-oss-jssdk@1.0.6:
dependencies: dependencies:
ali-oss: 6.23.0 ali-oss: 6.23.0
axios: 1.15.0 axios: 1.15.0
......
export const OSS_CONFIG = { export const OSS_CONFIG = {
BUCKET_NAME: "glsk-oss", BUCKET_NAME: "glsk-oss",
OSS_DOMAIN: "https://glsk-oss.oss-cn-shenzhen.aliyuncs.com", OSS_DOMAIN: "https://glsk-oss.oss-cn-shenzhen.aliyuncs.com",
FOLDER: "usedCarH5/", FOLDER: "usedCarH5/",
/** /**
* glsk-oss-jssdk 需要的 systemSource(会传给 STS 凭证接口) * glsk-oss-jssdk 需要的 systemSource(会传给 STS 凭证接口)
* H5 默认用 h5,按你们接口约定调整 * H5 默认用 h5,按你们接口约定调整
*/ */
SYSTEM_SOURCE: "h5", SYSTEM_SOURCE: "web",
} as const; } as const;
...@@ -34,6 +34,11 @@ import "vue3-colorpicker/style.css"; ...@@ -34,6 +34,11 @@ import "vue3-colorpicker/style.css";
import isoWeek from "dayjs/plugin/isoWeek"; import isoWeek from "dayjs/plugin/isoWeek";
import weekOfYear from "dayjs/plugin/weekOfYear"; import weekOfYear from "dayjs/plugin/weekOfYear";
import quarterOfYear from 'dayjs/plugin/quarterOfYear'; import quarterOfYear from 'dayjs/plugin/quarterOfYear';
import weekday from "dayjs/plugin/weekday";
import weekYear from "dayjs/plugin/weekYear";
import localeData from "dayjs/plugin/localeData";
import customParseFormat from "dayjs/plugin/customParseFormat";
import advancedFormat from "dayjs/plugin/advancedFormat";
import dayjs from "dayjs"; import dayjs from "dayjs";
import "dayjs/locale/zh-cn"; import "dayjs/locale/zh-cn";
import updateLocale from "dayjs/plugin/updateLocale"; import updateLocale from "dayjs/plugin/updateLocale";
...@@ -44,6 +49,11 @@ import {WALDEN_THEME} from "@/assets/style/walden"; ...@@ -44,6 +49,11 @@ import {WALDEN_THEME} from "@/assets/style/walden";
import SecurityDirective from "lib/src/core/security/SecurityDirective"; import SecurityDirective from "lib/src/core/security/SecurityDirective";
dayjs.locale("zh-cn"); dayjs.locale("zh-cn");
dayjs.extend(customParseFormat);
dayjs.extend(advancedFormat);
dayjs.extend(localeData);
dayjs.extend(weekday);
dayjs.extend(weekYear);
dayjs.extend(weekOfYear); dayjs.extend(weekOfYear);
dayjs.extend(isoWeek); dayjs.extend(isoWeek);
dayjs.extend(updateLocale); dayjs.extend(updateLocale);
......
...@@ -53,13 +53,28 @@ export function uploadFile(file, options = {}) { ...@@ -53,13 +53,28 @@ export function uploadFile(file, options = {}) {
* @param {File[]} files * @param {File[]} files
* @param {Parameters<typeof uploadFile>[1]} [options] * @param {Parameters<typeof uploadFile>[1]} [options]
*/ */
export function uploadFiles(files, options = {}) { const IMAGE_EXT = /\.(jpe?g|png|gif|webp|bmp|svg|ico|heic|heif)$/i;
if (!Array.isArray(files) || files.length === 0) { const VIDEO_EXT = /\.(mp4|webm|ogg|mov|mpe?g|avi|wmv|flv|mkv)$/i;
return Promise.reject(new Error("files 不能为空"));
} /** 是否为图片(MIME 优先;无 MIME 时按扩展名兜底,常见于部分移动端) */
return Promise.all(files.map((f) => uploadFile(f, options))); export function isLikelyImageFile(file) {
if (!file) return false;
const t = (file.type || "").toLowerCase();
if (t.startsWith("image/")) return true;
if (!t && IMAGE_EXT.test(file.name || "")) return true;
return false;
} }
/** 是否为视频 */
export function isLikelyVideoFile(file) {
if (!file) return false;
const t = (file.type || "").toLowerCase();
if (t.startsWith("video/")) return true;
if (!t && VIDEO_EXT.test(file.name || "")) return true;
return false;
}
// 将图片进行格式转换。 // 将图片进行格式转换。
async function format() { async function format() {
try { try {
......
...@@ -65,12 +65,12 @@ export default class AccountPicker extends PaginationComponent<Account> { ...@@ -65,12 +65,12 @@ export default class AccountPicker extends PaginationComponent<Account> {
created(): void { created(): void {
this.init(this.axios, AccountController.PAGE_ACCOUNT); this.init(this.axios, AccountController.PAGE_ACCOUNT);
this.buildQueryForm({ this.buildQueryForm({
accountName: [null, {label: '用户名', field: 'accountName', operator: Operator.like}], accountName: [null, {label: '认证姓名', field: 'accountName', operator: Operator.like}],
createTime: [null, {label: '创建时间', field: 'createTime', operator: Operator.dateBetween, type: 'date-range'}], createTime: [null, {label: '注册时间', field: 'createTime', operator: Operator.dateBetween, type: 'date-range'}],
lastLoginTime: [null, {label: '最近活跃时间', field: 'lastLoginTime', operator: Operator.dateBetween, type: 'date-range'}], lastLoginTime: [null, {label: '最近活跃时间', field: 'lastLoginTime', operator: Operator.dateBetween, type: 'date-range'}],
mobile: [null, {label: '手机号', field: 'mobile', operator: Operator.like}], mobile: [null, {label: '手机号', field: 'mobile', operator: Operator.like}],
openId: [null, {label: '微信ID', field: 'openId', operator: Operator.like}], // openId: [null, {label: '微信ID', field: 'openId', operator: Operator.like}],
idCard: [null, {label: '身份证', field: 'idCard', operator: Operator.like}], // idCard: [null, {label: '身份证', field: 'idCard', operator: Operator.like}],
nickName: [null, {label: '昵称', field: 'nickName', operator: Operator.like}], nickName: [null, {label: '昵称', field: 'nickName', operator: Operator.like}],
enabled: [null, {label: '账号状态', field: 'enabled', type: 'select', allowClear: true, optionItems: [{label: '启用', value: true}, {label: '禁用', value: false}], operator: Operator.eq}], enabled: [null, {label: '账号状态', field: 'enabled', type: 'select', allowClear: true, optionItems: [{label: '启用', value: true}, {label: '禁用', value: false}], operator: Operator.eq}],
}); });
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
<template v-if="record.payType==='拍卖保证金'"> <template v-if="record.payType==='拍卖保证金'">
<deposit-state-tag :deposit-state="record.payState"></deposit-state-tag> <deposit-state-tag :deposit-state="record.payState"></deposit-state-tag>
</template> </template>
<template v-else-if="record.payType === '优惠券抵扣'">-</template>
<template v-else-if="orderTransaction"> <template v-else-if="orderTransaction">
<audit-state-tag :audit-state="orderTransaction.auditState"></audit-state-tag> <audit-state-tag :audit-state="orderTransaction.auditState"></audit-state-tag>
</template> </template>
...@@ -111,6 +112,7 @@ ...@@ -111,6 +112,7 @@
<template v-if="record.payType==='拍卖保证金'"> <template v-if="record.payType==='拍卖保证金'">
{{ record.payMethod }} {{ record.payMethod }}
</template> </template>
<template v-else-if="record.payType === '优惠券抵扣'">-</template>
<template v-else-if="orderTransaction"> <template v-else-if="orderTransaction">
{{ $t(`enum.orderTransaction.paymentType.${orderTransaction.paymentType}`) }} {{ $t(`enum.orderTransaction.paymentType.${orderTransaction.paymentType}`) }}
</template> </template>
...@@ -130,6 +132,7 @@ ...@@ -130,6 +132,7 @@
<template v-if="record.payType==='拍卖保证金'"> <template v-if="record.payType==='拍卖保证金'">
{{ record.payTime }} {{ record.payTime }}
</template> </template>
<template v-else-if="record.payType === '优惠券抵扣'">-</template>
<template v-else-if="orderTransaction"> <template v-else-if="orderTransaction">
{{ orderTransaction.createTime }} {{ orderTransaction.createTime }}
</template> </template>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<CustomizeForm ref="customizeFormRef" @submitSuccess="getTemplateData('0')" /> <CustomizeForm ref="customizeFormRef" @submitSuccess="getTemplateData('0')" />
</div> </div>
<div class="customizeFormBox" v-if="activeNodeId == -1"> <div class="customizeFormBox" v-if="activeNodeId == -1">
<TestingScore ref="testingScoreRef" /> <TestingScore ref="testingScoreRef" @submitSuccess="getTemplateData('0')" />
</div> </div>
</div> </div>
</template> </template>
...@@ -32,6 +32,7 @@ import { DetectionController } from "@/api/DetectionController"; ...@@ -32,6 +32,7 @@ import { DetectionController } from "@/api/DetectionController";
import { CheckCircleFilled } from '@ant-design/icons-vue' import { CheckCircleFilled } from '@ant-design/icons-vue'
import { TrackHelper } from "@/common/TrackHelper"; import { TrackHelper } from "@/common/TrackHelper";
import { Modal } from "ant-design-vue"; import { Modal } from "ant-design-vue";
import { applyResolvedInitialValuesToLeafNodes } from "@/views/detection/order/utils/inspectInitialValues";
@Component({ @Component({
...@@ -132,7 +133,10 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> { ...@@ -132,7 +133,10 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
} else { } else {
this.inspectionNodeList = nodeList; this.inspectionNodeList = nodeList;
} }
this.inspectionNodeList = this.inspectionNodeList.map(item => ({ ...item, childrenNodes: this.setDefaultData(item.childrenNodes || []) })); this.inspectionNodeList = this.inspectionNodeList.map(item => ({
...item,
childrenNodes: this.applyLeafDefaults(item.childrenNodes || []),
}));
this.$refs.customizeFormRef.init({ this.$refs.customizeFormRef.init({
customizeFormList: this.inspectionNodeList, customizeFormList: this.inspectionNodeList,
carTypeList: this.carTypeList, carTypeList: this.carTypeList,
...@@ -142,89 +146,39 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> { ...@@ -142,89 +146,39 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
}); });
} }
setDefaultData(list: any[] = []) { applyLeafDefaults(list: any[] = []) {
const typeToKeyMap = { const withDefaults = applyResolvedInitialValuesToLeafNodes(
text_input: 'valueText', list,
textarea_input: 'valueText', this.defaultData || {},
number_input: 'valueText', this.carTypeList || [],
date_picker: 'valueText', );
dropdown: 'valueKey', return this.mapNodeResultStatus(withDefaults);
radio_button_select: 'valueKey' }
};
// 节点名称 -> /inspectionTemplate/default 字段,按包含关系匹配
const matchers: { match: (n: string) => boolean; key: string }[] = [
{ match: n => n === '品牌', key: 'carBrand' },
{ match: n => n === '车系', key: 'carSeriesName' },
{ match: n => n === '车型', key: 'carTypeId' },
{ match: n => /车源/.test(n), key: 'sourceNo' },
{ match: n => /VIN|车架号/i.test(n), key: 'vin' },
{ match: n => /车牌/.test(n), key: 'licensePlate' },
{ match: n => /注册|登记/.test(n), key: 'registrationDate' },
{ match: n => /出厂|生产/.test(n), key: 'productionDate' },
{ match: n => /年检/.test(n), key: 'annualInspectionExpiry' },
{ match: n => /交强险/.test(n), key: 'compulsoryInsuranceExpiry' },
{ match: n => /排量/.test(n), key: 'displacement' },
{ match: n => /排放/.test(n), key: 'emissionStandard' },
{ match: n => /发动机/.test(n), key: 'engineNumber' },
{ match: n => /颜色/.test(n), key: 'exteriorColor' },
{ match: n => /钥匙/.test(n), key: 'keyCount' },
{ match: n => /里程/.test(n), key: 'mileage' },
{ match: n => /使用性质|营运/.test(n), key: 'usageType' },
];
const defaultList = list.map(item => {
const inspectionValueList = item?.inspectionResultVO?.inspectionValueList || [];
let value = null;
if (inspectionValueList.length > 0) {
const key = typeToKeyMap[item.interactionType];
if (key) value = inspectionValueList[0][key] || '';
}
if (value == null || value === '') { mapNodeResultStatus(nodes: any[] = []): any[] {
const hit = matchers.find(m => m.match(String(item.nodeName || ''))); return (nodes || []).map((item) => {
if (hit) { const mapped = {
const dv = this.defaultData?.[hit.key]; ...item,
if (dv != null && dv !== '') { resultStatus: item?.inspectionResultVO?.resultStatus == 3 ? true : false,
value = String(dv); };
// 下拉/单选:default 返回的是名称,需要换成 options 里的 id if (mapped.childrenNodes?.length) {
if (item.interactionType === 'dropdown' || item.interactionType === 'radio_button_select') { mapped.childrenNodes = this.mapNodeResultStatus(mapped.childrenNodes);
const optionsList = item.nodeName === '车型'
? this.carTypeList
: JSON.parse(item.options || '[]').map((s: string) => {
const parts = (s || '').split('-');
return { text: parts[1] || '', value: parts[0] || '' };
});
const opt = optionsList.find((o: any) => String(o.value) === value)
|| optionsList.find((o: any) => String(o.text) === value);
value = opt ? String(opt.value) : '';
}
}
}
} }
return { ...item, resultStatus: item?.inspectionResultVO?.resultStatus == 3 ? true : false, value }; return mapped;
}); });
return defaultList;
} }
handleNodeList(item: any) { handleNodeList(item: any) {
if (item.id == this.activeNodeId) return; if (item.id == this.activeNodeId) return;
if (this.hasCurrentTabRequiredUnfilled()) { Modal.confirm({
Modal.confirm({ title: '提示',
title: '提示', content: '当前一级类目下,存在必填检测项未完成,强制离开将丢失数据,请完成检查后切换tab或离开标签页。',
content: '当前一级类目下,存在必填检测项未完成,强制离开将丢失数据,请完成检查后切换tab或离开标签页。', okText: '强制离开',
okText: '强制离开', cancelText: '继续填写',
cancelText: '继续填写', onOk: () => {
onOk: () => { this.switchNode(item);
this.switchNode(item); },
}, });
});
return;
}
this.switchNode(item);
}
hasCurrentTabRequiredUnfilled(): boolean {
const ref: any = Number(this.activeNodeId) === -1 ? this.$refs.testingScoreRef : this.$refs.customizeFormRef;
return !!ref?.hasRequiredUnfilled?.();
} }
switchNode(item: any) { switchNode(item: any) {
......
...@@ -106,7 +106,8 @@ ...@@ -106,7 +106,8 @@
<a-button type="link" size="small">检测报告</a-button> <a-button type="link" size="small">检测报告</a-button>
</router-link> </router-link>
<router-link v-if="record.status != 3" <router-link
v-if="!((record.status == 3 && record.auditStatus == 3) || record.status == 4)"
:to="{ path: '/detection/order/edit', query: { id: record.id, page: 'order', action: 'EDIT' } }"> :to="{ path: '/detection/order/edit', query: { id: record.id, page: 'order', action: 'EDIT' } }">
<a-button type="link" size="small" @click="trackEnterEditMode(record)">编辑报告</a-button> <a-button type="link" size="small" @click="trackEnterEditMode(record)">编辑报告</a-button>
</router-link> </router-link>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-facing-decorator"; import { Component, Prop, Vue, Watch } from "vue-facing-decorator";
import { uploadFile } from "@/utils/upload.js"; import { uploadFile, isLikelyImageFile } from "@/utils/upload.js";
import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue"; import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
...@@ -89,10 +89,14 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue { ...@@ -89,10 +89,14 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue {
const file = input.files?.[0]; const file = input.files?.[0];
input.value = ""; input.value = "";
if (!file) return; if (!file) return;
if (!isLikelyImageFile(file)) {
return message.error("仅支持上传图片文件");
}
const maxSize10MB = 10 * 1024 * 1024; const maxSize10MB = 10 * 1024 * 1024;
const maxSize100MB = 100 * 1024 * 1024; const maxSize100MB = 100 * 1024 * 1024;
if ( if (
this.item.interactionType == "image_upload" && (this.item.interactionType == "image_upload" ||
this.item.interactionType == "image_upload_and_button_select") &&
file.size > maxSize10MB file.size > maxSize10MB
) { ) {
return message.error("文件大小不能超过10MB"); return message.error("文件大小不能超过10MB");
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue } from "vue-facing-decorator"; import { Component, Prop, Vue } from "vue-facing-decorator";
import { uploadFile } from "@/utils/upload.js"; import { uploadFile, isLikelyImageFile, isLikelyVideoFile } from "@/utils/upload.js";
import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue"; import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
...@@ -122,6 +122,15 @@ export default class CustomizeFormUploadFile extends Vue { ...@@ -122,6 +122,15 @@ export default class CustomizeFormUploadFile extends Vue {
const file = input.files?.[0]; const file = input.files?.[0];
input.value = ""; input.value = "";
if (!file) return; if (!file) return;
if (this.item.interactionType == "image_upload") {
if (!isLikelyImageFile(file)) {
return message.error("仅支持上传图片文件");
}
} else if (this.item.interactionType == "video_upload") {
if (!isLikelyVideoFile(file)) {
return message.error("仅支持上传视频文件");
}
}
const maxSize10MB = 10 * 1024 * 1024; const maxSize10MB = 10 * 1024 * 1024;
const maxSize100MB = 100 * 1024 * 1024; const maxSize100MB = 100 * 1024 * 1024;
if ( if (
......
...@@ -52,8 +52,22 @@ ...@@ -52,8 +52,22 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { DetectionController } from "@/api/DetectionController"; import { DetectionController } from "@/api/DetectionController";
import { CopyOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue";
import { h, type VNode } from "vue";
@Component({ components: {} }) function formatLogValue(value: unknown): string {
if (value == null || value === "") {
return "-";
}
return String(value);
}
function hasCopyableValue(value: unknown): boolean {
return value != null && String(value).trim() !== "";
}
@Component({ components: { CopyOutlined } })
export default class OperationLog extends Vue { export default class OperationLog extends Vue {
workOrderId: any = ""; workOrderId: any = "";
logList: any[] = []; logList: any[] = [];
...@@ -63,29 +77,57 @@ export default class OperationLog extends Vue { ...@@ -63,29 +77,57 @@ export default class OperationLog extends Vue {
loading = false; loading = false;
hasMore = true; hasMore = true;
detailColumns: any[] = [ detailColumns: any[] = [];
{
title: "变更项", created() {
dataIndex: "fieldLabel", this.detailColumns = this.buildDetailColumns();
key: "fieldLabel", }
width: 200,
ellipsis: true, buildDetailColumns() {
}, const renderCell = (text: unknown) => this.renderValueCell(text);
{ const valueColumn = (title: string, dataIndex: string, key: string) => ({
title: "变更前的值", title,
dataIndex: "beforeValue", dataIndex,
key: "beforeValue", key,
width: 280,
ellipsis: true,
},
{
title: "变更后的值",
dataIndex: "afterValue",
key: "afterValue",
width: 280, width: 280,
ellipsis: true, customRender: ({ text }: { text: unknown }) => renderCell(text),
}, });
]; return [
{
title: "变更项",
dataIndex: "fieldLabel",
key: "fieldLabel",
width: 200,
ellipsis: true,
},
valueColumn("变更前的值", "beforeValue", "beforeValue"),
valueColumn("变更后的值", "afterValue", "afterValue"),
];
}
renderValueCell = (value: unknown): VNode => {
const display = formatLogValue(value);
const children: VNode[] = [
h("span", { class: "op-log-value-text", title: display }, display),
];
if (hasCopyableValue(value)) {
children.push(
h(
"a",
{
class: "op-log-copy-btn",
onClick: (e: Event) => {
e.stopPropagation();
e.preventDefault();
void this.copyLogValue(value);
},
},
[h(CopyOutlined), " 复制"],
),
);
}
return h("div", { class: "op-log-value-cell" }, children);
};
isChangeLog(item: any) { isChangeLog(item: any) {
const type = Number(item?.operationType); const type = Number(item?.operationType);
...@@ -142,6 +184,19 @@ export default class OperationLog extends Vue { ...@@ -142,6 +184,19 @@ export default class OperationLog extends Vue {
if (!str) return ""; if (!str) return "";
return String(str).charAt(0); return String(str).charAt(0);
} }
async copyLogValue(value: unknown) {
const text = formatLogValue(value);
if (text === "-") {
return;
}
try {
await navigator.clipboard.writeText(text);
message.success("复制成功");
} catch {
message.error("复制失败");
}
}
} }
</script> </script>
...@@ -196,7 +251,7 @@ export default class OperationLog extends Vue { ...@@ -196,7 +251,7 @@ export default class OperationLog extends Vue {
.logBox-content { .logBox-content {
float: left; float: left;
width: 100%; max-width: 100%;
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
line-height: 20px; line-height: 20px;
...@@ -260,4 +315,43 @@ export default class OperationLog extends Vue { ...@@ -260,4 +315,43 @@ export default class OperationLog extends Vue {
.p-l-8 { .p-l-8 {
padding-left: 8px; padding-left: 8px;
} }
</style>
<style lang="less">
.op-log-detail-popover .op-log-detail-table .ant-table-cell {
vertical-align: middle;
}
.op-log-detail-popover .op-log-value-cell {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
padding-right: 4px;
}
.op-log-detail-popover .op-log-value-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding-right: 4px;
}
.op-log-detail-popover .op-log-copy-btn {
flex-shrink: 0;
margin-left: 4px;
padding-left: 12px;
font-size: 12px;
color: #1956fe;
white-space: nowrap;
cursor: pointer;
border-left: 1px solid #e8eaed;
}
.op-log-detail-popover .op-log-copy-btn:hover {
color: #0d3fd4;
}
</style> </style>
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
v-model:value="postData.exteriorScore" v-model:value="postData.exteriorScore"
:min="0" :min="0"
:max="100" :max="100"
:step="0.01"
:precision="2"
:controls="false" :controls="false"
class="score-value-input" class="score-value-input"
placeholder="请输入" placeholder="请输入"
...@@ -26,6 +28,7 @@ ...@@ -26,6 +28,7 @@
v-model:value="postData.exteriorScore" v-model:value="postData.exteriorScore"
:min="0" :min="0"
:max="100" :max="100"
:step="0.01"
/> />
</div> </div>
</div> </div>
...@@ -222,6 +225,8 @@ ...@@ -222,6 +225,8 @@
v-model:value="postData.overallScore" v-model:value="postData.overallScore"
:min="0" :min="0"
:max="200" :max="200"
:step="0.01"
:precision="2"
:controls="false" :controls="false"
class="score-value-input" class="score-value-input"
placeholder="请对车况做整体总结,如:车况良好,仅有正常使痕迹,无重大事故..." placeholder="请对车况做整体总结,如:车况良好,仅有正常使痕迹,无重大事故..."
...@@ -236,6 +241,7 @@ ...@@ -236,6 +241,7 @@
v-model:value="postData.overallScore" v-model:value="postData.overallScore"
:min="0" :min="0"
:max="100" :max="100"
:step="0.01"
/> />
</div> </div>
</div> </div>
...@@ -356,13 +362,13 @@ export default class TestingScore extends Vue { ...@@ -356,13 +362,13 @@ export default class TestingScore extends Vue {
postData = { postData = {
taskId: 0, taskId: 0,
exteriorScore: 0, exteriorScore: null as number | null,
exteriorComment: "", exteriorComment: "",
skeletonLevel: "", skeletonLevel: "",
skeletonComment: "", skeletonComment: "",
interiorLevel: "", interiorLevel: "",
interiorComment: "", interiorComment: "",
overallScore: 0, overallScore: null as number | null,
overallComment: "", overallComment: "",
}; };
...@@ -405,14 +411,26 @@ export default class TestingScore extends Vue { ...@@ -405,14 +411,26 @@ export default class TestingScore extends Vue {
return changed.filter((k) => !ignoreKeys.has(k)); return changed.filter((k) => !ignoreKeys.has(k));
} }
/** 评分为 0 视为已填写;仅 null / undefined / 空字符串 视为未填 */
isScoreFilled(value: unknown): boolean {
if (value === 0 || value === "0") {
return true;
}
if (value === null || value === undefined || value === "") {
return false;
}
const n = Number(value);
return !Number.isNaN(n);
}
hasRequiredUnfilled(): boolean { hasRequiredUnfilled(): boolean {
return !this.postData.exteriorScore return !this.isScoreFilled(this.postData.exteriorScore)
|| !this.postData.exteriorComment || !this.postData.exteriorComment
|| !this.postData.skeletonLevel || !this.postData.skeletonLevel
|| !this.postData.skeletonComment || !this.postData.skeletonComment
|| !this.postData.interiorLevel || !this.postData.interiorLevel
|| !this.postData.interiorComment || !this.postData.interiorComment
|| !this.postData.overallScore || !this.isScoreFilled(this.postData.overallScore)
|| !this.postData.overallComment; || !this.postData.overallComment;
} }
...@@ -452,7 +470,7 @@ export default class TestingScore extends Vue { ...@@ -452,7 +470,7 @@ export default class TestingScore extends Vue {
} }
submitForm() { submitForm() {
if (!this.postData.exteriorScore) { if (!this.isScoreFilled(this.postData.exteriorScore)) {
message.error("请输入外观评分"); message.error("请输入外观评分");
return; return;
} }
...@@ -476,7 +494,7 @@ export default class TestingScore extends Vue { ...@@ -476,7 +494,7 @@ export default class TestingScore extends Vue {
message.error("请查验车辆内饰相关部位和程度"); message.error("请查验车辆内饰相关部位和程度");
return; return;
} }
if (!this.postData.overallScore) { if (!this.isScoreFilled(this.postData.overallScore)) {
message.error("请输入综合评分"); message.error("请输入综合评分");
return; return;
} }
...@@ -497,6 +515,7 @@ export default class TestingScore extends Vue { ...@@ -497,6 +515,7 @@ export default class TestingScore extends Vue {
message.success(res.message || "保存成功"); message.success(res.message || "保存成功");
this.sendSaveTrack(modifiedFields); this.sendSaveTrack(modifiedFields);
this.snapshotInitialPostData(); this.snapshotInitialPostData();
this.$emit("submitSuccess", res);
} else { } else {
message.error(res.message || "保存失败"); message.error(res.message || "保存失败");
} }
......
import dayjs from "dayjs";
/** /inspectionTemplate/default 返回的模板默认值 */
export type TemplateDefaultData = Record<string, string | string[] | null | undefined>;
const SELECT_INTERACTION_TYPES = new Set([
"dropdown",
"radio_button_select",
"button_select",
]);
function isSelectInteractionType(interactionType: string): boolean {
return SELECT_INTERACTION_TYPES.has(interactionType);
}
function isLeafNode(node: Record<string, unknown>): boolean {
const children = node.childrenNodes as unknown[] | undefined;
return !children?.length;
}
/** 是否已有保存过的检测结果 */
export function hasSavedInspectionResult(node: Record<string, unknown>): boolean {
const list = (node.inspectionResultVO as { inspectionValueList?: unknown[] } | undefined)
?.inspectionValueList;
return Array.isArray(list) && list.length > 0;
}
/** 解析单条默认值字符串为 valueKey / valueText */
export function parseDefaultValueParts(
interactionType: string,
raw: string,
): { valueKey: string; valueText: string } {
if (isSelectInteractionType(interactionType) && raw.includes("-")) {
const idx = raw.indexOf("-");
return {
valueKey: raw.slice(0, idx),
valueText: raw.slice(idx + 1),
};
}
return { valueKey: "", valueText: raw };
}
function resolveApiDefaultKey(node: Record<string, unknown>): string {
return String(node.defaultField || node.nodeCode || "").trim();
}
function readTemplateDefaultRaw(
templateDefaultData: TemplateDefaultData,
apiKey: string,
): string | string[] | null | undefined {
if (!apiKey || !templateDefaultData) {
return undefined;
}
if (templateDefaultData[apiKey] != null) {
return templateDefaultData[apiKey];
}
return undefined;
}
function rawToValueTexts(raw: string | string[] | null | undefined): string[] {
if (raw == null) {
return [];
}
if (Array.isArray(raw)) {
return raw.map((item) => String(item)).filter((s) => s !== "");
}
const s = String(raw);
return s !== "" ? [s] : [];
}
/**
* 按节点配置与 templateDefaultData 解析默认值字符串列表(未写入 inspectionResultVO)
*/
export function resolveDefaultValueTexts(
node: Record<string, unknown>,
templateDefaultData: TemplateDefaultData,
): string[] {
if (String(node.existsDefaultValue ?? "") !== "1") {
return [];
}
const defaultType =
node.defaultType != null && node.defaultType !== ""
? Number(node.defaultType)
: null;
if (defaultType === 3) {
return [];
}
if (
defaultType === 1 &&
node.defaultValue != null &&
node.defaultValue !== ""
) {
return [String(node.defaultValue)];
}
// defaultType=2,或未配置 type、或 type=1 但无固定值:从接口 Map 按 nodeCode/defaultField 取值
const apiKey = resolveApiDefaultKey(node);
const apiTexts = rawToValueTexts(
readTemplateDefaultRaw(templateDefaultData, apiKey),
);
if (apiTexts.length) {
return apiTexts;
}
if (node.defaultValue != null && node.defaultValue !== "") {
return [String(node.defaultValue)];
}
return [];
}
function normalizeDatePickerValue(
node: Record<string, unknown>,
raw: string,
): string {
if (String(node.interactionType ?? "") !== "date_picker" || !raw) {
return raw;
}
const parsed = dayjs(raw);
if (!parsed.isValid()) {
return raw;
}
try {
const rules = JSON.parse(String(node.validationRules || "{}"));
const pattern = String(rules.datePattern || "");
if (pattern.length > 8) {
return parsed.format("YYYY-MM-DD");
}
return parsed.format("YYYY-MM");
} catch {
return parsed.format("YYYY-MM-DD");
}
}
function buildInspectionValueEntry(
node: Record<string, unknown>,
raw: string,
valueSeq: number,
): Record<string, unknown> {
const normalized = normalizeDatePickerValue(node, raw);
const { valueKey, valueText } = parseDefaultValueParts(
String(node.interactionType ?? ""),
normalized,
);
return {
valueKey,
valueText,
interactionType: node.interactionType,
valueSeq,
};
}
function resolveDropdownFormValue(
node: Record<string, unknown>,
valueKey: string,
valueText: string,
carTypeList: { text: string; value: string }[],
): string {
if (valueKey) {
return valueKey;
}
const options =
node.nodeName === "车型"
? carTypeList
: JSON.parse(String(node.options || "[]")).map((s: string) => {
const parts = (s || "").split("-");
return { text: parts[1] || "", value: parts[0] || "" };
});
const opt =
options.find((o: { value: string }) => String(o.value) === valueText) ||
options.find((o: { text: string }) => String(o.text) === valueText);
return opt ? String(opt.value) : "";
}
/** 将 inspectionResultVO 同步到表单字段 item.value 等 */
export function syncLeafNodeFormValue(
node: Record<string, unknown>,
carTypeList: { text: string; value: string }[] = [],
): void {
const list =
((node.inspectionResultVO as { inspectionValueList?: Record<string, unknown>[] } | undefined)
?.inspectionValueList) || [];
if (!list.length) {
return;
}
const interactionType = String(node.interactionType ?? "");
if (interactionType === "dropdown" || interactionType === "radio_button_select") {
const first = list[0];
const valueKey = String(first.valueKey ?? "");
const valueText = String(first.valueText ?? "");
node.valueKey = valueKey;
node.valueText = valueText;
node.value = valueKey || resolveDropdownFormValue(node, valueKey, valueText, carTypeList);
return;
}
if (interactionType === "button_select") {
const entries = list.map((entry) => ({
valueKey: String(entry.valueKey ?? ""),
valueText: String(entry.valueText ?? ""),
}));
node.value = entries.length > 0 ? JSON.stringify(entries) : "";
return;
}
const text = normalizeDatePickerValue(node, String(list[0].valueText ?? ""));
if (text !== "") {
node.value = text;
}
}
function applyDefaultsToSingleLeaf(
node: Record<string, unknown>,
templateDefaultData: TemplateDefaultData,
carTypeList: { text: string; value: string }[] = [],
): Record<string, unknown> {
const next = { ...node };
if (hasSavedInspectionResult(next)) {
syncLeafNodeFormValue(next, carTypeList);
return next;
}
const valueTexts = resolveDefaultValueTexts(next, templateDefaultData);
if (!valueTexts.length) {
syncLeafNodeFormValue(next, carTypeList);
return next;
}
const inspectionValueList = valueTexts.map((raw, index) =>
buildInspectionValueEntry(next, raw, index + 1),
);
const resolvedInitialValue = inspectionValueList
.map((entry) => String(entry.valueText ?? ""))
.filter((text) => text !== "")
.join(", ");
next.inspectionResultVO = {
...(typeof next.inspectionResultVO === "object" && next.inspectionResultVO
? next.inspectionResultVO
: {}),
inspectionValueList,
};
next.resolvedInitialValue = resolvedInitialValue;
const interactionType = String(next.interactionType ?? "");
if (interactionType === "dropdown" || interactionType === "radio_button_select") {
const first = inspectionValueList[0];
const valueKey = String(first.valueKey ?? "");
const valueText = String(first.valueText ?? "");
next.valueKey = valueKey;
next.valueText = valueText;
next.value =
valueKey || resolveDropdownFormValue(next, valueKey, valueText, carTypeList);
} else if (interactionType === "button_select") {
const entries = inspectionValueList.map((entry) => ({
valueKey: String(entry.valueKey ?? ""),
valueText: String(entry.valueText ?? ""),
}));
next.value = JSON.stringify(entries);
} else {
next.value = normalizeDatePickerValue(
next,
String(inspectionValueList[0].valueText ?? ""),
);
}
return next;
}
/**
* 递归对叶子节点应用解析后的默认值(分组节点会向下遍历 childrenNodes)
*/
export function applyResolvedInitialValuesToLeafNodes(
nodes: Record<string, unknown>[],
templateDefaultData: TemplateDefaultData,
carTypeList: { text: string; value: string }[] = [],
): Record<string, unknown>[] {
return (nodes || []).map((node) => {
if (!isLeafNode(node)) {
const children = (node.childrenNodes as Record<string, unknown>[]) || [];
return {
...node,
childrenNodes: applyResolvedInitialValuesToLeafNodes(
children,
templateDefaultData,
carTypeList,
),
};
}
return applyDefaultsToSingleLeaf(node, templateDefaultData, carTypeList);
});
}
...@@ -66,6 +66,12 @@ export default class DetectionTemplatePage extends PaginationComponent<Inspectio ...@@ -66,6 +66,12 @@ export default class DetectionTemplatePage extends PaginationComponent<Inspectio
}, },
}, },
{ {
title: "模板ID",
dataIndex: "templateCode",
key: "templateCode",
align: "center",
},
{
title: "模板名称", title: "模板名称",
dataIndex: "templateName", dataIndex: "templateName",
key: "templateName", key: "templateName",
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
<!--查询栏--> <!--查询栏-->
<m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm" <m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm"
@onSearch="handlePageReload" @onReset="handleReset" :simpleFieldNum="4"></m-pagination-query-render> @onSearch="handlePageReload" @onReset="handleReset" :simpleFieldNum="4">
<template #couponTemplateId="{ record }">
<a-input v-model:value="pagination.queryForm.couponTemplateId" @input="handleIntNativeInput($event)" placeholder="输入优惠券ID"></a-input>
</template>
</m-pagination-query-render>
<!--查询栏end--> <!--查询栏end-->
<div class="table-operations" style="margin-bottom: 16px;width: 100%;float: left;"> <div class="table-operations" style="margin-bottom: 16px;width: 100%;float: left;">
...@@ -169,25 +173,26 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> { ...@@ -169,25 +173,26 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
created(): void { created(): void {
this.init(this.axios, DiscountController.PAGE_COUPON_ACTIVITY); this.init(this.axios, DiscountController.PAGE_COUPON_ACTIVITY);
const pageQuery = this.$route.query const pageQuery = this.$route.query
// 从优惠券管理列表跳转 直接打开活动详情
if (pageQuery?.activityId) {
this.$nextTick(() => {
this.handleAdd({ id: pageQuery.activityId, pageState: "VIEW" });
this.$router.replace({ query: { ...this.$route.query, activityId: undefined } })
})
}
this.buildQueryForm({ this.buildQueryForm({
keyword: [null, { label: '活动名称/ID', field: 'keyword', placeholder: '请输入活动名称/ID', operator: Operator.like }], keyword: [null, { label: '活动名称/ID', field: 'keyword', placeholder: '请输入活动名称/ID', operator: Operator.like }],
status: [null, { label: '活动状态', field: 'status', type: 'select', allowClear: true, optionItems: this.statusList, operator: Operator.eq }], status: [null, { label: '活动状态', field: 'status', type: 'select', allowClear: true, optionItems: this.statusList, operator: Operator.eq }],
activityType: [null, { label: '发放策略', type: 'select', optionItems: this.activityTypeList, allowClear: true, field: 'activityType', operator: Operator.eq }], activityType: [null, { label: '发放策略', type: 'select', optionItems: this.activityTypeList, allowClear: true, field: 'activityType', operator: Operator.eq }],
createTime: [null, { label: '创建时间', field: 'createTime', operator: Operator.dateBetween, type: 'date-range' }], validTime: [null, { label: '活动有效期', field: 'validTime', operator: Operator.dateBetween, type: 'date-range' }],
couponTemplateId: [this.$route.query.couponTemplateId ?? null, { name: 'couponTemplateId', label: '优惠券模板ID', type: 'slot', field: 'couponTemplateId', placeholder: '输入优惠券模板ID', operator: Operator.eq }]
}); });
this.pagination.setDefaultSort('createTime', Order.desc); this.pagination.setDefaultSort('createTime', Order.desc);
// 从优惠券管理列表跳转 直接打开活动详情
if (pageQuery?.activityId) {
this.$nextTick(() => {
this.handleAdd({ id: pageQuery.activityId, pageState: "VIEW" });
this.$router.replace({ query: { ...this.$route.query, activityId: undefined, couponTemplateId: undefined } })
})
}
this.pageLoad(); this.pageLoad();
} }
//查询 //查询
handlePageReload() { handlePageReload() {
this.pageReload(); this.pageReload();
} }
......
...@@ -208,7 +208,8 @@ import { EyeOutlined } from "@ant-design/icons-vue"; ...@@ -208,7 +208,8 @@ import { EyeOutlined } from "@ant-design/icons-vue";
import { ModalService } from "@/components/ModalService"; import { ModalService } from "@/components/ModalService";
import { AgreementController } from "@/api/AgreementController"; import { AgreementController } from "@/api/AgreementController";
import { DiscountController } from "@/api/DiscountController"; import { DiscountController } from "@/api/DiscountController";
import { formatDate, parseDate } from "lib/src/utils/DateTimeUtils"; import { formatDate } from "lib/src/utils/DateTimeUtils";
import dayjs from "dayjs";
import { COMMISSION_RULE_APPLICABLE_TYPES, CommissionRule } from "lib/src/entity/account/entity/CommissionRule"; import { COMMISSION_RULE_APPLICABLE_TYPES, CommissionRule } from "lib/src/entity/account/entity/CommissionRule";
import AccountPicker from "@/views/account/account/AccountPicker.vue"; import AccountPicker from "@/views/account/account/AccountPicker.vue";
import {AccountTag} from "lib/src/entity/account/entity/AccountTag"; import {AccountTag} from "lib/src/entity/account/entity/AccountTag";
...@@ -257,6 +258,11 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> { ...@@ -257,6 +258,11 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
tags: AccountTag[] = []; tags: AccountTag[] = [];
parseDateValue(date: any) {
if (date === null || date === undefined || date === "") return undefined as any;
return dayjs(String(date).slice(0, 10), "YYYY-MM-DD");
}
get isViewMode() { get isViewMode() {
return this.pageState === "VIEW"; return this.pageState === "VIEW";
} }
...@@ -407,18 +413,27 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> { ...@@ -407,18 +413,27 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
]; ];
} }
handlePositiveIntNativeInput(index: number, field: "priceMin" | "priceMax", e: any) { handlePositiveIntNativeInput(index: number, field: "priceMin" | "priceMax", event: any) {
const raw = e?.target?.value ?? ""; const inputEl = event?.target as undefined | HTMLInputElement;
const next = String(raw).replace(/[^\d]/g, "").replace(/^0+/, ""); const raw = inputEl ? String(inputEl.value ?? "") : String(event ?? "");
const next = this.sanitizeIntText(raw);
if (inputEl && inputEl.value !== next) inputEl.value = next;
if (this.postData.priceRanges?.[index]) { if (this.postData.priceRanges?.[index]) {
this.postData.priceRanges[index][field] = next; this.postData.priceRanges[index][field] = next;
} }
this.scheduleClearPriceRangeValidate(); this.scheduleClearPriceRangeValidate();
} }
handlePerUserQuantityInput(e: any) { sanitizeIntText(raw: string) {
const raw = e?.target?.value ?? ""; return raw.replace(/[^\d]/g, "").slice(0, 7);
this.postData.distributionQuantity = String(raw).replace(/[^\d]/g, "").replace(/^0+/, "") || ""; }
handlePerUserQuantityInput(event: any) {
const inputEl = event?.target as undefined | HTMLInputElement;
const raw = inputEl ? String(inputEl.value ?? "") : String(event ?? "");
const next = this.sanitizeIntText(raw);
if (inputEl && inputEl.value !== next) inputEl.value = next;
this.postData.distributionQuantity = next;
} }
getCouponBrief(templateId: any) { getCouponBrief(templateId: any) {
...@@ -486,7 +501,7 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> { ...@@ -486,7 +501,7 @@ export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
if (responseData) { if (responseData) {
responseData = { responseData = {
...responseData, ...responseData,
activityRange: responseData.validStartTime && responseData.validEndTime ? [parseDate(responseData.validStartTime), parseDate(responseData.validEndTime)] : [], activityRange: responseData.validStartTime && responseData.validEndTime ? [this.parseDateValue(responseData.validStartTime), this.parseDateValue(responseData.validEndTime)] : [],
applicableType: responseData?.targetType == 1 ? 'ALL' : responseData?.targetType == 2 ? 'ACCOUNT' : 'TAG', applicableType: responseData?.targetType == 1 ? 'ALL' : responseData?.targetType == 2 ? 'ACCOUNT' : 'TAG',
activityName: this.pageState === "COPY" ? `${responseData.activityName}_副本` : responseData.activityName, activityName: this.pageState === "COPY" ? `${responseData.activityName}_副本` : responseData.activityName,
accountTags: responseData?.tagIds || [], accountTags: responseData?.tagIds || [],
......
...@@ -44,11 +44,11 @@ ...@@ -44,11 +44,11 @@
<template v-if="column.key === 'relatedActivities'"> <template v-if="column.key === 'relatedActivities'">
<div v-if="record.relatedActivities && record.relatedActivities.length === 1"> <div v-if="record.relatedActivities && record.relatedActivities.length === 1">
<a-tooltip :title="record.relatedActivities[0].activityName"> <a-tooltip :title="record.relatedActivities[0].activityName">
<a class="text_hide" style="text-decoration: underline;display: inline-block;width: 160px;" :href="`#/discount/activity?activityId=${record.relatedActivities[0].id}`" target="_blank">{{ record.relatedActivities[0].activityName }}</a> <a class="text_hide" style="text-decoration: underline;display: inline-block;width: 160px;" :href="`#/discount/activity?activityId=${record.relatedActivities[0].id}&couponTemplateId=${record.templateId}`" target="_blank">{{ record.relatedActivities[0].activityName }}</a>
</a-tooltip> </a-tooltip>
</div> </div>
<div v-else-if="record.relatedActivities && record.relatedActivities.length > 1"> <div v-else-if="record.relatedActivities && record.relatedActivities.length > 1">
<a style="text-decoration: underline;" :href="`#/discount/activity?activityId=${record.relatedActivities[0].id}`" target="_blank">关联{{ record.relatedActivities.length }}个活动</a> <a style="text-decoration: underline;" :href="`#/discount/activity?activityId=${record.relatedActivities[0].id}&couponTemplateId=${record.templateId}`" target="_blank">关联{{ record.relatedActivities.length }}个活动</a>
</div> </div>
<div v-else>-</div> <div v-else>-</div>
</template> </template>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</a-tag> </a-tag>
</template> </template>
<template v-if="column.key === 'totalQuantity'"> <template v-if="column.key === 'totalQuantity'">
{{ (record.totalQuantity ?? '') === '' ? '不限制' : record.totalQuantity }} {{ (record.totalQuantity ?? '') === '' ? '不限制' : `${record.totalQuantity - (record.remainingQuantity || 0)}/${record.totalQuantity}` }}
</template> </template>
<template v-if="column.key === 'remark'"> <template v-if="column.key === 'remark'">
<a-tooltip :title="record.remark"> <a-tooltip :title="record.remark">
...@@ -152,7 +152,7 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> { ...@@ -152,7 +152,7 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
{ title: '抵扣类型', dataIndex: 'deductionType', key: 'deductionType', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '抵扣类型', dataIndex: 'deductionType', key: 'deductionType', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '面额/最高抵扣(元)', dataIndex: 'faceAmount', key: 'faceAmount', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '面额/最高抵扣(元)', dataIndex: 'faceAmount', key: 'faceAmount', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '关联活动数', dataIndex: 'relatedActivities', key: 'relatedActivities', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '关联活动数', dataIndex: 'relatedActivities', key: 'relatedActivities', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '发放总量', dataIndex: 'totalQuantity', key: 'totalQuantity', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '已发放/发放总量', dataIndex: 'totalQuantity', key: 'totalQuantity', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '备注', dataIndex: 'remark', key: 'remark', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '备注', dataIndex: 'remark', key: 'remark', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '状态', dataIndex: 'status', key: 'status', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '状态', dataIndex: 'status', key: 'status', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '创建/更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'left', width: 170, resizable: true, ellipsis: true }, { title: '创建/更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'left', width: 170, resizable: true, ellipsis: true },
......
...@@ -164,7 +164,8 @@ import { Component, Watch } from "vue-facing-decorator"; ...@@ -164,7 +164,8 @@ import { Component, Watch } from "vue-facing-decorator";
import { EnhanceFormComponent } from "@/core/form/EnhanceFormComponent"; import { EnhanceFormComponent } from "@/core/form/EnhanceFormComponent";
import { message, Modal } from "ant-design-vue"; import { message, Modal } from "ant-design-vue";
import TitleDivider from "@/components/TitleDivider.vue"; import TitleDivider from "@/components/TitleDivider.vue";
import { formatDate, parseDate } from "lib/src/utils/DateTimeUtils"; import { formatDate } from "lib/src/utils/DateTimeUtils";
import dayjs from "dayjs";
import { CloseOutlined, InfoCircleFilled } from "@ant-design/icons-vue"; import { CloseOutlined, InfoCircleFilled } from "@ant-design/icons-vue";
import { DiscountController } from "@/api/DiscountController"; import { DiscountController } from "@/api/DiscountController";
@Component({ @Component({
...@@ -202,6 +203,11 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -202,6 +203,11 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
remark: "", remark: "",
} }
parseDateValue(date: any) {
if (date === null || date === undefined || date === "") return undefined as any;
return dayjs(String(date).slice(0, 10), "YYYY-MM-DD");
}
init(data): void { init(data): void {
this.postData = JSON.parse(JSON.stringify(this.initPostData)); this.postData = JSON.parse(JSON.stringify(this.initPostData));
this.pageState = data.pageState === "VIEW" ? "VIEW" : (data.pageState === "ADD" ? "ADD" : "EDIT"); this.pageState = data.pageState === "VIEW" ? "VIEW" : (data.pageState === "ADD" ? "ADD" : "EDIT");
...@@ -212,7 +218,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -212,7 +218,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
if (responseData) { if (responseData) {
responseData.totalQuantityType = (responseData.totalQuantity ?? '') === '' ? 1 : 2 responseData.totalQuantityType = (responseData.totalQuantity ?? '') === '' ? 1 : 2
if (responseData.validStartTime && responseData.validEndTime) { if (responseData.validStartTime && responseData.validEndTime) {
responseData.validityRange = [parseDate(responseData.validStartTime), parseDate(responseData.validEndTime)]; responseData.validityRange = [this.parseDateValue(responseData.validStartTime), this.parseDateValue(responseData.validEndTime)];
} else if (responseData.delayDays !== undefined || responseData.validDays !== undefined) { } else if (responseData.delayDays !== undefined || responseData.validDays !== undefined) {
responseData.delayDays = String(responseData.delayDays ?? ""); responseData.delayDays = String(responseData.delayDays ?? "");
responseData.validDays = String(responseData.validDays ?? ""); responseData.validDays = String(responseData.validDays ?? "");
...@@ -225,6 +231,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -225,6 +231,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
})); }));
} }
} }
console.log("responseData", responseData);
this.postData = responseData this.postData = responseData
}) })
} }
...@@ -283,8 +290,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -283,8 +290,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
const num = typeof value === "number" ? value : Number(value); const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入展示面额")); if (!Number.isFinite(num)) return Promise.reject(new Error("请输入展示面额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数")); if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
return Promise.resolve(); return Promise.resolve();
}, },
}, },
...@@ -350,16 +355,16 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -350,16 +355,16 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
} }
sanitizeIntText(raw: string) { sanitizeIntText(raw: string) {
return raw.replace(/[^\d]/g, ""); return raw.replace(/[^\d]/g, "").slice(0, 7);
} }
sanitizeDecimalText(raw: string, decimalScale = 2) { sanitizeDecimalText(raw: string, decimalScale = 2) {
const cleaned = raw.replace(/[^\d.]/g, ""); const cleaned = raw.replace(/[^\d.]/g, "");
if (!cleaned) return ""; if (!cleaned) return "";
const firstDot = cleaned.indexOf("."); const firstDot = cleaned.indexOf(".");
if (firstDot === -1) return cleaned; if (firstDot === -1) return cleaned?.slice(0, 7);
const intPart = cleaned.slice(0, firstDot); const intPart = cleaned.slice(0, firstDot).slice(0, 7);
let fracPart = cleaned.slice(firstDot + 1).replace(/\./g, ""); let fracPart = cleaned.slice(firstDot + 1).replace(/\./g, "");
fracPart = fracPart.slice(0, decimalScale); fracPart = fracPart.slice(0, decimalScale);
const nextInt = intPart === "" ? "0" : intPart; const nextInt = intPart === "" ? "0" : intPart;
...@@ -432,8 +437,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -432,8 +437,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
const num = typeof value === "number" ? value : Number(value); const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入券面额")); if (!Number.isFinite(num)) return Promise.reject(new Error("请输入券面额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数")); if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
return Promise.resolve(); return Promise.resolve();
}, },
}, },
...@@ -453,8 +456,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -453,8 +456,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
const num = typeof value === "number" ? value : Number(value); const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入使用门槛")); if (!Number.isFinite(num)) return Promise.reject(new Error("请输入使用门槛"));
if (num < 0) return Promise.reject(new Error("必须为非负数")); if (num < 0) return Promise.reject(new Error("必须为非负数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
return Promise.resolve(); return Promise.resolve();
}, },
}, },
...@@ -469,9 +470,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -469,9 +470,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入中拍价门槛")); if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入中拍价门槛"));
const num = typeof value === "number" ? value : Number(value); const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入中拍价门槛")); if (!Number.isFinite(num)) return Promise.reject(new Error("请输入中拍价门槛"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数")); if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));;
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
const prev = this.postData.tierRules[index - 1]?.thresholdAmount; const prev = this.postData.tierRules[index - 1]?.thresholdAmount;
const prevNum = typeof prev === "number" ? prev : Number(prev); const prevNum = typeof prev === "number" ? prev : Number(prev);
...@@ -493,8 +492,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -493,8 +492,6 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
const num = typeof value === "number" ? value : Number(value); const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入抵扣金额")); if (!Number.isFinite(num)) return Promise.reject(new Error("请输入抵扣金额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数")); if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
const threshold = this.postData.tierRules[index]?.thresholdAmount; const threshold = this.postData.tierRules[index]?.thresholdAmount;
const thresholdNum = typeof threshold === "number" ? threshold : Number(threshold); const thresholdNum = typeof threshold === "number" ? threshold : Number(threshold);
...@@ -553,6 +550,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -553,6 +550,7 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
this.submitted = true; this.submitted = true;
const payload = this.buildSubmitPayload(); const payload = this.buildSubmitPayload();
DiscountController[this.pageState === 'EDIT' ? 'editCouponTemplate' : 'createCouponTemplate'](this.axios, payload).then(res => { DiscountController[this.pageState === 'EDIT' ? 'editCouponTemplate' : 'createCouponTemplate'](this.axios, payload).then(res => {
this.submitted = false;
let { code, message: msg } = res?.data || {}; let { code, message: msg } = res?.data || {};
if (code !== '200') { if (code !== '200') {
message.error(msg || (this.pageState === 'EDIT' ? '更新失败' : '创建失败')); message.error(msg || (this.pageState === 'EDIT' ? '更新失败' : '创建失败'));
...@@ -561,6 +559,8 @@ export default class CouponAddForm extends EnhanceFormComponent<any> { ...@@ -561,6 +559,8 @@ export default class CouponAddForm extends EnhanceFormComponent<any> {
message.success(this.postData.templateId ? "更新成功" : "创建成功"); message.success(this.postData.templateId ? "更新成功" : "创建成功");
this.$emit("emitOk", payload); this.$emit("emitOk", payload);
this.dialogVisible = false; this.dialogVisible = false;
}).catch(() => {
this.submitted = false;
}) })
} }
......
...@@ -88,7 +88,11 @@ ...@@ -88,7 +88,11 @@
<!--查询栏--> <!--查询栏-->
<m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm" <m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm"
@onSearch="handlePageReload" @onReset="handleReset" :simpleFieldNum="4"></m-pagination-query-render> @onSearch="handlePageReload" @onReset="handleReset" :simpleFieldNum="4">
<template #couponTemplateId="{ record }">
<a-input v-model:value="pagination.queryForm.couponTemplateId" @input="handleIntNativeInput($event)" placeholder="输入优惠券ID"></a-input>
</template>
</m-pagination-query-render>
<div class="table-operations" style="margin-bottom: 16px;width: 100%;float: left;"> <div class="table-operations" style="margin-bottom: 16px;width: 100%;float: left;">
<div class="flex justify-end" style="float: left;"> <div class="flex justify-end" style="float: left;">
...@@ -251,6 +255,8 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> { ...@@ -251,6 +255,8 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
distributionType: [null, { label: '发放类型', type: 'select', optionItems: this.distributionTypeList, allowClear: true, field: 'distributionType', operator: Operator.eq }], distributionType: [null, { label: '发放类型', type: 'select', optionItems: this.distributionTypeList, allowClear: true, field: 'distributionType', operator: Operator.eq }],
orderCode: [null, { label: '关联订单号', field: 'orderCode', placeholder: '输入订单号', operator: Operator.like }], orderCode: [null, { label: '关联订单号', field: 'orderCode', placeholder: '输入订单号', operator: Operator.like }],
distributionTime: [null, { label: '发放时间', field: 'distributionTime', operator: Operator.dateBetween, type: 'date-range' }], distributionTime: [null, { label: '发放时间', field: 'distributionTime', operator: Operator.dateBetween, type: 'date-range' }],
templateName: [null, { label: '优惠券名称', field: 'templateName', placeholder: '输入优惠券名称', operator: Operator.like }],
couponTemplateId: [null, { name: 'couponTemplateId', label: '优惠券模板ID', type: 'slot', field: 'couponTemplateId', placeholder: '输入优惠券模板ID', operator: Operator.eq }]
}); });
const pageQuery = this.$route.query const pageQuery = this.$route.query
// 从优惠券管理列表跳转 直接打开活动详情 // 从优惠券管理列表跳转 直接打开活动详情
...@@ -270,7 +276,19 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> { ...@@ -270,7 +276,19 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
this.selectIds = [] this.selectIds = []
this.selectedItems = []; this.selectedItems = [];
this.pageReload(); this.pageReload();
} }
handleIntNativeInput(event: any) {
const inputEl = event?.target as undefined | HTMLInputElement;
const raw = inputEl ? String(inputEl.value ?? "") : String(event ?? "");
const next = this.sanitizeIntText(raw);
if (inputEl && inputEl.value !== next) inputEl.value = next;
this.pagination.queryForm.couponTemplateId = next;
}
sanitizeIntText(text: string): string {
return text.slice(0, 30)
}
//重置查询条件 //重置查询条件
handleReset() { handleReset() {
......
import {loadEnv, UserConfig} from "vite"; import {loadEnv, Plugin, UserConfig} from "vite";
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import {fileURLToPath, URL} from 'node:url'; import {fileURLToPath, URL} from 'node:url';
import { version } from './package.json'; import { version } from './package.json';
...@@ -23,7 +23,8 @@ export default ({ command, mode }): UserConfig => { ...@@ -23,7 +23,8 @@ export default ({ command, mode }): UserConfig => {
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url))
} },
dedupe: ['dayjs']
}, },
server: { server: {
hmr: { hmr: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!