feat: 2.1.0

1. 针对groupName添加正则表达式限制
This commit is contained in:
byteblogs168 2023-07-17 23:36:15 +08:00
parent 0afc0b489f
commit 9fbaa7fc24
16 changed files with 53 additions and 653 deletions

View File

@ -37,7 +37,7 @@ public class MyBatisPlusConfig {
if (!TABLES.contains(tableName)) {
return tableName;
}
Integer partition = RequestDataHelper.getRequestData("partition");
Integer partition = RequestDataHelper.getPartition();
RequestDataHelper.remove();
return tableName + "_"+ partition;
});

View File

@ -22,6 +22,7 @@ public class RequestDataHelper {
* 请求参数存取
*/
private static final ThreadLocal<Map<String, Object>> REQUEST_DATA = new ThreadLocal<>();
private static final String PARTITION = "group-partition";
/**
* 设置请求参数
@ -40,7 +41,7 @@ public class RequestDataHelper {
public static void setPartition(int partition) {
Map<String, Object> map = new HashMap<>();
map.put("partition", partition);
map.put(PARTITION, partition);
RequestDataHelper.setRequestData(map);
}
@ -91,6 +92,16 @@ public class RequestDataHelper {
return REQUEST_DATA.get();
}
public static Integer getPartition() {
Map<String, Object> requestData = getRequestData();
if (CollectionUtils.isEmpty(requestData)) {
return null;
}
return (Integer) requestData.get(PARTITION);
}
public static void remove() {
REQUEST_DATA.remove();

View File

@ -13,6 +13,6 @@ public interface RetryTaskMapper extends BaseMapper<RetryTask> {
int countAllRetryTaskByRetryStatus(@Param("partition") Integer partition,
@Param("retryStatus") Integer retryStatus);
int batchInsert(List<RetryTask> list);
int batchInsert(@Param("list") List<RetryTask> list, @Param("partition") Integer partition);
}

View File

@ -2,15 +2,14 @@ package com.aizuda.easy.retry.server.server.handler;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.net.url.UrlQuery;
import com.aizuda.easy.retry.common.core.log.LogUtils;
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
import com.aizuda.easy.retry.common.core.model.NettyResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.easy.retry.server.enums.StatusEnum;
import com.aizuda.easy.retry.server.enums.TaskGeneratorScene;
import com.aizuda.easy.retry.server.exception.EasyRetryServerException;
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
import com.aizuda.easy.retry.server.service.RetryService;
import com.aizuda.easy.retry.server.enums.StatusEnum;
import com.aizuda.easy.retry.common.core.log.LogUtils;
import com.aizuda.easy.retry.common.core.model.NettyResult;
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.easy.retry.server.service.convert.TaskContextConverter;
import com.aizuda.easy.retry.server.support.generator.TaskGenerator;
import com.aizuda.easy.retry.server.support.generator.task.TaskContext;
@ -19,6 +18,7 @@ import io.netty.handler.codec.http.HttpMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@ -52,6 +52,7 @@ public class ReportRetryInfoHttpRequestHandler extends PostHttpRequestHandler {
}
@Override
@Transactional
public String doHandler(String content, UrlQuery urlQuery, HttpHeaders headers) {
LogUtils.info(log, "Batch Report Retry Data. content:[{}]", content);

View File

@ -68,6 +68,7 @@ public abstract class AbstractGenerator implements TaskGenerator {
Set<String> idempotentIdSet = taskInfos.stream().map(TaskContext.TaskInfo::getIdempotentId).collect(Collectors.toSet());
// 获取相关的任务用户幂等校验
RequestDataHelper.setPartition(taskContext.getGroupName());
List<RetryTask> retryTasks = retryTaskMapper.selectList(new LambdaQueryWrapper<RetryTask>()
.eq(RetryTask::getGroupName, taskContext.getGroupName())
.eq(RetryTask::getSceneName, taskContext.getSceneName())
@ -84,8 +85,12 @@ public abstract class AbstractGenerator implements TaskGenerator {
waitInsertTaskLogs.addAll(pair.getValue());
}
if (CollectionUtils.isEmpty(waitInsertTasks)) {
return;
}
RequestDataHelper.setPartition(taskContext.getGroupName());
Assert.isTrue(waitInsertTasks.size() == retryTaskMapper.batchInsert(waitInsertTasks), () -> new EasyRetryServerException("failed to report data"));
Assert.isTrue(waitInsertTasks.size() == retryTaskMapper.batchInsert(waitInsertTasks, RequestDataHelper.getPartition()), () -> new EasyRetryServerException("failed to report data"));
Assert.isTrue(waitInsertTaskLogs.size() == retryTaskLogMapper.batchInsert(waitInsertTaskLogs),
() -> new EasyRetryServerException("新增重试日志失败"));
}
@ -102,7 +107,7 @@ public abstract class AbstractGenerator implements TaskGenerator {
List<RetryTaskLog> waitInsertTaskLogs = new ArrayList<>();
// 判断是否存在与幂等ID相同的任务
List<RetryTask> list = retryTaskMap.get(taskInfo.getIdempotentId()).stream()
List<RetryTask> list = retryTaskMap.getOrDefault(taskInfo.getIdempotentId(), new ArrayList<>()).stream()
.filter(retryTask -> taskContext.getGroupName().equals(retryTask.getGroupName())
&& taskContext.getSceneName().equals(retryTask.getSceneName())).collect(Collectors.toList());
// 说明存在相同的任务

View File

@ -31,7 +31,7 @@ public class GroupConfigController {
@LoginRequired(role = RoleEnum.ADMIN)
@PostMapping("")
public Boolean addGroup(@RequestBody @Validated(PostMapping.class) GroupConfigRequestVO groupConfigRequestVO) {
public Boolean addGroup(@RequestBody @Validated GroupConfigRequestVO groupConfigRequestVO) {
return groupConfigService.addGroup(groupConfigRequestVO);
}

View File

@ -1,9 +1,9 @@
package com.aizuda.easy.retry.server.web.model.request;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
@ -19,6 +19,7 @@ public class BatchDeleteRetryTaskVO {
* 组名称
*/
@NotBlank(message = "groupName 不能为空")
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private String groupName;
/**

View File

@ -2,10 +2,10 @@ package com.aizuda.easy.retry.server.web.model.request;
import com.aizuda.easy.retry.server.web.model.base.BaseQueryVO;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
@ -15,8 +15,8 @@ import javax.validation.constraints.NotNull;
@Data
public class GroupConfigQueryVO extends BaseQueryVO {
@NotBlank(message = "组名称不能为空")
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private String groupName;
@NotNull(message = "组状态不能为空")

View File

@ -3,11 +3,8 @@ package com.aizuda.easy.retry.server.web.model.request;
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
import com.aizuda.easy.retry.server.enums.IdGeneratorMode;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.*;
import java.util.List;
/**
@ -21,6 +18,7 @@ import java.util.List;
public class GroupConfigRequestVO {
@NotBlank(message = "组名称不能为空")
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private String groupName;
@NotNull(message = "组状态不能为空")

View File

@ -1,9 +1,10 @@
package com.aizuda.easy.retry.server.web.model.request;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* 解析参数模型
@ -17,7 +18,8 @@ public class ParseLogsVO {
/**
* 客户端打印的上报日志信息
*/
@NotBlank(message = "日志信息不能为空")
@NotBlank(message = "组名称不能为空")
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private String logStr;
/**

View File

@ -2,9 +2,10 @@ package com.aizuda.easy.retry.server.web.model.request;
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
@ -19,7 +20,8 @@ public class RetryTaskUpdateExecutorNameRequestVO {
/**
* 组名称
*/
@NotBlank(message = "groupName 不能为空")
@NotBlank(message = "组名称不能为空")
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private String groupName;
/**

View File

@ -4,6 +4,7 @@ import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* 更新重试任务模型
@ -18,6 +19,7 @@ public class RetryTaskUpdateStatusRequestVO {
* 重试状态 {@link RetryStatusEnum}
*/
@NotBlank(message = "重试状态 不能为空")
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
private Integer retryStatus;
/**

View File

@ -89,10 +89,10 @@
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status, task_type, create_dt)
INSERT INTO retry_task_log (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, task_type, create_dt)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId}, #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, #{item.retryStatus}, #{item.taskType}, #{item.createDt})
(#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId}, #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, #{item.taskType}, #{item.createDt})
</foreach>
</insert>
</mapper>

View File

@ -70,10 +70,10 @@
</select>
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_${partition} (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, next_trigger_at, retry_count, retry_status, task_type, create_dt, update_dt)
INSERT INTO retry_task_${partition} (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, next_trigger_at, task_type, create_dt)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId}, #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, #{item.nextTriggerAt}, #{item.retryCount}, #{item.retryStatus}, #{item.taskType}, #{item.createDt}, #{item.updateDt})
(#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId}, #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, #{item.nextTriggerAt}, #{item.taskType}, #{item.createDt})
</foreach>
</insert>
</mapper>

View File

@ -1,373 +0,0 @@
<template>
<page-header-wrapper
title="单号234231029431"
:tab-list="tabList"
:tab-active-key="tabActiveKey"
@tabChange="handleTabChange"
>
<template v-slot:content>
<a-descriptions size="small" :column="isMobile ? 1 : 2">
<a-descriptions-item label="创建人">曲丽丽</a-descriptions-item>
<a-descriptions-item label="订购产品">XX 服务</a-descriptions-item>
<a-descriptions-item label="创建时间">2017-07-07</a-descriptions-item>
<a-descriptions-item label="关联单据">
<a href="">12421</a>
</a-descriptions-item>
<a-descriptions-item label="生效日期">2017-07-07 ~ 2017-08-08</a-descriptions-item>
<a-descriptions-item label="备注">请于两个工作日内确认</a-descriptions-item>
</a-descriptions>
</template>
<!-- actions -->
<template v-slot:extra>
<a-button-group style="margin-right: 4px;">
<a-button>操作</a-button>
<a-button>操作</a-button>
<a-button><a-icon type="ellipsis"/></a-button>
</a-button-group>
<a-button type="primary" >主操作</a-button>
</template>
<template v-slot:extraContent>
<a-row class="status-list">
<a-col :xs="12" :sm="12">
<div class="text">状态</div>
<div class="heading">待审批</div>
</a-col>
<a-col :xs="12" :sm="12">
<div class="text">订单金额</div>
<div class="heading">¥ 568.08</div>
</a-col>
</a-row>
</template>
<a-card :bordered="false" title="流程进度">
<a-steps :direction="isMobile && 'vertical' || 'horizontal'" :current="1" progressDot>
<a-step>
<template v-slot:title>
<span>创建项目</span>
</template>
<template v-slot:description>
<div class="antd-pro-pages-profile-advanced-style-stepDescription">
曲丽丽<a-icon type="dingding" style="margin-left: 8px;" />
<div>2016-12-12 12:32</div>
</div>
</template>
</a-step>
<a-step>
<template v-slot:title>
<span>部门初审</span>
</template>
<template v-slot:description>
<div class="antd-pro-pages-profile-advanced-style-stepDescription">
周毛毛<a-icon type="dingding" style="color: rgb(0, 160, 233); margin-left: 8px;" />
<div><a>催一下</a></div>
</div>
</template>
</a-step>
<a-step title="财务复核" />
<a-step title="完成" />
</a-steps>
</a-card>
<a-card style="margin-top: 24px" :bordered="false" title="用户信息">
<a-descriptions>
<a-descriptions-item label="用户姓名">付晓晓</a-descriptions-item>
<a-descriptions-item label="会员卡号">32943898021309809423</a-descriptions-item>
<a-descriptions-item label="身份证">3321944288191034921</a-descriptions-item>
<a-descriptions-item label="联系方式">18112345678</a-descriptions-item>
<a-descriptions-item label="联系地址">浙江省杭州市西湖区黄姑山路工专路交叉路口</a-descriptions-item>
</a-descriptions>
<a-descriptions title="信息组">
<a-descriptions-item label="某某数据">725</a-descriptions-item>
<a-descriptions-item label="该数据更新时间">2018-08-08</a-descriptions-item>
<a-descriptions-item ></a-descriptions-item>
<a-descriptions-item label="某某数据">725</a-descriptions-item>
<a-descriptions-item label="该数据更新时间">2018-08-08</a-descriptions-item>
<a-descriptions-item ></a-descriptions-item>
</a-descriptions>
<a-card type="inner" title="多层信息组">
<a-descriptions title="组名称" size="small">
<a-descriptions-item label="负责人">林东东</a-descriptions-item>
<a-descriptions-item label="角色码">1234567</a-descriptions-item>
<a-descriptions-item label="所属部门">XX公司-YY部</a-descriptions-item>
<a-descriptions-item label="过期时间">2018-08-08</a-descriptions-item>
<a-descriptions-item label="描述">这段描述很长很长很长很长很长很长很长很长很长很长很长很长很长很长...</a-descriptions-item>
</a-descriptions>
<a-divider style="margin: 16px 0" />
<a-descriptions title="组名称" size="small" :col="1">
<a-descriptions-item label="学名"> Citrullus lanatus (Thunb.) Matsum. et Nakai一年生蔓生藤本枝粗壮具明显的棱卷须较粗..</a-descriptions-item>
</a-descriptions>
<a-divider style="margin: 16px 0" />
<a-descriptions title="组名称" size="small" :col="2">
<a-descriptions-item label="负责人">付小小</a-descriptions-item>
<a-descriptions-item label="角色码">1234567</a-descriptions-item>
</a-descriptions>
</a-card>
</a-card>
<a-card style="margin-top: 24px" :bordered="false" title="用户近半年来电记录">
<div class="no-data"><a-icon type="frown-o"/>暂无数据</div>
</a-card>
<!-- 操作 -->
<a-card
style="margin-top: 24px"
:bordered="false"
:tabList="operationTabList"
:activeTabKey="operationActiveTabKey"
@tabChange="(key) => {this.operationActiveTabKey = key}"
>
<a-table
v-if="operationActiveTabKey === '1'"
:columns="operationColumns"
:dataSource="operation1"
:pagination="false"
>
<template
slot="status"
slot-scope="status">
<a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
</template>
</a-table>
<a-table
v-if="operationActiveTabKey === '2'"
:columns="operationColumns"
:dataSource="operation2"
:pagination="false"
>
<template
slot="status"
slot-scope="status">
<a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
</template>
</a-table>
<a-table
v-if="operationActiveTabKey === '3'"
:columns="operationColumns"
:dataSource="operation3"
:pagination="false"
>
<template
slot="status"
slot-scope="status">
<a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
</template>
</a-table>
</a-card>
</page-header-wrapper>
</template>
<script>
import { baseMixin } from '@/store/app-mixin'
export default {
name: 'Advanced',
mixins: [baseMixin],
data () {
return {
tabList: [
{ key: 'detail', tab: '详情' },
{ key: 'rule', tab: '规则' }
],
tabActiveKey: 'detail',
operationTabList: [
{
key: '1',
tab: '操作日志一'
},
{
key: '2',
tab: '操作日志二'
},
{
key: '3',
tab: '操作日志三'
}
],
operationActiveTabKey: '1',
operationColumns: [
{
title: '操作类型',
dataIndex: 'type',
key: 'type'
},
{
title: '操作人',
dataIndex: 'name',
key: 'name'
},
{
title: '执行结果',
dataIndex: 'status',
key: 'status',
scopedSlots: { customRender: 'status' }
},
{
title: '操作时间',
dataIndex: 'updatedAt',
key: 'updatedAt'
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark'
}
],
operation1: [
{
key: 'op1',
type: '订购关系生效',
name: '曲丽丽',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '-'
},
{
key: 'op2',
type: '财务复审',
name: '付小小',
status: 'reject',
updatedAt: '2017-10-03 19:23:12',
remark: '不通过原因'
},
{
key: 'op3',
type: '部门初审',
name: '周毛毛',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '-'
},
{
key: 'op4',
type: '提交订单',
name: '林东东',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '很棒'
},
{
key: 'op5',
type: '创建订单',
name: '汗牙牙',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '-'
}
],
operation2: [
{
key: 'op2',
type: '财务复审',
name: '付小小',
status: 'reject',
updatedAt: '2017-10-03 19:23:12',
remark: '不通过原因'
},
{
key: 'op3',
type: '部门初审',
name: '周毛毛',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '-'
},
{
key: 'op4',
type: '提交订单',
name: '林东东',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '很棒'
}
],
operation3: [
{
key: 'op2',
type: '财务复审',
name: '付小小',
status: 'reject',
updatedAt: '2017-10-03 19:23:12',
remark: '不通过原因'
},
{
key: 'op3',
type: '部门初审',
name: '周毛毛',
status: 'agree',
updatedAt: '2017-10-03 19:23:12',
remark: '-'
}
]
}
},
filters: {
statusFilter (status) {
const statusMap = {
'agree': '成功',
'reject': '驳回'
}
return statusMap[status]
},
statusTypeFilter (type) {
const statusTypeMap = {
'agree': 'success',
'reject': 'error'
}
return statusTypeMap[type]
}
},
methods: {
handleTabChange (key) {
console.log('')
this.tabActiveKey = key
}
}
}
</script>
<style lang="less" scoped>
.detail-layout {
margin-left: 44px;
}
.text {
color: rgba(0, 0, 0, .45);
}
.heading {
color: rgba(0, 0, 0, .85);
font-size: 20px;
}
.no-data {
color: rgba(0, 0, 0, .25);
text-align: center;
line-height: 64px;
font-size: 16px;
i {
font-size: 24px;
margin-right: 16px;
position: relative;
top: 3px;
}
}
.mobile {
.detail-layout {
margin-left: unset;
}
.text {
}
.status-list {
text-align: left;
}
}
</style>

View File

@ -1,249 +0,0 @@
<template>
<page-header-wrapper>
<a-card :bordered="false">
<a-descriptions title="退款申请">
<a-descriptions-item label="取货单号">1000000000</a-descriptions-item>
<a-descriptions-item label="状态">已取货</a-descriptions-item>
<a-descriptions-item label="销售单号">1234123421</a-descriptions-item>
<a-descriptions-item label="子订单">3214321432</a-descriptions-item>
</a-descriptions>
<a-divider style="margin-bottom: 32px"/>
<a-descriptions title="用户信息">
<a-descriptions-item label="用户姓名">付小小</a-descriptions-item>
<a-descriptions-item label="联系电话">18100000000</a-descriptions-item>
<a-descriptions-item label="常用快递">菜鸟仓储</a-descriptions-item>
<a-descriptions-item label="取货地址">浙江省杭州市西湖区万塘路18号</a-descriptions-item>
<a-descriptions-item label="备注"> </a-descriptions-item>
</a-descriptions>
<a-divider style="margin-bottom: 32px"/>
<div class="title">退货商品</div>
<s-table
style="margin-bottom: 24px"
row-key="id"
:columns="goodsColumns"
:data="loadGoodsData">
</s-table>
<div class="title">退货进度</div>
<s-table
style="margin-bottom: 24px"
row-key="key"
:columns="scheduleColumns"
:data="loadScheduleData">
<template
slot="status"
slot-scope="status">
<a-badge :status="status" :text="status | statusFilter"/>
</template>
</s-table>
</a-card>
</page-header-wrapper>
</template>
<script>
import { STable } from '@/components'
export default {
components: {
STable
},
data () {
return {
goodsColumns: [
{
title: '商品编号',
dataIndex: 'id',
key: 'id'
},
{
title: '商品名称',
dataIndex: 'name',
key: 'name'
},
{
title: '商品条码',
dataIndex: 'barcode',
key: 'barcode'
},
{
title: '单价',
dataIndex: 'price',
key: 'price',
align: 'right'
},
{
title: '数量(件)',
dataIndex: 'num',
key: 'num',
align: 'right'
},
{
title: '金额',
dataIndex: 'amount',
key: 'amount',
align: 'right'
}
],
// Promise
loadGoodsData: () => {
return new Promise(resolve => {
resolve({
data: [
{
id: '1234561',
name: '矿泉水 550ml',
barcode: '12421432143214321',
price: '2.00',
num: '1',
amount: '2.00'
},
{
id: '1234562',
name: '凉茶 300ml',
barcode: '12421432143214322',
price: '3.00',
num: '2',
amount: '6.00'
},
{
id: '1234563',
name: '好吃的薯片',
barcode: '12421432143214323',
price: '7.00',
num: '4',
amount: '28.00'
},
{
id: '1234564',
name: '特别好吃的蛋卷',
barcode: '12421432143214324',
price: '8.50',
num: '3',
amount: '25.50'
}
],
pageSize: 10,
pageNo: 1,
totalPage: 1,
totalCount: 10
})
}).then(res => {
return res
})
},
scheduleColumns: [
{
title: '时间',
dataIndex: 'time',
key: 'time'
},
{
title: '当前进度',
dataIndex: 'rate',
key: 'rate'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
scopedSlots: { customRender: 'status' }
},
{
title: '操作员ID',
dataIndex: 'operator',
key: 'operator'
},
{
title: '耗时',
dataIndex: 'cost',
key: 'cost'
}
],
loadScheduleData: () => {
return new Promise(resolve => {
resolve({
data: [
{
key: '1',
time: '2017-10-01 14:10',
rate: '联系客户',
status: 'processing',
operator: '取货员 ID1234',
cost: '5mins'
},
{
key: '2',
time: '2017-10-01 14:05',
rate: '取货员出发',
status: 'success',
operator: '取货员 ID1234',
cost: '1h'
},
{
key: '3',
time: '2017-10-01 13:05',
rate: '取货员接单',
status: 'success',
operator: '取货员 ID1234',
cost: '5mins'
},
{
key: '4',
time: '2017-10-01 13:00',
rate: '申请审批通过',
status: 'success',
operator: '系统',
cost: '1h'
},
{
key: '5',
time: '2017-10-01 12:00',
rate: '发起退货申请',
status: 'success',
operator: '用户',
cost: '5mins'
}
],
pageSize: 10,
pageNo: 1,
totalPage: 1,
totalCount: 10
})
}).then(res => {
return res
})
}
}
},
filters: {
statusFilter (status) {
const statusMap = {
'processing': '进行中',
'success': '完成',
'failed': '失败'
}
return statusMap[status]
}
},
computed: {
title () {
return this.$route.meta.title
}
}
}
</script>
<style lang="less" scoped>
.title {
color: rgba(0,0,0,.85);
font-size: 16px;
font-weight: 500;
margin-bottom: 16px;
}
</style>