dealerManage.js 39 KB

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