public virtual async Task <FlowSheet> CreateSheet(FlowInstance instance, FlowForm flowForm)
        {
            var formData = instance.FormData;
            var formKey  = flowForm.FormKey;
            //生成单据
            var flowSheet = new FlowSheet()
            {
                FlowInstanceId = instance.Id,
                SheetName      = instance.InstanceName,
                FormKey        = formKey,
                SheetNature    = SheetNature.正单
            };
            var sheetId = await FlowSheetManager.InsertAndGetIdAsync(flowSheet);

            return(flowSheet);
        }
        public async Task CreateRevertSheet(FlowSheet flowSheet, string revertReason)
        {
            //产生新的流程实例
            var instance    = flowSheet.FlowInstance;
            var newInstance = new FlowInstance()
            {
                InstanceName   = instance.InstanceName,
                FormContent    = instance.FormContent,
                FormData       = instance.FormData,
                FlowFormId     = instance.FlowFormId,
                FormType       = instance.FormType,
                InstanceStatus = instance.InstanceStatus,
                IsActive       = true,
                Code           = Common.Fun.ConvertToTimeStamp(DateTime.Now).ToString()
            };
            var newInstanceId = await FlowInstanceManager.InsertAndGetIdAsync(newInstance);

            //生成新的单据
            var newFlowSheet = new FlowSheet()
            {
                UnitId         = flowSheet.UnitId,
                FlowInstanceId = newInstanceId,
                SheetSN        = FlowSheetManager.GenerateSheetSN(flowSheet.FormKey),
                SheetName      = newInstance.InstanceName,
                FormKey        = flowSheet.FormKey,
                SheetNature    = SheetNature.冲红,
                RelSheetId     = flowSheet.Id,
                RevertReason   = revertReason,
                Property       = flowSheet.Property
            };

            newFlowSheet.SheetDate = flowSheet.SheetDate;
            newFlowSheet.Remarks   = flowSheet.Remarks;
            var newSheetId = await FlowSheetManager.InsertAndGetIdAsync(newFlowSheet);

            //设置旧单据状态
            flowSheet.SheetNature  = SheetNature.被冲红;
            flowSheet.RelSheetId   = newSheetId;
            flowSheet.RevertReason = revertReason;

            await HandleRevert(newFlowSheet);
        }
        public virtual async Task <IEnumerable <ModuleButton> > GetFlowBtns(FlowSheet flowSheet)
        {
            var result = new List <ModuleButton>();

            //加入打印按钮
            result.Add(new ModuleButton()
            {
                ButtonKey   = "print",
                ButtonName  = "打印",
                ButtonClass = "layui-btn-normal"
            });
            if (flowSheet.SheetNature == SheetNature.正单)
            {
                //加入冲红按钮
                result.Add(new ModuleButton()
                {
                    ButtonKey   = "revert",
                    ButtonName  = "冲红",
                    ConfirmMsg  = "确认冲红此单据?",
                    ButtonClass = "layui-btn-danger"
                });
            }
            return(result);
        }
 public virtual async Task Handle(FlowSheet flowSheet)
 {
     flowSheet.SheetNature = SheetNature.正单;
 }
 public virtual async Task Action(FlowSheet flowSheet, string action, DateTime?lastModifyTime)
 {
 }
 public abstract Task HandleRevert(FlowSheet flowSheet);