12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169 |
- 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 () {
- console.log("changeProvince")
- //无论是否选择了数据,都清空子级下拉框选中的项
- $scope.dialogData.bankCity = null;
- var bankProvinceID = $scope.dialogData.bankProvince.value;
- for (var index in $scope.provinceList) {
- var item = $scope.provinceList[index];
- var children = item.children
- if (item.value == bankProvinceID) {
- // 初始化二级 市
- $scope.cityList = children
- break
- }
- }
- }
- }
- //枚举常量
- $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.enum.merchantStatus = [
- {value: 0, label: "尚未申请"},
- {value: 1, label: "商户入驻成功,产品开通中"},
- {value: 2, label: "开通失败"},
- {value: 3, label: "商户产品开通完成,准备提交微信审核"},
- {value: 4, label: "开通成功"},
- {value: 5, label: "微信实名审核中"},
- {value: 6, label: "微信实名审核待用户确认"},
- {value: 7, label: "微信实名确认已完成"},
- ];
- $scope.enum.merchantType = [
- {value: 'N', label: "个人商户"},
- {value: 'E', 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: '<div class="temp-row">' +
- '<i class="fa fa-bullhorn text-success" title="已开启广告" ng-if="row.entity.adShow" ></i>' +
- ' {{row.entity.nickname}} ' +
- '<i class="fa fa-lock text-warning" title="被锁定" ng-if="!row.entity.status==\'normal\'" ></i>' +
- ' </div>',
- },
- {
- field: 'merchantInfo',
- displayName: '商户信息',
- cellTemplate: '<div class="temp-row text-info" style="cursor: pointer;" ng-click="grid.appScope.showMerchantInfo(row.entity)" >商户详情</div>'
- },
- {field: 'username', displayName: '用户名'},
- {
- field: 'createdTime',
- displayName: '注册时间',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.dateTimeAdded"></div>'
- },
- {
- field: 'annualTrafficCost',
- displayName: '流量卡年费',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.annualTrafficCost"></div>'
- },
- {
- field: 'balance',
- displayName: '商家余额',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.balance| currency:\'¥\'"></div>'
- },
- {
- field: 'withdrawFeeRatio',
- displayName: '提现手续费',
- cellTemplate: '<div class="temp-row">{{row.entity.withdrawFeeRatio+"‰"}}</div>',
- },
- {
- field: 'agentInfo',
- displayName: '代理商',
- },
- {
- field: 'productName',
- displayName: '产品名称',
- },
- {
- field: 'agentForceFollowGzh',
- displayName: '代理商强制关注',
- minWidth: 140,
- },
- {
- field: 'moniAppName',
- displayName: '监督号名称',
- },
- {
- field: 'pointDict',
- displayName: '监督号位置',
- cellTemplate: '<div class="temp-row"><span ng-repeat="item in row.entity.pointDict" ng-class="{\'text-success\':item.switch}">{{item.name}};</span></div>'
- },
- {
- field: 'forceFollowGzh',
- displayName: '强制关注公众号',
- minWidth: 140,
- },
- {
- field: 'devCount',
- displayName: '设备数量',
- },
- // {
- // field: 'beforeChargeUnpay',
- // displayName: '使用前充值',
- // },
- {
- field: 'maxPackagePrice',
- displayName: '最大套餐价格',
- },
- {
- field: 'detail',
- displayName: '详细信息',
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetail(\'详细信息\',row.entity.detail)" >{{row.entity.detail}}</div>'
- },
- {
- field: 'status',
- displayName: '状态',
- cellTemplate: '<div class="temp-row" >{{row.entity.status}}</div>'
- },
- ];
- var operCol = {
- field: 'operation',
- displayName: '操作',
- enableFiltering: false,
- enableSorting: false,
- enableHiding: false,//禁止在列选择器中隐藏
- enableColumnMenu: false,// 是否显示列头部菜单按钮
- minWidth: 320,
- cellTemplate: '<div class="grid-button">' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-if="row.entity.status==\'normal\'" ng-click="grid.appScope.ban(row.entity,false)"><i class="fa fa-ban"></i> 封号</button>' +
- '<button class="btn btn-sm btn-rounded btn-success" ng-if="row.entity.status!==\'normal\'" ng-click="grid.appScope.ban(row.entity,true)"><i class="fa fa-unlock"></i> 解封</button>' +
- // '<button class="btn btn-sm btn-rounded btn-info"ng-click="grid.appScope.unfreeze(row.entity)"><i class="fa fa-smile-o"></i> 解除限制</button>' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-if="row.entity.status==\'normal\'" ng-click="grid.appScope.toggleDealerWithdrawStatus(row.entity,true)"><i class="fa fa-ban"></i> 禁止提现</button>' +
- '<button class="btn btn-sm btn-rounded btn-success" ng-if="row.entity.status!==\'normal\'" ng-click="grid.appScope.toggleDealerWithdrawStatus(row.entity,false)"><i class="fa fa-unlock"></i> 允许提现</button>' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.editFeature(row.entity)"><i class="fa fa-cubes"></i> 配置特性</button>' +
- '<button class="btn btn-sm btn-rounded btn-default" ng-click="grid.appScope.checkDevice(row.entity)"><i class="glyphicon glyphicon-phone"></i> 设备</button>' +
- '</div>'
- };
- $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.parentBankNameList = []
- $scope.provinceList = []
- $scope.cityList = []
- //加载地址列表
- $http.get('/common/loadDistrictData', {}).then(function (data) {
- data = data.data
- var payload = data.payload
- $scope.provinceList = payload
- });
- //加载对公提现支持银行列表
- $http.get('/common/banks/list', {params: {accountType: 'public'}}).then(function (data) {
- var bankList = data.data.payload
- bankList.forEach(function (item, index) {
- $scope.parentBankNameList.push({value: item, text: item})
- })
- });
- //封号|解封
- $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");
- };
- //展示详情
- $scope.showMerchantInfo = function (entity) {
- $("#merchantInfoPanel").modal("show");
- $http.get('/superadmin/getMerchantInfo', {
- params: {id: entity.id}
- }).then(function (res) {
- $scope.dialogData = res.data.payload;
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取数据失败");
- });
- }
- // 关闭显示
- $scope.closeMerchantInfo = function () {
- $("#merchantInfoPanel").modal("hide");
- };
- // 刷新经销商微信状态
- $scope.refreshMerchantInfo = function (_id) {
- $http.get('/superadmin/refreshMerchantInfo', {
- params: {id: _id}
- }).then(function (res) {
- toaster.pop("info", "提示", "成功,请重新查看");
- }).catch(function (data) {
- toaster.pop("error", "提示", "失败");
- });
- $("#merchantInfoPanel").modal("hide");
- };
- // 刷新经销商微信状态
- $scope.wechatReplay = function (_id) {
- $http.get('/superadmin/wechatReplay', {
- params: {id: _id}
- }).then(function (res) {
- toaster.pop("info", "提示", "成功");
- }).catch(function (data) {
- toaster.pop("error", "提示", "失败");
- });
- $("#merchantInfoPanel").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", "提示", "修改密码失败!");
- });
- };
- $scope.editBankAccount = 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]
- $scope.dialogData = $.extend({id: row.id}, row.bankAccountInfo)
- var bankInfo = row.bankAccountInfo || {}
- if (bankInfo) {
- // 必须用provinceList ,确保引用地址一致,ui-select才能双绑。
- for (var index in $scope.provinceList) {
- var item = $scope.provinceList[index];
- var children = item.children
- if (item.value == bankInfo.bankProvinceID) {
- // 设置省份对应关系
- $scope.dialogData.bankProvince = item
- // 初始化二级 市
- $scope.cityList = children
- for (var index2 in children) {
- var item2 = children[index2];
- if (item2.value == bankInfo.bankCityID) {
- // 设置省份对应关系
- $scope.dialogData.bankCity = item2
- break
- }
- }
- break
- }
- }
- }
- // 找对应关系
- $scope.parentBankNameList.forEach(function (item, index) {
- if (item.text === bankInfo.parentBankName) {
- $scope.dialogData.parentBankItem = item
- return
- }
- })
- $("#bankAccountForm").modal();
- }
- $scope.saveBankAccount = function () {
- var row = getOneRow();
- if (!row) {
- return
- }
- if ($scope.bankAccountForm.$invalid) {
- toaster.pop("warning", "提示", "请填写正确的数据");
- return
- }
- // ui-select ng-required不生效。。。
- var saveData = $.extend(true, {}, $scope.dialogData)
- if ($.isEmptyObject(saveData.bankProvince) || $.isEmptyObject(saveData.bankCity)) {
- toaster.pop("error", "提示", "请填写省市");
- return
- }
- saveData.bankCityID = saveData.bankCity.value
- saveData.bankCityName = saveData.bankCity.text
- saveData.bankProvinceID = saveData.bankProvince.value
- saveData.bankProvinceName = saveData.bankProvince.text
- saveData.parentBankName = saveData.parentBankNameOther || saveData.parentBankItem.text
- delete saveData.bankCity
- delete saveData.bankProvince
- delete saveData.parentBankItem
- delete saveData.parentBankNameOther
- $http({
- method: 'POST',
- url: '/superadmin/editDealerBankAccount',
- data: saveData
- }).then(function (response) {
- initDataGrid();
- $('#bankAccountForm').modal('hide');
- toaster.pop("success", "提示", "保存成功!");
- }, function (response) {
- 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", "提示", "保存失败!");
- });
- }
- }]);
|