define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backend, Form) { var Controller = { start: function () { $('#fastflow-c-flow_id').on('change', function (e) { src = $('#fastflow-viewer').attr('src'); if(src === undefined){ return false; } src = src.replace(/(?<=flow_id=)\d*/, $(this).val()); $('#fastflow-viewer').attr('src', src); $.ajax({ type: "POST", url: 'fastflow/flow/run/getStartDynamicSteps', data: {flow_id: $(this).val(), bill: Config.bill, bill_id: Config.bill_id}, dataType: "json", success: function (data) { $('#fastflow-selectworker table tbody tr:gt(0)').remove(); if (data['code'] == 1) { if (data['data'].length > 0) { $('#fastflow-selectworker').removeClass('hidden'); Controller.api.methods.addDynamicStepItem(data['data']); } else { $('#fastflow-selectworker').addClass('hidden'); } } else if (data['code'] == 0) { $('#fastflow-selectworker').addClass('hidden'); Toastr.error(data['msg']); } } }); }); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Form.api.bindevent($("form[role=form]")); Controller.api.methods.buildBillEdit(); $('#fastflow-c-flow_id').trigger('change'); $('#addebill-btn').click(function () { if($(this).attr('aria-expanded') === 'false'){ Controller.api.refreshEbillList(); } }); $('#removeebill-btn').click(function () { $('#fastflow-ebill').attr('src', ''); $('input[name="row[ebill_id]"]').val(''); $('#fastflow-ebill').addClass('hidden'); $('.ebill-empty-hint').removeClass('hidden'); }); $('#refreshebill-btn').click(function () { var ebillId = $('input[name="row[ebill_id]"]').val(); if (ebillId !== ''){ let row = $('form[role="form"]','#bill-edit').serialize(); var src = $('#fastflow-ebill').data('src'); $('#fastflow-ebill').attr('src', src + '?' + 'action=preview' + '&id=' + ebillId + '&bill=' + Config.bill + '&bill_id=' + Config.bill_id + '&' + row); } }); $('#contenedorCards').click(function () { return false; }); }, start2: function () { $('#fastflow-c-flow_id').on('change', function (e) { src = $('#fastflow-viewer').attr('src'); if(src === undefined){ return false; } src = src.replace(/(?<=flow_id=)\d*/, $(this).val()); $('#fastflow-viewer').attr('src', src); $.ajax({ type: "POST", url: 'fastflow/flow/run/getStartDynamicSteps', data: {flow_id: $(this).val(), bill: Config.bill, bill_id: Config.bill_id}, dataType: "json", success: function (data) { $('#fastflow-selectworker table tbody tr:gt(0)').remove(); if (data['code'] == 1) { if (data['data'].length > 0) { $('#fastflow-selectworker').removeClass('hidden'); Controller.api.methods.addDynamicStepItem(data['data']); } else { $('#fastflow-selectworker').addClass('hidden'); } } else if (data['code'] == 0) { $('#fastflow-selectworker').addClass('hidden'); Toastr.error(data['msg']); } } }); }); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Form.api.bindevent($("form[role=form]")); Controller.api.methods.buildBillEdit(); $('#fastflow-c-flow_id').trigger('change'); $('#addebill-btn').click(function () { if($(this).attr('aria-expanded') === 'false'){ Controller.api.refreshEbillList(); } }); $('#removeebill-btn').click(function () { $('#fastflow-ebill').attr('src', ''); $('input[name="row[ebill_id]"]').val(''); $('#fastflow-ebill').addClass('hidden'); $('.ebill-empty-hint').removeClass('hidden'); }); $('#refreshebill-btn').click(function () { var ebillId = $('input[name="row[ebill_id]"]').val(); if (ebillId !== ''){ let row = $('form[role="form"]','#bill-edit').serialize(); var src = $('#fastflow-ebill').data('src'); $('#fastflow-ebill').attr('src', src + '?' + 'action=preview' + '&id=' + ebillId + '&bill=' + Config.bill + '&bill_id=' + Config.bill_id + '&' + row); } }); $('#contenedorCards').click(function () { return false; }); }, start3: function () { $('#fastflow-c-flow_id').on('change', function (e) { src = $('#fastflow-viewer').attr('src'); if(src === undefined){ return false; } src = src.replace(/(?<=flow_id=)\d*/, $(this).val()); $('#fastflow-viewer').attr('src', src); $.ajax({ type: "POST", url: 'fastflow/flow/run/getStartDynamicSteps', data: {flow_id: $(this).val(), bill: Config.bill, bill_id: Config.bill_id}, dataType: "json", success: function (data) { $('#fastflow-selectworker table tbody tr:gt(0)').remove(); if (data['code'] == 1) { if (data['data'].length > 0) { $('#fastflow-selectworker').removeClass('hidden'); Controller.api.methods.addDynamicStepItem(data['data']); } else { $('#fastflow-selectworker').addClass('hidden'); } } else if (data['code'] == 0) { $('#fastflow-selectworker').addClass('hidden'); Toastr.error(data['msg']); } } }); }); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Form.api.bindevent($("form[role=form]")); Controller.api.methods.buildBillEdit(); $('#fastflow-c-flow_id').trigger('change'); $('#addebill-btn').click(function () { if($(this).attr('aria-expanded') === 'false'){ Controller.api.refreshEbillList(); } }); $('#removeebill-btn').click(function () { $('#fastflow-ebill').attr('src', ''); $('input[name="row[ebill_id]"]').val(''); $('#fastflow-ebill').addClass('hidden'); $('.ebill-empty-hint').removeClass('hidden'); }); $('#refreshebill-btn').click(function () { var ebillId = $('input[name="row[ebill_id]"]').val(); if (ebillId !== ''){ let row = $('form[role="form"]','#bill-edit').serialize(); var src = $('#fastflow-ebill').data('src'); $('#fastflow-ebill').attr('src', src + '?' + 'action=preview' + '&id=' + ebillId + '&bill=' + Config.bill + '&bill_id=' + Config.bill_id + '&' + row); } }); $('#contenedorCards').click(function () { return false; }); }, agree: function () { Form.api.bindevent($("form[role=form]")); let data = Config.dynamic_step_data; for (let index in data) { $('#fastflow-scope-' + data[index]['id']).on('change', function () { if ($(this).val() == 5) { $('#fastflow-span-' + data[index]['id']).addClass('hidden'); } else { $('#fastflow-span-' + data[index]['id']).removeClass('hidden'); $('#fastflow-worker-' + data[index]['id']).selectPageClear(); } }) $('#fastflow-worker-' + data[index]['id']).data("params", function (obj) { return {"scope": $('#fastflow-scope-' + data[index]['id']).val()}; }); } $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); $(document).on('click', '#dateils', function (data) { var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%']; console.log(3111); var options = { shadeClose : false, shade : [0.3, '#393D49'], area : area, } $(this).data('id') $type = $(this).data('type') if($type == 1 ){ Fast.api.open('fastflow/bill/Czgprz/dateils' + "?ids=" + $(this).data('id'), '详情',options); } if($type == 2 ){ Fast.api.open('fastflow/bill/Bywnpk/dateils' + "?ids=" + $(this).data('id'), '详情',options); } if($type == 3 ){ Fast.api.open('fastflow/bill/Tmrxyo/dateils' + "?ids=" + $(this).data('id'), '详情',options); } }) Controller.api.methods.buildBillEdit(); Controller.api.bindEbillTabEvent(); }, agree2: function () { Form.api.bindevent($("form[role=form]")); let data = Config.dynamic_step_data; for (let index in data) { $('#fastflow-scope-' + data[index]['id']).on('change', function () { if ($(this).val() == 5) { $('#fastflow-span-' + data[index]['id']).addClass('hidden'); } else { $('#fastflow-span-' + data[index]['id']).removeClass('hidden'); $('#fastflow-worker-' + data[index]['id']).selectPageClear(); } }) $('#fastflow-worker-' + data[index]['id']).data("params", function (obj) { return {"scope": $('#fastflow-scope-' + data[index]['id']).val()}; }); } $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Controller.api.methods.buildBillEdit(); Controller.api.bindEbillTabEvent(); }, sign: function () { Form.api.bindevent($("form[role=form]")); $('#fastflow-sign_worker').data("params", function (obj) { return {"scope": $('#fastflow-sign_scope').val()}; }); $('#fastflow-sign_scope').change(function () { $('#fastflow-sign_worker').selectPageClear(); }); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Controller.api.methods.buildBillEdit(); Controller.api.bindEbillTabEvent(); }, back: function () { Form.api.bindevent($("form[role=form]")); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); $(document).on('click', '#dateils', function (data) { var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%']; console.log(3111); var options = { shadeClose : false, shade : [0.3, '#393D49'], area : area, } $(this).data('id') $type = $(this).data('type') if($type == 1 ){ Fast.api.open('fastflow/bill/Czgprz/dateils' + "?ids=" + $(this).data('id'), '详情',options); } if($type == 2 ){ Fast.api.open('fastflow/bill/Bywnpk/dateils' + "?ids=" + $(this).data('id'), '详情',options); } if($type == 3 ){ Fast.api.open('fastflow/bill/Tmrxyo/dateils' + "?ids=" + $(this).data('id'), '详情',options); } }) Controller.api.methods.buildBillEdit(); Controller.api.bindEbillTabEvent(); }, sign2: function () { Form.api.bindevent($("form[role=form]")); $('#fastflow-sign_worker').data("params", function (obj) { return {"scope": $('#fastflow-sign_scope').val()}; }); $('#fastflow-sign_scope').change(function () { $('#fastflow-sign_worker').selectPageClear(); }); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Controller.api.methods.buildBillEdit(); Controller.api.bindEbillTabEvent(); }, back2: function () { Form.api.bindevent($("form[role=form]")); $('#fastflow-carbon_receiver').data("params", function (obj) { return {"scope": $('#fastflow-carbon_scope').val()}; }); $('#fastflow-carbon_scope').change(function () { $('#fastflow-carbon_receiver').selectPageClear(); }); Controller.api.methods.buildBillEdit(); Controller.api.bindEbillTabEvent(); }, change : function () { Form.api.bindevent($("form[role=form]")); }, api: { bindevent: function () { }, bindEbillSelectEvent: function(){ $('.imgProd', '#contenedorCards').click(function () { let row = $('form[role="form"]','#bill-edit').serialize(); let ebillId = $(this).data('id'); var src = $('#fastflow-ebill').data('src'); $('#fastflow-ebill').attr('src', src + '?' + 'action=preview' + '&id=' + ebillId + '&bill=' + Config.bill + '&bill_id=' + Config.bill_id + '&' + row); $('#addebill-btn').closest('.btn-group').removeClass('open'); $('input[name="row[ebill_id]"]','#flow-form').val($(this).data('id')); $('input[name="row[ebill_id]"]','#flow-form').val($(this).data('id')); $('#addebill-btn').attr('aria-expanded','false'); $('.ebill-empty-hint').addClass('hidden'); $('#fastflow-ebill').removeClass('hidden'); }); $('.selectebill-btn', '#contenedorCards').click(function (e) { var ebillThumbnail = $(this).closest('.wrapper').find('.imgProd')[0]; ebillThumbnail.click(); }); }, showEbill:function(){ if(Config.ebill_id === null){ return; } $('.ebill-empty-hint').addClass('hidden'); $('#fastflow-ebill').removeClass('hidden'); let row = $('form[role="form"]','#bill-edit').serialize(); var src = $('#fastflow-ebill').data('src'); $('#fastflow-ebill').attr('src', src + '?' + 'action=detail' + '&bill=' + Config.bill + '&bill_id=' + Config.bill_id + '&' + row); }, bindEbillTabEvent:function(){ $('#ebill-tab').click(function (e) { Controller.api.showEbill(); }); }, formatter: {}, events: {}, methods: { addDynamicStepItem: function (data) { for (let index in data) { $('#fastflow-selectworker table tbody').append( '\n' + ' ' + data[index]['name'] + '\n' + ' ' + ' ' + ' \n' + ' \n' + ' ' + ' \n' + ' ' + ' \n' + ' \n' + '
\n' + ' \n' + ' \n' + '
\n' + ' \n' + '' ); $('#fastflow-scope-' + data[index]['id']).on('change', function () { if ($(this).val() == 5) { $('#fastflow-span-' + data[index]['id']).addClass('hidden'); } else { $('#fastflow-span-' + data[index]['id']).removeClass('hidden'); } }) $('#fastflow-worker-' + data[index]['id']).data("params", function (obj) { return {"scope": $('#fastflow-scope-' + data[index]['id']).val()}; }); } Form.api.bindevent($("form[role=form]")); }, addScope: function () { let result = ''; let scope = Config.scope; for (let i in scope) { result += ''; } return result; }, buildBillEdit: function () { let index = layer.load(); //4.4.1-- require(['/assets/js/backend/' + Config.controller_url + '.js'], function (billJs) { billJs.edit(); }); //-- $.ajax({ type: "get", url: Config.controller_url + "/edit", data: {ids: Config.bill_id, threadid: Config.thread_id}, success: function (data) { $('#bill-edit').append($('form[role="form"]',data)); $('.layer-footer','#bill-edit').remove(); if(Config.can_edit_fields !== true){ Config.bill_fields.forEach(function (item) { if ($.inArray(item, Config.can_edit_fields) === -1) { let input = $('[name^="row[' + item + ']"]',$('form[role="form"]','#bill-edit')); input.attr('disabled','disabled'); input.closest('.form-group').find('button').attr('disabled','disabled'); } else{ $($('[name="row[' + item + ']"]',$('form[role="form"]','#bill-edit'))).closest('.form-group').find('label').addClass('text-warning'); } }); } Form.api.bindevent($('form[role="form"]','#bill-edit')); require(['backend/fastflow/fastflow_yongyou_baojiadan_detail'], function (YongyouQuotationHook) { if (YongyouQuotationHook && typeof YongyouQuotationHook.attach === 'function') { YongyouQuotationHook.attach(Config); } }); $('button[disabled="disabled"]').closest('.form-group').find('a.btn').attr('disabled','disabled').click(function(){return false;}); $(document).on("fa.event.appendfieldlist", function(){ $('textarea[disabled="disabled"]').closest('.form-group').find('.btn-remove').attr('disabled','disabled').click(function(){return false;}); $('textarea[disabled="disabled"]').closest('.form-group').find('.btn-dragsort').attr('disabled','disabled').click(function(){return false;}); $('textarea[disabled="disabled"]').closest('.form-group').find('input').attr('disabled','disabled'); $('textarea[disabled="disabled"]').closest('.form-group').find('.btn-append').attr('disabled','disabled').click(function(){return false;}); }); layer.close(index); }, error:function (e) { layer.close(index); } }); $('button[type="submit"]','#flow-form').click(function (e) { e.stopPropagation(); e.preventDefault(); let loadIndex = layer.load(); $.ajax({ type: "post", url: Config.controller_url + "/edit?ids=" + Config.bill_id + "&threadid=" + Config.thread_id, data: $('#edit-form').serialize(), success: function (data) { if (data['code'] == 1){ $.ajax({ type: "post", url: location.href, data: $('#flow-form').serialize(), success: function (data) { if (data['code'] == 1){ parent.Toastr.success(data['msg']); Layer.close(loadIndex); let index = parent.Layer.getFrameIndex(window.name); parent.Layer.close(index); parent.$('.btn-refresh', parent.document).trigger('click'); } else{ Layer.close(loadIndex); Toastr.error(data['msg']); } } }); } else{ Layer.close(loadIndex); Toastr.error(data['msg']); } } }); return false; }); } }, refreshEbillList: function () { var index = layer.load(); $.ajax({ type: "get", url: 'fastflow/flow/ebill/getEbillList', data: { bill: Config.bill }, success: function (data) { if (data['code'] == 1) { $('.imgProd', '.ebill-list').unbind('click'); $('.selectebill-btn').unbind('click'); var ebills = data['ebills']; var html = Template('itemTpl', {list: data['ebills']}); document.getElementById('contenedorCards').innerHTML = html; ebills.length !== 0 ? $('.list-empty-hint').hide() : $('.list-empty-hint').show(); Controller.api.bindEbillSelectEvent(); } else if (data['code'] == 0) { Toastr.error(data['msg']); } layer.close(index); }, error: function (e) { layer.close(index); } }); }, } }; return Controller; });