agentsManage.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. app.controller('agentsManageCtrl', ['$scope', '$http', "$state", '$timeout', 'uiGridConstants', 'i18nService', 'FileUploader', 'toaster', 'md5', function ($scope, $http, $state, $timeout, uiGridConstants, i18nService, FileUploader, toaster, MD5) {
  2. i18nService.setCurrentLang("zh-cn");
  3. $scope.gridOptions = {
  4. data: 'myData',
  5. showGridFooter: true, //是否显示grid footer
  6. // rowHeight: 80,
  7. //-------- 分页属性 ----------------
  8. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  9. paginationCurrentPage: 1, //当前页码
  10. paginationPageSize: 10, //每页显示个数
  11. totalItems: 0,// 总数量
  12. useExternalPagination: true,//是否使用分页按钮
  13. //过滤
  14. // enableFiltering: true,
  15. columnDefs: [],
  16. //---------------api---------------------
  17. onRegisterApi: function (gridApi) {
  18. $scope.gridApi = gridApi;
  19. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  20. if ($scope.setPagingData) {
  21. $scope.getPagedDataAsync(newPage, pageSize);
  22. }
  23. });
  24. }
  25. };
  26. //查询条件
  27. var condition = $scope.condition = {
  28. searchKey: ""
  29. };
  30. //枚举常量
  31. $scope.enum = {};
  32. // 事件
  33. $scope.ngEvent = {
  34. compressorImg: function (file, callback) {
  35. if (file) {
  36. var imageCompressor = new Compressor(file, {
  37. quality: .7,
  38. // 图片尺寸
  39. maxWidth: 1920,
  40. maxHeight: 1920,
  41. success: function (result) {
  42. var formData = new FormData();
  43. formData.append('file', result, result.name);
  44. if (callback) {
  45. callback(formData);
  46. }
  47. }
  48. });
  49. }
  50. },
  51. deletePic: function (index) {
  52. $scope.dialogData.bannerImgList.splice(index, 1);
  53. },
  54. editPicUrl: function (index) {
  55. if ($scope.nowClickPicIndex == index) {
  56. $scope.nowClickPicIndex = null
  57. } else {
  58. $scope.nowClickPicIndex = index
  59. }
  60. },
  61. addPic: function () {
  62. var imgUpload = $("#addImg");
  63. var file = imgUpload[0].files[0];
  64. this.compressorImg(file, function (formData) {
  65. var url = '/common/upload?type=banner';
  66. $http({
  67. method: 'POST',
  68. url: url,
  69. transformRequest: angular.identity,
  70. headers: {
  71. 'Content-Type': undefined// 禁止angular对data的处理
  72. },
  73. data: formData
  74. }).then(function (response) {
  75. var url = response.data.para;
  76. $scope.dialogData.bannerImgList.push({img: url});
  77. //重置文件路径,避免选中重复不触发onchange
  78. var imgUpload = $("#addImg");
  79. imgUpload[0].value = "";
  80. }, function (response) {
  81. toaster.pop("error", "提示", "上传失败!");
  82. });
  83. })
  84. },
  85. saveBanner: function () {
  86. $http({
  87. method: 'POST',
  88. url: "/manager/setAgentBanner",
  89. data: {
  90. id: $scope.dialogData.id,
  91. bannerImgList: $scope.dialogData.bannerImgList,
  92. bannerName: $scope.dialogData.bannerName,
  93. }
  94. }).then(function (response) {
  95. if (response.data.result === 1) {
  96. toaster.pop("success", "提示", "保存成功!")
  97. }
  98. }, function (response) {
  99. toaster.pop("error", "提示", "保存失败!");
  100. });
  101. }
  102. };
  103. //事件
  104. $scope.event = {
  105. search: function () {
  106. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  107. },
  108. generateNewAppKeyPair: function () {
  109. var dialogData = $scope.dialogData
  110. if (!dialogData.aliPayApp.appid) {
  111. toaster.pop("warning", "提示", "请填写支付宝的APP ID!");
  112. return
  113. }
  114. $http({
  115. method: 'POST',
  116. url: '/common/generateNewAppKeyPair',
  117. data: {
  118. appid: dialogData.aliPayApp.appid,
  119. }
  120. }).then(function (response) {
  121. if (response.data.result) {
  122. toaster.pop("success", "提示", "生成成功!");
  123. $scope.dialogData.aliPayApp.app_private_key_path = response.data.payload.path;
  124. $scope.dialogData.aliPayApp.hasAlipayAppKeyPair = true;
  125. $scope.dialogData.aliPayApp.appPublicKeyContent = response.data.payload.appPublicKeyContent;
  126. } else {
  127. toaster.pop("error", "提示", "生成失败");
  128. }
  129. }, function (response) {
  130. toaster.pop("error", "提示", "生成失败!");
  131. });
  132. },
  133. };
  134. function setColumnDefs() {
  135. $scope.gridOptions.columnDefs = [
  136. {
  137. field: 'nickname', displayName: '代理商名称',
  138. cellTemplate: '<div class="temp-row" ng-class="{\' text-info\':row.entity.isPrimary}"><i class="fa fa-user" title="主代理商" ng-if="row.entity.isPrimary" ></i> {{row.entity.nickname}}</div>',
  139. },
  140. {field: 'username', displayName: '联系方式'},
  141. {
  142. field: 'dateTimeAdded',
  143. displayName: '注册时间',
  144. cellTemplate: '<div class="temp-row" ng-bind="row.entity.dateTimeAdded"></div>'
  145. },
  146. {
  147. field: 'dealerTotal',
  148. displayName: '经销商总数',
  149. cellTemplate: '<div class="temp-row" ng-bind="row.entity.dealerTotal"></div>'
  150. },
  151. {
  152. field: 'annualTrafficCost',
  153. displayName: '流量卡最低费用',
  154. cellTemplate: '<div class="temp-row" ng-bind="row.entity.annualTrafficCost"></div>'
  155. },
  156. {
  157. field: 'withdrawFeeRatio',
  158. displayName: '最低提现费率',
  159. cellTemplate: '<div class="temp-row">{{row.entity.withdrawFeeRatio}}‰</div>'
  160. },
  161. {
  162. field: 'pay_config',
  163. displayName: '资金池',
  164. cellTemplate: '<div class="temp-row"><span class="iconfont icon-wechat c-wechat" ng-if="row.entity.customizedWechatCashflowAllowable" title="微信"></span> <span class="iconfont icon-alipay c-alipay" ng-if="row.entity.customizedAlipayCashflowAllowable" title="支付宝"></span><span ng-if="!row.entity.customizedAlipayCashflowAllowable&&!row.entity.customizedAlipayCashflowAllowable">暂无</span></div>',
  165. enableFiltering: false,
  166. enableSorting: false
  167. },
  168. {
  169. field: 'detail',
  170. displayName: '详细信息',
  171. cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetail(\'详细信息\',row.entity.detail)">{{row.entity.detail}}</div>'
  172. },
  173. {
  174. field: 'operation',
  175. displayName: '操作',
  176. enableFiltering: false,
  177. enableSorting: false,
  178. enableHiding: false,//禁止在列选择器中隐藏
  179. enableColumnMenu: false,// 是否显示列头部菜单按钮
  180. minWidth: 160,
  181. // 注意,主代理商自己不能分配设备类型
  182. cellTemplate: '<div class="grid-button">' +
  183. '<button class="btn btn-sm btn-rounded btn-green" ng-click="grid.appScope.goDealer(row.entity)"><i class="fa fa-male"></i> 经销商</button>' +
  184. '</div>'
  185. },
  186. ];
  187. var fields = $scope.gridOptions.columnDefs;
  188. for (var index in fields) {
  189. var item = fields[index];
  190. if (item && item['minWidth'] == null) {
  191. item['minWidth'] = 100;
  192. }
  193. }
  194. }
  195. function getOneRow() {
  196. var rows = $scope.gridApi.selection.getSelectedRows();
  197. if (rows.length === 0) {
  198. toaster.pop("info", "提示", "请选择数据!");
  199. return false;
  200. }
  201. if (rows.length > 1) {
  202. toaster.pop("info", "提示", "只能选中编辑一条数据");
  203. return false;
  204. }
  205. return rows[0]
  206. }
  207. //查看经销商
  208. $scope.goDealer = function (entity) {
  209. $scope.nowAgentName = entity.nickname;
  210. $("#agentDealerList").modal();
  211. $timeout(function () {
  212. // random避免刷新后显示问题
  213. $state.go('app.user.agents.dealer', {
  214. agentId: entity.id,
  215. v: "v" + new Date().getTime()
  216. });
  217. });
  218. };
  219. $scope.closeDealer = function () {
  220. $("#agentDealerList").modal('hide');
  221. };
  222. $scope.setPagingData = function (data, curPage, pageSize) {
  223. var firstRow = (curPage - 1) * pageSize;
  224. var pagedData = data.data.dataList;
  225. $scope.myData = pagedData;
  226. $scope.gridOptions.totalItems = data.data.total;
  227. };
  228. $scope.getPagedDataAsync = function (curPage, pageSize, searchText) {
  229. if ($scope.gridOptionsLoading) {
  230. return;
  231. }
  232. var params = {
  233. pageSize: pageSize,
  234. pageIndex: curPage
  235. };
  236. if (condition.searchKey != "") {
  237. params.searchKey = condition.searchKey
  238. }
  239. $scope.gridOptionsLoading = true;
  240. $http.get('/agent/getAgentsDetailList', {
  241. params: params
  242. }).then(function (data) {
  243. $scope.gridOptionsLoading = false;
  244. $scope.setPagingData(data.data, curPage, pageSize);
  245. }).catch(function (data) {
  246. toaster.pop("error", "提示", "获取数据列表失败");
  247. });
  248. };
  249. function initDataGrid() {
  250. //首次加载表格
  251. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  252. }
  253. setColumnDefs();
  254. initDataGrid();
  255. //展示详情
  256. $scope.showInfoDetail = function (title, content) {
  257. $scope.infoDetail = {title: title, content: content};
  258. $("#detailInfoPanel").modal();
  259. };
  260. $scope.closeDetailInfoPanel = function () {
  261. $("#detailInfoPanel").modal("hide");
  262. };
  263. /********************链接拷贝面板***********************/
  264. var copyLinkData = $scope.copyLinkData = {};
  265. var currentDomain = location.protocol + "//" + location.host;
  266. //生成推广链接
  267. $scope.openLinkPanel = function () {
  268. var entity = getOneRow();
  269. if (!entity) {
  270. return
  271. }
  272. $("#copyLinkPanel").modal();
  273. //经销商注册链接
  274. var url = currentDomain + "/dealerAccess?agentId=" + entity.id;
  275. copyLinkData.link1 = url;
  276. // 个人主页链接
  277. var url = currentDomain + "/userLogin?agentId=" + entity.id + "&redirect=" + encodeURIComponent("/user/index.html#/user/me");
  278. copyLinkData.link2 = url;
  279. // 用户地图链接
  280. var url = currentDomain + "/userLogin?agentId=" + entity.id + "&redirect=" + encodeURIComponent("/user/index.html#/user/index");
  281. copyLinkData.link3 = url;
  282. // 用户扫码
  283. var url = currentDomain + "/userLogin?agentId=" + entity.id + "&redirect=" + encodeURIComponent("/user/index.html#/dev");
  284. copyLinkData.link4 = url;
  285. };
  286. // 关闭链接生成器
  287. $scope.closeCopyLinkPanel = function () {
  288. $("#copyLinkPanel").modal("hide");
  289. };
  290. var clipboard;
  291. //事件绑定
  292. $timeout(function () {
  293. //在弹窗绑定 COPY组件
  294. clipboard = new ClipboardJS('.copyLinkBtn');
  295. clipboard.on('success', function (e) {
  296. e.clearSelection();
  297. toaster.pop("info", "提示", "复制成功");
  298. $scope.$apply();
  299. });
  300. clipboard.on('error', function (e) {
  301. toaster.pop("info", "提示", "请选择“拷贝”进行复制!");
  302. $scope.$apply();
  303. });
  304. });
  305. $scope.$on("$destroy", function () {
  306. if (clipboard) {
  307. clipboard.destroy();
  308. console.log("clipboard destroy");
  309. }
  310. });
  311. // 必须先声明,否则ui-select无法双绑
  312. $scope.dialogData = {};
  313. //添加
  314. $scope.add = function () {
  315. //重置表单状态
  316. $scope.agentsForm.$setPristine();
  317. $scope.agentsForm.$setUntouched();
  318. $scope.dialogName = "代理商开户";
  319. $scope.dialogData = {isNew: true,};
  320. $("#agentsPanel").modal();
  321. };
  322. //编辑
  323. $scope.edit = function () {
  324. //重置表单状态
  325. $scope.agentsForm.$setPristine();
  326. $scope.agentsForm.$setUntouched();
  327. $scope.dialogName = "编辑代理商信息";
  328. var row = getOneRow();
  329. if (!row) {
  330. return
  331. }
  332. $scope.dialogData = $.extend({}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
  333. $("#agentsPanel").modal();
  334. };
  335. //编辑
  336. $scope.editOtherAPI = function () {
  337. //重置表单状态
  338. $scope.otherAPIForm.$setPristine();
  339. $scope.otherAPIForm.$setUntouched();
  340. var row = getOneRow();
  341. if (!row) {
  342. return
  343. }
  344. $scope.dialogFireData = $.extend(true, {id: row.id}, row.ZJFirePlatform);
  345. $("#otherAPIForm").modal();
  346. };
  347. $scope.saveOtherAPIForm = function () {
  348. if ($scope.otherAPIForm.$invalid) {
  349. return;
  350. }
  351. var url = "/manager/editAgentZJFirePlatform";
  352. $http({
  353. method: 'POST',
  354. url: url,
  355. data: $scope.dialogFireData
  356. }).then(function (response) {
  357. $('#otherAPIForm').modal('hide');
  358. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  359. }, function (response) {
  360. toaster.pop("error", "提示", "保存失败!");
  361. });
  362. }
  363. $scope.editBanner = function () {
  364. //重置表单状态
  365. $scope.bannerForm.$setPristine();
  366. $scope.bannerForm.$setUntouched();
  367. $scope.dialogName = "编辑代理商Banner";
  368. var row = getOneRow();
  369. if (!row) {
  370. return
  371. }
  372. $scope.dialogData = $.extend({bannerImgList: []}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
  373. $("#bannerForm").modal();
  374. };
  375. //编辑密码 默认123456
  376. $scope.editPassword = function () {
  377. //重置表单状态
  378. $scope.passwordForm.$setPristine();
  379. $scope.passwordForm.$setUntouched();
  380. var row = getOneRow();
  381. if (!row) {
  382. return
  383. }
  384. $scope.passwordData = $.extend({password: 123456}, row);
  385. $("#passwordPanel").modal();
  386. };
  387. //解锁经销商的登录限制,如密码输错后导致的锁
  388. $scope.unlock = function () {
  389. var row = getOneRow();
  390. if (!row) {
  391. return
  392. }
  393. var url = "/manager/unlockAgent";
  394. $http({
  395. method: 'POST',
  396. url: url,
  397. data: {
  398. id: row.id
  399. }
  400. }).then(function (response) {
  401. toaster.pop("info", "提示", "解锁成功!")
  402. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  403. }, function (response) {
  404. toaster.pop("error", "提示", "解锁失败!");
  405. });
  406. }
  407. //提交表单保存
  408. $scope.saveData = function () {
  409. var url = "";
  410. if ($scope.dialogData.id == null) {
  411. url = "/manager/addAgents";
  412. } else {
  413. url = "/manager/editAgents";
  414. }
  415. var data = {
  416. nickname: $scope.dialogData.nickname,
  417. username: $scope.dialogData.username,
  418. annualTrafficCost: parseFloat($scope.dialogData.annualTrafficCost),//最低流量卡年费
  419. withdrawFeeRatio: parseFloat($scope.dialogData.withdrawFeeRatio),
  420. managerProfitShare: parseFloat($scope.dialogData.managerProfitShare),
  421. };
  422. if ($scope.dialogData.id != null) {
  423. data.id = $scope.dialogData.id
  424. } else {
  425. //新建
  426. data.password = MD5.createHash($scope.dialogData.password + '');
  427. }
  428. $http({
  429. method: 'POST',
  430. url: url,
  431. data: data
  432. }).then(function (response) {
  433. $('#agentsPanel').modal('hide');//弹窗消失
  434. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  435. }, function (response) {
  436. toaster.pop("error", "提示", "保存失败!");
  437. });
  438. };
  439. /*****************公众号*********************/
  440. $scope.editWechat = function () {
  441. //重置表单状态
  442. $scope.wechatForm.$setPristine();
  443. $scope.wechatForm.$setUntouched();
  444. var row = getOneRow();
  445. if (!row) {
  446. return
  447. }
  448. $scope.dialogData = $.extend({user: {}, dealer: {}}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
  449. $("#wechatForm").modal();
  450. }
  451. $scope.saveWechat = function () {
  452. var url = "/manager/bind_wechat_cust";
  453. var data = {};
  454. // 防止为空没填报错
  455. $scope.dialogData.dealer = $scope.dialogData.dealer || {};
  456. $scope.dialogData.user = $scope.dialogData.user || {};
  457. //编辑
  458. $.extend(data, {
  459. 'id': $scope.dialogData.id,
  460. customizedDealerGzhAllowable: $scope.dialogData.customizedDealerGzhAllowable,
  461. dealer: {
  462. appid: $scope.dialogData.dealer.appid,
  463. secret: $scope.dialogData.dealer.secret,
  464. templateIdMap: $scope.dialogData.dealer.templateIdMap,
  465. },
  466. customizedUserGzhAllowable: $scope.dialogData.customizedUserGzhAllowable,
  467. user: {
  468. appid: $scope.dialogData.user.appid,
  469. secret: $scope.dialogData.user.secret,
  470. templateIdMap: $scope.dialogData.user.templateIdMap,
  471. },
  472. })
  473. $http({
  474. method: 'POST',
  475. url: url,
  476. data: data
  477. }).then(function (response) {
  478. $('#wechatForm').modal('hide');//弹窗消失
  479. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  480. }, function (response) {
  481. toaster.pop("error", "提示", "操作失败!");
  482. });
  483. };
  484. /*****************资金池*********************/
  485. $scope.cashPoolWechat = function () {
  486. //重置表单状态
  487. $scope.cashPoolWechatForm.$setPristine();
  488. $scope.cashPoolWechatForm.$setUntouched();
  489. var row = getOneRow();
  490. if (!row) {
  491. return
  492. }
  493. $scope.dialogData = $.extend({wechatPayApp: {}}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
  494. $("#cashPoolWechatForm").modal();
  495. };
  496. $scope.cashPoolAlipay = function () {
  497. //重置表单状态
  498. $scope.cashPoolAlipayForm.$setPristine();
  499. $scope.cashPoolAlipayForm.$setUntouched();
  500. var row = getOneRow();
  501. if (!row) {
  502. return
  503. }
  504. $scope.dialogData = $.extend({aliPayApp: {}}, row);//非深度克隆的优点是:如果不小心取消了,下次编辑时,子对象的数据还在
  505. $("#cashPoolAlipayForm").modal();
  506. };
  507. $scope.changeFile = function (files,key) {
  508. if (files.length) {
  509. var file = files[0];
  510. var reader = new FileReader();
  511. // 文件不能大于1M
  512. if (file.size > 1000 * 1024) {
  513. toaster.pop("info", "提示", "文件太大,请重新选择");
  514. } else {
  515. reader.onload = function() {
  516. if(reader.result) {
  517. var text = reader.result
  518. $scope.dialogData.wechatPayApp[key] = btoa(text)
  519. $scope.$apply();
  520. }
  521. };
  522. reader.readAsText(file);
  523. }
  524. }
  525. }
  526. $scope.saveCashPoolAlipay = function () {
  527. var url = "/manager/bind_ali_app";
  528. var data = {};
  529. // 防止未空没填报错
  530. $scope.dialogData.aliPayApp = $scope.dialogData.aliPayApp || {};
  531. //编辑
  532. $.extend(data, {
  533. 'id': $scope.dialogData.id,
  534. customizedAlipayCashflowAllowable: $scope.dialogData.customizedAlipayCashflowAllowable,
  535. aliPayApp: {
  536. appid: $scope.dialogData.aliPayApp.appid,
  537. alipayPublicKeyContent: $scope.dialogData.aliPayApp.alipayPublicKeyContent,
  538. app_private_key_path: $scope.dialogData.aliPayApp.app_private_key_path,
  539. appPublicKeyContent: $scope.dialogData.aliPayApp.appPublicKeyContent,
  540. shadow: $scope.dialogData.aliPayApp.shadow,
  541. public_key_path: $scope.dialogData.aliPayApp.public_key_path
  542. }
  543. })
  544. $http({
  545. method: 'POST',
  546. url: url,
  547. data: data
  548. }).then(function (response) {
  549. $('#cashPoolAlipayForm').modal('hide');//弹窗消失
  550. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  551. }, function (response) {
  552. toaster.pop("error", "提示", "保存失败!");
  553. });
  554. }
  555. //修改密码提交
  556. $scope.savePassword = function () {
  557. //表单未校验通过不能提交
  558. if ($scope.passwordForm.$invalid) {
  559. return;
  560. }
  561. var url = "/manager/editAgentPassword";
  562. var password = MD5.createHash($scope.passwordData.password + '');
  563. $http({
  564. method: 'POST',
  565. url: url,
  566. data: {
  567. id: $scope.passwordData.id,
  568. password: password,
  569. }
  570. }).then(function (response) {
  571. $('#passwordPanel').modal('hide');//弹窗消失
  572. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  573. }, function (response) {
  574. toaster.pop("error", "提示", "修改密码失败!");
  575. });
  576. };
  577. /***************** 分配厂商的设备类型弹窗**********************/
  578. $scope.editDeviceType = function () {
  579. var entity = getOneRow();
  580. if (!entity) {
  581. return
  582. }
  583. if (entity.isPrimary) {
  584. toaster.pop("warning", "提示", "该角色是主代理商,不能配置!");
  585. return
  586. }
  587. $("#editDeviceTypePanel").modal();
  588. $scope.dialogName = entity.nickname + "配置设备类型";
  589. $("#dealerDevList").modal();
  590. // todo 由于ui-grid 之前隐藏,表格渲染有问题
  591. setTimeout(function () {
  592. // 刷新设备
  593. $scope.$broadcast("initDriverCodeList", {id: entity.id, role: "agent"});
  594. }, 100);
  595. };
  596. $scope.closeDeviceConfig = function (entity) {
  597. $("#editDeviceTypePanel").modal('hide');
  598. };
  599. }]);