app.controller('dealerManageCtrl', ['$scope', "$state", '$stateParams', '$http', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', 'md5', function ($scope, $state, $stateParams, $http, $timeout, uiGridConstants, i18nService, toaster, MD5) { i18nService.setCurrentLang("zh-cn"); var managerId = $stateParams.managerId; var agentId = $stateParams.agentId; $scope.gridOptions = { data: 'myData', showGridFooter: true, //是否显示grid footer // rowHeight: 80, //-------- 分页属性 ---------------- paginationPageSizes: [50, 200, 500, 1000, 2000], //每页显示个数可选项 paginationCurrentPage: 1, //当前页码 paginationPageSize: 50, //每页显示个数 totalItems: 0,// 总数量 useExternalPagination: true,//是否使用分页按钮 //过滤 // enableFiltering: true, columnDefs: [], //---------------api--------------------- onRegisterApi: function (gridApi) { $scope.gridApi = gridApi; gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { if ($scope.setPagingData) { $scope.getPagedDataAsync(newPage, pageSize); } }); } }; $scope.ngEvent = { changeProvince: function (bankInfo) { console.log("changeProvince") //无论是否选择了数据,都清空子级下拉框选中的项 bankInfo.bankCity = null; var bankProvinceID = bankInfo.bankProvince.value; if (bankProvinceID) $scope.searchArea(bankProvinceID,bankInfo) else bankInfo.cityList = [] } } //枚举常量 $scope.enum = {}; $scope.enum.adShow = [ {value: "", label: "-广告状态-"}, {value: false, label: "无广告"}, {value: true, label: "有广告"} ]; $scope.enum.forceFollowGzh = [ {value: "", label: "-强制关注状态-"}, {value: "agent", label: "以代理商为准"}, {value: "yes", label: "强制关注"}, {value: "no", label: "不允许强制关注"}, {value: "never", label: "永不强制关注公众号"}, {value: "free", label: "自由选择"}, ]; $scope.enum.platformSupport = [ {value: "", label: "-客服接管状态-"}, {value: "agent", label: "以代理商为准"}, {value: "yes", label: "需要平台"}, {value: "no", label: "不需要平台"}, {value: "never", label: "永远用自己的客服"}, {value: "free", label: "无所谓"}, ]; $scope.enum.beforeChargeUnpay = [ {value: "", label: "-使用前充值-"}, {value: "yes", label: "是"}, {value: "no", label: "否"}, {value: "never", label: "永不"}, {value: "free", label: "自由选择"}, ]; $scope.findEnum = function (list, value) { return list.find((item) => item.value === value) } var managerDefault = {"nickname": "厂商"} var agentDefault = {"nickname": "代理商"} //查询条件 var condition = $scope.condition = { adShow: $.extend({}, $scope.enum.adShow[0]), forceFollowGzh: $.extend({}, $scope.enum.forceFollowGzh[0]), beforeChargeUnpay: $.extend({}, $scope.enum.beforeChargeUnpay[0]), managerDefault: managerDefault, managerList: [managerDefault], manager: managerDefault, agentDefault: agentDefault, agentList: [agentDefault], agent: agentDefault, searchKey: "", }; var searchTimer = null; //事件 $scope.event = { statusChange: function (key, item) { condition[key].value = item.value; condition[key].label = item.label; this.search() }, managerInit: function ($event) { var searchKey = $event ? $event.target.value : ""; $timeout.cancel(searchTimer); searchTimer = $timeout(function () { $http.get('/superadmin/getManagerList', { params: { pageSize: 1000, pageIndex: 1, searchKey: searchKey, } }).then(function (data) { data = data.data $scope.condition.managerList = data.data.dataList; }).catch(function (data) { toaster.pop("error", "提示", "搜索失败"); }); }, 500);//延迟搜索,否则请求太频繁 }, agentInit: function ($event) { var searchKey = $event.target.value; var managerId = ""; if (condition.manager.id != "") { managerId = condition.manager.id } $timeout.cancel(searchTimer); searchTimer = $timeout(function () { $http.get('/superadmin/getAgentsDetailList', { params: { pageSize: 1000, pageIndex: 1, searchKey: searchKey, managerId: managerId, } }).then(function (data) { data = data.data $scope.condition.agentList = data.data.dataList; }).catch(function (data) { toaster.pop("error", "提示", "搜索失败"); }); }, 500);//延迟搜索,否则请求太频繁 }, search: function () { $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize); } }; // 初始化一次 $scope.event.managerInit(); function setColumnDefs() { $scope.gridOptions.columnDefs = [ { field: 'nickname', displayName: '商家名称', cellTemplate: '
' + '' + ' {{row.entity.nickname}} ' + '' + '
', }, {field: 'username', displayName: '用户名'}, { field: 'createdTime', displayName: '注册时间', cellTemplate: '
' }, { field: 'annualTrafficCost', displayName: '流量卡年费', cellTemplate: '
' }, { field: 'balance', displayName: '商家余额', cellTemplate: '
' }, { field: 'withdrawFeeRatio', displayName: '提现手续费', cellTemplate: '
{{row.entity.withdrawFeeRatio+"‰"}}
', }, { field: 'agentInfo', displayName: '代理商', }, { field: 'productName', displayName: '产品名称', }, { field: 'agentForceFollowGzh', displayName: '代理商强制关注', minWidth: 140, }, { field: 'moniAppName', displayName: '监督号名称', }, { field: 'pointDict', displayName: '监督号位置', cellTemplate: '
{{item.name}};
' }, { field: 'forceFollowGzh', displayName: '强制关注公众号', minWidth: 140, }, { field: 'devCount', displayName: '设备数量', }, // { // field: 'beforeChargeUnpay', // displayName: '使用前充值', // }, { field: 'maxPackagePrice', displayName: '最大套餐价格', }, { field: 'detail', displayName: '详细信息', cellTemplate: '
{{row.entity.detail}}
' }, { field: 'status', displayName: '状态', cellTemplate: '
{{row.entity.status}}
' }, ]; var operCol = { field: 'operation', displayName: '操作', enableFiltering: false, enableSorting: false, enableHiding: false,//禁止在列选择器中隐藏 enableColumnMenu: false,// 是否显示列头部菜单按钮 minWidth: 320, cellTemplate: '
' + '' + '' + // '' + '' + '' + '' + '' + '
' }; $scope.gridOptions.columnDefs.push(operCol) var fields = $scope.gridOptions.columnDefs; for (var index in fields) { var item = fields[index]; if (item && item['minWidth'] == null) { item['minWidth'] = 120; } } } $scope.setPagingData = function (data, curPage, pageSize) { var firstRow = (curPage - 1) * pageSize; var pagedData = data.data.dataList; $scope.myData = pagedData; $scope.gridOptions.totalItems = data.data.total; }; $scope.getPagedDataAsync = function (curPage, pageSize, searchText) { if ($scope.gridOptionsLoading) { return; } var params = { forceFollowGzh: condition.forceFollowGzh.value, beforeChargeUnpay: condition.beforeChargeUnpay.value, devCountMin: condition.devCountMin, devCountMax: condition.devCountMax, adShow: condition.adShow.value, pageSize: pageSize, pageIndex: curPage }; if (condition.searchKey != "") { params.searchKey = condition.searchKey } // 路由参数也可能有managerId if (managerId) { params.managerId = managerId } if (agentId) { params.agentId = agentId } if (condition.manager.id && condition.manager.id != "") { params.managerId = condition.manager.id } if (condition.agent.id && condition.agent.id != "") { params.agentId = condition.agent.id } $scope.gridOptionsLoading = true; $http.get('/superadmin/getDealerDetailList', { params: params }).then(function (data) { data = data.data $scope.gridOptionsLoading = false; $scope.setPagingData(data, curPage, pageSize); }).catch(function (data) { toaster.pop("error", "提示", "获取数据列表失败"); }); }; function initDataGrid() { //首次加载表格 $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); } setColumnDefs(); // initDataGrid(); 由于比较卡,初始化不加载 //广告开关 $scope.selectedIds = [] function getSelectRows() { var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length === 0) { toaster.pop("info", "提示", "请选择数据!"); return false; } var ids = []; for (var i = 0; i < rows.length; i++) { ids.push(rows[i].id); } $scope.selectedIds = ids; return ids } $scope.provinceList = [] $scope.searchSubBank = function (bankInfo) { let form = bankInfo $http.get('/common/withdraw/branchBank/list', { params: { bankCode: form?.bankItem?.value, provinceCode: form?.bankProvince?.value, cityCode: form?.bankCity?.value, } }).then(function (data) { data = data.data let {payload} = data let list = payload?.dataList || [] list = list.map(item => ({ text: item.name, value: item.code, })) bankInfo.branchBankList = list; }).catch(function (data) { toaster.pop("error", "提示", "支行获取失败"); }); } $scope.searchBank = function (bankInfo) { bankInfo.bankList = [] $http.get('/common/withdraw/bank/list', { params: { keyWord: bankInfo.keyWord, range: 'all' } }).then(function (data) { var bankList = data.data.payload.dataList bankList.forEach(function (item, index) { bankInfo.bankList.push({value: item.code, text: item.name}) }) }); } $scope.searchArea = function (province, bankInfo) { return new Promise((resolve => { //加载地址列表 $http.get('/common/withdraw/area/list', {params: {province: province || ""}}).then(function (data) { data = data.data var payload = data.payload let dataRe = (payload.dataList || []).map(item => { return { ...item, text: item.name, value: item.code, } }) if (province) { bankInfo.cityList = dataRe } else { $scope.provinceList = dataRe } resolve() }); })) } $scope.searchArea();// 加载省 //封号|解封 $scope.ban = function (entity, isNormal) { var url = "/superadmin/toggleDealerStatus"; $.confirm({ content: '确定这样操作?', buttons: { ok: { btnClass: 'btn-red', action: function () { $http({ method: 'POST', url: url, data: { id: entity.id, normal: isNormal } }).then(function (response) { if (isNormal) { entity.status = "normal"; } else { entity.status = "ban"; } console.log(response); if (response.data.result) { toaster.pop("success", "提示", "修改状态成功!"); } else { toaster.pop("error", "提示", "修改状态失败!"); } }, function (response) { toaster.pop("error", "提示", "修改状态失败!"); }); } }, } }); }; function getOneRow() { var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length === 0) { toaster.pop("info", "提示", "请选择数据!"); return false; } if (rows.length > 1) { toaster.pop("info", "提示", "只能选中编辑一条数据"); return false; } return rows[0] } // 解除5次错误限制 $scope.unfreeze = function (entity) { var entity = getOneRow(); if (!entity) { return } var url = "/superadmin/unfreeze"; $http({ method: 'POST', url: url, data: { role: "dealer", id: entity.id, } }).then(function (response) { if (response.data.result) { toaster.pop("success", "提示", "解除限制成功!"); } else { toaster.pop("error", "提示", "解除限制失败!"); } }, function (response) { toaster.pop("error", "提示", "解除限制失败!"); }); }; // 解除注册限制 $scope.unlockRegisterLimit = function () { var entity = getOneRow(); if (!entity) { return } var url = "/superadmin/unlockRegisterLimit"; $http({ method: 'POST', url: url, data: { role: "dealer", id: entity.id, } }).then(function (response) { if (response.data.result) { toaster.pop("success", "提示", "解除限制成功!"); } else { toaster.pop("error", "提示", "解除限制失败!"); } }, function (response) { toaster.pop("error", "提示", "解除限制失败!"); }); }; // 允许|禁止提现 $scope.toggleDealerWithdrawStatus = function (entity, noWithdraw) { var url = "/superadmin/toggleDealerWithdrawStatus"; $.confirm({ content: '确定这样操作?', buttons: { ok: { btnClass: 'btn-red', action: function () { $http({ method: 'POST', url: url, data: { dealer_id: entity.id, noWithdraw: noWithdraw } }).then(function (response) { if (noWithdraw) { entity.status = "noWithdraw"; // 仅仅用于刷新显示效果 } else { entity.status = "normal"; } console.log(response); if (response.data.result) { toaster.pop("success", "提示", "提现功能切换成功!"); } else { toaster.pop("error", "提示", "提现功能切换失败!"); } }, function (response) { toaster.pop("error", "提示", "提现功能切换失败!"); }); } }, } }); }; //查看设备 $scope.checkDevice = function (entity) { if (entity.id == null) { toaster.pop("error", "提示", "接口缺少经销商id!"); return } $state.go('app.dev.devManage', { managerId: "", agentId: "", dealerId: entity.id || "", searchKey: "", }, { reload: true }); }; //展示详情 $scope.showInfoDetail = function (title, content) { if (content) { $scope.infoDetail = {title: title, content: JSON.parse(content)}; $("#detailInfoPanel").modal(); } else { toaster.pop("info", "提示", "没有更多信息"); } } $scope.closeDetailInfoPanel = function () { $("#detailInfoPanel").modal("hide"); }; // 必须先声明,否则ui-select无法双绑 $scope.dialogData = {}; // 配置特性 $scope.editFeature = function (entity) { $scope.dialogData = { id: entity.id, featureList: entity.featureList, specialFeature: entity.specialFeature, }; $("#featureForm").modal(); } $scope.saveFeature = function () { if ($scope.featureForm.$invalid) { toaster.pop("warning", "提示", "请填写正确的数据"); return } $.confirm({ content: '确定要变更特性?', buttons: { ok: { btnClass: 'btn-red', action: function () { var url = "/superadmin/editDealerFeature"; $http({ method: 'POST', url: url, data: $scope.dialogData }).then(function (response) { //保存成功 弹窗消失 $('#featureForm').modal('hide'); if (response.data.result) { toaster.pop("info", "提示", "成功"); $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); } }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } }, } }); }; //广告开关 $scope.selectedIds = [] $scope.editAdShow = function () { $scope.dialogData = {}; var rows = getSelectRows() if (rows) { $("#editAdForm").modal(); } } $scope.saveAdEdit = function () { var ids = $scope.selectedIds if ($scope.editAdForm.$invalid) { toaster.pop("warning", "提示", "请填写正确的数据"); return } $http({ method: 'POST', url: '/superadmin/editAdShow', data: {ids: ids, adShow: $scope.dialogData.adShow, role: "dealer"} }).then(function (response) { initDataGrid(); $('#editAdForm').modal('hide'); toaster.pop("success", "提示", "保存成功!"); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } // 强制关注公众号 $scope.forceFollowGzh = function () { $scope.dialogData = {}; var rows = getSelectRows() if (rows) { $("#editGzhForm").modal(); } } $scope.saveGzg = function () { var ids = $scope.selectedIds if ($scope.editGzhForm.$invalid) { toaster.pop("warning", "提示", "请填写正确的数据"); return } $http({ method: 'POST', url: '/superadmin/editDealerFollowGzh', data: {ids: ids, forceFollowGzh: $scope.dialogData.forceFollowGzh} }).then(function (response) { initDataGrid(); $('#editGzhForm').modal('hide'); toaster.pop("success", "提示", "保存成功!"); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } // 编辑 $scope.editDealer = function (entity) { var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length === 0) { toaster.pop("info", "提示", "请选择数据!"); return; } if (rows.length > 1) { toaster.pop("info", "提示", "只能选中编辑一条数据"); return; } $scope.dialogData = rows[0]; $("#dealerForm").modal(); } $scope.saveDealer = function () { if ($scope.dealerForm.$invalid) { toaster.pop("warning", "提示", "请填写正确的数据"); return } $http({ method: 'POST', url: '/superadmin/editUserInfo', data: {role: 'dealer', id: $scope.dialogData.id, 'info': {username: $scope.dialogData.username}} }).then(function (response) { initDataGrid(); $('#dealerForm').modal('hide'); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } /**监督号展现位置**/ $scope.moniPoint = [] $http.get('/superadmin/getMoniPointList', { params: { pageSize: 1000, pageIndex: 1 } }).then(function (res) { var payload = res.data.payload; $scope.moniPoint = payload.dataList; }).catch(function (data) { toaster.pop("error", "提示", "获取监督号展现位置列表失败"); }); $scope.moniPointConfig = function () { var ids = getSelectRows() if (ids) { $("#moniPointForm").modal(); $scope.dialogData = {} for (var key in $scope.moniPoint) { var item = $scope.moniPoint[key] $scope.dialogData[item.key] = false } } }; $scope.setMoniPoint = function (pointKey) { var data = { dealerIds: $scope.selectedIds, moniPoint: [], } // 单个保存 if (pointKey) { data.moniPoint.push({ key: pointKey, switch: $scope.dialogData[pointKey] || false,// 默认为false }) } else { var tempApp = [] for (var key in $scope.dialogData) { tempApp.push({ key: key, switch: $scope.dialogData[key] || false,// 默认为false }) } data.moniPoint = tempApp } $http({ method: 'POST', url: "/superadmin/editMoniPointForDealers", data: data }).then(function (response) { toaster.pop("success", "提示", "保存成功!"); $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); //批量保存关闭弹窗 if (!pointKey) { $('#moniPointForm').modal('hide');//弹窗消失 } }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); }; $scope.editSupporter = function () { $scope.dialogData = {}; var rows = getSelectRows() if (rows) { $("#editSupporterForm").modal(); } } $scope.saveSuporter = function () { var ids = $scope.selectedIds if ($scope.editSupporterForm.$invalid) { toaster.pop("warning", "提示", "请填写正确的数据"); return } $http({ method: 'POST', url: '/superadmin/editSupporterForDealers', data: { ids: ids, platformSupport: $scope.dialogData.platformSupport } }).then(function (response) { initDataGrid(); $('#editSupporterForm').modal('hide'); toaster.pop("success", "提示", "保存成功!"); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } // 使用前充值 $scope.openSaveBeforeCharge = function () { $scope.dialogData = {}; var rows = getSelectRows() if (rows) { $("#beforeChargeUnpayForm").modal(); } } $scope.saveBeforeChargeUnpay = function () { var ids = $scope.selectedIds if ($scope.beforeChargeUnpayForm.$invalid) { toaster.pop("warning", "提示", "请填写正确的数据"); return } $http({ method: 'POST', url: '/superadmin/editDealerBeforeChargeUnpay', data: {ids: ids, beforeChargeUnpay: $scope.dialogData.beforeChargeUnpay} }).then(function (response) { initDataGrid(); $('#beforeChargeUnpayForm').modal('hide'); toaster.pop("success", "提示", "保存成功!"); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } //编辑密码 默认123456 $scope.editPassword = function () { //重置表单状态 $scope.passwordForm.$setPristine(); $scope.passwordForm.$setUntouched(); var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length == 0) { toaster.pop("info", "提示", "请选择数据!"); return; } if (rows.length > 1) { toaster.pop("info", "提示", "只能选中编辑一条数据"); return; } var item = rows[0]; $scope.passwordData = $.extend({password: 123456}, item); $("#passwordPanel").modal(); }; //修改密码提交 $scope.savePassword = function () { //表单未校验通过不能提交 if ($scope.passwordForm.$invalid) { return; } var url = "/superadmin/changeDealerPassword" var password = MD5.createHash($scope.passwordData.password + ''); $http({ method: 'POST', url: url, data: { id: $scope.passwordData.id, password: password, } }).then(function (response) { $('#passwordPanel').modal('hide');//弹窗消失 $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); }, function (response) { toaster.pop("error", "提示", "修改密码失败!"); }); }; // 获取此经销商的银行卡配置 function getBankConfigs(id) { return new Promise(((resolve, reject) => { $http.get('/superadmin/getDealerBanks', { params: { dealerId: id, } }).then(function (res) { resolve(res.data?.payload?.dataList) }).catch(function (data) { toaster.pop("error", "提示", "getDealerBanks失败。"); reject() }); })) } var lastRowId = "" async function renderBanksDialog(id){ let list = await getBankConfigs(id) || []; list.forEach(bankInfo => { findName(bankInfo) }) function findName(bankInfo) { if (bankInfo) { // 必须用provinceList ,确保引用地址一致,ui-select才能双绑。 for (var index in $scope.provinceList) { var item = $scope.provinceList[index]; if (item.value == bankInfo.provinceCode) { // 设置省份对应关系 bankInfo.bankProvince = item // 初始化二级 市(暂时不查接口) bankInfo.bankCity = { "text": bankInfo.city, "value": bankInfo.cityCode, } bankInfo.cityList = [ { "text": bankInfo.city, "value": bankInfo.cityCode, } ] break } } bankInfo.bankItem = { text: bankInfo.bankName, value: bankInfo.bankCode } bankInfo.branchBankItem = { text: bankInfo.branchBankName, value: bankInfo.branchBankCode } } } $scope.dialogData = { id: id, bankCards: list } $scope.$apply(); } $scope.editBankAccount = async function () { var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length === 0) { toaster.pop("info", "提示", "请选择数据!"); return; } if (rows.length > 1) { toaster.pop("info", "提示", "只能选中编辑一条数据"); return; } var row = rows[0] lastRowId = row.id; await renderBanksDialog(lastRowId) $("#bankAccountForm").modal(); } $scope.addBank = function () { $scope.dialogData.bankCards.push({}) } $scope.deleteBank = function (index, bankInfo) { if(bankInfo.id) { $.confirm({ content: '确定删除?', buttons: { ok: { btnClass: 'btn-red', action: function () { $http({ method: 'POST', url: '/superadmin/deleteDealerBankAccount', data: {id: bankInfo.id} }).then(function () { renderBanksDialog(lastRowId) }, function () { toaster.pop("error", "提示", "删除失败!"); }); } }, } }); } else { $scope.dialogData.bankCards.splice(index, 1) } } $scope.saveBankAccount = function (bankInfo) { bankInfo = $.extend(true, {dealerId: lastRowId}, bankInfo); if (bankInfo.isPublic) { if ($.isEmptyObject(bankInfo.bankProvince) || $.isEmptyObject(bankInfo.bankCity)) { toaster.pop("warning", "提示", "请填写省市"); return } if ($.isEmptyObject(bankInfo.branchBankItem)) { toaster.pop("warning", "提示", "请填写支行名称"); return } bankInfo.cityCode = bankInfo?.bankCity?.value bankInfo.city = bankInfo?.bankCity?.text bankInfo.provinceCode = bankInfo?.bankProvince?.value bankInfo.province = bankInfo?.bankProvince?.text bankInfo.bankCode = bankInfo?.bankItem?.value bankInfo.bankName = bankInfo?.bankItem?.text bankInfo.branchBankCode = bankInfo?.branchBankItem?.value bankInfo.branchBankName = bankInfo?.branchBankItem?.text } else { bankInfo.bankName = bankInfo?.bankItem?.text } delete bankInfo.bankCity delete bankInfo.bankProvince delete bankInfo.bankItem delete bankInfo.branchBankItem delete bankInfo.keyWord delete bankInfo.cityList delete bankInfo.branchBankList delete bankInfo.bankList $http({ method: 'POST', url: '/superadmin/saveDealerBankAccount', data: bankInfo }).then(function () { renderBanksDialog(lastRowId) toaster.pop("success", "提示", "保存成功!"); }, function () { toaster.pop("error", "提示", "保存失败!"); }); } $scope.editCardFee = function () { var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length === 0) { toaster.pop("info", "提示", "请选择数据!"); return; } var ids = []; for (var i = 0; i < rows.length; i++) { ids.push(rows[i].id); } $scope.dialogData = {ids: ids} $("#editCardFeeForm").modal(); } $scope.saveCardFeeEdit = function () { if ($scope.editCardFeeForm.$invalid) { return; } var url = "/superadmin/changeDealerAnnualTrafficCost" $http({ method: 'POST', url: url, data: { ids: $scope.dialogData.ids, annualTrafficCost: $scope.dialogData.annualTrafficCost, } }).then(function (response) { $('#editCardFeeForm').modal('hide'); $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } $scope.setDealerMaxPackagePrice = function () { var rows = $scope.gridApi.selection.getSelectedRows(); if (rows.length === 0) { toaster.pop("info", "提示", "请选择数据!"); return; } var ids = []; let maxPackagePrice = 100 if (rows.length) { maxPackagePrice = rows[0].maxPackagePrice } for (var i = 0; i < rows.length; i++) { ids.push(rows[i].id); } $scope.dialogData = {ids: ids, maxPackagePrice: maxPackagePrice} $("#dealerMaxPackagePrice").modal(); } $scope.saveDealerMaxPackagePrice = function () { if ($scope.dealerMaxPackagePrice.$invalid) { return; } var url = "/superadmin/setDealerMaxPackagePrice" $http({ method: 'POST', url: url, data: { ids: $scope.dialogData.ids, maxPackagePrice: $scope.dialogData.maxPackagePrice, } }).then(function (response) { $('#dealerMaxPackagePrice').modal('hide'); $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } $scope.editApiShow = function () { var entity = getOneRow(); if (!entity) { return } $scope.dialogData = { id: entity.id } $http.get('/superadmin/apiapp/get', { params: { dealerId: entity.id, } }).then(function (res) { $scope.dialogData = res.data.payload; $scope.dialogData.id = entity.id; $("#apiAppForm").modal(); }).catch(function (data) { toaster.pop("error", "提示", "查询api应用信息失败。"); }); } $scope.saveApiApp = function () { if ($scope.apiAppForm.$invalid) { return } var url = "/superadmin/apiapp/set"; $http({ method: 'POST', url: url, data: { dealerId: $scope.dialogData.id, people: $scope.dialogData.people, tel: $scope.dialogData.tel, callbackUrl: $scope.dialogData.callbackUrl, apiDeviceMax: $scope.dialogData.apiDeviceMax, apiDevicePerCost: $scope.dialogData.apiDevicePerCost, } }).then(function (response) { $('#apiAppForm').modal('hide'); if (response.data.result) { toaster.pop("info", "提示", "成功") } }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); } }]);