/// /// /// ;(function () { var platform = { initInfo: function () { var editor1 = utils.initCkEditor({ id: 'FirstGuideUrl', zIndex: 900 }); var editor2 = utils.initCkEditor({ id: 'DayGuideUrl', zIndex: 900 }); var editor3 = utils.initCkEditor({ id: 'WeekGuideUrl', zIndex: 900 }); var editor4 = utils.initCkEditor({ id: 'MonthGuideUrl', zIndex: 900 }); utils.getRequest('platforminfo/getbytoken/1', {}, function (d) { if (d && d.Data) { loadData(d.Data); } }); $('#btnedit').unbind('click').click(function () { $('[data-edit]').removeClass('hide'); $('[data-view]').addClass('hide'); $(this).closest('div').addClass('hide'); }); $('#btncancel').unbind('click').click(function () { $('[data-edit]').addClass('hide'); $('[data-view]').removeClass('hide'); $('#btnedit').closest('div').removeClass('hide'); utils.getRequest('platforminfo/getbytoken/1', {}, function (d) { if (d && d.Data) { loadData(d.Data); } }); }); initUpload(); function initUpload() { //utils.uploader({ // browse_button: 'FirstGuideUrl', completeCallback: function (d) { // $('[data-FirstGuideUrl]').attr('src', d); // } //}); //utils.uploader({ // browse_button: 'DayGuideUrl', completeCallback: function (d) { // $('[data-DayGuideUrl]').attr('src', d); // } //}); //utils.uploader({ // browse_button: 'WeekGuideUrl', completeCallback: function (d) { // $('[data-WeekGuideUrl]').attr('src', d); // } //}); //utils.uploader({ // browse_button: 'MonthGuideUrl', completeCallback: function (d) { // $('[data-MonthGuideUrl]').attr('src', d); // } //}); utils.uploader({ browse_button: 'FamilyProDutyUrl', completeCallback: function (d) { $('[data-FamilyProDutyUrl]').attr('src', d); } }); utils.uploader({ browse_button: 'PayrollCreditDesUrl', completeCallback: function (d) { $('[data-PayrollCreditDesUrl]').attr('src', d); } }); utils.uploader({ browse_button: 'HomeServiceUrl', completeCallback: function (d) { $('[data-HomeServiceUrl]').attr('src', d); } }); utils.uploader({ browse_button: 'HomeMarkingUrl', completeCallback: function (d) { $('[data-HomeMarkingUrl]').attr('src', d); } }); utils.uploader({ browse_button: 'HomeMarkingSupUrl', completeCallback: function (d) { $('[data-HomeMarkingSupUrl]').attr('src', d); } }); utils.uploader({ browse_button: 'PreChargeDesUrl', completeCallback: function (d) { $('[data-PreChargeDesUrl]').attr('src', d); } }); } function getParams() { var params = {}; params.FirstGuideUrl = editor1.getContent(); params.DayGuideUrl = editor2.getContent(); params.WeekGuideUrl = editor3.getContent(); params.MonthGuideUrl = editor4.getContent(); params.FamilyProDutyUrl = $('[data-FamilyProDutyUrl]').attr('src'); params.PayrollCreditDesUrl = $('[data-PayrollCreditDesUrl]').attr('src'); params.HomeServiceUrl = $('[data-HomeServiceUrl]').attr('src'); params.HomeMarkingUrl = $('[data-HomeMarkingUrl]').attr('src'); params.PreChargeDesUrl = $('[data-PreChargeDesUrl]').attr('src'); params.HomeMarkingSupUrl = $('[data-HomeMarkingSupUrl]').attr('src'); return params; } function loadData(d) { $('#FirstGuide').html(template('platforminfo/viewdetail', { data: d.FirstGuideUrl })); $('#DayGuide').html(template('platforminfo/viewdetail', { data: d.DayGuideUrl })); $('#WeekGuide').html(template('platforminfo/viewdetail', { data: d.WeekGuideUrl })); $('#MonthGuide').html(template('platforminfo/viewdetail', { data: d.MonthGuideUrl })); editor1.ready(function () { editor1.setContent(d.FirstGuideUrl); $('[data-edit1]').addClass('hide'); }); editor2.ready(function () { editor2.setContent(d.DayGuideUrl); $('[data-edit2]').addClass('hide'); }); editor3.ready(function () { editor3.setContent(d.WeekGuideUrl); $('[data-edit3]').addClass('hide'); }); editor4.ready(function () { editor4.setContent(d.MonthGuideUrl); $('[data-edit4]').addClass('hide'); }); $('[data-FamilyProDutyUrl]').attr('src', d.FamilyProDutyUrl); $('[data-PayrollCreditDesUrl]').attr('src', d.PayrollCreditDesUrl); $('[data-HomeServiceUrl]').attr('src', d.HomeServiceUrl); $('[data-HomeMarkingUrl]').attr('src', d.HomeMarkingUrl); $('[data-PreChargeDesUrl]').attr('src', d.PreChargeDesUrl); $('#id').val(d.Id); } $('#btnsave').unbind('click').click(function () { var btn = new utils.buttonHelper(this); btn.disable(); var params = getParams(); params.Id = $('#id').val(); utils.postRequest('platforminfo/{0}'.format(params.Id || 0), params, function () { $.msg('success', '保存成功'); setTimeout(function () { $('#btncancel').trigger('click'); }, 500); }).then(function () { btn.setText('确认'); btn.enable(); }); }); }, initAddAccount: function () { var id = $.getUrlParamBy('id') || 0; var f = $.getUrlParamBy('f'); if (id == 0) { //新增 $('[data-title]').html('新增账号'); $('#btnadd').html('保存'); $('[data-btn-del]').addClass('hide'); $('#username').removeAttr('disabled'); $('[data-edit]').removeClass('hide'); $('#btnadd').unbind('click').click(function () { var btn = new utils.buttonHelper(this); btn.disable(); var params = getParams(); if (params.IsError) { btn.setText('保存'); btn.enable(); return; } utils.postRequest('platform', params, function () { $.msg('success', '添加成功'); setTimeout(function () { location.hash = '#platforminfo/loginacc/index'; }, 300); }).complete(function () { btn.setText('保存'); btn.enable(); }); }); } else { //修改 $('[data-title]').html('修改账号'); $('#btnadd').html('保存'); $('#username').attr('disabled', 'disabled'); $('[data-edit]').addClass('hide'); loadData(); $('#btnadd').unbind('click').click(function () { var btn = new utils.buttonHelper(this); btn.disable(); var params = {}; params.RoleId = $('#roleid').val(); params.Curstatus = $('#curstatus').val(); params.Id = id; utils.postRequest('platform/{0}'.format(id), params, function () { $.msg('success', '更新成功'); setTimeout(function () { location.hash = '#platforminfo/loginacc/index'; }, 300); }).complete(function () { btn.setText('保存'); btn.enable(); }); }); } $('#btncancel').unbind('click').click(function () { window.history.back(); }); function loadData() { utils.getRequest('platform/{0}'.format(id), {}, function (d) { $('#username').val(d.Data.UserName); $('#roleid').val(d.Data.RoleId); $('#curstatus').val(d.Data.CurStatus); $('Id').val(d.Data.id); }); }; function getParams() { var params = {}; params.UserName = $.trim($('#username').val()); if (utils.isNull(params.UserName)) { $.msg('用户名不能为空'); params.IsError = true; return params; } var pwd = $.trim($('#pwd').val()); if (utils.isNull(pwd)) { $.msg('密码不能为空'); params.IsError = true; return params; } var pwd1 = $.trim($('#pwd1').val()); if (pwd !== pwd1) { $.msg('两次密码输入不一致!'); params.IsError = true; return params; } params.Password = CryptoJS.MD5(pwd).toString(); params.RoleId = $('#roleid').val(); params.CurStatus = $('#curstatus').val(); if (params.CurStatus == -1) { $.msg('请选择状态'); params.IsError = true; return params; } params.IsError = false; return params; } }, initEditPwd: function () { $('#btnadd').unbind('click').click(function () { var btn = new utils.buttonHelper(this); btn.disable(); var oldPwd = $.trim($('#oldpwd').val()); if (utils.isNull(oldPwd)) { $.msg('原密码不能为空'); btn.setText('保存'); btn.enable(); return; } var pwd = $.trim($('#pwd').val()); if (utils.isNull(pwd)) { $.msg('新密码不能为空'); btn.setText('保存'); btn.enable(); return; } var pwd1 = $.trim($('#pwd1').val()); if (pwd !== pwd1) { $.msg('两次输入的密码不一致'); btn.setText('保存'); btn.enable(); return; } utils.postRequest('platform/updatepwd', { id: $.cookie('userid'), UserName: $.cookie('username'), Password: CryptoJS.MD5(oldPwd).toString(), newpwd: CryptoJS.MD5(pwd).toString() }, function () { $.msg('success', '密码修改成功'); setTimeout(function () { window.location = 'login.html'; }, 300); }).complete(function () { btn.setText('保存'); btn.enable(); }); }); $('#btncancel').unbind('click').click(function () { window.history.back(); }); }, initAcc: function () { $('[data-query-value]').unbind('click').click(function () { loadData(); }); $('[data-query-text]').keypress(function (evt) { var et = evt || event; var iKeyCode = et.keyCode || et.which; if (iKeyCode == 13) { loadData(); } }); loadData(); function loadData(p) { var params = {}; $.extend(params, p); params.UserName = $.trim($('[data-query-text]').val()); utils.loadDataList('platform', params, 'platforminfo/loginacc/itemlist', $('#datalist'), $('.pg'), null, null, null, function () { $('[data-delete]').unbind('click').click(function () { var id = $(this).closest('tr').attr('id'); utils.postHandleFun('platform/del', { id: id }, function () { $.msg('success', '删除成功'); setTimeout(function () { loadData(); }, 500); }, '确定要删除吗?', null, null, function () { console.log(1111); }); }) }); }; }, initBaseAccount: function () { var cxapi; function initSelect(d) { if (cxapi) { cxapi.detach(); } /*初始化省市县三级联动*/ $('#bankarea').cxSelect({ url: "/js/cityData.min.json", // 如果服务器不支持 .json 类型文件,请将文件改为 .js 文件 selects: ["province", "city"] // 数组,请注意顺序 }, function (api) { cxapi = api; }); utils.initSelect($('#BankId'), 'bankitem', null, d && d.Data ? [{ id: d.Data.BankId, text: d.Data.BankItemName }] : []); } function loadData() { utils.getRequest('platforminfo/detail', {}, function (d) { initData(d); }); } function initData(d) { initSelect(d); if (d && d.Data) { $('#Province').attr('data-value', d.Data.Province); $('#City').attr('data-value', d.Data.City); $('#Id').val(d.Data.Id); $('#AccountTypeId').val(d.Data.AccountType); $('#AccountName').val(d.Data.AccountName); $('#AccountNo').val(d.Data.AccountNo); $('#BankBranchName').val(d.Data.BranchName); } } loadData(); $('#btnEdit').unbind('click').click(function () { $(this).closest('div [data-edit]').addClass('hide'); $('[data-save]').removeClass('hide'); enabledObj(); }); $('#btncancel').unbind('click').click(function () { $('[data-save]').addClass('hide'); $('[data-edit]').removeClass('hide'); loadData(); disabledObj(); }); $('#btnsave').unbind('click').click(function () { var self = this; var params = {}; params.Id = $('#Id').val(); params.AccountType = $('#AccountTypeId').val(); if (!params.AccountType) { $.msg('请选择账户类型'); return; } params.AccountName = $('#AccountName').val(); if (utils.isNull(params.AccountName)) { $.msg('账户名称不能为空'); return; } params.AccountNo = $('#AccountNo').val(); if (utils.isNull(params.AccountNo)) { $.msg('银行卡号不能为空'); return; } params.Province = $('#Province').val(); if (utils.isNull(params.Province)) { $.msg('开户行所在省份不能为空'); return; } params.City = $('#City').val(); if (utils.isNull(params.City)) { $.msg('开户行所在的城市不能为空'); return; } params.BankId = $('#BankId').val(); if (!params.BankId || params.BankId == 0) { $.msg('请选择开户银行'); return; } params.BranchName = $('#BankBranchName').val(); if (utils.isNull(params.BranchName)) { $.msg('分行名称不能为空'); return; } $(this).attr('disabled', 'disabled'); utils.postRequest('platforminfo/create', params, function (d) { $.msg('保存成功'); initData(d); $('[data-save]').addClass('hide'); $('[data-edit]').removeClass('hide'); disabledObj(); }).complete(function () { $(self).removeAttr('disabled'); }) }); function enabledObj() { $('#AccountTypeId').removeAttr('disabled'); $('#AccountName').removeAttr('disabled'); $('#AccountNo').removeAttr('disabled'); $('#BankId').removeAttr('disabled'); $('#BankBranchName').removeAttr('disabled'); } function disabledObj() { $('#AccountTypeId').attr('disabled', 'disabled'); $('#AccountName').attr('disabled', 'disabled'); $('#AccountNo').attr('disabled', 'disabled'); $('#BankId').attr('disabled', 'disabled'); $('#BankBranchName').attr('disabled', 'disabled'); } }, /*资产管理*/ initAsset: { unissued: function () { $('[data-query-start],[data-query-end]').focus(function () { WdatePicker(); }); function loadData() { var params = {}; params.StartTime = $('[data-query-start]').val(); params.EndTime = $('[data-query-end]').val(); params.Vague = $.trim($('[data-query-text]').val()); params.CurStatus = 0; utils.loadDataList('DrawCashRecord', params, 'asset/drawcashrecord/itemlist', $('#datalist'), $('.pg'), null, null, null, function () { $('[data-evt="ok"]').off('click').on('click', function () { var objtr = $(this).closest('tr'); var id = objtr.data('id'); var drawcash = objtr.find('[data-evt="drawcash"]').html(); var serviceamount = objtr.find('[data-evt="servicecharge"]').html(); var paymentamount = objtr.find('[data-evt="paymentamount"]').html(); var html = template('asset/drawcashrecord/issuedialog', { DrawCash: drawcash, ServiceAmount: serviceamount, PaymentAmount:paymentamount}); utils.openDialog({ id: 'drawcash', title: '提现发放', content: html, showFooter: false, modelSizeCss:'modal-md', callBack: function (dlgbox) { $(dlgbox).on('click', '#btnok', function () { var btn = utils.buttonHelper(this); btn.disable(); utils.postRequest('DrawCashRecord/audit/{0}'.format(id), {}, function (d) { if (d.IsError) { $.msg(d.Msg); return; } $.msg('success', '发放成功'); setTimeout(function () { utils.closeDialog('drawcash'); loadData(); }, 300); }).complete(function () { btn.enable(); btn.setText('确认发放'); }); }); } }) }); }); } loadData(); $('[data-query-value]').off('click').on('click', function () { loadData(); }); $('[data-query-text]').keydown(function (evt) { var ev = evt || window.event; var keCode = ev.keyCode || ev.which; if (keCode === 13) { loadData(); } }); }, issued: function () { $('[data-query-start],[data-query-end]').focus(function () { WdatePicker(); }); function loadData() { var params = {}; params.StartTime = $('[data-query-start]').val(); params.EndTime = $('[data-query-end]').val(); params.Vague = $.trim($('[data-query-text]').val()); params.CurStatus = 1; utils.loadDataList('DrawCashRecord', params, 'asset/drawcashrecord/itemlist', $('#datalist'), $('.pg'), null, null, null, function (d) { if (d && d.Data && d.Data.Collection.length > 0) { $('#datalist tr').each(function (index, ele) { $(ele).find('td:last').empty().remove(); }); } }); } loadData(); $('[data-query-value]').off('click').on('click', function () { loadData(); }); $('[data-query-text]').keydown(function (evt) { var ev = evt || window.event; var keCode = ev.keyCode || ev.which; if (keCode === 13) { loadData(); } }); } }, message: function () { function loadData() { utils.loadDataList('Message/list', { FromType: 6, flag: 1 }, 'message/itemlist', $('#datalist'), $('.pg')); }; loadData(); $('#datalist').on('click', '[data-evt="detail"]', function () { var id = $(this).data('id'); utils.getRequest('message/{0}'.format(id), {}, function (d) { var html = template('message/detail', d.Data || {}); utils.openDialog({ id: 'view', title: '详情', content: html, showFooter: false, callBack: function () { } }); }); }); $('[data-evt="sndmsg"]').off('click').on('click', function () { var html = template('message/sndmsg', {}); utils.openDialog({ id: 'sndmsg', title: '发送消息', content: html, showFooter: false, callBack: function (dlgbox) { $(dlgbox).find('[for="all"]').off('click').on('click', function () { $(dlgbox).find('#receive').closest('div.form-group').addClass('hide'); }); $(dlgbox).find('#all').off('click').on('click', function () { $(dlgbox).find('[for="all"]').trigger('click'); }); $(dlgbox).find('#localteam').off('click').on('click', function () { $(dlgbox).find('[for="localteam"]').trigger('click'); }); $(dlgbox).find('#seller').off('click').on('click', function () { $(dlgbox).find('[for="seller"]').trigger('click'); }); $(dlgbox).find('#housekeeper').off('click').on('click', function () { $(dlgbox).find('[for="housekeeper"]').trigger('click'); }); $(dlgbox).find('#customer').off('click').on('click', function () { $(dlgbox).find('[for="customer"]').trigger('click'); }); $(dlgbox).find('#localteam_lb,#seller_lb,#housekeeper_lb,#customer_lb').off('click').on('click', function () { showDialog($(dlgbox), $(this).data('type') + ''); }); $(dlgbox).find('#btnsave').off('click').on('click', function () { var params = {}; params.content = $(dlgbox).find('#content').val(); if (utils.isNull(params.content)) { $.msg('内容不能为空'); return; } params.ids = $(this).data('ids') || []; $(dlgbox).find('[type="radio"]').each(function () { if ($(this).prop('checked')) { params.type = $(this).data('type'); return; } }); params.isall = $(this).data('isall') || false; if (params.type !== 0) { if (params.isall == false) { if (params.ids.length === 0) { $.msg('请选择发送对象'); return; } } } var btn = utils.buttonHelper(this); btn.disable(); utils.postRequest('Message/batchcreate', params, function (d) { if (d.IsError) { $.msg(d.Msg); return; } $.msg('success', '消息发送成功'); utils.closeDialog('sndmsg'); setTimeout(function () { loadData();}, 250); }).complete(function () { btn.enable(); btn.setText('确定'); }); }); } }); }); function showDialog(dlgbox, type) { var ids = []; var isAll = false; var htm = template('message/sndtooltip', {}); utils.openDialog({ id: 'choose', title: '选择', content: htm, showFooter: false, modelSizeCss: 'modal-sm', callBack: function (box) { $(box).find('[for="chooseone"]').off('click').on('click', function () { var htmlchoose = template('message/choose', {}); utils.closeDialog('choose'); utils.openDialog({ id: 'chooses', title: '选择', showFooter: false, content: htmlchoose, callBack: function (ddlgbox) { var url = ""; switch (type) { case "1": url = "localteamOther/choose"; break; case "2": url = "localteamOther/choose"; break; case "3": url = "HouseKeeper/choose"; break; case "4": url = "customer/choose"; break; default: break; } function loadChooseData() { var params = {}; if (type === "1") { params.IsPlatform = true; } else { params.IsPlatform = false; } params.Vague = $.trim($(ddlgbox).find('#queryValue').val()); utils.loadDataList(url, params, 'message/chooseitem', $(ddlgbox).find('#datalist'), $(ddlgbox).find('.pg'), null, null, null, function () { $(ddlgbox).find('#datalist tr').off('click').on('click', function () { if ($(this).hasClass('active')) { $(this).removeClass('active'); $(this).find('.cbone').prop('checked', false); } else { $(this).addClass('active'); $(this).find('.cbone').prop('checked', true); } }); }); } loadChooseData(); $(ddlgbox).find('#queryValue').keypress(function (evt) { var ev = evt || window.event; var keyCode = ev.keyCode || ev.which; if (keyCode === 13) { loadChooseData(); } }); $(ddlgbox).find('[data-evt="query"]').off('click').on('click', function () { loadChooseData(); }); $(ddlgbox).find('.cball').off('click').on('click', function () { if ($(this).prop('checked')) { $(ddlgbox).find('#datalist tr').addClass('active'); $(ddlgbox).find('#datalist tr .cbone').prop('checked', true); } else { $(ddlgbox).find('#datalist tr').removeClass('active'); $(ddlgbox).find('#datalist tr .cbone').prop('checked', false); } }); $(ddlgbox).find('[data-evt="ok"]').off('click').on('click', function () { if ($(ddlgbox).find('#datalist tr.active').length === 0) { $.msg('请选择记录后操作'); return; } var idss = []; var names = []; $(ddlgbox).find('#datalist tr.active').each(function () { idss.push($(this).data('id')); names.push($(this).find('td:last').text()); }); ids = idss; idsss = []; $(dlgbox).find('#receive').closest('div.form-group').removeClass('hide'); $(dlgbox).find('#receive').val(names.join(',')); utils.closeDialog('chooses'); $(dlgbox).find('#btnsave').data('isall', isAll).data('ids', ids).data('type', type); }); } }); }); $(box).find('#chooseone').off('click').on('click', function () { $(box).find('[for="chooseone"]').trigger('click'); }); $(box).find('#chooseall').off('click').on('click', function () { $(box).find('[for="chooseall"]').trigger('click'); }); $(box).find('[for="chooseall"]').off('click').on('click', function () { utils.closeDialog('choose'); var tips = ""; switch (type) { case "1": tips = "全部的地方平台"; break; case "2": tips = "全部的商家"; break; case "3": tips = "全部的家政员"; break; case "4": tips = "全部的客户"; break; default: break; } isAll = true; $(dlgbox).find('#receive').closest('div.form-group').removeClass('hide'); $(dlgbox).find('#receive').val(tips); $(dlgbox).find('#btnsave').data('isall', isAll).data('type', type); }); } }); } }, /*账目管理*/ initAccount: { initSer: function () { function loadData(){ var params = {}; params.curstatus = $('#curstatus').val(); params[$('#selectvalue').val()] = $.trim($('[data-query-text]').val()); utils.loadDataList('accountrecord/servicecharge', params, 'accountrecord/seritemlist', $('#datalist'), $('.pg')); } loadData(); $('[data-query-text]').keypress(function (evt) { var ev = evt || window.event; var keyCode = ev.keyCode || ev.which; if (keyCode === 13) { loadData(); } }); $('[data-query-value]').off('click').on('click', function () { loadData(); }); }, initSerPay: function () { function loadData() { var params = {}; params.curstatus = $('#curstatus').val(); params[$('#selectvalue').val()] = $.trim($('[data-query-text]').val()); utils.loadDataList('accountrecord/servicechargepay', params, 'accountrecord/serpayitem', $('#datalist'), $('.pg')); } loadData(); $('[data-query-text]').keypress(function (evt) { var ev = evt || window.event; var keyCode = ev.keyCode || ev.which; if (keyCode === 13) { loadData(); } }); $('[data-query-value]').off('click').on('click', function () { loadData(); }); }, initPayRoll: function () { function loadData() { var params = {}; params.curstatus = $('#curstatus').val(); params[$('#selectvalue').val()] = $.trim($('[data-query-text]').val()); utils.loadDataList('accountrecord/payrollpay', params, 'accountrecord/payrollitem', $('#datalist'), $('.pg')); } loadData(); $('[data-query-text]').keypress(function (evt) { var ev = evt || window.event; var keyCode = ev.keyCode || ev.which; if (keyCode === 13) { loadData(); } }); $('[data-query-value]').off('click').on('click', function () { loadData(); }); } } } window.platform = platform;})();