$(function () { }); function initSelectize(selector, options) { var defaultOptions = { plugins: ['remove_button'], onItemAdd: function (value, $item) { $item.on('dblclick', function () { var selectize = $item.closest('.selectize-control').prev('select')[0].selectize; selectize.removeItem(value, true); }); } }; if (options) { _.assign(options, defaultOptions); } else { options = defaultOptions; } $(selector).selectize(options); } function setRuleDiv() { initSelectize("[name='selectRule']", { options: getRules(), valueField: 'Value', labelField: 'Text', searchField: 'Text' }); } function getRules() { var items = []; for (var i = 0; i < selectItems.length; i++) { items.push({ Value: selectItems[i].Value, Text: selectItems[i].Text }); } return items; } var app = new Vue({ el: '#app', data: { selected: '0', options: [ { text: '--请选择--', value: '0' }, { text: '客户开户', value: '1' }, { text: '客户信息修改', value: '5' }, { text: '交易', value: '2' }, /* { text: '资信与授信', value: '3' },*/ { text: '出金', value: '4' } ], isOpen: false, isTrade: false, isCredit: false, isOutCash: false, isClient: false, openItems: [], clientItems: [], tradeItems: [], creditItems: [], outCashItems: [], openCounter: 0, tradeCounter: 0, creditCounter: 0, clientCounter: 0, tradeIndex: 0, grouplist: [], node: 0 }, computed: { roleOptions: function () { var items = []; main.post("/AccountOpeningProcess/GetRolesOption", {}, { async: false }).done( function (res) { for (var i = 0; i < res.length; i++) { items.push({ Value: res[i].Value, Text: res[i].Text }); } } ); return items; }, filterBranch() { return this.tradeItems.filter(x => x.approvalCondition != 0); }, openFilterBranch() { return this.openItems.filter(x => x.approvalCondition != 0); }, clientFilterBranch() { return this.clientItems.filter(x => x.approvalCondition != 0); } }, methods: { changeType: function () { var thisObj = this; $("#addtooltip-warpper").hide(); if (thisObj.selected === '1') { thisObj.isOpen = true; thisObj.isTrade = false; thisObj.isCredit = false; thisObj.isOutCash = false; thisObj.isClient = false; } else if (thisObj.selected === '2') { thisObj.isOpen = false; thisObj.isTrade = true; thisObj.isCredit = false; thisObj.isOutCash = false; thisObj.isClient = false; } else if (thisObj.selected === '3') { thisObj.isOpen = false; thisObj.isTrade = false; thisObj.isCredit = true; thisObj.isOutCash = false; thisObj.isClient = false; } else if (thisObj.selected === '4') { thisObj.isOpen = false; thisObj.isTrade = false; thisObj.isCredit = false; thisObj.isOutCash = true; thisObj.isClient = false; } else if (thisObj.selected === '5') { thisObj.isOpen = false; thisObj.isTrade = false; thisObj.isCredit = false; thisObj.isOutCash = false; thisObj.isClient = true; } else { thisObj.isOpen = false; thisObj.isTrade = false; thisObj.isCredit = false; thisObj.isOutCash = false; thisObj.isClient = false; } thisObj.getProcess(); }, selectChangeType: function (index, value) { var thisObj = this; var selectType = thisObj.selected; if (selectType === "1") { //客户开户 for (var i = 0; i < thisObj.openItems.length; i++) { if (i === index) continue; if (thisObj.openItems[i].SelectValue === parseInt(value) && thisObj.openItems[i].node == 0) { main.message("不得选择重复角色"); return; } } } if (selectType === "2") { //交易 for (var j = 0; j < thisObj.tradeItems.length; j++) { if (j === index) continue; if (thisObj.tradeItems[j].SelectValue === parseInt(value) && thisObj.tradeItems[j].node == 0) { main.message("不得选择重复角色"); return; } } } if (selectType === "3") {//资信与授信 for (var n = 0; n < thisObj.creditItems.length; n++) { if (n === index) continue; if (thisObj.creditItems[n].SelectValue === parseInt(value)) { main.message("不得选择重复角色"); return; } } } if (selectType === "4") {//出金 for (var n = 0; n < thisObj.outCashItems.length; n++) { if (n === index) continue; if (thisObj.outCashItems[n].SelectValue === parseInt(value)) { main.message("不得选择重复角色"); return; } } } if (selectType === "5") {//客户信息 for (var n = 0; n < thisObj.clientItems.length; n++) { if (n === index) continue; if (thisObj.clientItems[n].SelectValue === parseInt(value) && thisObj.clientItems[n].node==0) { main.message("不得选择重复角色"); return; } } } }, showProcess(index, child, obj) { var thisObj = this; var selectType = thisObj.selected; var tradeBranch = thisObj.tradeItems.find(x => x.approvalCondition != 0); var openBranch = thisObj.openItems.find(x => x.approvalCondition != 0); var clientBranch = thisObj.clientItems.find(x => x.approvalCondition != 0); if ((selectType === "1" && !openBranch) || (selectType == "2" && !tradeBranch) || (selectType == "5" && !clientBranch) ) { let offsetTop = $(obj.target).offset().top; let offsetLeft = $(obj.target).offset().left; $("#addtooltip-warpper").css({ "left": offsetLeft - 180, "top": offsetTop - 110, "margin-left": "30px" }); $("#addtooltip-warpper").hide(); $("#addtooltip-warpper").show(150); this.tradeIndex = index; thisObj.node = index; } else { thisObj.addProcess(index, child, 0); $("#addtooltip-warpper").hide(100); } }, tradeAddProcess(type) { var thisObj = this; var selectType = thisObj.selected; if (type == 1) { thisObj.addProcess(thisObj.node, false, 0); } else { var typeName = 'TradeProcess'; if (selectType == "1") { typeName = 'OpenProcess' } if (selectType == "5") { typeName = 'ClientProcess' } var item = { id: 0, Type: typeName, Index: thisObj.node + 1, SelectValue: 0, approvalCondition: 1, node: 1, parentNode: thisObj.node, approvalGroupId: 0 } var item2 = { id: 0, Type: typeName, Index: thisObj.node + 1, SelectValue: 0, approvalCondition: 1, node: 2, parentNode: thisObj.node, approvalGroupId: 0 } if (selectType == "2") { //交易 thisObj.tradeItems.splice(thisObj.node, 0, item, item2); thisObj.initTradeItemIndex(); } else if (selectType == "1") { //开户 thisObj.openItems.splice(thisObj.node, 0, item, item2); thisObj.initOpenItemIndex(); } else if (selectType == "5") { //客户信息 thisObj.clientItems.splice(thisObj.node, 0, item, item2); thisObj.initClientItemIndex(); } } $("#addtooltip-warpper").hide(100); }, addProcess: function (index, child, node) { var thisObj = this; var selectType = thisObj.selected; if (selectType === '0') { main.message('请选择流程类型'); return; } if (selectType === "1") { //客户开户 thisObj.addOpenProcess(index, child, node); return; } else if (selectType === "2") { //交易 thisObj.addTradeProcess(index, child, node); return; } else if (selectType === "3") {//资信与授信 var item = { Type: 'CreditProcess', Index: index + 1, SelectValue: 0 } thisObj.creditItems.forEach(x => { if (x.Index >= index) { x.Index = x.Index + 1; } }); thisObj.creditItems.splice(index, 0, item); thisObj.creditItems.forEach((x, index) => { x.Index = index + 1; }); thisObj.creditItems = thisObj.creditItems.sort((a, b) => a.Index - b.Index); return; } else if (selectType === "4") {//出金 var item = { Type: 'OutCashProcess', Index: index + 1, SelectValue: 0 } thisObj.outCashItems.forEach(x => { if (x.Index >= index) { x.Index = x.Index + 1; } }); thisObj.outCashItems.splice(index, 0, item); thisObj.outCashItems.forEach((x, index) => { x.Index = index + 1; }); thisObj.outCashItems = thisObj.outCashItems.sort((a, b) => a.Index - b.Index); return; } else if (selectType === "5") { //客户信息 thisObj.addClientProcess(index, child, node); return; } }, delProcess: function (openItem) { var thisObj = this; var selectType = thisObj.selected; if (selectType === "0") { main.message('请选择流程类型后删除!'); return; } if (selectType === "1") { //客户开户 thisObj.delOpenProcess(openItem); return; } else if (selectType === "2") { //交易 thisObj.delTradeProcess(openItem); return; } else if (selectType === "3") {//资信与授信 var index = thisObj.creditItems.indexOf(openItem); thisObj.creditItems.splice(index, 1); thisObj.creditItems.forEach((x, index) => { x.Index = index + 1; }); return; } else if (selectType === "4") {//出金 var index = thisObj.outCashItems.indexOf(openItem); thisObj.outCashItems.splice(index, 1); thisObj.outCashItems.forEach((x, index) => { x.Index = index + 1; }); return; } else if (selectType === "5") { //客户信息 thisObj.delClientProcess(openItem); return; } }, delOpenProcess(openItem) { var thisObj = this; if (openItem.approvalCondition != 0) {//删除分支下,所有东西 var childNodes = thisObj.openItems.filter(x => x.node != 0); thisObj.openItems = thisObj.openItems.concat(childNodes).filter(function (v) { return thisObj.openItems.indexOf(v) === -1 || childNodes.indexOf(v) === -1 }); thisObj.initOpenItemIndex(); } else if (openItem.node != 0) {//删除分支下某节点 var index = thisObj.openItems.indexOf(openItem); thisObj.openItems.splice(index, 1); var childNodes = thisObj.openItems.filter(x => x.node == openItem.node && x.Index >= openItem.Index); childNodes.forEach(item => { item.parentNode = item.parentNode - 1; item.Index = item.Index - 1; }); } else {//删除非分支下某节点 var index = thisObj.openItems.indexOf(openItem); thisObj.openItems.splice(index, 1); var nodes = thisObj.openItems.filter(x => x.Index >= openItem.Index); nodes.forEach(item => { item.Index = item.Index - 1; }); thisObj.initOpenItemIndex(); } }, delTradeProcess(tradeItem) { var thisObj = this; thisObj.getRuleType(); if (tradeItem.approvalCondition != 0) {//删除分支下,所有东西 var childNodes = thisObj.tradeItems.filter(x => x.node != 0); thisObj.tradeItems = thisObj.tradeItems.concat(childNodes).filter(function (v) { return thisObj.tradeItems.indexOf(v) === -1 || childNodes.indexOf(v) === -1 }); thisObj.initTradeItemIndex(); } else if (tradeItem.node != 0) {//删除分支下某节点 var index = thisObj.tradeItems.indexOf(tradeItem); thisObj.tradeItems.splice(index, 1); var childNodes = thisObj.tradeItems.filter(x => x.node == tradeItem.node && x.Index >= tradeItem.Index); childNodes.forEach(item => { item.parentNode = item.parentNode - 1; item.Index = item.Index - 1; }); } else {//删除非分支下某节点 var index = thisObj.tradeItems.indexOf(tradeItem); thisObj.tradeItems.splice(index, 1); var nodes = thisObj.tradeItems.filter(x => x.Index >= tradeItem.Index); nodes.forEach(item => { item.Index = item.Index - 1; }); thisObj.initTradeItemIndex(); } }, delClientProcess(clientItem) { var thisObj = this; if (clientItem.approvalCondition != 0) {//删除分支下,所有东西 var childNodes = thisObj.clientItems.filter(x => x.node != 0); thisObj.clientItems = thisObj.clientItems.concat(childNodes).filter(function (v) { return thisObj.clientItems.indexOf(v) === -1 || childNodes.indexOf(v) === -1 }); thisObj.initClientItemIndex(); } else if (clientItem.node != 0) {//删除分支下某节点 var index = thisObj.clientItems.indexOf(clientItem); thisObj.clientItems.splice(index, 1); var childNodes = thisObj.clientItems.filter(x => x.node == clientItem.node && x.Index >= clientItem.Index); childNodes.forEach(item => { item.parentNode = item.parentNode - 1; item.Index = item.Index - 1; }); } else {//删除非分支下某节点 var index = thisObj.clientItems.indexOf(clientItem); thisObj.clientItems.splice(index, 1); var nodes = thisObj.clientItems.filter(x => x.Index >= clientItem.Index); nodes.forEach(item => { item.Index = item.Index - 1; }); thisObj.initClientItemIndex(); } }, addOpenProcess(index, child, node) { var thisObj = this; var item = { Type: 'OpenProcess', Index: index + 1, SelectValue: 0, approvalCondition: 0, node: node, parentNode: child ? index : 0, approvalGroupId: 0 } var childNodes = thisObj.openItems.filter(x => x.Index > index); childNodes.forEach(item => { if (item.parentNode != 0) { item.parentNode = item.parentNode + 1; } item.Index = item.Index + 1; }); thisObj.openItems.splice(index, 0, item); thisObj.initOpenItemIndex(); }, addTradeProcess(index, child, node) { var thisObj = this; var item = { id: 0, Type: 'TradeProcess', Index: index + 1, SelectValue: 0, approvalCondition: 0, node: node, parentNode: child ? index : 0, approvalGroupId: 0 } thisObj.getRuleType(); var childNodes = thisObj.tradeItems.filter(x => x.Index > index); childNodes.forEach(item => { if (item.parentNode != 0) { item.parentNode = item.parentNode + 1; } item.Index = item.Index + 1; }); thisObj.tradeItems.splice(index, 0, item); thisObj.initTradeItemIndex(); }, addClientProcess(index, child, node) { var thisObj = this; var item = { id: 0, Type: 'ClientProcess', Index: index + 1, SelectValue: 0, approvalCondition: 0, node: node, parentNode: child ? index : 0, approvalGroupId: 0 } var childNodes = thisObj.clientItems.filter(x => x.Index > index); childNodes.forEach(item => { if (item.parentNode != 0) { item.parentNode = item.parentNode + 1; } item.Index = item.Index + 1; }); thisObj.clientItems.splice(index, 0, item); thisObj.initClientItemIndex(); }, ok: function () { var thisObj = this; var selectType = thisObj.selected; if (selectType === "0") { main.message('请选择流程类型后进行确认提交!'); return; } else if (selectType === "1") { //客户开户 thisObj.openOk(); return; } else if (selectType === "2") { //交易 thisObj.tradeOk(); return; } else if (selectType === "3") {//资信与授信 thisObj.creditOk(); return; } else if (selectType === "4") {//出金 thisObj.cashOk(); return; } else if (selectType === "5") { thisObj.clientOk(); return; } }, openOk() { var thisObj = this; var openLength = thisObj.openItems.length; for (var j = 0; j < openLength; j++) { if (thisObj.openItems[j].approvalCondition == 0) { if (thisObj.openItems[j].SelectValue === "" || thisObj.openItems[j].SelectValue === 0) { main.message('流程中断,请重新选择'); return; } } else { if (thisObj.openItems[j].approvalGroupId === "" || thisObj.openItems[j].approvalGroupId === 0) { main.message('流程中断,请重新选择'); return; } } } var temp1 = 0; for (var w1 = 0; w1 < openLength - 1; w1++) { for (var n1 = 1; n1 < openLength; n1++) { if (w1 !== n1) { if (parseInt(thisObj.openItems[w1].SelectValue) === parseInt(thisObj.openItems[n1].SelectValue) && parseInt(thisObj.openItems[n1].SelectValue) != 0) { if (parseInt(thisObj.openItems[w1].node) == parseInt(thisObj.openItems[n1].node)) { temp1 = temp1 + 1; } } } } } var approvalGroupItems = thisObj.openItems.filter(x => x.approvalGroupId != 0); var approvalOpenLength = approvalGroupItems.length; var temp2 = 0; for (var w1 = 0; w1 < approvalOpenLength - 1; w1++) { for (var n1 = 1; n1 < approvalOpenLength; n1++) { if (w1 !== n1) { if (parseInt(approvalGroupItems[w1].approvalCondition) === parseInt(approvalGroupItems[n1].approvalCondition) && parseInt(approvalGroupItems[w1].approvalGroupId) === parseInt(approvalGroupItems[n1].approvalGroupId)) { temp2 = temp2 + 1; } } } } if (temp1 > 0 || temp2 > 0) { main.message('流程包含重复项,请重新选择'); return; } thisObj.initOpenItemIndex(); var firstChildOpenItem = thisObj.openItems.filter(x => x.node == 1); var secondchildOpenItem = thisObj.openItems.filter(x => x.node == 2); if (firstChildOpenItem.length == 1 && secondchildOpenItem.length == 1) { main.message('分支节点流程未设置完毕'); return; } if (thisObj.openItems != null && thisObj.openItems.length > 0) { main.confirm("修改客户开户流程后,处于审批中的客户需要重新审批,确认修改?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: thisObj.openItems[0].Type, data: thisObj.openItems }, { async: false }).done( function (res) { thisObj.getProcess(); }); }); } else { main.confirm("删除审批流程后,开户审批就会直接审批通过,确认删除?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: "OpenProcess" }, { async: false }).done( function (res) { }); }); } }, tradeOk() { var thisObj = this; var tradeLength = thisObj.tradeItems.length; for (var j = 0; j < tradeLength; j++) { if (thisObj.tradeItems[j].approvalCondition == 0) { if (thisObj.tradeItems[j].SelectValue === "" || thisObj.tradeItems[j].SelectValue === 0) { main.message('流程中断,请重新选择'); return; } } else { if (thisObj.tradeItems[j].approvalGroupId === "" || thisObj.tradeItems[j].approvalGroupId === 0) { main.message('流程中断,请重新选择'); return; } } } var temp1 = 0; for (var w1 = 0; w1 < tradeLength - 1; w1++) { for (var n1 = 1; n1 < tradeLength; n1++) { if (w1 !== n1) { if (parseInt(thisObj.tradeItems[w1].SelectValue) === parseInt(thisObj.tradeItems[n1].SelectValue) && parseInt(thisObj.tradeItems[n1].SelectValue) != 0) { if (parseInt(thisObj.tradeItems[w1].node) == parseInt(thisObj.tradeItems[n1].node)) { temp1 = temp1 + 1; } } } } } var approvalGroupItems = thisObj.tradeItems.filter(x => x.approvalGroupId != 0); var approvalTradeLength = approvalGroupItems.length; var temp2 = 0; for (var w1 = 0; w1 < approvalTradeLength - 1; w1++) { for (var n1 = 1; n1 < approvalTradeLength; n1++) { if (w1 !== n1) { if (parseInt(approvalGroupItems[w1].approvalCondition) === parseInt(approvalGroupItems[n1].approvalCondition) && parseInt(approvalGroupItems[w1].approvalGroupId) === parseInt(approvalGroupItems[n1].approvalGroupId)) { temp2 = temp2 + 1; } } } } if (temp1 > 0 || temp2 > 0) { main.message('流程包含重复项,请重新选择'); return; } thisObj.getRuleType(); thisObj.initTradeItemIndex(); var firstChildTradeItem = thisObj.tradeItems.filter(x => x.node == 1); var secondchildTradeItem = thisObj.tradeItems.filter(x => x.node == 2); if (firstChildTradeItem.length == 1 && secondchildTradeItem.length == 1) { main.message('分支节点流程未设置完毕'); return; } if (thisObj.tradeItems != null && thisObj.tradeItems.length > 0) { main.confirm("确认修改交易审批流程?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: thisObj.tradeItems[0].Type, data: thisObj.tradeItems }, { async: false }).done( function (res) { thisObj.getProcess(); }); }); } else { main.confirm("删除审批流程后,交易审批就会直接审批通过,确认删除?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: "TradeProcess" }, { async: false }).done( function (res) { }); }); } }, creditOk() { var thisObj = this; var creditLength = thisObj.creditItems.length; for (var n = 0; n < creditLength; n++) { if (thisObj.creditItems[n].SelectValue === "" || thisObj.creditItems[n].SelectValue === 0) { main.message('流程中断,请重新选择'); return; } } var tempr = 0; for (var wr = 0; wr < creditLength - 1; wr++) { for (var nr = 0; nr < creditLength; nr++) { if (wr !== nr) { if (parseInt(thisObj.creditItems[wr].SelectValue) === parseInt(thisObj.creditItems[nr].SelectValue)) { tempr = tempr + 1; } } } } if (tempr > 0) { main.message('流程包含重复项,请重新选择'); return; } if (thisObj.creditItems != null && thisObj.creditItems.length > 0) { thisObj.creditItems.forEach((x, index) => { x.Index = index + 1; }); main.confirm("修改资信与授信审批流程后,处于审批中的资信与授信需要重新审批,确认修改?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: thisObj.creditItems[0].Type, data: thisObj.creditItems }, { async: false }).done( function (res) { }); }); } else { main.confirm("删除审批流程后,资信与授信审批就会直接审批通过,确认删除?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: "CreditProcess" }, { async: false }).done( function (res) { }); }); } }, cashOk() { var thisObj = this; var outCashLength = thisObj.outCashItems.length; for (var n = 0; n < outCashLength; n++) { if (thisObj.outCashItems[n].SelectValue === "" || thisObj.outCashItems[n].SelectValue === 0) { main.message('流程中断,请重新选择'); return; } } var tempr = 0; for (var wr = 0; wr < outCashLength - 1; wr++) { for (var nr = 0; nr < outCashLength; nr++) { if (wr !== nr) { if (parseInt(thisObj.outCashItems[wr].SelectValue) === parseInt(thisObj.outCashItems[nr].SelectValue)) { tempr = tempr + 1; } } } } if (tempr > 0) { main.message('流程包含重复项,请重新选择'); return; } if (thisObj.outCashItems != null && thisObj.outCashItems.length > 0) { thisObj.outCashItems.forEach((x, index) => { x.Index = index + 1; }); main.confirm("确认修改出金审批流程?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: thisObj.outCashItems[0].Type, data: thisObj.outCashItems }, { async: false }).done( function (res) { }); }); } else { main.confirm("删除审批流程后,出金审批就会直接审批通过,确认删除?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: "OutCashProcess" }, { async: false }).done( function (res) { }); }); } }, clientOk() { var thisObj = this; var clientLength = thisObj.clientItems.length; for (var j = 0; j < clientLength; j++) { if (thisObj.clientItems[j].approvalCondition == 0) { if (thisObj.clientItems[j].SelectValue === "" || thisObj.clientItems[j].SelectValue === 0) { main.message('流程中断,请重新选择'); return; } } else { if (thisObj.clientItems[j].approvalGroupId === "" || thisObj.clientItems[j].approvalGroupId === 0) { main.message('流程中断,请重新选择'); return; } } } var temp1 = 0; for (var w1 = 0; w1 < clientLength - 1; w1++) { for (var n1 = 1; n1 < clientLength; n1++) { if (w1 !== n1) { if (parseInt(thisObj.clientItems[w1].SelectValue) === parseInt(thisObj.clientItems[n1].SelectValue) && parseInt(thisObj.clientItems[n1].SelectValue) != 0) { if (parseInt(thisObj.clientItems[w1].node) == parseInt(thisObj.clientItems[n1].node)) { temp1 = temp1 + 1; } } } } } var approvalGroupItems = thisObj.clientItems.filter(x => x.approvalGroupId != 0); var approvalClientLength = approvalGroupItems.length; var temp2 = 0; for (var w1 = 0; w1 < approvalClientLength - 1; w1++) { for (var n1 = 1; n1 < approvalClientLength; n1++) { if (w1 !== n1) { if (parseInt(approvalGroupItems[w1].approvalCondition) === parseInt(approvalGroupItems[n1].approvalCondition) && parseInt(approvalGroupItems[w1].approvalGroupId) === parseInt(approvalGroupItems[n1].approvalGroupId)) { temp2 = temp2 + 1; } } } } if (temp1 > 0 || temp2 > 0) { main.message('流程包含重复项,请重新选择'); return; } thisObj.initClientItemIndex(); var firstChildClientItem = thisObj.clientItems.filter(x => x.node == 1); var secondchildClientItem = thisObj.clientItems.filter(x => x.node == 2); if (firstChildClientItem.length == 1 && secondchildClientItem.length == 1) { main.message('分支节点流程未设置完毕'); return; } if (thisObj.clientItems != null && thisObj.clientItems.length > 0) { main.confirm("修改客户信息流程后,处于审批中的客户信息需要重新审批,确认修改?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: thisObj.clientItems[0].Type, data: thisObj.clientItems }, { async: false }).done( function (res) { thisObj.getProcess(); }); }); } else { main.confirm("删除审批流程后,客户信息审批就会直接审批通过,确认删除?", function () { main.post("/AccountOpeningProcess/AddProcess", { type: "ClientProcess" }, { async: false }).done( function (res) { }); }); } }, getProcess() { var thisObj = this; thisObj.openItems = []; thisObj.tradeItems = []; thisObj.creditItems = []; thisObj.outCashItems = []; thisObj.clientItems = []; main.post("/AccountOpeningProcess/GetProcess", {}, { async: false }).done( function (res) { res.OpenProcess.forEach(function (value, index, array) { thisObj.openItems.push({ id: value.id, Type: value.processType, Index: value.order, SelectValue: value.roleId, node: value.node, parentNode: value.parentNode, approvalGroupId: value.approvalGroupId, approvalCondition: value.approvalCondition }); }); res.TradeProcess.forEach(function (value, index, array) { thisObj.tradeItems.push({ id: value.id, Type: value.processType, Index: value.order, SelectValue: value.roleId, ApprovalRules: value.ruleType, node: value.node, parentNode: value.parentNode, approvalGroupId: value.approvalGroupId, approvalCondition: value.approvalCondition }); }); res.CreditProcess.forEach(function (value, index, array) { thisObj.creditItems.push({ Type: value.processType, Index: value.order, SelectValue: value.roleId }); }); res.OutCashProcess.forEach(function (value, index, array) { thisObj.outCashItems.push({ Type: value.processType, Index: value.order, SelectValue: value.roleId }); }); res.ClientProcess.forEach(function (value, index, array) { thisObj.clientItems.push({ id: value.id, Type: value.processType, Index: value.order, SelectValue: value.roleId, node: value.node, parentNode: value.parentNode, approvalGroupId: value.approvalGroupId, approvalCondition: value.approvalCondition }); }); } ); }, getApprovalGroup() { var thisObj = this; main.post("/System/ApplovalGroupSearch", { MemberName: "" }).done(function (resp) { thisObj.grouplist = resp.obj; }).fail(function () { main.alert("加载失败"); }) }, filterChild(node) { return this.tradeItems.filter(x => x.node == node && x.approvalCondition == 0); }, openFilterChild(node) { return this.openItems.filter(x => x.node == node && x.approvalCondition == 0); }, clientFilterChild(node) { return this.clientItems.filter(x => x.node == node && x.approvalCondition == 0); }, initTradeItemIndex() { var thisObj = this; var newSortTradeItems = []; var mainTradeItems = thisObj.tradeItems.filter(x => x.node == 0).sort((a, b) => a.Index - b.Index); var childTradeItem = thisObj.tradeItems.filter(x => x.node != 0); var childTradeItemSort = childTradeItem.sort((a, b) => a.Index - b.Index); var firstChildIndex = childTradeItemSort.length > 0 ? childTradeItemSort[0].Index : -1; var j = 1; for (var i = 0; i < mainTradeItems.length; i++) { if (mainTradeItems[i].Index >= firstChildIndex) { if (childTradeItemSort.length > 0) { mainTradeItems[i].Index = childTradeItemSort[childTradeItemSort.length - 1].Index + j; j++; } else { mainTradeItems[i].Index = i + 1; } } newSortTradeItems.push(mainTradeItems[i]); } var firstChildTradeItems = childTradeItem.filter(x => x.node == 1); var secondChildTradeItems = childTradeItem.filter(x => x.node == 2); firstChildTradeItems.forEach((x, index) => { //分支index不用再排序 if (x.approvalCondition == 0) { x.Index = firstChildIndex + index; x.parentNode = firstChildIndex + index - 1; } newSortTradeItems.push(x); }); secondChildTradeItems.forEach((x, index) => { if (x.approvalCondition == 0) { x.Index = firstChildIndex + index; x.parentNode = firstChildIndex + index - 1; } newSortTradeItems.push(x); }); thisObj.tradeItems = newSortTradeItems.sort((a, b) => a.Index - b.Index); thisObj.initRuleType(); }, initOpenItemIndex() { var thisObj = this; var newSortOpenItems = []; var mainOpenItems = thisObj.openItems.filter(x => x.node == 0).sort((a, b) => a.Index - b.Index); var childOpenItem = thisObj.openItems.filter(x => x.node != 0); var childOpenItemSort = childOpenItem.sort((a, b) => a.Index - b.Index); var firstChildIndex = childOpenItemSort.length > 0 ? childOpenItemSort[0].Index : -1; var j = 1; for (var i = 0; i < mainOpenItems.length; i++) { if (mainOpenItems[i].Index >= firstChildIndex) { if (childOpenItemSort.length > 0) { mainOpenItems[i].Index = childOpenItemSort[childOpenItemSort.length - 1].Index + j; j++; } else { mainOpenItems[i].Index = i + 1; } } newSortOpenItems.push(mainOpenItems[i]); } var firstChildOpenItems = childOpenItem.filter(x => x.node == 1); var secondChildOpenItems = childOpenItem.filter(x => x.node == 2); firstChildOpenItems.forEach((x, index) => { //分支index不用再排序 if (x.approvalCondition == 0) { x.Index = firstChildIndex + index; x.parentNode = firstChildIndex + index - 1; } newSortOpenItems.push(x); }); secondChildOpenItems.forEach((x, index) => { if (x.approvalCondition == 0) { x.Index = firstChildIndex + index; x.parentNode = firstChildIndex + index - 1; } newSortOpenItems.push(x); }); thisObj.openItems = newSortOpenItems.sort((a, b) => a.Index - b.Index); }, initClientItemIndex() { var thisObj = this; var newSortClientItems = []; var mainClientItems = thisObj.clientItems.filter(x => x.node == 0).sort((a, b) => a.Index - b.Index); var childClientItem = thisObj.clientItems.filter(x => x.node != 0); var childClientItemSort = childClientItem.sort((a, b) => a.Index - b.Index); var firstChildIndex = childClientItemSort.length > 0 ? childClientItemSort[0].Index : -1; var j = 1; for (var i = 0; i < mainClientItems.length; i++) { if (mainClientItems[i].Index >= firstChildIndex) { if (childClientItemSort.length > 0) { mainClientItems[i].Index = childClientItemSort[childClientItemSort.length - 1].Index + j; j++; } else { mainClientItems[i].Index = i + 1; } } newSortClientItems.push(mainClientItems[i]); } var firstChildClientItems = childClientItem.filter(x => x.node == 1); var secondChildClientItems = childClientItem.filter(x => x.node == 2); firstChildClientItems.forEach((x, index) => { //分支index不用再排序 if (x.approvalCondition == 0) { x.Index = firstChildIndex + index; x.parentNode = firstChildIndex + index - 1; } newSortClientItems.push(x); }); secondChildClientItems.forEach((x, index) => { if (x.approvalCondition == 0) { x.Index = firstChildIndex + index; x.parentNode = firstChildIndex + index - 1; } newSortClientItems.push(x); }); thisObj.clientItems = newSortClientItems.sort((a, b) => a.Index - b.Index); }, initRuleType() { var thisObj = this; var tradeLength = thisObj.tradeItems.length; for (var i = 0; i < tradeLength; i++) { var ruleId = "#ruleType" + thisObj.tradeItems[i].Index + thisObj.tradeItems[i].node; var $selectize = $(ruleId).get(0); if (thisObj.tradeItems[i].ApprovalRules != null && thisObj.tradeItems[i].ApprovalRules.length > 0) { var ruleArr = thisObj.tradeItems[i].ApprovalRules.split(','); $selectize.selectize.setValue(ruleArr); } else if ($selectize) { $selectize.selectize.setValue([]); } } }, getRuleType() { var thisObj = this; var tradeLength = thisObj.tradeItems.length; for (var i = 0; i < tradeLength; i++) { var ruleId = "#ruleType" + thisObj.tradeItems[i].Index + thisObj.tradeItems[i].node; var $selectize = $(ruleId).get(0); if ($selectize) { var ruleArr = $selectize.selectize.items; thisObj.tradeItems[i].ApprovalRules = ruleArr.join(','); } } } }, mounted: function () { this.getProcess(); this.getApprovalGroup(); }, watch: { tradeItems: { handler(val, oldVal) { this.$nextTick(function () { setRuleDiv(); }) }, } } });