317 lines
13 KiB
JavaScript
317 lines
13 KiB
JavaScript
/*
|
||
* 版 本 PIT-ADMS V7.0.3 敏捷开发框架
|
||
* Copyright (c) 2013-2018 Hexagon PPM
|
||
* 创建人:研发部
|
||
* 日 期:2017.04.17
|
||
* 描 述:流程模板管理(协同设计平台)
|
||
*/
|
||
var refreshGirdData; // 更新数据
|
||
var nowschemeId;
|
||
var ProjectId = !parent.request('ProjectId') ? "" : parent.request('ProjectId');
|
||
var isCaoz = false;
|
||
var refreshtree;
|
||
var bootstrap = function ($, learun) {
|
||
"use strict";
|
||
|
||
var categoryId = '';
|
||
var page = {
|
||
init: function () {
|
||
if (!!ProjectId) {
|
||
$('#lr_add').hide();
|
||
$('#lr_delete').hide();
|
||
$('#lr_category').hide();
|
||
}
|
||
refreshtree();
|
||
page.initGrid();
|
||
page.bind();
|
||
},
|
||
bind: function () {
|
||
|
||
// 查询
|
||
$('#btn_Search').on('click', function () {
|
||
var keyword = $('#txt_Keyword').val();
|
||
page.search({ keyword: keyword });
|
||
});
|
||
// 刷新
|
||
$('#lr_refresh').on('click', function () {
|
||
location.reload();
|
||
});
|
||
|
||
// 新增
|
||
$('#lr_add').on('click', function () {
|
||
learun.layerForm({
|
||
id: 'Form',
|
||
title: '新增流程模板',
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/Form?categoryId=' + categoryId + '&ProjectId=' + ProjectId,
|
||
width: 1200,
|
||
height: 900,
|
||
maxmin: true,
|
||
btn: null
|
||
});
|
||
});
|
||
// 编辑
|
||
$('#lr_edit').on('click', function () {
|
||
var name = $('#gridtable').jfGridValue('F_Name');
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
var code = $('#gridtable').jfGridValue('F_Code');
|
||
|
||
if (learun.checkrow(keyValue)) {
|
||
learun.layerForm({
|
||
id: 'Form',
|
||
title: '编辑流程模板-' + name,
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/Form?keyValue=' + keyValue + '&categoryId=' + categoryId + '&shcemeCode=' + code + '&ProjectId=' + ProjectId,
|
||
width: 1200,
|
||
height: 900,
|
||
maxmin: true,
|
||
btn: null
|
||
});
|
||
}
|
||
});
|
||
// 更新
|
||
$('#lr_update').on('click', function () {
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
if (learun.checkrow(keyValue)) {
|
||
learun.layerConfirm('是否确认更新成通用模板!', function (res) {
|
||
if (res) {
|
||
learun.deleteForm(top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/UpdateForm', { keyValue: keyValue }, function () {
|
||
refreshGirdData();
|
||
});
|
||
}
|
||
});
|
||
} else {
|
||
learun.httpPost(top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/CopyScheme', { ProjectId: ProjectId }, function () {
|
||
refreshGirdData();
|
||
});
|
||
}
|
||
});
|
||
// 删除
|
||
$('#lr_delete').on('click', function () {
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
if (learun.checkrow(keyValue)) {
|
||
learun.layerConfirm('是否确认删除该项!', function (res) {
|
||
if (res) {
|
||
learun.deleteForm(top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/DeleteForm', { keyValue: keyValue }, function () {
|
||
refreshGirdData();
|
||
});
|
||
}
|
||
});
|
||
}
|
||
});
|
||
// 预览
|
||
$('#lr_preview').on('click', function () {
|
||
var schemeId = $('#gridtable').jfGridValue('F_SchemeId');
|
||
if (learun.checkrow(schemeId)) {
|
||
learun.layerForm({
|
||
id: 'PreviewForm',
|
||
title: '预览当前模板',
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/PreviewForm?schemeId=' + schemeId,
|
||
width: 1200,
|
||
height: 900,
|
||
maxmin: true,
|
||
btn: null
|
||
});
|
||
}
|
||
});
|
||
// 启用
|
||
$('#lr_enable').on('click', function () {
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
var enabledMark = $('#gridtable').jfGridValue('F_EnabledMark');
|
||
|
||
var type = $('#gridtable').jfGridValue('F_Type');
|
||
if (type == 2) {
|
||
learun.alert.warning('草稿模板不能启用!');
|
||
return false;
|
||
}
|
||
|
||
if (learun.checkrow(keyValue)) {
|
||
if (enabledMark != 1) {
|
||
learun.layerConfirm('是否确认启用该表单模板!', function (res) {
|
||
if (res) {
|
||
learun.postForm(top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/UpDateSate', { keyValue: keyValue, state: 1 }, function () {
|
||
refreshGirdData();
|
||
});
|
||
}
|
||
});
|
||
}
|
||
else {
|
||
learun.alert.warning('该模板已启用!');
|
||
}
|
||
}
|
||
});
|
||
// 禁用
|
||
$('#lr_disabled').on('click', function () {
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
var enabledMark = $('#gridtable').jfGridValue('F_EnabledMark');
|
||
|
||
var type = $('#gridtable').jfGridValue('F_Type');
|
||
if (type == 2) {
|
||
learun.alert.warning('草稿模板不能禁用!');
|
||
return false;
|
||
}
|
||
|
||
if (learun.checkrow(keyValue)) {
|
||
if (enabledMark == 1) {
|
||
learun.layerConfirm('是否确认禁用该表单模板!', function (res) {
|
||
if (res) {
|
||
learun.postForm(top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/UpDateSate', { keyValue: keyValue, state: 0 }, function () {
|
||
refreshGirdData();
|
||
});
|
||
}
|
||
});
|
||
}
|
||
else {
|
||
learun.alert.warning('该表单已禁用!');
|
||
}
|
||
}
|
||
});
|
||
// 查看历史记录
|
||
$('#lr_history').on('click', function () {
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
var Name = $('#gridtable').jfGridValue('F_Name');
|
||
nowschemeId = $('#gridtable').jfGridValue('F_SchemeId');
|
||
if (learun.checkrow(keyValue)) {
|
||
learun.layerForm({
|
||
id: 'HistoryForm',
|
||
title: '流程模板历史记录-' + Name,
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/HistoryForm?&keyValue=' + keyValue,
|
||
width: 600,
|
||
height: 400,
|
||
maxmin: true,
|
||
btn: null
|
||
});
|
||
}
|
||
});
|
||
// 导出
|
||
$('#lr_export').on('click', function () {
|
||
var keyValue = $('#gridtable').jfGridValue('F_Id');
|
||
var code = $('#gridtable').jfGridValue('F_Code');
|
||
if (learun.checkrow(keyValue)) {
|
||
learun.download({
|
||
method: "POST",
|
||
url: '/LR_NewWorkFlow/NWFScheme/ExportScheme',
|
||
param: {
|
||
code: code
|
||
}
|
||
});
|
||
}
|
||
});
|
||
// 流程复制
|
||
$('#lr_copy').on('click', function () {
|
||
learun.layerForm({
|
||
id: 'Form',
|
||
title: '复制流程模板',
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/CopyForm?categoryId=' + categoryId + '&ProjectId=' + ProjectId,
|
||
width: 400,
|
||
height:400,
|
||
maxmin: true,
|
||
callBack: function (id)
|
||
{
|
||
return top[id].acceptClick(function (formdata) { refreshGirdData(); });
|
||
}
|
||
});
|
||
});
|
||
|
||
// 导入
|
||
$('#lr_import').on('click', function () {
|
||
learun.layerForm({
|
||
id: 'ImportForm',
|
||
title: '导入模板',
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/ImportForm?type=2',
|
||
width: 600,
|
||
height: 400,
|
||
maxmin: true,
|
||
btn: null
|
||
});
|
||
});
|
||
|
||
/*分类管理*/
|
||
$('#lr_category').on('click', function () {
|
||
learun.layerForm({
|
||
id: 'ClassifyIndex',
|
||
title: '分类管理',
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/CategoryIndex?ProjectId=' + ProjectId,
|
||
width: 800,
|
||
height: 500,
|
||
maxmin: true,
|
||
btn: null,
|
||
end: function () {
|
||
if (isCaoz) {
|
||
isCaoz = false;
|
||
refreshtree();
|
||
}
|
||
learun.clientdata.update('dataItem');
|
||
}
|
||
});
|
||
});
|
||
},
|
||
initGrid: function () {
|
||
$('#gridtable').jfGrid({
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/GetInfoPageList',
|
||
headData: [
|
||
//{ label: "编号", name: "F_Code", width: 150, align: "left" },
|
||
{ label: "名称", name: "F_Name", width: 160, align: "left" },
|
||
{ label: "分类", name: "CategoryName", width: 120, align: "center"},
|
||
{
|
||
label: "状态", name: "F_EnabledMark", width: 50, align: "center",
|
||
formatter: function (cellvalue, row) {
|
||
if (row.F_Type == 1) {
|
||
if (cellvalue == 1) {
|
||
return '<span class=\"label label-success\" style=\"cursor: pointer;\">正常</span>';
|
||
} else if (cellvalue == 0) {
|
||
return '<span class=\"label label-default\" style=\"cursor: pointer;\">禁用</span>';
|
||
}
|
||
}
|
||
else {
|
||
return '<span class=\"label label-info\" style=\"cursor: pointer;\">草稿</span>';
|
||
}
|
||
}
|
||
},
|
||
{ label: "编辑人", name: "F_CreateUserName", width: 80, align: "center" },
|
||
{
|
||
label: "编辑时间", name: "F_CreateDate", width: 80, align: "center",
|
||
formatter: function (cellvalue) {
|
||
return learun.formatDate(cellvalue, 'yyyy-MM-dd');
|
||
},
|
||
sort: true
|
||
},
|
||
{ label: "备注", name: "F_Description", width: 300, align: "left" },
|
||
{ name: "" }
|
||
],
|
||
mainId: 'F_Id',
|
||
reloadSelected: true,
|
||
sidx: "F_CreateDate",
|
||
sord: "desc",
|
||
isPage: true
|
||
});
|
||
page.search();
|
||
},
|
||
search: function (param) {
|
||
param = param || {};
|
||
param.ProjectId = ProjectId ;
|
||
param.category = categoryId;
|
||
$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
|
||
}
|
||
};
|
||
|
||
// 保存数据后回调刷新
|
||
refreshGirdData = function () {
|
||
$('#gridtable').jfGridSet('reload');
|
||
}
|
||
refreshtree = function () {
|
||
// 左侧数据加载
|
||
$('#lr_left_tree').lrtree({
|
||
url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/GetCategoryTree?ProjectId=' + ProjectId,
|
||
param: { itemCode: 'FlowSort' },
|
||
nodeClick: function (item) {
|
||
categoryId = item.value
|
||
$('#titleinfo').text(item.text);
|
||
page.search();
|
||
}
|
||
});
|
||
}
|
||
|
||
page.init();
|
||
}
|
||
|
||
|