1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- app.controller('agentsManageCtrl', ['$scope', '$http', '$stateParams', "$state", '$timeout', 'uiGridConstants', 'i18nService', 'FileUploader', 'toaster', 'md5', function ($scope, $http, $stateParams, $state, $timeout, uiGridConstants, i18nService, FileUploader, toaster, MD5) {
- i18nService.setCurrentLang("zh-cn");
- var managerId = $stateParams.managerId;
- var moniAppId = $stateParams.moniAppId;// 根据是否有监督号查询代理商
- $scope.gridOptions = {
- data: 'myData',
- showGridFooter: true, //是否显示grid footer
- // rowHeight: 80,
- //-------- 分页属性 ----------------
- paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
- paginationCurrentPage: 1, //当前页码
- paginationPageSize: 10, //每页显示个数
- 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.enum = {};
- $scope.enum.adShow = [
- {value: "", label: "广告状态"},
- {value: false, label: "无广告"},
- {value: true, label: "有广告"}
- ];
- $scope.enum.forceFollowGzh = [
- {value: "", label: "-强制关注状态-"},
- {value: "yes", label: "强制关注"},
- {value: "no", label: "不强制关注"},
- ];
- $scope.enum.forceFollowGzhForDealer = [
- {value: "", label: "-经销商的是否允许关注-"},
- {value: "never", label: "永不强制关注公众号"},
- {value: "free", label: "自由选择"},
- ];
- $scope.enum.platformSupport = [
- {value: "", label: "-客服接管状态-"},
- {value: "yes", label: "用平台客服"},
- {value: "no", label: "不用"},
- {value: "never", label: "用自己的"},
- ];
- $scope.enum.beforeChargeUnpay = [
- {value: "", label: "-使用前充值-"},
- {value: "yes", label: "是"},
- {value: "no", label: "否"},
- {value: "never", label: "永不"},
- {value: "free", label: "自由选择"},
- ];
- var managerDefault = {"nickname": "厂商"}
- //查询条件
- var condition = $scope.condition = {
- adShow: $.extend({}, $scope.enum.adShow[0]),
- forceFollowGzh: $.extend({}, $scope.enum.forceFollowGzh[0]),
- forceFollowGzhForDealer: $.extend({}, $scope.enum.forceFollowGzhForDealer[0]),
- beforeChargeUnpay: $.extend({}, $scope.enum.beforeChargeUnpay[0]),
- managerDefault: managerDefault,
- managerList: [
- managerDefault
- ],
- manager: managerDefault,
- 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);//延迟搜索,否则请求太频繁
- },
- search: function () {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- },
- generateNewAppKeyPair: function () {
- var dialogData = $scope.dialogData
- if (!dialogData.aliPayApp.appid) {
- toaster.pop("warning", "提示", "请填写支付宝的APP ID!");
- return
- }
- $http({
- method: 'POST',
- url: '/common/generateNewAppKeyPair',
- data: {
- appid: dialogData.aliPayApp.appid,
- }
- }).then(function (response) {
- if (response.data.result) {
- toaster.pop("success", "提示", "生成成功!");
- $scope.dialogData.aliPayApp.app_private_key_path = response.data.payload.path;
- $scope.dialogData.aliPayApp.hasAlipayAppKeyPair = true;
- $scope.dialogData.aliPayApp.appPublicKeyContent = response.data.payload.appPublicKeyContent;
- } else {
- toaster.pop("error", "提示", "生成失败");
- }
- }, function (response) {
- toaster.pop("error", "提示", "生成失败!");
- });
- },
- };
- // 初始化一次
- $scope.event.managerInit();
- function setColumnDefs() {
- $scope.gridOptions.columnDefs = [
- {
- field: 'nickname', displayName: '代理商名称',
- cellTemplate: '<div class="temp-row" ng-class="{\' text-info\':row.entity.isPrimary}"><i class="fa fa-bullhorn text-success" title="已开启广告" ng-if="row.entity.adShow" ></i> <i class="fa fa-user" title="主代理商" ng-if="row.entity.isPrimary" ></i> {{row.entity.nickname}}</div>',
- },
- {field: 'username', displayName: '用户名'},
- {
- field: 'dateTimeAdded',
- displayName: '注册时间',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.dateTimeAdded"></div>'
- },
- {
- field: 'dealerTotal',
- displayName: '经销商总数',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.dealerTotal"></div>'
- },
- {
- field: 'annualTrafficCost',
- displayName: '流量年费下限',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.annualTrafficCost"></div>'
- },
- {
- field: 'trafficCardCost',
- displayName: '流量卡成本',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.trafficCardCost"></div>'
- },
- {
- field: 'productName',
- displayName: '产品名称',
- },
- {
- field: 'moniApps',
- displayName: '监督号',
- cellTemplate: '<div class="temp-row"><span ng-repeat="item in row.entity.moniApps">{{item.appName}};</span></div>'
- },
- {
- field: 'moniApps',
- 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: '强制关注状态',
- },
- {
- field: 'forceFollowGzhForDealer',
- displayName: '经销商的是否允许关注',
- minWidth: 180,
- },
- // {
- // field: 'beforeChargeUnpay',
- // displayName: '使用前充值',
- // },
- {
- field: 'detail',
- displayName: '详细信息',
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetail(\'详细信息\',row.entity.detail)">{{row.entity.detail}}</div>'
- },
- {
- field: 'operation',
- displayName: '操作',
- enableFiltering: false,
- enableSorting: false,
- enableHiding: false,//禁止在列选择器中隐藏
- enableColumnMenu: false,// 是否显示列头部菜单按钮
- minWidth: 300,
- 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-default" ng-click="grid.appScope.checkDealer(row.entity)"><i class="fa fa-users"></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>'
- },
- ];
- 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 = {
- adShow: condition.adShow.value,
- forceFollowGzh: condition.forceFollowGzh.value,
- forceFollowGzhForDealer: condition.forceFollowGzhForDealer.value,
- beforeChargeUnpay: condition.beforeChargeUnpay.value,
- pageSize: pageSize,
- pageIndex: curPage
- };
- if (condition.searchKey != "") {
- params.searchKey = condition.searchKey
- }
- // 路由参数也可能有managerId
- if (managerId) {
- params.managerId = managerId
- }
- // 也可以直接根据筛选条件进行查询,优先级高
- if (condition.manager.id && condition.manager.id != "") {
- params.managerId = condition.manager.id
- }
- // 路由参数也可能有moniAppId
- if (moniAppId) {
- params.moniAppId = moniAppId
- }
- $scope.gridOptionsLoading = true;
- $http.get('/superadmin/getAgentsDetailList', {
- 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.ban = function (entity, targetStatus) {
- var url = "/superadmin/toggleAgentStatus";
- $.confirm({
- content: '确定这样操作?',
- buttons: {
- ok: {
- btnClass: 'btn-red',
- action: function () {
- $http({
- method: 'POST',
- url: url,
- data: {
- id: entity.id,
- normal: targetStatus
- }
- }).then(function (response) {
- entity.normal = targetStatus;
- console.log(response);
- if (response.data.result) {
- toaster.pop("success", "提示", "修改状态成功!");
- } else {
- toaster.pop("error", "提示", "修改状态失败!");
- }
- }, function (response) {
- toaster.pop("error", "提示", "修改状态失败!");
- });
- }
- },
- }
- });
- };
- // 解除5次错误限制
- $scope.unfreeze = function (entity) {
- var entity = getOneRow();
- if (!entity) {
- return
- }
- var url = "/superadmin/unfreeze";
- $http({
- method: 'POST',
- url: url,
- data: {
- role: "agent",
- id: entity.id,
- }
- }).then(function (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]
- }
- /********************链接拷贝面板***********************/
- var copyLinkData = $scope.copyLinkData = {};
- var currentDomain = location.protocol + "//" + location.host;
- //生成推广链接
- $scope.openLinkPanel = function () {
- var entity = getOneRow();
- if (!entity) {
- return
- }
- $("#copyLinkPanel").modal();
- //经销商注册链接
- var url = currentDomain + "/dealerAccess?agentId=" + entity.id;
- copyLinkData.link1 = url;
- // 个人主页链接
- var url = currentDomain + "/userLogin?agentId=" + entity.id + "&redirect=" + encodeURIComponent("/user/index.html#/user/me");
- copyLinkData.link2 = url;
- // 用户地图链接
- var url = currentDomain + "/userLogin?agentId=" + entity.id + "&redirect=" + encodeURIComponent("/user/index.html#/user/index");
- copyLinkData.link3 = url;
- // 用户扫码
- var url = currentDomain + "/userLogin?agentId=" + entity.id + "&redirect=" + encodeURIComponent("/user/index.html#/dev");
- copyLinkData.link4 = url;
- };
- // 关闭链接生成器
- $scope.closeCopyLinkPanel = function () {
- $("#copyLinkPanel").modal("hide");
- };
- var clipboard;
- //事件绑定
- $timeout(function () {
- //在弹窗绑定 COPY组件
- clipboard = new ClipboardJS('.copyLinkBtn');
- clipboard.on('success', function (e) {
- e.clearSelection();
- toaster.pop("info", "提示", "复制成功");
- $scope.$apply();
- });
- clipboard.on('error', function (e) {
- toaster.pop("info", "提示", "请选择“拷贝”进行复制!");
- $scope.$apply();
- });
- });
- $scope.$on("$destroy", function () {
- if (clipboard) {
- clipboard.destroy();
- console.log("clipboard destroy");
- }
- });
- //查看经销商
- $scope.checkDealer = function (entity) {
- $state.go('app.user.dealer', {
- agentId: entity.id,
- managerId: ""
- }, {
- reload: true
- });
- };
- //查看设备
- $scope.checkDevice = function (entity) {
- $state.go('app.dev.devManage', {
- managerId: "",
- agentId: entity.id,
- dealerId: "",
- searchKey: "",
- }, {
- reload: true
- });
- };
- //展示详情
- $scope.showInfoDetail = function (title, content) {
- $scope.infoDetail = {title: title, content: content};
- $("#detailInfoPanel").modal();
- };
- $scope.closeDetailInfoPanel = function () {
- $("#detailInfoPanel").modal("hide");
- };
- // 必须先声明,否则ui-select无法双绑
- $scope.dialogData = {};
- // 配置特性
- $scope.editFeature = function () {
- var entity = getOneRow();
- if (!entity) {
- return
- }
- $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/editAgentFeature";
- $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 = []
- 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.editAdShow = function () {
- $scope.dialogData = {};
- if (getSelectRows()) {
- $("#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: "agent"}
- }).then(function (response) {
- initDataGrid();
- $('#editAdForm').modal('hide');
- toaster.pop("success", "提示", "保存成功!");
- }, function (response) {
- toaster.pop("error", "提示", "保存失败!");
- });
- }
- //流量卡配置
- $scope.editCardShow = function () {
- $scope.dialogData = {};
- if (getSelectRows()) {
- $("#editCardForm").modal();
- }
- }
- $scope.saveCardEdit = function () {
- var ids = $scope.selectedIds
- if ($scope.editCardForm.$invalid) {
- toaster.pop("warning", "提示", "请填写正确的数据");
- return
- }
- $http({
- method: 'POST',
- url: '/superadmin/setTrafficCardCost',
- data: {ids: ids, cost: $scope.dialogData.cost}
- }).then(function (response) {
- initDataGrid();
- $('#editCardForm').modal('hide');
- }, function (response) {
- toaster.pop("error", "提示", "保存失败!");
- });
- }
- // 编辑代理商
- $scope.editAgents = function (entity) {
- var entity = getOneRow();
- if (!entity) {
- return
- }
- $scope.dialogData = entity;
- $("#agentsForm").modal();
- }
- $scope.saveAgents = function () {
- if ($scope.agentsForm.$invalid) {
- toaster.pop("warning", "提示", "请填写正确的数据");
- return
- }
- $http({
- method: 'POST',
- url: '/superadmin/editUserInfo',
- data: {
- role: 'agent',
- id: $scope.dialogData.id,
- 'info': {
- username: $scope.dialogData.username,
- isChangingPaymentGateway: $scope.dialogData.isChangingPaymentGateway,
- maxPayLimit: $scope.dialogData.maxPayLimit,
- }
- }
- }).then(function (response) {
- initDataGrid();
- $('#agentsForm').modal('hide');
- }, function (response) {
- toaster.pop("error", "提示", "保存失败!");
- });
- }
- /*****************公众号*********************/
- $scope.editWechat = function () {
- //重置表单状态
- $scope.wechatForm.$setPristine();
- $scope.wechatForm.$setUntouched();
- var row = getOneRow();
- if (!row) {
- return
- }
- $scope.dialogData = $.extend({user: {}, dealer: {}, dealer_sub: {}, user_sub: {}}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
- $("#wechatForm").modal();
- }
- $scope.saveWechat = function () {
- var url = "/superadmin/bind_wechat_cust";
- var data = {};
- // 防止为空没填报错
- $scope.dialogData.dealer = $scope.dialogData.dealer || {};
- $scope.dialogData.dealer_sub = $scope.dialogData.dealer_sub || {};
- $scope.dialogData.user = $scope.dialogData.user || {};
- $scope.dialogData.user_sub = $scope.dialogData.user_sub || {};
- //编辑
- $.extend(data, {
- 'id': $scope.dialogData.id,
- customizedDealerGzhAllowable: $scope.dialogData.customizedDealerGzhAllowable,
- customizedDealerSubGzhAllowable: $scope.dialogData.customizedDealerSubGzhAllowable,
- dealer: {
- appid: $scope.dialogData.dealer.appid,
- secret: $scope.dialogData.dealer.secret,
- templateIdMap: $scope.dialogData.dealer.templateIdMap,
- name: $scope.dialogData.dealer.name,
- companyName: $scope.dialogData.dealer.companyName
- },
- dealer_sub: {
- appid: $scope.dialogData.dealer_sub.appid,
- secret: $scope.dialogData.dealer_sub.secret,
- templateIdMap: $scope.dialogData.dealer_sub.templateIdMap,
- name: $scope.dialogData.dealer_sub.name,
- companyName: $scope.dialogData.dealer_sub.companyName
- },
- customizedUserGzhAllowable: $scope.dialogData.customizedUserGzhAllowable,
- customizedUserSubGzhAllowable: $scope.dialogData.customizedUserSubGzhAllowable,
- user: {
- appid: $scope.dialogData.user.appid,
- secret: $scope.dialogData.user.secret,
- templateIdMap: $scope.dialogData.user.templateIdMap,
- name: $scope.dialogData.user.name,
- companyName: $scope.dialogData.user.companyName
- },
- user_sub: {
- appid: $scope.dialogData.user_sub.appid,
- secret: $scope.dialogData.user_sub.secret,
- templateIdMap: $scope.dialogData.user_sub.templateIdMap,
- name: $scope.dialogData.user_sub.name,
- companyName: $scope.dialogData.user_sub.companyName
- },
- })
- $http({
- method: 'POST',
- url: url,
- data: data
- }).then(function (response) {
- $('#wechatForm').modal('hide');//弹窗消失
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- }, function (response) {
- toaster.pop("error", "提示", "操作失败!");
- });
- };
- /*****************资金池*********************/
- $scope.cashPoolWechat = function () {
- //重置表单状态
- $scope.cashPoolWechatForm.$setPristine();
- $scope.cashPoolWechatForm.$setUntouched();
- var row = getOneRow();
- if (!row) {
- return
- }
- $scope.dialogData = $.extend({wechatPayApp: {}}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
- $("#cashPoolWechatForm").modal();
- };
- $scope.cashPoolAlipay = function () {
- //重置表单状态
- $scope.cashPoolAlipayForm.$setPristine();
- $scope.cashPoolAlipayForm.$setUntouched();
- var row = getOneRow();
- if (!row) {
- return
- }
- $scope.dialogData = $.extend({aliPayApp: {}}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
- $("#cashPoolAlipayForm").modal();
- };
- $scope.changeFile = function (files,key) {
- if (files.length) {
- var file = files[0];
- var reader = new FileReader();
- // 文件不能大于1M
- if (file.size > 1000 * 1024) {
- toaster.pop("info", "提示", "文件太大,请重新选择");
- } else {
- reader.onload = function() {
- if(reader.result) {
- var text = reader.result
- $scope.dialogData.wechatPayApp[key] = btoa(text)
- $scope.$apply();
- }
- };
- reader.readAsText(file);
- }
- }
- }
- /***********监督号************/
- $scope.moniApps = []
- $http.get('/superadmin/getMoniApps', {
- params: {
- pageSize: 1000,
- pageIndex: 1
- }
- }).then(function (res) {
- var payload = res.data.payload;
- $scope.moniApps = payload.dataList;
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取监督号列表失败");
- });
- $scope.moniConfig = function () {
- var ids = getSelectRows()
- if (ids) {
- $("#moniConfigForm").modal();
- $scope.dialogData = {}
- for (var key in $scope.moniApps) {
- var item = $scope.moniApps[key]
- $scope.dialogData[item.appId] = false
- }
- }
- };
- $scope.setMoniAppId = function (appId) {
- var data = {
- agentIds: $scope.selectedIds,
- moniApp: [],
- }
- // 单个保存
- if (appId) {
- data.moniApp.push({
- appId: appId,
- switch: $scope.dialogData[appId] || false,// 默认为false
- })
- } else {
- var tempApp = []
- for (var key in $scope.dialogData) {
- tempApp.push({
- appId: key,
- switch: $scope.dialogData[key] || false,// 默认为false
- })
- }
- data.moniApp = tempApp
- }
- $http({
- method: 'POST',
- url: "/superadmin/editMoniAppForAgents",
- data: data
- }).then(function (response) {
- toaster.pop("success", "提示", "保存成功!");
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- //批量保存关闭弹窗
- if (!appId) {
- $('#moniConfigForm').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 = {
- agentIds: $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/editMoniPointForAgents",
- 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.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/editAgentForceFollowGzh',
- data: {
- ids: ids,
- forceFollowGzh: $scope.dialogData.forceFollowGzh,
- forceFollowGzhForDealer: $scope.dialogData.forceFollowGzhForDealer
- }
- }).then(function (response) {
- initDataGrid();
- $('#editGzhForm').modal('hide');
- toaster.pop("success", "提示", "保存成功!");
- }, 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/editSupporterForAgents',
- 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/changeAgentPassword"
- 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.setDisclaimer = function () {
- var entity = getOneRow();
- if (!entity) {
- return
- }
- $state.go('app.user.disclaimer', {
- agentId: entity.id,
- agentName: entity.nickname,
- });
- }
- $scope.editDeviceType = function () {
- var entity = getOneRow();
- if (!entity) {
- return
- }
- if (entity.isPrimary) {
- toaster.pop("warning", "提示", "该角色是主代理商,不能配置!");
- return
- }
- $("#editDeviceTypePanel").modal();
- $scope.dialogName = entity.nickname + "配置设备类型";
- $("#dealerDevList").modal();
- // todo 由于ui-grid 之前隐藏,表格渲染有问题
- setTimeout(function () {
- // 刷新设备
- $scope.$broadcast("initDriverCodeList", {id: entity.id, role: "agent"});
- }, 100);
- };
- $scope.closeDeviceConfig = function (entity) {
- $("#editDeviceTypePanel").modal('hide');
- };
- }]);
|