dealerManage.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. app.controller('dealerManageCtrl', ['$scope', "$state", '$stateParams', '$http', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', 'md5', function ($scope, $state, $stateParams, $http, $timeout, uiGridConstants, i18nService, toaster, MD5) {
  2. i18nService.setCurrentLang("zh-cn");
  3. var managerId = $stateParams.managerId;
  4. var agentId = $stateParams.agentId;
  5. $scope.gridOptions = {
  6. data: 'myData',
  7. showGridFooter: true, //是否显示grid footer
  8. // rowHeight: 80,
  9. //-------- 分页属性 ----------------
  10. paginationPageSizes: [50, 200, 500, 1000, 2000], //每页显示个数可选项
  11. paginationCurrentPage: 1, //当前页码
  12. paginationPageSize: 50, //每页显示个数
  13. totalItems: 0,// 总数量
  14. useExternalPagination: true,//是否使用分页按钮
  15. //过滤
  16. // enableFiltering: true,
  17. columnDefs: [],
  18. //---------------api---------------------
  19. onRegisterApi: function (gridApi) {
  20. $scope.gridApi = gridApi;
  21. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  22. if ($scope.setPagingData) {
  23. $scope.getPagedDataAsync(newPage, pageSize);
  24. }
  25. });
  26. }
  27. };
  28. $scope.ngEvent = {
  29. changeProvince: function (bankInfo) {
  30. console.log("changeProvince")
  31. //无论是否选择了数据,都清空子级下拉框选中的项
  32. bankInfo.bankCity = null;
  33. var bankProvinceID = bankInfo.bankProvince.value;
  34. if (bankProvinceID)
  35. $scope.searchArea(bankProvinceID,bankInfo)
  36. else
  37. bankInfo.cityList = []
  38. }
  39. }
  40. //枚举常量
  41. $scope.enum = {};
  42. $scope.enum.adShow = [
  43. {value: "", label: "-广告状态-"},
  44. {value: false, label: "无广告"},
  45. {value: true, label: "有广告"}
  46. ];
  47. $scope.enum.forceFollowGzh = [
  48. {value: "", label: "-强制关注状态-"},
  49. {value: "agent", label: "以代理商为准"},
  50. {value: "yes", label: "强制关注"},
  51. {value: "no", label: "不允许强制关注"},
  52. {value: "never", label: "永不强制关注公众号"},
  53. {value: "free", label: "自由选择"},
  54. ];
  55. $scope.enum.platformSupport = [
  56. {value: "", label: "-客服接管状态-"},
  57. {value: "agent", label: "以代理商为准"},
  58. {value: "yes", label: "需要平台"},
  59. {value: "no", label: "不需要平台"},
  60. {value: "never", label: "永远用自己的客服"},
  61. {value: "free", label: "无所谓"},
  62. ];
  63. $scope.enum.beforeChargeUnpay = [
  64. {value: "", label: "-使用前充值-"},
  65. {value: "yes", label: "是"},
  66. {value: "no", label: "否"},
  67. {value: "never", label: "永不"},
  68. {value: "free", label: "自由选择"},
  69. ];
  70. $scope.enum.merchantStatus = [
  71. {value: 0, label: "尚未申请"},
  72. {value: 1, label: "商户入驻成功,产品开通中"},
  73. {value: 2, label: "开通失败"},
  74. {value: 3, label: "商户产品开通完成,准备提交微信审核"},
  75. {value: 4, label: "开通成功"},
  76. {value: 5, label: "微信实名审核中"},
  77. {value: 6, label: "微信实名审核待用户确认"},
  78. {value: 7, label: "微信实名确认已完成"},
  79. ];
  80. $scope.enum.merchantType = [
  81. {value: 'N', label: "个人商户"},
  82. {value: 'E', label: "企业商户"},
  83. ];
  84. $scope.findEnum = function (list, value) {
  85. return list.find((item) => item.value === value)
  86. }
  87. var managerDefault = {"nickname": "厂商"}
  88. var agentDefault = {"nickname": "代理商"}
  89. //查询条件
  90. var condition = $scope.condition = {
  91. adShow: $.extend({}, $scope.enum.adShow[0]),
  92. forceFollowGzh: $.extend({}, $scope.enum.forceFollowGzh[0]),
  93. beforeChargeUnpay: $.extend({}, $scope.enum.beforeChargeUnpay[0]),
  94. managerDefault: managerDefault,
  95. managerList: [managerDefault],
  96. manager: managerDefault,
  97. agentDefault: agentDefault,
  98. agentList: [agentDefault],
  99. agent: agentDefault,
  100. searchKey: "",
  101. };
  102. var searchTimer = null;
  103. //事件
  104. $scope.event = {
  105. statusChange: function (key, item) {
  106. condition[key].value = item.value;
  107. condition[key].label = item.label;
  108. this.search()
  109. },
  110. managerInit: function ($event) {
  111. var searchKey = $event ? $event.target.value : "";
  112. $timeout.cancel(searchTimer);
  113. searchTimer = $timeout(function () {
  114. $http.get('/superadmin/getManagerList', {
  115. params: {
  116. pageSize: 1000,
  117. pageIndex: 1,
  118. searchKey: searchKey,
  119. }
  120. }).then(function (data) {
  121. data = data.data
  122. $scope.condition.managerList = data.data.dataList;
  123. }).catch(function (data) {
  124. toaster.pop("error", "提示", "搜索失败");
  125. });
  126. }, 500);//延迟搜索,否则请求太频繁
  127. },
  128. agentInit: function ($event) {
  129. var searchKey = $event.target.value;
  130. var managerId = "";
  131. if (condition.manager.id != "") {
  132. managerId = condition.manager.id
  133. }
  134. $timeout.cancel(searchTimer);
  135. searchTimer = $timeout(function () {
  136. $http.get('/superadmin/getAgentsDetailList', {
  137. params: {
  138. pageSize: 1000,
  139. pageIndex: 1,
  140. searchKey: searchKey,
  141. managerId: managerId,
  142. }
  143. }).then(function (data) {
  144. data = data.data
  145. $scope.condition.agentList = data.data.dataList;
  146. }).catch(function (data) {
  147. toaster.pop("error", "提示", "搜索失败");
  148. });
  149. }, 500);//延迟搜索,否则请求太频繁
  150. },
  151. search: function () {
  152. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  153. }
  154. };
  155. // 初始化一次
  156. $scope.event.managerInit();
  157. function setColumnDefs() {
  158. $scope.gridOptions.columnDefs = [
  159. {
  160. field: 'nickname', displayName: '商家名称',
  161. cellTemplate: '<div class="temp-row">' +
  162. '<i class="fa fa-bullhorn text-success" title="已开启广告" ng-if="row.entity.adShow" ></i>' +
  163. ' {{row.entity.nickname}} ' +
  164. '<i class="fa fa-lock text-warning" title="被锁定" ng-if="!row.entity.status==\'normal\'" ></i>' +
  165. ' </div>',
  166. },
  167. {
  168. field: 'merchantInfo',
  169. displayName: '商户信息',
  170. cellTemplate: '<div class="temp-row text-info" style="cursor: pointer;" ng-click="grid.appScope.showMerchantInfo(row.entity)" >商户详情</div>'
  171. },
  172. {field: 'username', displayName: '用户名'},
  173. {
  174. field: 'createdTime',
  175. displayName: '注册时间',
  176. cellTemplate: '<div class="temp-row" ng-bind="row.entity.dateTimeAdded"></div>'
  177. },
  178. {
  179. field: 'annualTrafficCost',
  180. displayName: '流量卡年费',
  181. cellTemplate: '<div class="temp-row" ng-bind="row.entity.annualTrafficCost"></div>'
  182. },
  183. {
  184. field: 'balance',
  185. displayName: '商家余额',
  186. cellTemplate: '<div class="temp-row" ng-bind="row.entity.balance| currency:\'¥\'"></div>'
  187. },
  188. {
  189. field: 'withdrawFeeRatio',
  190. displayName: '提现手续费',
  191. cellTemplate: '<div class="temp-row">{{row.entity.withdrawFeeRatio+"‰"}}</div>',
  192. },
  193. {
  194. field: 'agentInfo',
  195. displayName: '代理商',
  196. },
  197. {
  198. field: 'productName',
  199. displayName: '产品名称',
  200. },
  201. {
  202. field: 'agentForceFollowGzh',
  203. displayName: '代理商强制关注',
  204. minWidth: 140,
  205. },
  206. {
  207. field: 'moniAppName',
  208. displayName: '监督号名称',
  209. },
  210. {
  211. field: 'pointDict',
  212. displayName: '监督号位置',
  213. cellTemplate: '<div class="temp-row"><span ng-repeat="item in row.entity.pointDict" ng-class="{\'text-success\':item.switch}">{{item.name}};</span></div>'
  214. },
  215. {
  216. field: 'forceFollowGzh',
  217. displayName: '强制关注公众号',
  218. minWidth: 140,
  219. },
  220. {
  221. field: 'devCount',
  222. displayName: '设备数量',
  223. },
  224. // {
  225. // field: 'beforeChargeUnpay',
  226. // displayName: '使用前充值',
  227. // },
  228. {
  229. field: 'maxPackagePrice',
  230. displayName: '最大套餐价格',
  231. },
  232. {
  233. field: 'detail',
  234. displayName: '详细信息',
  235. cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetail(\'详细信息\',row.entity.detail)" >{{row.entity.detail}}</div>'
  236. },
  237. {
  238. field: 'status',
  239. displayName: '状态',
  240. cellTemplate: '<div class="temp-row" >{{row.entity.status}}</div>'
  241. },
  242. ];
  243. var operCol = {
  244. field: 'operation',
  245. displayName: '操作',
  246. enableFiltering: false,
  247. enableSorting: false,
  248. enableHiding: false,//禁止在列选择器中隐藏
  249. enableColumnMenu: false,// 是否显示列头部菜单按钮
  250. minWidth: 320,
  251. cellTemplate: '<div class="grid-button">' +
  252. '<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>' +
  253. '<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>' +
  254. // '<button class="btn btn-sm btn-rounded btn-info"ng-click="grid.appScope.unfreeze(row.entity)"><i class="fa fa-smile-o"></i> 解除限制</button>' +
  255. '<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>' +
  256. '<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>' +
  257. '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.editFeature(row.entity)"><i class="fa fa-cubes"></i> 配置特性</button>' +
  258. '<button class="btn btn-sm btn-rounded btn-default" ng-click="grid.appScope.checkDevice(row.entity)"><i class="glyphicon glyphicon-phone"></i> 设备</button>' +
  259. '</div>'
  260. };
  261. $scope.gridOptions.columnDefs.push(operCol)
  262. var fields = $scope.gridOptions.columnDefs;
  263. for (var index in fields) {
  264. var item = fields[index];
  265. if (item && item['minWidth'] == null) {
  266. item['minWidth'] = 120;
  267. }
  268. }
  269. }
  270. $scope.setPagingData = function (data, curPage, pageSize) {
  271. var firstRow = (curPage - 1) * pageSize;
  272. var pagedData = data.data.dataList;
  273. $scope.myData = pagedData;
  274. $scope.gridOptions.totalItems = data.data.total;
  275. };
  276. $scope.getPagedDataAsync = function (curPage, pageSize, searchText) {
  277. if ($scope.gridOptionsLoading) {
  278. return;
  279. }
  280. var params = {
  281. forceFollowGzh: condition.forceFollowGzh.value,
  282. beforeChargeUnpay: condition.beforeChargeUnpay.value,
  283. devCountMin: condition.devCountMin,
  284. devCountMax: condition.devCountMax,
  285. adShow: condition.adShow.value,
  286. pageSize: pageSize,
  287. pageIndex: curPage
  288. };
  289. if (condition.searchKey != "") {
  290. params.searchKey = condition.searchKey
  291. }
  292. // 路由参数也可能有managerId
  293. if (managerId) {
  294. params.managerId = managerId
  295. }
  296. if (agentId) {
  297. params.agentId = agentId
  298. }
  299. if (condition.manager.id && condition.manager.id != "") {
  300. params.managerId = condition.manager.id
  301. }
  302. if (condition.agent.id && condition.agent.id != "") {
  303. params.agentId = condition.agent.id
  304. }
  305. $scope.gridOptionsLoading = true;
  306. $http.get('/superadmin/getDealerDetailList', {
  307. params: params
  308. }).then(function (data) {
  309. data = data.data
  310. $scope.gridOptionsLoading = false;
  311. $scope.setPagingData(data, curPage, pageSize);
  312. }).catch(function (data) {
  313. toaster.pop("error", "提示", "获取数据列表失败");
  314. });
  315. };
  316. function initDataGrid() {
  317. //首次加载表格
  318. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  319. }
  320. setColumnDefs();
  321. // initDataGrid(); 由于比较卡,初始化不加载
  322. //广告开关
  323. $scope.selectedIds = []
  324. function getSelectRows() {
  325. var rows = $scope.gridApi.selection.getSelectedRows();
  326. if (rows.length === 0) {
  327. toaster.pop("info", "提示", "请选择数据!");
  328. return false;
  329. }
  330. var ids = [];
  331. for (var i = 0; i < rows.length; i++) {
  332. ids.push(rows[i].id);
  333. }
  334. $scope.selectedIds = ids;
  335. return ids
  336. }
  337. $scope.provinceList = []
  338. $scope.searchSubBank = function (bankInfo) {
  339. let form = bankInfo
  340. $http.get('/common/withdraw/branchBank/list', {
  341. params: {
  342. bankCode: form?.bankItem?.value,
  343. provinceCode: form?.bankProvince?.value,
  344. cityCode: form?.bankCity?.value,
  345. }
  346. }).then(function (data) {
  347. data = data.data
  348. let {payload} = data
  349. let list = payload?.dataList || []
  350. list = list.map(item => ({
  351. text: item.name,
  352. value: item.code,
  353. }))
  354. bankInfo.branchBankList = list;
  355. }).catch(function (data) {
  356. toaster.pop("error", "提示", "支行获取失败");
  357. });
  358. }
  359. $scope.searchBank = function (bankInfo) {
  360. bankInfo.bankList = []
  361. $http.get('/common/withdraw/bank/list', {
  362. params: {
  363. keyWord: bankInfo.keyWord,
  364. range: 'all'
  365. }
  366. }).then(function (data) {
  367. var bankList = data.data.payload.dataList
  368. bankList.forEach(function (item, index) {
  369. bankInfo.bankList.push({value: item.code, text: item.name})
  370. })
  371. });
  372. }
  373. $scope.searchArea = function (province, bankInfo) {
  374. return new Promise((resolve => {
  375. //加载地址列表
  376. $http.get('/common/withdraw/area/list', {params: {province: province || ""}}).then(function (data) {
  377. data = data.data
  378. var payload = data.payload
  379. let dataRe = (payload.dataList || []).map(item => {
  380. return {
  381. ...item,
  382. text: item.name,
  383. value: item.code,
  384. }
  385. })
  386. if (province) {
  387. bankInfo.cityList = dataRe
  388. } else {
  389. $scope.provinceList = dataRe
  390. }
  391. resolve()
  392. });
  393. }))
  394. }
  395. $scope.searchArea();// 加载省
  396. //封号|解封
  397. $scope.ban = function (entity, isNormal) {
  398. var url = "/superadmin/toggleDealerStatus";
  399. $.confirm({
  400. content: '确定这样操作?',
  401. buttons: {
  402. ok: {
  403. btnClass: 'btn-red',
  404. action: function () {
  405. $http({
  406. method: 'POST',
  407. url: url,
  408. data: {
  409. id: entity.id,
  410. normal: isNormal
  411. }
  412. }).then(function (response) {
  413. if (isNormal) {
  414. entity.status = "normal";
  415. } else {
  416. entity.status = "ban";
  417. }
  418. console.log(response);
  419. if (response.data.result) {
  420. toaster.pop("success", "提示", "修改状态成功!");
  421. } else {
  422. toaster.pop("error", "提示", "修改状态失败!");
  423. }
  424. }, function (response) {
  425. toaster.pop("error", "提示", "修改状态失败!");
  426. });
  427. }
  428. },
  429. }
  430. });
  431. };
  432. function getOneRow() {
  433. var rows = $scope.gridApi.selection.getSelectedRows();
  434. if (rows.length === 0) {
  435. toaster.pop("info", "提示", "请选择数据!");
  436. return false;
  437. }
  438. if (rows.length > 1) {
  439. toaster.pop("info", "提示", "只能选中编辑一条数据");
  440. return false;
  441. }
  442. return rows[0]
  443. }
  444. // 解除5次错误限制
  445. $scope.unfreeze = function (entity) {
  446. var entity = getOneRow();
  447. if (!entity) {
  448. return
  449. }
  450. var url = "/superadmin/unfreeze";
  451. $http({
  452. method: 'POST',
  453. url: url,
  454. data: {
  455. role: "dealer",
  456. id: entity.id,
  457. }
  458. }).then(function (response) {
  459. if (response.data.result) {
  460. toaster.pop("success", "提示", "解除限制成功!");
  461. } else {
  462. toaster.pop("error", "提示", "解除限制失败!");
  463. }
  464. }, function (response) {
  465. toaster.pop("error", "提示", "解除限制失败!");
  466. });
  467. };
  468. // 解除注册限制
  469. $scope.unlockRegisterLimit = function () {
  470. var entity = getOneRow();
  471. if (!entity) {
  472. return
  473. }
  474. var url = "/superadmin/unlockRegisterLimit";
  475. $http({
  476. method: 'POST',
  477. url: url,
  478. data: {
  479. role: "dealer",
  480. id: entity.id,
  481. }
  482. }).then(function (response) {
  483. if (response.data.result) {
  484. toaster.pop("success", "提示", "解除限制成功!");
  485. } else {
  486. toaster.pop("error", "提示", "解除限制失败!");
  487. }
  488. }, function (response) {
  489. toaster.pop("error", "提示", "解除限制失败!");
  490. });
  491. };
  492. // 允许|禁止提现
  493. $scope.toggleDealerWithdrawStatus = function (entity, noWithdraw) {
  494. var url = "/superadmin/toggleDealerWithdrawStatus";
  495. $.confirm({
  496. content: '确定这样操作?',
  497. buttons: {
  498. ok: {
  499. btnClass: 'btn-red',
  500. action: function () {
  501. $http({
  502. method: 'POST',
  503. url: url,
  504. data: {
  505. dealer_id: entity.id,
  506. noWithdraw: noWithdraw
  507. }
  508. }).then(function (response) {
  509. if (noWithdraw) {
  510. entity.status = "noWithdraw"; // 仅仅用于刷新显示效果
  511. } else {
  512. entity.status = "normal";
  513. }
  514. console.log(response);
  515. if (response.data.result) {
  516. toaster.pop("success", "提示", "提现功能切换成功!");
  517. } else {
  518. toaster.pop("error", "提示", "提现功能切换失败!");
  519. }
  520. }, function (response) {
  521. toaster.pop("error", "提示", "提现功能切换失败!");
  522. });
  523. }
  524. },
  525. }
  526. });
  527. };
  528. //查看设备
  529. $scope.checkDevice = function (entity) {
  530. if (entity.id == null) {
  531. toaster.pop("error", "提示", "接口缺少经销商id!");
  532. return
  533. }
  534. $state.go('app.dev.devManage', {
  535. managerId: "",
  536. agentId: "",
  537. dealerId: entity.id || "",
  538. searchKey: "",
  539. }, {
  540. reload: true
  541. });
  542. };
  543. //展示详情
  544. $scope.showInfoDetail = function (title, content) {
  545. if (content) {
  546. $scope.infoDetail = {title: title, content: JSON.parse(content)};
  547. $("#detailInfoPanel").modal();
  548. } else {
  549. toaster.pop("info", "提示", "没有更多信息");
  550. }
  551. }
  552. $scope.closeDetailInfoPanel = function () {
  553. $("#detailInfoPanel").modal("hide");
  554. };
  555. //展示详情
  556. $scope.showMerchantInfo = function (entity) {
  557. $("#merchantInfoPanel").modal("show");
  558. $http.get('/superadmin/getMerchantInfo', {
  559. params: {id: entity.id}
  560. }).then(function (res) {
  561. $scope.dialogData = res.data.payload;
  562. }).catch(function (data) {
  563. toaster.pop("error", "提示", "获取数据失败");
  564. });
  565. }
  566. // 关闭显示
  567. $scope.closeMerchantInfo = function () {
  568. $("#merchantInfoPanel").modal("hide");
  569. };
  570. // 刷新经销商微信状态
  571. $scope.refreshMerchantInfo = function (_id) {
  572. $http.get('/superadmin/refreshMerchantInfo', {
  573. params: {id: _id}
  574. }).then(function (res) {
  575. toaster.pop("info", "提示", "成功,请重新查看");
  576. }).catch(function (data) {
  577. toaster.pop("error", "提示", "失败");
  578. });
  579. $("#merchantInfoPanel").modal("hide");
  580. };
  581. // 刷新经销商微信状态
  582. $scope.wechatReplay = function (_id) {
  583. $http.get('/superadmin/wechatReplay', {
  584. params: {id: _id}
  585. }).then(function (res) {
  586. toaster.pop("info", "提示", "成功");
  587. }).catch(function (data) {
  588. toaster.pop("error", "提示", "失败");
  589. });
  590. $("#merchantInfoPanel").modal("hide");
  591. };
  592. // 必须先声明,否则ui-select无法双绑
  593. $scope.dialogData = {};
  594. // 配置特性
  595. $scope.editFeature = function (entity) {
  596. $scope.dialogData = {
  597. id: entity.id,
  598. featureList: entity.featureList,
  599. specialFeature: entity.specialFeature,
  600. };
  601. $("#featureForm").modal();
  602. }
  603. $scope.saveFeature = function () {
  604. if ($scope.featureForm.$invalid) {
  605. toaster.pop("warning", "提示", "请填写正确的数据");
  606. return
  607. }
  608. $.confirm({
  609. content: '确定要变更特性?',
  610. buttons: {
  611. ok: {
  612. btnClass: 'btn-red',
  613. action: function () {
  614. var url = "/superadmin/editDealerFeature";
  615. $http({
  616. method: 'POST',
  617. url: url,
  618. data: $scope.dialogData
  619. }).then(function (response) {
  620. //保存成功 弹窗消失
  621. $('#featureForm').modal('hide');
  622. if (response.data.result) {
  623. toaster.pop("info", "提示", "成功");
  624. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  625. }
  626. }, function (response) {
  627. toaster.pop("error", "提示", "保存失败!");
  628. });
  629. }
  630. },
  631. }
  632. });
  633. };
  634. //广告开关
  635. $scope.selectedIds = []
  636. $scope.editAdShow = function () {
  637. $scope.dialogData = {};
  638. var rows = getSelectRows()
  639. if (rows) {
  640. $("#editAdForm").modal();
  641. }
  642. }
  643. $scope.saveAdEdit = function () {
  644. var ids = $scope.selectedIds
  645. if ($scope.editAdForm.$invalid) {
  646. toaster.pop("warning", "提示", "请填写正确的数据");
  647. return
  648. }
  649. $http({
  650. method: 'POST',
  651. url: '/superadmin/editAdShow',
  652. data: {ids: ids, adShow: $scope.dialogData.adShow, role: "dealer"}
  653. }).then(function (response) {
  654. initDataGrid();
  655. $('#editAdForm').modal('hide');
  656. toaster.pop("success", "提示", "保存成功!");
  657. }, function (response) {
  658. toaster.pop("error", "提示", "保存失败!");
  659. });
  660. }
  661. // 强制关注公众号
  662. $scope.forceFollowGzh = function () {
  663. $scope.dialogData = {};
  664. var rows = getSelectRows()
  665. if (rows) {
  666. $("#editGzhForm").modal();
  667. }
  668. }
  669. $scope.saveGzg = function () {
  670. var ids = $scope.selectedIds
  671. if ($scope.editGzhForm.$invalid) {
  672. toaster.pop("warning", "提示", "请填写正确的数据");
  673. return
  674. }
  675. $http({
  676. method: 'POST',
  677. url: '/superadmin/editDealerFollowGzh',
  678. data: {ids: ids, forceFollowGzh: $scope.dialogData.forceFollowGzh}
  679. }).then(function (response) {
  680. initDataGrid();
  681. $('#editGzhForm').modal('hide');
  682. toaster.pop("success", "提示", "保存成功!");
  683. }, function (response) {
  684. toaster.pop("error", "提示", "保存失败!");
  685. });
  686. }
  687. // 编辑
  688. $scope.editDealer = function (entity) {
  689. var rows = $scope.gridApi.selection.getSelectedRows();
  690. if (rows.length === 0) {
  691. toaster.pop("info", "提示", "请选择数据!");
  692. return;
  693. }
  694. if (rows.length > 1) {
  695. toaster.pop("info", "提示", "只能选中编辑一条数据");
  696. return;
  697. }
  698. $scope.dialogData = rows[0];
  699. $("#dealerForm").modal();
  700. }
  701. $scope.saveDealer = function () {
  702. if ($scope.dealerForm.$invalid) {
  703. toaster.pop("warning", "提示", "请填写正确的数据");
  704. return
  705. }
  706. $http({
  707. method: 'POST',
  708. url: '/superadmin/editUserInfo',
  709. data: {role: 'dealer', id: $scope.dialogData.id, 'info': {username: $scope.dialogData.username}}
  710. }).then(function (response) {
  711. initDataGrid();
  712. $('#dealerForm').modal('hide');
  713. }, function (response) {
  714. toaster.pop("error", "提示", "保存失败!");
  715. });
  716. }
  717. /**监督号展现位置**/
  718. $scope.moniPoint = []
  719. $http.get('/superadmin/getMoniPointList', {
  720. params: {
  721. pageSize: 1000,
  722. pageIndex: 1
  723. }
  724. }).then(function (res) {
  725. var payload = res.data.payload;
  726. $scope.moniPoint = payload.dataList;
  727. }).catch(function (data) {
  728. toaster.pop("error", "提示", "获取监督号展现位置列表失败");
  729. });
  730. $scope.moniPointConfig = function () {
  731. var ids = getSelectRows()
  732. if (ids) {
  733. $("#moniPointForm").modal();
  734. $scope.dialogData = {}
  735. for (var key in $scope.moniPoint) {
  736. var item = $scope.moniPoint[key]
  737. $scope.dialogData[item.key] = false
  738. }
  739. }
  740. };
  741. $scope.setMoniPoint = function (pointKey) {
  742. var data = {
  743. dealerIds: $scope.selectedIds,
  744. moniPoint: [],
  745. }
  746. // 单个保存
  747. if (pointKey) {
  748. data.moniPoint.push({
  749. key: pointKey,
  750. switch: $scope.dialogData[pointKey] || false,// 默认为false
  751. })
  752. } else {
  753. var tempApp = []
  754. for (var key in $scope.dialogData) {
  755. tempApp.push({
  756. key: key,
  757. switch: $scope.dialogData[key] || false,// 默认为false
  758. })
  759. }
  760. data.moniPoint = tempApp
  761. }
  762. $http({
  763. method: 'POST',
  764. url: "/superadmin/editMoniPointForDealers",
  765. data: data
  766. }).then(function (response) {
  767. toaster.pop("success", "提示", "保存成功!");
  768. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  769. //批量保存关闭弹窗
  770. if (!pointKey) {
  771. $('#moniPointForm').modal('hide');//弹窗消失
  772. }
  773. }, function (response) {
  774. toaster.pop("error", "提示", "保存失败!");
  775. });
  776. };
  777. $scope.editSupporter = function () {
  778. $scope.dialogData = {};
  779. var rows = getSelectRows()
  780. if (rows) {
  781. $("#editSupporterForm").modal();
  782. }
  783. }
  784. $scope.saveSuporter = function () {
  785. var ids = $scope.selectedIds
  786. if ($scope.editSupporterForm.$invalid) {
  787. toaster.pop("warning", "提示", "请填写正确的数据");
  788. return
  789. }
  790. $http({
  791. method: 'POST',
  792. url: '/superadmin/editSupporterForDealers',
  793. data: {
  794. ids: ids,
  795. platformSupport: $scope.dialogData.platformSupport
  796. }
  797. }).then(function (response) {
  798. initDataGrid();
  799. $('#editSupporterForm').modal('hide');
  800. toaster.pop("success", "提示", "保存成功!");
  801. }, function (response) {
  802. toaster.pop("error", "提示", "保存失败!");
  803. });
  804. }
  805. // 使用前充值
  806. $scope.openSaveBeforeCharge = function () {
  807. $scope.dialogData = {};
  808. var rows = getSelectRows()
  809. if (rows) {
  810. $("#beforeChargeUnpayForm").modal();
  811. }
  812. }
  813. $scope.saveBeforeChargeUnpay = function () {
  814. var ids = $scope.selectedIds
  815. if ($scope.beforeChargeUnpayForm.$invalid) {
  816. toaster.pop("warning", "提示", "请填写正确的数据");
  817. return
  818. }
  819. $http({
  820. method: 'POST',
  821. url: '/superadmin/editDealerBeforeChargeUnpay',
  822. data: {ids: ids, beforeChargeUnpay: $scope.dialogData.beforeChargeUnpay}
  823. }).then(function (response) {
  824. initDataGrid();
  825. $('#beforeChargeUnpayForm').modal('hide');
  826. toaster.pop("success", "提示", "保存成功!");
  827. }, function (response) {
  828. toaster.pop("error", "提示", "保存失败!");
  829. });
  830. }
  831. //编辑密码 默认123456
  832. $scope.editPassword = function () {
  833. //重置表单状态
  834. $scope.passwordForm.$setPristine();
  835. $scope.passwordForm.$setUntouched();
  836. var rows = $scope.gridApi.selection.getSelectedRows();
  837. if (rows.length == 0) {
  838. toaster.pop("info", "提示", "请选择数据!");
  839. return;
  840. }
  841. if (rows.length > 1) {
  842. toaster.pop("info", "提示", "只能选中编辑一条数据");
  843. return;
  844. }
  845. var item = rows[0];
  846. $scope.passwordData = $.extend({password: 123456}, item);
  847. $("#passwordPanel").modal();
  848. };
  849. //修改密码提交
  850. $scope.savePassword = function () {
  851. //表单未校验通过不能提交
  852. if ($scope.passwordForm.$invalid) {
  853. return;
  854. }
  855. var url = "/superadmin/changeDealerPassword"
  856. var password = MD5.createHash($scope.passwordData.password + '');
  857. $http({
  858. method: 'POST',
  859. url: url,
  860. data: {
  861. id: $scope.passwordData.id,
  862. password: password,
  863. }
  864. }).then(function (response) {
  865. $('#passwordPanel').modal('hide');//弹窗消失
  866. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  867. }, function (response) {
  868. toaster.pop("error", "提示", "修改密码失败!");
  869. });
  870. };
  871. // 获取此经销商的银行卡配置
  872. function getBankConfigs(id) {
  873. return new Promise(((resolve, reject) => {
  874. $http.get('/superadmin/getDealerBanks', {
  875. params: {
  876. dealerId: id,
  877. }
  878. }).then(function (res) {
  879. resolve(res.data?.payload?.dataList)
  880. }).catch(function (data) {
  881. toaster.pop("error", "提示", "getDealerBanks失败。");
  882. reject()
  883. });
  884. }))
  885. }
  886. var lastRowId = ""
  887. async function renderBanksDialog(id){
  888. let list = await getBankConfigs(id) || [];
  889. list.forEach(bankInfo => {
  890. findName(bankInfo)
  891. })
  892. function findName(bankInfo) {
  893. if (bankInfo) {
  894. // 必须用provinceList ,确保引用地址一致,ui-select才能双绑。
  895. for (var index in $scope.provinceList) {
  896. var item = $scope.provinceList[index];
  897. if (item.value == bankInfo.provinceCode) {
  898. // 设置省份对应关系
  899. bankInfo.bankProvince = item
  900. // 初始化二级 市(暂时不查接口)
  901. bankInfo.bankCity = {
  902. "text": bankInfo.city,
  903. "value": bankInfo.cityCode,
  904. }
  905. bankInfo.cityList = [
  906. {
  907. "text": bankInfo.city,
  908. "value": bankInfo.cityCode,
  909. }
  910. ]
  911. break
  912. }
  913. }
  914. bankInfo.bankItem = {
  915. text: bankInfo.bankName,
  916. value: bankInfo.bankCode
  917. }
  918. bankInfo.branchBankItem = {
  919. text: bankInfo.branchBankName,
  920. value: bankInfo.branchBankCode
  921. }
  922. }
  923. }
  924. $scope.dialogData = {
  925. id: id,
  926. bankCards: list
  927. }
  928. $scope.$apply();
  929. }
  930. $scope.editBankAccount = async function () {
  931. var rows = $scope.gridApi.selection.getSelectedRows();
  932. if (rows.length === 0) {
  933. toaster.pop("info", "提示", "请选择数据!");
  934. return;
  935. }
  936. if (rows.length > 1) {
  937. toaster.pop("info", "提示", "只能选中编辑一条数据");
  938. return;
  939. }
  940. var row = rows[0]
  941. lastRowId = row.id;
  942. await renderBanksDialog(lastRowId)
  943. $("#bankAccountForm").modal();
  944. }
  945. $scope.addBank = function () {
  946. $scope.dialogData.bankCards.push({})
  947. }
  948. $scope.deleteBank = function (index, bankInfo) {
  949. if(bankInfo.id) {
  950. $.confirm({
  951. content: '确定删除?',
  952. buttons: {
  953. ok: {
  954. btnClass: 'btn-red',
  955. action: function () {
  956. $http({
  957. method: 'POST',
  958. url: '/superadmin/deleteDealerBankAccount',
  959. data: {id: bankInfo.id}
  960. }).then(function () {
  961. renderBanksDialog(lastRowId)
  962. }, function () {
  963. toaster.pop("error", "提示", "删除失败!");
  964. });
  965. }
  966. },
  967. }
  968. });
  969. } else {
  970. $scope.dialogData.bankCards.splice(index, 1)
  971. }
  972. }
  973. $scope.saveBankAccount = function (bankInfo) {
  974. bankInfo = $.extend(true, {dealerId: lastRowId}, bankInfo);
  975. if (bankInfo.isPublic) {
  976. if ($.isEmptyObject(bankInfo.bankProvince) || $.isEmptyObject(bankInfo.bankCity)) {
  977. toaster.pop("warning", "提示", "请填写省市");
  978. return
  979. }
  980. if ($.isEmptyObject(bankInfo.branchBankItem)) {
  981. toaster.pop("warning", "提示", "请填写支行名称");
  982. return
  983. }
  984. bankInfo.cityCode = bankInfo?.bankCity?.value
  985. bankInfo.city = bankInfo?.bankCity?.text
  986. bankInfo.provinceCode = bankInfo?.bankProvince?.value
  987. bankInfo.province = bankInfo?.bankProvince?.text
  988. bankInfo.bankCode = bankInfo?.bankItem?.value
  989. bankInfo.bankName = bankInfo?.bankItem?.text
  990. bankInfo.branchBankCode = bankInfo?.branchBankItem?.value
  991. bankInfo.branchBankName = bankInfo?.branchBankItem?.text
  992. } else {
  993. bankInfo.bankName = bankInfo?.bankItem?.text
  994. }
  995. delete bankInfo.bankCity
  996. delete bankInfo.bankProvince
  997. delete bankInfo.bankItem
  998. delete bankInfo.branchBankItem
  999. delete bankInfo.keyWord
  1000. delete bankInfo.cityList
  1001. delete bankInfo.branchBankList
  1002. delete bankInfo.bankList
  1003. $http({
  1004. method: 'POST',
  1005. url: '/superadmin/saveDealerBankAccount',
  1006. data: bankInfo
  1007. }).then(function () {
  1008. renderBanksDialog(lastRowId)
  1009. toaster.pop("success", "提示", "保存成功!");
  1010. }, function () {
  1011. toaster.pop("error", "提示", "保存失败!");
  1012. });
  1013. }
  1014. $scope.editCardFee = function () {
  1015. var rows = $scope.gridApi.selection.getSelectedRows();
  1016. if (rows.length === 0) {
  1017. toaster.pop("info", "提示", "请选择数据!");
  1018. return;
  1019. }
  1020. var ids = [];
  1021. for (var i = 0; i < rows.length; i++) {
  1022. ids.push(rows[i].id);
  1023. }
  1024. $scope.dialogData = {ids: ids}
  1025. $("#editCardFeeForm").modal();
  1026. }
  1027. $scope.saveCardFeeEdit = function () {
  1028. if ($scope.editCardFeeForm.$invalid) {
  1029. return;
  1030. }
  1031. var url = "/superadmin/changeDealerAnnualTrafficCost"
  1032. $http({
  1033. method: 'POST',
  1034. url: url,
  1035. data: {
  1036. ids: $scope.dialogData.ids,
  1037. annualTrafficCost: $scope.dialogData.annualTrafficCost,
  1038. }
  1039. }).then(function (response) {
  1040. $('#editCardFeeForm').modal('hide');
  1041. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  1042. }, function (response) {
  1043. toaster.pop("error", "提示", "保存失败!");
  1044. });
  1045. }
  1046. $scope.setDealerMaxPackagePrice = function () {
  1047. var rows = $scope.gridApi.selection.getSelectedRows();
  1048. if (rows.length === 0) {
  1049. toaster.pop("info", "提示", "请选择数据!");
  1050. return;
  1051. }
  1052. var ids = [];
  1053. let maxPackagePrice = 100
  1054. if (rows.length) {
  1055. maxPackagePrice = rows[0].maxPackagePrice
  1056. }
  1057. for (var i = 0; i < rows.length; i++) {
  1058. ids.push(rows[i].id);
  1059. }
  1060. $scope.dialogData = {ids: ids, maxPackagePrice: maxPackagePrice}
  1061. $("#dealerMaxPackagePrice").modal();
  1062. }
  1063. $scope.saveDealerMaxPackagePrice = function () {
  1064. if ($scope.dealerMaxPackagePrice.$invalid) {
  1065. return;
  1066. }
  1067. var url = "/superadmin/setDealerMaxPackagePrice"
  1068. $http({
  1069. method: 'POST',
  1070. url: url,
  1071. data: {
  1072. ids: $scope.dialogData.ids,
  1073. maxPackagePrice: $scope.dialogData.maxPackagePrice,
  1074. }
  1075. }).then(function (response) {
  1076. $('#dealerMaxPackagePrice').modal('hide');
  1077. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  1078. }, function (response) {
  1079. toaster.pop("error", "提示", "保存失败!");
  1080. });
  1081. }
  1082. $scope.editApiShow = function () {
  1083. var entity = getOneRow();
  1084. if (!entity) {
  1085. return
  1086. }
  1087. $scope.dialogData = {
  1088. id: entity.id
  1089. }
  1090. $http.get('/superadmin/apiapp/get', {
  1091. params: {
  1092. dealerId: entity.id,
  1093. }
  1094. }).then(function (res) {
  1095. $scope.dialogData = res.data.payload;
  1096. $scope.dialogData.id = entity.id;
  1097. $("#apiAppForm").modal();
  1098. }).catch(function (data) {
  1099. toaster.pop("error", "提示", "查询api应用信息失败。");
  1100. });
  1101. }
  1102. $scope.saveApiApp = function () {
  1103. if ($scope.apiAppForm.$invalid) {
  1104. return
  1105. }
  1106. var url = "/superadmin/apiapp/set";
  1107. $http({
  1108. method: 'POST',
  1109. url: url,
  1110. data: {
  1111. dealerId: $scope.dialogData.id,
  1112. people: $scope.dialogData.people,
  1113. tel: $scope.dialogData.tel,
  1114. callbackUrl: $scope.dialogData.callbackUrl,
  1115. apiDeviceMax: $scope.dialogData.apiDeviceMax,
  1116. apiDevicePerCost: $scope.dialogData.apiDevicePerCost,
  1117. }
  1118. }).then(function (response) {
  1119. $('#apiAppForm').modal('hide');
  1120. if (response.data.result) {
  1121. toaster.pop("info", "提示", "成功")
  1122. }
  1123. }, function (response) {
  1124. toaster.pop("error", "提示", "保存失败!");
  1125. });
  1126. }
  1127. }]);