提交申请时,可以选择流程模板

This commit is contained in:
yubaolee 2016-09-16 18:05:57 +08:00
parent dbdfbaab52
commit 5996d6b5f7
9 changed files with 43 additions and 9 deletions

View File

@ -31,7 +31,8 @@ namespace OpenAuth.App
{ {
UserId = model.UserId, UserId = model.UserId,
Name = model.Name, Name = model.Name,
Comment = model.Comment Comment = model.Comment,
WorkflowName = model.WorkflowName
}); });
} }

View File

@ -52,6 +52,8 @@ namespace OpenAuth.App.ViewModel
/// </summary> /// </summary>
public System.Guid? ControllerUserId { get; set; } public System.Guid? ControllerUserId { get; set; }
public string WorkflowName { get; set; }
/// <summary> /// <summary>
/// 可用命令 /// 可用命令
/// </summary> /// </summary>

View File

@ -60,5 +60,7 @@ namespace OpenAuth.Domain
/// </summary> /// </summary>
public System.Guid? ControllerUserId { get; set; } public System.Guid? ControllerUserId { get; set; }
public string WorkflowName { get; set; }
} }
} }

View File

@ -72,11 +72,26 @@ function MainGrid() {
MainGrid.prototype = new Grid(); MainGrid.prototype = new Grid();
var list = new MainGrid(); var list = new MainGrid();
var selectScheme = function(val) {
$("#WorkflowName").empty();
$.getJSON('/workflowschemas/Load',
function (data) {
$.each(data.list, function (i, n) {
$("#WorkflowName").append("<option value='" + this.Code + "'>" + this.Code + "</option>");
});
if (val != undefined) {
$('#WorkflowName').val(val);
}
});
}
//添加(编辑)对话框 //添加(编辑)对话框
var editDlg = function () { var editDlg = function () {
var show = function () { var show = function () {
BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' }); BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' });
$("#btnSave").on("click", function () { $("#btnSave").on("click", function () {
editDlg.save(); editDlg.save();
}); });
@ -84,6 +99,7 @@ var editDlg = function () {
return { return {
add: function () { //弹出添加 add: function () { //弹出添加
show(); show();
selectScheme();
$.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用 $.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
$("#Id").val('00000000-0000-0000-0000-000000000000'); $("#Id").val('00000000-0000-0000-0000-000000000000');
}, },
@ -92,6 +108,7 @@ var editDlg = function () {
$('#Id').val(ret.Id); $('#Id').val(ret.Id);
$('#Name').val(ret.Name); $('#Name').val(ret.Name);
$('#Comment').val(ret.Comment); $('#Comment').val(ret.Comment);
selectScheme(ret.WorkflowName);
}, },
save: function () { //编辑-->保存 save: function () { //编辑-->保存
$('#editForm').isValid(function (v) { $('#editForm').isValid(function (v) {

View File

@ -1,4 +1,4 @@
var schemecode = 'SimpleWF'; 
var wfdesigner = undefined; var wfdesigner = undefined;
function wfdesignerRedraw() { function wfdesignerRedraw() {
@ -9,6 +9,7 @@ function wfdesignerRedraw() {
wfdesigner.destroy(); wfdesigner.destroy();
} }
var processid = $("#processId").val(); var processid = $("#processId").val();
var schemecode = $("#schemeCode").val();
wfdesigner = new WorkflowDesigner({ wfdesigner = new WorkflowDesigner({
name: 'simpledesigner', name: 'simpledesigner',

View File

@ -43,7 +43,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
apply.UserId = AuthUtil.GetCurrentUser().User.Id; apply.UserId = AuthUtil.GetCurrentUser().User.Id;
_app.AddOrUpdate(apply); _app.AddOrUpdate(apply);
CreateWorkflowIfNotExists(apply.Id); CreateWorkflowIfNotExists(apply.Id,apply.WorkflowName);
} }
catch (Exception ex) catch (Exception ex)
@ -110,14 +110,14 @@ namespace OpenAuth.Mvc.Controllers
} }
private void CreateWorkflowIfNotExists(Guid id) private void CreateWorkflowIfNotExists(Guid id, string schemecode)
{ {
if (WorkflowInit.Runtime.IsProcessExists(id)) if (WorkflowInit.Runtime.IsProcessExists(id))
return; return;
using (var sync = new WorkflowSync(WorkflowInit.Runtime, id)) using (var sync = new WorkflowSync(WorkflowInit.Runtime, id))
{ {
WorkflowInit.Runtime.CreateInstance("SimpleWF", id); WorkflowInit.Runtime.CreateInstance(schemecode, id);
sync.StatrtWaitingFor(new List<ProcessStatus> { ProcessStatus.Initialized, ProcessStatus.Initialized }); sync.StatrtWaitingFor(new List<ProcessStatus> { ProcessStatus.Initialized, ProcessStatus.Initialized });

View File

@ -16,7 +16,8 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<input value="@Model.Id" id="processId" class="hidden" /> <input value="@Model.Id" id="processId" class="hidden"/>
<input value="@Model.WorkflowName" id="schemeCode" class="hidden" />
<h3 class="panel-title"> <h3 class="panel-title">
@Model.Name @Model.Name
</h3> </h3>

View File

@ -29,11 +29,17 @@
<input type="text" id="Name" name="Name" value="" /> <input type="text" id="Name" name="Name" value="" />
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="Comment" class="control-label x120">申请描述:</label>
<textarea type="text" id="Comment" name="Comment" value=""></textarea>
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="Comment" class="control-label x120">申请描述:</label> <label for="Comment" class="control-label x120">流程模板</label>
<textarea type="text" id="Comment" name="Comment" value=""></textarea> <select id="WorkflowName" name="WorkflowName"></select>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -45,6 +45,10 @@ namespace OpenAuth.Repository.Models.Mapping
.HasColumnName("State") .HasColumnName("State")
.HasMaxLength(1024) .HasMaxLength(1024)
.IsRequired(); .IsRequired();
Property(t => t.WorkflowName)
.HasColumnName("WorkflowName")
.HasMaxLength(1024)
.IsRequired();
Property(t => t.StateName) Property(t => t.StateName)
.HasColumnName("StateName") .HasColumnName("StateName")
.HasMaxLength(1024) .HasMaxLength(1024)