1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276 |
- 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.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.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");
- };
- //展示详情
- $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", "提示", "修改密码失败!");
- });
- };
- // 获取此经销商的银行卡配置
- 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", "提示", "保存失败!");
- });
- }
- }]);
|