agent.js 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'toastr'], function ($, undefined, Backend, Table, Form, Toastr) {
  2. var Controller = {
  3. index: function () {
  4. var agentIndex = new Vue({
  5. el: "#agentIndex",
  6. data() {
  7. return {
  8. isAjax: true,
  9. isAjaxtable: false,
  10. activeTabsName: 'all',
  11. tabsList: [{
  12. name: 'all',
  13. label: '分销商'
  14. },
  15. {
  16. name: 'pending',
  17. label: '待审核'
  18. },
  19. {
  20. name: '1',
  21. label: '待升级'
  22. }
  23. ],
  24. agentLevelList: [],
  25. agentStatusOptions: [{
  26. value: 'all',
  27. label: '全部'
  28. }, {
  29. value: 'normal',
  30. label: '正常'
  31. }, {
  32. value: 'forbidden',
  33. label: '禁用'
  34. }, {
  35. value: 'pending',
  36. label: '审核中'
  37. }, {
  38. value: 'freeze',
  39. label: '冻结'
  40. }],
  41. // form搜索
  42. searchForm: {
  43. status: "all",
  44. level: "all",
  45. updatetime: [],
  46. form_1_key: "user_id",
  47. form_1_value: "",
  48. level_status: "all",
  49. },
  50. searchFormInit: {
  51. status: "all",
  52. level: "all",
  53. updatetime: [],
  54. form_1_key: "user_id",
  55. form_1_value: "",
  56. level_status: "all"
  57. },
  58. searchOp: {
  59. status: "=",
  60. updatetime: 'range',
  61. level: "=",
  62. user_id: "=",
  63. nickname: "like",
  64. mobile: "like",
  65. level_status: ">"
  66. },
  67. sort: 'createtime',
  68. listData: [],
  69. offset: 0,
  70. limit: 10,
  71. totalPage: 0,
  72. currentPage: 1,
  73. }
  74. },
  75. created() {
  76. this.getListData();
  77. this.getAgentLevel();
  78. },
  79. methods: {
  80. getListData() {
  81. let that = this;
  82. if (!that.isAjax) {
  83. that.isAjaxtable = true;
  84. }
  85. let filter = {}
  86. let op = {}
  87. for (key in that.searchForm) {
  88. if (key == 'form_1_value') {
  89. if (that.searchForm[key] != '') {
  90. filter[that.searchForm.form_1_key] = that.searchForm[key];
  91. }
  92. } else if (key == 'updatetime') {
  93. if (that.searchForm[key]) {
  94. if (that.searchForm[key].length > 0) {
  95. filter[key] = that.searchForm[key].join(' - ');
  96. }
  97. }
  98. } else if (key == 'status' || key == 'level' || key == 'level_status') {
  99. if (that.searchForm[key] != '' && that.searchForm[key] != 'all') {
  100. filter[key] = that.searchForm[key];
  101. }
  102. }
  103. }
  104. for (key in filter) {
  105. op[key] = that.searchOp[key]
  106. }
  107. Fast.api.ajax({
  108. url: 'shopro/commission/agent/index',
  109. loading: false,
  110. type: 'GET',
  111. data: {
  112. offset: that.offset,
  113. limit: that.limit,
  114. sort: that.sort,
  115. order: 'desc',
  116. filter: JSON.stringify(filter),
  117. op: JSON.stringify(op)
  118. },
  119. }, function (ret, res) {
  120. that.listData = res.data.rows;
  121. that.totalPage = res.data.total;
  122. that.isAjax = false;
  123. that.isAjaxtable = false;
  124. return false;
  125. }, function (ret, res) {
  126. that.isAjax = false;
  127. that.isAjaxtable = false;
  128. return false;
  129. })
  130. },
  131. getAgentLevel() {
  132. let that = this;
  133. Fast.api.ajax({
  134. url: 'shopro/commission/level/index',
  135. loading: false,
  136. type: 'GET',
  137. }, function (ret, res) {
  138. that.agentLevelList = res.data;
  139. that.agentLevelList.unshift({
  140. level: 'all',
  141. name: "全部"
  142. })
  143. return false;
  144. })
  145. },
  146. screenEmpty() {
  147. let padding=this.searchForm.status
  148. this.searchForm = JSON.parse(JSON.stringify(this.searchFormInit))
  149. if(padding=='pending'){
  150. this.searchForm.status='pending'
  151. }
  152. },
  153. operation(type, id, row) {
  154. let that = this;
  155. switch (type) {
  156. case 'edit':
  157. Fast.api.open('shopro/commission/agent/profile?id=' + id, '查看', {
  158. callback() {
  159. that.getListData();
  160. }
  161. })
  162. break;
  163. case 'del':
  164. that.$confirm('此操作将永久直接删除, 是否继续?', '提示', {
  165. confirmButtonText: '确定',
  166. cancelButtonText: '取消',
  167. type: 'warning'
  168. }).then(() => {
  169. Fast.api.ajax({
  170. url: 'shopro/commission/agent/del/ids/' + id,
  171. loading: false,
  172. type: 'POST',
  173. }, function (ret, res) {
  174. that.getListData();
  175. })
  176. return false;
  177. }).catch(() => {
  178. that.$message({
  179. type: 'info',
  180. message: '已取消删除'
  181. });
  182. });
  183. break;
  184. case 'reject':
  185. Fast.api.ajax({
  186. url: 'shopro/commission/agent/update?id=' + id,
  187. loading: false,
  188. type: 'POST',
  189. data: {
  190. key: 'info_status',
  191. value: '-1'
  192. }
  193. }, function (ret, res) {
  194. that.getListData();
  195. })
  196. break;
  197. case 'agree':
  198. if (row.info_status == 0) {
  199. that.$confirm('用户还未完善资料, 是否同意申请?', '提示', {
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消',
  202. type: 'warning'
  203. }).then(() => {
  204. Fast.api.ajax({
  205. url: 'shopro/commission/agent/update?id=' + id,
  206. loading: false,
  207. type: 'POST',
  208. data: {
  209. key: 'status',
  210. value: 'normal'
  211. }
  212. }, function (ret, res) {
  213. that.getListData();
  214. })
  215. }).catch(() => {
  216. that.$message({
  217. type: 'info',
  218. message: '已取消删除'
  219. });
  220. });
  221. } else {
  222. Fast.api.ajax({
  223. url: 'shopro/commission/agent/update?id=' + id,
  224. loading: false,
  225. type: 'POST',
  226. data: {
  227. key: 'status',
  228. value: 'normal'
  229. }
  230. }, function (ret, res) {
  231. that.getListData();
  232. })
  233. }
  234. break;
  235. case 'agree-null-status':
  236. Fast.api.ajax({
  237. url: 'shopro/commission/agent/update?id=' + id,
  238. loading: false,
  239. type: 'POST',
  240. data: {
  241. key: 'status',
  242. value: 'normal'
  243. }
  244. }, function (ret, res) {
  245. that.getListData();
  246. })
  247. break;
  248. case 'filter':
  249. var data = {
  250. value: '',
  251. color: ''
  252. }
  253. switch (id) {
  254. case 'normal':
  255. data.value = '正常';
  256. data.color = '#444';
  257. break;
  258. case 'forbidden':
  259. data.value = '禁用';
  260. data.color = '#ED655F';
  261. break;
  262. case 'pending':
  263. data.value = '审核中';
  264. data.color = '#999';
  265. break;
  266. case 'freeze':
  267. data.value = '冻结';
  268. data.color = '#687FF4';
  269. break;
  270. }
  271. return data;
  272. break;
  273. case 'update-agree':
  274. Fast.api.ajax({
  275. url: 'shopro/commission/agent/update?id=' + id,
  276. loading: false,
  277. type: 'POST',
  278. data: {
  279. key: 'level_status',
  280. value: row
  281. }
  282. }, function (ret, res) {
  283. that.getListData();
  284. })
  285. break;
  286. case 'update-refuse':
  287. Fast.api.ajax({
  288. url: 'shopro/commission/agent/update?id=' + id,
  289. loading: false,
  290. type: 'POST',
  291. data: {
  292. key: 'level_status',
  293. value: 0
  294. }
  295. }, function (ret, res) {
  296. that.getListData();
  297. })
  298. break;
  299. }
  300. },
  301. handleSizeChange(val) {
  302. this.offset = 0
  303. this.limit = val;
  304. this.currentPage = 1;
  305. this.getListData()
  306. },
  307. handleCurrentChange(val) {
  308. this.currentPage = val;
  309. this.offset = (val - 1) * this.limit;
  310. this.getListData()
  311. },
  312. tabshandleClick(value) {
  313. this.searchForm.status = "";
  314. this.searchForm.level_status = "";
  315. if (value.name == 'pending') {
  316. this.searchForm.status = value.name;
  317. this.sort = 'updatetime';
  318. } else if (value.name == '1') {
  319. this.searchForm.level_status = value.name;
  320. this.sort = 'updatetime';
  321. } else {
  322. this.sort = 'createtime'
  323. }
  324. this.listData = [];
  325. this.isAjaxtable = true;
  326. this.offset = 0;
  327. this.limit = 10;
  328. this.totalPage = 0;
  329. this.currentPage = 1;
  330. this.getListData();
  331. },
  332. tableCellClassName({
  333. columnIndex
  334. }) {
  335. if (columnIndex == 1 || columnIndex == 7 || columnIndex == 13) {
  336. return 'cell-left';
  337. }
  338. return '';
  339. },
  340. tableCellClassName2({
  341. columnIndex
  342. }) {
  343. if (columnIndex == 1 || columnIndex == 4 || columnIndex == 10) {
  344. return 'cell-left';
  345. }
  346. return '';
  347. },
  348. tableCellClassName3({
  349. columnIndex
  350. }) {
  351. if (columnIndex == 1 || columnIndex == 7) {
  352. return 'cell-left';
  353. }
  354. return '';
  355. },
  356. },
  357. })
  358. },
  359. profile: function () {
  360. function debounce(handle, delay) {
  361. let time = null;
  362. return function () {
  363. let self = this,
  364. arg = arguments;
  365. clearTimeout(time);
  366. time = setTimeout(function () {
  367. handle.apply(self, arg);
  368. }, delay)
  369. }
  370. }
  371. let formatterHtml = {
  372. order_id: (row) => {
  373. if(row.order){
  374. return `${row.order.id}`
  375. }
  376. },
  377. order_sn: (row) => {
  378. if(row.order){
  379. return `<span class="theme-cursor">${row.order.order_sn}</span>`
  380. }
  381. },
  382. time: (row) => {
  383. return `${moment(row.createtime*1000).format('YYYY-MM-DD HH:mm:ss')}`
  384. },
  385. user_message: (row) => {
  386. if(row.buyer){
  387. return `<div class="display-flex" style="justify-content: flex-start;width: 100%;">
  388. <div style="width:36px;height:36px;border: 1px solid #E6E6E6;border-radius: 2px;margin-right:10px;overflow: hidden;">
  389. <img style="width:100%;" src="${Fast.api.cdnurl(row.buyer.avatar)}"/>
  390. </div>
  391. <div class="ellipsis-item">${row.buyer.nickname}</div>
  392. </div>`
  393. }
  394. },
  395. rate: (row) => {
  396. return `${row.commission_total}元/${row.commissioned_total}元`
  397. },
  398. money: (row) => {
  399. return `${row.amount}元`
  400. },
  401. commission_detail: (row) => {
  402. let ht = ''
  403. if (row.reward && row.reward.length > 0) {
  404. row.reward.forEach(it => {
  405. ht += `<div class="reward-item">
  406. <div style="width:30px;height:30px;border: 1px solid #E6E6E6;border-radius: 50%;margin-bottom:6px;overflow: hidden;">
  407. <img style="width:100%;" src="${Fast.api.cdnurl(it.agent.avatar)}"/>
  408. </div>
  409. <div style="line-height:12px;font-size:12px">${it.commission}元</div>
  410. </div>`
  411. })
  412. }
  413. return ht
  414. },
  415. oper_id: (row) => {
  416. let ht = `<div class="display-flex" style="justify-content: flex-start;width: 100%;">系统</div>`
  417. if (row.oper) {
  418. ht = `<div class="display-flex" style="justify-content: flex-start;width: 100%;">
  419. <div style="width:36px;height:36px;border: 1px solid #E6E6E6;border-radius: 2px;margin-right:10px;overflow: hidden;">
  420. <img style="width:100%;" src="${Fast.api.cdnurl(row.oper.avatar)}"/>
  421. </div>
  422. <div class="ellipsis-item">${row.oper.nickname}</div>
  423. </div>`
  424. }
  425. return ht;
  426. },
  427. commission_reward_status: (row) => {
  428. let color = "#999"
  429. if (row.commission_reward_status == 1) {
  430. color = "#22D38D"
  431. } else if (row.commission_reward_status == -1) {
  432. color = "#EC5B55"
  433. }
  434. return `<div class="display-flex" style="color:${color}">
  435. ${row.commission_reward_status_text}
  436. </div>`
  437. },
  438. status: (row) => {
  439. let color = "#999"
  440. if (row.status == 1) {
  441. color = "#22D38D"
  442. } else if (row.status == -1) {
  443. color = "#EC5B55"
  444. }
  445. return `<div class="display-flex" style="color:${color}">
  446. ${row.status_text}
  447. </div>`
  448. },
  449. open: (row) => {
  450. let ht = "-"
  451. if (row.event == 'order' || row.event == 'reward' || row.event == 'share') {
  452. ht = `<div style="color:#7438D5;cursor: pointer;">详情</div>`
  453. }
  454. return ht
  455. },
  456. }
  457. var agentDetail = new Vue({
  458. el: "#agentDetail",
  459. data() {
  460. return {
  461. profileData: {},
  462. columns: {
  463. 'log': [{
  464. type: 'vmodel',
  465. field: 'id',
  466. title: 'ID',
  467. width: '70px',
  468. }, {
  469. type: 'vmodel',
  470. field: 'event_text',
  471. title: '动态',
  472. width: '140px',
  473. header: 'custom-header'
  474. }, {
  475. type: 'vmodel',
  476. field: 'remark',
  477. title: '内容',
  478. width: '400',
  479. }, {
  480. type: 'vmodel',
  481. field: 'oper_type_text',
  482. title: '操作人类型',
  483. width: '100',
  484. }, {
  485. type: 'vhtml',
  486. field: '',
  487. title: '操作人',
  488. width: '160px',
  489. formatter: formatterHtml.oper_id,
  490. align: 'left',
  491. }, {
  492. type: 'vhtml',
  493. field: '',
  494. title: '动态时间',
  495. width: '160px',
  496. formatter: formatterHtml.time,
  497. align: 'left',
  498. }, {
  499. type: 'open',
  500. field: '',
  501. title: '操作',
  502. width: '80px',
  503. formatter: formatterHtml.open,
  504. align: 'left',
  505. // fixed: 'right',
  506. }],
  507. 'order': [{
  508. type: 'vhtml',
  509. field: '',
  510. title: 'ID',
  511. width: '70px',
  512. formatter: formatterHtml.order_id,
  513. }, {
  514. type: 'click',
  515. field: '',
  516. title: '订单号',
  517. width: '220px',
  518. formatter: formatterHtml.order_sn,
  519. }, {
  520. type: 'vhtml',
  521. field: '',
  522. title: '下单用户信息',
  523. width: '160px',
  524. formatter: formatterHtml.user_message,
  525. align: 'left',
  526. }, {
  527. type: 'vhtml',
  528. field: '',
  529. title: '分佣状态',
  530. width: '90px',
  531. formatter: formatterHtml.commission_reward_status,
  532. }, {
  533. type: 'vhtml',
  534. field: '',
  535. title: '商品结算金额',
  536. width: '120px',
  537. formatter: formatterHtml.money,
  538. }, {
  539. type: 'vhtml',
  540. field: '',
  541. title: '分佣金额/到账金额',
  542. width: '144px',
  543. formatter: formatterHtml.rate,
  544. }, {
  545. type: 'vhtml',
  546. field: '',
  547. title: '佣金详情',
  548. width: '260px',
  549. formatter: formatterHtml.commission_detail,
  550. }, {
  551. type: 'vhtml',
  552. field: '',
  553. title: '加入时间',
  554. width: '160px',
  555. formatter: formatterHtml.time,
  556. align: 'left',
  557. }],
  558. 'reward': [{
  559. type: 'vhtml',
  560. field: '',
  561. title: 'ID',
  562. width: '70px',
  563. formatter: formatterHtml.order_id,
  564. }, {
  565. type: 'click',
  566. field: '',
  567. title: '订单号',
  568. width: '220px',
  569. formatter: formatterHtml.order_sn,
  570. }, {
  571. type: 'vhtml',
  572. field: '',
  573. title: '下单用户信息',
  574. width: '160px',
  575. formatter: formatterHtml.user_message,
  576. align: 'left',
  577. }, {
  578. type: 'vmodel',
  579. field: 'commission',
  580. title: '分佣金额',
  581. width: '90px',
  582. }, {
  583. type: 'vhtml',
  584. field: '',
  585. title: '分佣用户',
  586. width: '160px',
  587. formatter: formatterHtml.user_message,
  588. align: 'left',
  589. }, {
  590. type: 'vhtml',
  591. field: 'type_text',
  592. title: '入账状态',
  593. width: '90px',
  594. formatter: formatterHtml.status,
  595. }, {
  596. type: 'vmodel',
  597. field: 'type_text',
  598. title: '入账方式',
  599. width: '90px',
  600. }, {
  601. type: 'vhtml',
  602. field: '',
  603. title: '分佣时间',
  604. width: '160px',
  605. formatter: formatterHtml.time,
  606. align: 'left',
  607. }],
  608. },
  609. offset: 0,
  610. limit: 10,
  611. totalPage: 0,
  612. currentPage: 1,
  613. logList: [],
  614. activeStatus: 'log',
  615. dialogType: '',
  616. dialogVisible: false,
  617. agentLevelList: [],
  618. selectAgentLevel: '',
  619. dialogList: [],
  620. poffset: 0,
  621. plimit: 5,
  622. ptotalPage: 0,
  623. pcurrentPage: 1,
  624. defaultProps: {
  625. children: 'children',
  626. label: 'name',
  627. multiple: false,
  628. checkStrictly: true,
  629. value: 'id',
  630. },
  631. agentStatusOptions: [{
  632. value: 'normal',
  633. label: '正常'
  634. }, {
  635. value: 'forbidden',
  636. label: '禁用'
  637. }, {
  638. value: 'pending',
  639. label: '审核中'
  640. }, {
  641. value: 'freeze',
  642. label: '冻结'
  643. }],
  644. agentInfoOptions: [{
  645. value: -1,
  646. label: '驳回'
  647. }, {
  648. value: 0,
  649. label: '未完善'
  650. }, {
  651. value: 1,
  652. label: '已完善'
  653. }, {
  654. value: null,
  655. label: '无需资料'
  656. }],
  657. applyInfoList: [],
  658. isEditInfoStatus: false,
  659. selectedTeamId: null,
  660. agentAjax: true,
  661. logListAjax: true,
  662. logOptions: [{
  663. value: -1,
  664. label: '驳回'
  665. }, {
  666. value: 0,
  667. label: '未完善'
  668. }, {
  669. value: 1,
  670. label: '已完善'
  671. }],
  672. logStatus: 'all',
  673. filterForm: {
  674. agent_id: Config.row.user_id,
  675. event: 'all'
  676. },
  677. filterOp: {
  678. agent_id: "=",
  679. event: "=",
  680. },
  681. // 更换上级分销商搜索
  682. parentFilterForm: {
  683. status: "normal",
  684. form_1_key: "user_id",
  685. form_1_value: ""
  686. },
  687. parentFilterFormInit: {
  688. status: "normal",
  689. form_1_key: "user_id",
  690. form_1_value: ""
  691. },
  692. parentFilterOp: {
  693. status: "=",
  694. user_id: "=",
  695. nickname: "like",
  696. mobile: "like",
  697. },
  698. selectParentAgentId: null,
  699. noRecommendationChecked: false
  700. }
  701. },
  702. created() {
  703. this.getprofile();
  704. this.selectedTeamId = Config.row.user_id;
  705. this.getLogStatus();
  706. this.getListData(this.activeStatus);
  707. },
  708. methods: {
  709. getLogStatus() {
  710. let that = this;
  711. Fast.api.ajax({
  712. url: 'shopro/commission/log/getEventAll',
  713. loading: false,
  714. type: 'GET',
  715. }, function (ret, res) {
  716. that.logOptions = res.data;
  717. return false;
  718. })
  719. },
  720. changeLogEvent() {
  721. this.getListData('log')
  722. },
  723. isexpanded(data) {
  724. data.expanded = !data.expanded
  725. },
  726. getApplyInfo() {
  727. let that = this;
  728. that.agentAjax = true;
  729. Fast.api.ajax({
  730. url: 'shopro/commission/config/index',
  731. loading: false,
  732. type: 'GET',
  733. }, function (ret, res) {
  734. if (that.profileData.apply_info) {
  735. that.profileData.apply_info = JSON.parse(that.profileData.apply_info);
  736. } else {
  737. that.profileData.apply_info = []
  738. }
  739. if (JSON.parse(res.data.agent_form) == 0) {
  740. that.applyInfoList = JSON.parse(res.data.agent_form)
  741. } else {
  742. that.applyInfoList = JSON.parse(res.data.agent_form).content;
  743. if (that.profileData.apply_info) {
  744. if (that.profileData.apply_info) {
  745. that.applyInfoList.forEach(e => {
  746. let isexist = false;
  747. that.profileData.apply_info.forEach(j => {
  748. if (e.name == j.name && e.type == j.type) {
  749. isexist = true;
  750. }
  751. })
  752. if (!isexist) {
  753. that.profileData.apply_info.push({
  754. name: e.name,
  755. type: e.type,
  756. value: '',
  757. isdelete: true
  758. })
  759. }
  760. });
  761. } else {
  762. that.profileData.apply_info.push({
  763. name: e.name,
  764. type: e.type,
  765. value: '',
  766. isdelete: true
  767. })
  768. }
  769. }
  770. }
  771. //生成预览
  772. that.profileData.apply_info.forEach(i => {
  773. if (i.type == 'image') {
  774. i.value_arr = [];
  775. i.value_arr.push(Fast.api.cdnurl(i.value))
  776. }
  777. })
  778. that.agentAjax = false;
  779. return false;
  780. }, function (ret, res) {
  781. that.agentAjax = false;
  782. })
  783. },
  784. openDialog(type) {
  785. this.dialogType = type;
  786. this.dialogList = []
  787. if (this.dialogType == 'change-parent-agent') {
  788. this.getParentAgentList();
  789. } else if (this.dialogType == 'change-level') {
  790. this.getAgentLevel();
  791. }
  792. },
  793. closeDialog(opttype, type) {
  794. this.dialogVisible = false;
  795. this.parentFilterForm.form_1_value = "";
  796. this.parentFilterForm.form_1_key = "user_id";
  797. if (opttype == true) {
  798. if (type == 'change-level') {
  799. this.operation('save', 'level')
  800. } else if (type == 'change-parent-agent') {
  801. this.operation('save', 'parent_agent_id')
  802. }
  803. }
  804. },
  805. getAgentLevel() {
  806. let that = this;
  807. Fast.api.ajax({
  808. url: 'shopro/commission/level/index',
  809. loading: false,
  810. type: 'GET',
  811. }, function (ret, res) {
  812. that.agentLevelList = res.data;
  813. that.dialogVisible = true;
  814. return false;
  815. })
  816. },
  817. getParentAgentList() {
  818. let that = this;
  819. let filter = {}
  820. let op = {}
  821. for (key in that.parentFilterForm) {
  822. if (key == 'form_1_value') {
  823. if (that.parentFilterForm[key] != '') {
  824. filter[that.parentFilterForm.form_1_key] = that.parentFilterForm[key];
  825. }
  826. } else if (key == 'status') {
  827. if (that.parentFilterForm[key] != '' && that.parentFilterForm[key] != 'all') {
  828. filter[key] = that.parentFilterForm[key];
  829. }
  830. }
  831. }
  832. for (key in filter) {
  833. op[key] = that.parentFilterOp[key]
  834. }
  835. Fast.api.ajax({
  836. url: 'shopro/commission/agent/index',
  837. loading: false,
  838. type: 'GET',
  839. data: {
  840. offset: that.poffset,
  841. limit: that.plimit,
  842. filter: JSON.stringify(filter),
  843. op: JSON.stringify(op)
  844. },
  845. }, function (ret, res) {
  846. that.dialogList = res.data.rows;
  847. that.ptotalPage = res.data.total;
  848. that.dialogVisible = true;
  849. return false;
  850. })
  851. },
  852. parentDebounceFilter: debounce(function () {
  853. this.getParentAgentList()
  854. }, 1000),
  855. phandleCurrentChange(val) {
  856. this.pcurrentPage = val;
  857. this.poffset = (val - 1) * this.plimit;
  858. this.getParentAgentList()
  859. },
  860. getprofile() {
  861. let that = this;
  862. Fast.api.ajax({
  863. url: 'shopro/commission/agent/profile?id=' + Config.row.user_id,
  864. loading: false,
  865. type: 'GET',
  866. data: {},
  867. }, function (ret, res) {
  868. that.profileData = res.data;
  869. that.selectAgentLevel = that.profileData.level;
  870. that.getApplyInfo();
  871. return false;
  872. })
  873. },
  874. //列表
  875. radioChange(val) {
  876. this.logList = [];
  877. this.activeStatus = val;
  878. this.page = 1;
  879. this.limit = 10;
  880. this.currentPage = 1;
  881. this.totalPage = 0;
  882. this.getListData(val)
  883. },
  884. getListData(val) {
  885. let that = this;
  886. that.logListAjax = true;
  887. let filter = {}
  888. let op = {}
  889. for (key in that.filterForm) {
  890. if (key == 'event' && val == 'log') {
  891. if (that.filterForm[key] != '' && that.filterForm[key] != 'all') {
  892. filter[key] = that.filterForm[key];
  893. }
  894. } else if (key == 'agent_id') {
  895. if (that.filterForm[key] != '') {
  896. filter[key] = that.filterForm[key];
  897. }
  898. }
  899. }
  900. for (key in filter) {
  901. op[key] = that.filterOp[key]
  902. }
  903. Fast.api.ajax({
  904. url: `shopro/commission/${val}/index`,
  905. loading: false,
  906. type: 'GET',
  907. data: {
  908. offset: that.offset,
  909. limit: that.limit,
  910. op: JSON.stringify(op),
  911. filter: JSON.stringify(filter),
  912. },
  913. }, function (ret, res) {
  914. that.logList = res.data.rows;
  915. that.totalPage = res.data.total;
  916. that.logListAjax = false;
  917. return false;
  918. })
  919. },
  920. statusChange() {
  921. this.operation('save', 'status')
  922. },
  923. applyInfoStatusChange() {
  924. this.operation('save', 'info_status')
  925. },
  926. lockChange() {
  927. this.operation('save', 'upgrade_lock')
  928. },
  929. operation(type, id, data) {
  930. let that = this;
  931. switch (type) {
  932. case 'view-parent-agent':
  933. parent.Fast.api.open("shopro/commission/agent/profile?id=" + id, "上级分销商");
  934. break;
  935. case 'select-image':
  936. Fast.api.open("general/attachment/select?multiple=false", "选择", {
  937. callback: function (data) {
  938. that.profileData.apply_info[id].value = data.url;
  939. }
  940. });
  941. break;
  942. case 'delete-apply-info':
  943. that.profileData.apply_info.splice(id, 1);
  944. break;
  945. case 'save':
  946. let subValue;
  947. if (id == 'apply_info') {
  948. subValue = that.profileData.apply_info;
  949. subValue.forEach(i => {
  950. if (i.type == 'image') {
  951. delete i.value_arr;
  952. }
  953. delete i.isdelete;
  954. })
  955. subValue = JSON.stringify(subValue)
  956. } else if (id == 'level') {
  957. subValue = that.selectAgentLevel
  958. } else if (id == 'parent_agent_id') {
  959. subValue = that.selectParentAgentId
  960. } else {
  961. subValue = that.profileData[id]
  962. }
  963. Fast.api.ajax({
  964. url: 'shopro/commission/agent/update?id=' + Config.row.user_id,
  965. loading: false,
  966. type: 'POST',
  967. data: {
  968. key: id,
  969. value: subValue
  970. },
  971. }, function (ret, res) {
  972. that.isEditInfoStatus = false;
  973. that.selectParentAgentId = null;
  974. that.parentFilterForm.form_1_value = "";
  975. that.parentFilterForm.form_1_key = "user_id";
  976. that.getprofile();
  977. }, function (ret, res) {
  978. that.isEditInfoStatus = false;
  979. that.selectParentAgentId = null;
  980. that.parentFilterForm.form_1_value = "";
  981. that.parentFilterForm.form_1_key = "user_id";
  982. })
  983. break;
  984. case 'edit-info-status':
  985. that.isEditInfoStatus = true;
  986. break;
  987. case 'filter-color':
  988. switch (id) {
  989. case 'normal':
  990. return 'filter-color-normal'
  991. break;
  992. case 'forbidden':
  993. return 'filter-color-forbidden'
  994. break;
  995. case 'pending':
  996. return 'filter-color-pending'
  997. break;
  998. case 'freeze':
  999. return 'filter-color-freeze'
  1000. break;
  1001. }
  1002. break;
  1003. case 'select-agent-level':
  1004. that.selectAgentLevel = id;
  1005. break;
  1006. case 'open-order':
  1007. parent.Fast.api.open(`shopro/commission/order/index?agent_id=${Config.row.user_id}`, "直推分销订单");
  1008. break;
  1009. case 'open-reward':
  1010. parent.Fast.api.open(`shopro/commission/reward/index?agent_id=${Config.row.user_id}&status=${id}`, "佣金明细");
  1011. break;
  1012. case 'open-user':
  1013. parent.Fast.api.open('shopro/user/user/profile?id=' + id, '查看用户')
  1014. break;
  1015. case 'open-order':
  1016. parent.Fast.api.open('shopro/order/order/detail?id=' + id, "查看详情", {
  1017. callback() {
  1018. that.reqOrderList()
  1019. }
  1020. });
  1021. break;
  1022. case 'list-detail':
  1023. parent.Fast.api.open(`shopro/commission/${that.activeStatus}/index?agent_id=${Config.row.user_id}`, "查看详情", {
  1024. callback() {
  1025. that.reqOrderList();
  1026. }
  1027. });
  1028. break;
  1029. case 'order':
  1030. Fast.api.open(`shopro/commission/order/index?id=${id}`, '详情', {
  1031. callback(data) {
  1032. that.reqOrderList()
  1033. }
  1034. })
  1035. break;
  1036. case 'reward':
  1037. Fast.api.open(`shopro/commission/reward/index?id=${id}`, '详情', {
  1038. callback(data) {
  1039. that.reqOrderList()
  1040. }
  1041. })
  1042. break;
  1043. case 'share':
  1044. Fast.api.open(`shopro/user/user/profile?id=${id}`, '详情', {
  1045. callback(data) {
  1046. that.reqOrderList()
  1047. }
  1048. })
  1049. break;
  1050. case 'select-parent-agent':
  1051. if (id === true) {
  1052. that.selectParentAgentId = 0;
  1053. } else if (id === false) {
  1054. that.selectParentAgentId = null;
  1055. } else {
  1056. that.selectParentAgentId = id;
  1057. that.noRecommendationChecked = false;
  1058. }
  1059. break;
  1060. case 'level-status':
  1061. Fast.api.ajax({
  1062. url: 'shopro/commission/agent/update?id=' + Config.row.user_id,
  1063. loading: false,
  1064. type: 'POST',
  1065. data: {
  1066. key: 'level_status',
  1067. value: id
  1068. },
  1069. }, function (ret, res) {
  1070. that.getprofile();
  1071. })
  1072. break;
  1073. case 'view-team':
  1074. Fast.api.open(`shopro/commission/agent/team?id=${id}`, '查看团队')
  1075. break;
  1076. }
  1077. },
  1078. handleSizeChange(val) {
  1079. this.offset = 0
  1080. this.limit = val;
  1081. this.currentPage = 1;
  1082. this.getListData(this.activeStatus)
  1083. },
  1084. handleCurrentChange(val) {
  1085. this.currentPage = val;
  1086. this.offset = (val - 1) * this.limit;
  1087. this.getListData(this.activeStatus)
  1088. },
  1089. tableCellClassName({
  1090. columnIndex
  1091. }) {
  1092. if (columnIndex == 1) {
  1093. return 'cell-left';
  1094. }
  1095. return '';
  1096. },
  1097. },
  1098. })
  1099. },
  1100. team: function () {
  1101. function debounce(handle, delay) {
  1102. let time = null;
  1103. return function () {
  1104. let self = this,
  1105. arg = arguments;
  1106. clearTimeout(time);
  1107. time = setTimeout(function () {
  1108. handle.apply(self, arg);
  1109. }, delay)
  1110. }
  1111. }
  1112. let formatterHtml = {
  1113. time: (row) => {
  1114. return `${moment(row.createtime*1000).format('YYYY-MM-DD HH:mm:ss')}`
  1115. },
  1116. level: (row) => {
  1117. let ht = `<div>-</div>`
  1118. if (row.agent && row.agent.agent_level) {
  1119. ht = `<div class="display-flex" style="width:100%">
  1120. <div v-if="${row.agent.agent_level.image}"
  1121. style="width:36px;height:36px;border-radius: 2px;margin-right:10px;display:flex;align-items: center;">
  1122. <img style="width:100%" src="${Fast.api.cdnurl(row.agent.agent_level.image)}" />
  1123. </div>
  1124. <div class="ellipsis-item">${row.agent.agent_level.name}</div>
  1125. </div>`
  1126. }
  1127. return ht;
  1128. },
  1129. message: (row) => {
  1130. let ht = '<div>-<div>'
  1131. if (row.avatar) {
  1132. ht = `<div class="display-flex" style="width:100%">
  1133. <div style="width:36px;height:36px;border-radius: 2px;margin-right:10px;overflow: hidden;flex-shrink: 0;">
  1134. <img style="width:100%;" src="${Fast.api.cdnurl(row.avatar)}"/>
  1135. </div>
  1136. <div class="ellipsis-item">-</div>
  1137. </div>`
  1138. }
  1139. if (row.nickname) {
  1140. ht = `<div class="display-flex" style="width:100%">
  1141. <div class="ellipsis-item">${row.nickname}</div>
  1142. </div>`
  1143. }
  1144. if (row.avatar && row.nickname) {
  1145. ht = `<div class="display-flex" style="width:100%">
  1146. <div style="width:36px;height:36px;border-radius: 2px;margin-right:10px;overflow: hidden;flex-shrink: 0;">
  1147. <img style="width:100%;" src="${Fast.api.cdnurl(row.avatar)}"/>
  1148. </div>
  1149. <div class="ellipsis-item">${row.nickname}</div>
  1150. </div>`
  1151. }
  1152. return ht;
  1153. },
  1154. status: (row) => {
  1155. let ht = `<div>-</div>`;
  1156. let className = ''
  1157. if (row.agent) {
  1158. if (row.agent.status == 'normal') {
  1159. className = 'filter-color-normal';
  1160. } else if (row.agent.status == 'forbidden') {
  1161. className = 'filter-color-forbidden';
  1162. } else if (row.agent.status == 'pending') {
  1163. className = 'filter-color-pending';
  1164. } else if (row.agent.status == 'freeze') {
  1165. className = 'filter-color-freeze';
  1166. }
  1167. ht = `<div class="display-flex ${className}">
  1168. ${row.agent.status_text}
  1169. </div>`
  1170. }
  1171. return ht;
  1172. },
  1173. moneynum: (row, outterfield, field) => {
  1174. let ht = `<div>-</div>`
  1175. if (row.agent) {
  1176. ht = `<div class="display-flex">
  1177. ${row[field]}<span class="unit-tip-item">人</span>
  1178. </div>`
  1179. if (outterfield) {
  1180. ht = `<div class="display-flex">
  1181. ${row[outterfield][field]}<span class="unit-tip-item">元</span>
  1182. </div>`
  1183. }
  1184. if(field=='total_consume'){
  1185. ht = `<div class="display-flex">
  1186. ${row[field]}<span class="unit-tip-item">元</span>
  1187. </div>`
  1188. }
  1189. }
  1190. return ht;
  1191. },
  1192. singlenum: (row, outterfield, field) => {
  1193. let ht = `<div>-</div>`
  1194. if (row.agent) {
  1195. ht = `<div class="display-flex">
  1196. ${row[outterfield][field]}<span class="unit-tip-item">单</span>
  1197. </div>`
  1198. }
  1199. return ht;
  1200. },
  1201. peoplenum: (row, outterfield, field) => {
  1202. let ht = `<div class="display-flex">
  1203. ${row[field]}<span class="unit-tip-item">人</span>
  1204. </div>`
  1205. if (outterfield) {
  1206. if(row[outterfield]){
  1207. ht = `<div class="display-flex">
  1208. ${row[outterfield][field]}<span class="unit-tip-item">人</span>
  1209. </div>`
  1210. }else{
  1211. ht ='-'
  1212. }
  1213. }
  1214. return ht;
  1215. },
  1216. }
  1217. var agentTeam = new Vue({
  1218. el: "#agentTeam",
  1219. data() {
  1220. return {
  1221. id: new URLSearchParams(location.search).get('id'),
  1222. searchId: new URLSearchParams(location.search).get('id'),
  1223. blockSearchId: new URLSearchParams(location.search).get('id'),
  1224. teamList: [],
  1225. tableIdArr: [],
  1226. offset: 0,
  1227. limit: 10,
  1228. totalPage: 0,
  1229. currentPage: 1,
  1230. teamAjax: false,
  1231. agentLevelList: [],
  1232. // 筛选
  1233. searchForm: {
  1234. level: "",
  1235. form_1_key: "id",
  1236. form_1_value: ""
  1237. },
  1238. searchFormInit: {
  1239. level: "",
  1240. form_1_key: "id",
  1241. form_1_value: ""
  1242. },
  1243. searchOp: {
  1244. parent_user_id: '=',
  1245. level: "=",
  1246. id: "=",
  1247. nickname: "like",
  1248. mobile: "like",
  1249. },
  1250. parent_user: [],
  1251. dashboardIdList: ['id', 'avatar-nickname', 'level', 'status', 'child_user_count', 'child_user_count_1', 'child_user_count_2', 'child_agent_count', 'child_agent_count_1', 'child_agent_count_2', 'child_order_money', 'child_order_money_1', 'child_order_money_2', 'order_money', 'child_order_count', 'child_order_count_1', 'child_order_count_2', 'order_count', 'total_income', 'delay_money', 'total_consume', 'createtime'],
  1252. dashboardList: [{
  1253. label: 'ID',
  1254. value: 'id',
  1255. }, {
  1256. label: '团队用户',
  1257. value: 'avatar-nickname',
  1258. }, {
  1259. label: '等级',
  1260. value: 'level',
  1261. }, {
  1262. label: '状态',
  1263. value: 'status',
  1264. }, {
  1265. label: '团队人数',
  1266. value: 'child_user_count',
  1267. }, {
  1268. label: '一级团队人数',
  1269. value: 'child_user_count_1',
  1270. }, {
  1271. label: '二级团队人数',
  1272. value: 'child_user_count_2',
  1273. }, {
  1274. label: '分销商人数',
  1275. value: 'child_agent_count',
  1276. }, {
  1277. label: '一级分销商人数',
  1278. value: 'child_agent_count_1',
  1279. }, {
  1280. label: '二级分销商人数',
  1281. value: 'child_agent_count_2',
  1282. }, {
  1283. label: '团队分销总额',
  1284. value: 'child_order_money',
  1285. }, {
  1286. label: '一级分销总额',
  1287. value: 'child_order_money_1',
  1288. }, {
  1289. label: '二级分销总额',
  1290. value: 'child_order_money_2',
  1291. }, {
  1292. label: '直推分销总额',
  1293. value: 'order_money',
  1294. }, {
  1295. label: '团队分销订单',
  1296. value: 'child_order_count',
  1297. }, {
  1298. label: '一级分销订单',
  1299. value: 'child_order_count_1',
  1300. }, {
  1301. label: '二级分销订单',
  1302. value: 'child_order_count_2',
  1303. }, {
  1304. label: '直推分销订单',
  1305. value: 'order_count',
  1306. }, {
  1307. label: '累计佣金',
  1308. value: 'total_income',
  1309. }, {
  1310. label: '消费金额',
  1311. value: 'delay_money',
  1312. }, {
  1313. label: '待入账佣金',
  1314. value: 'total_consume',
  1315. }, {
  1316. label: '加入时间',
  1317. value: 'createtime',
  1318. }],
  1319. columns: [{
  1320. type: 'vmodel',
  1321. field: 'id',
  1322. title: 'ID',
  1323. width: '70px',
  1324. }, {
  1325. type: 'click',
  1326. field: 'avatar-nickname',
  1327. title: '团队用户',
  1328. width: '160px',
  1329. formatter: formatterHtml.message,
  1330. align: 'left',
  1331. }, {
  1332. type: 'vhtml',
  1333. field: 'level',
  1334. title: '等级',
  1335. width: '180px',
  1336. formatter: formatterHtml.level,
  1337. align: 'left',
  1338. }, {
  1339. type: 'vhtml',
  1340. field: 'status',
  1341. title: '状态',
  1342. width: '60px',
  1343. formatter: formatterHtml.status,
  1344. }, {
  1345. type: 'vhtml',
  1346. field: 'child_user_count',
  1347. title: '团队人数',
  1348. width: '120px',
  1349. formatter: formatterHtml.peoplenum,
  1350. }, {
  1351. type: 'vhtml',
  1352. field: 'child_user_count_1',
  1353. title: '一级团队人数',
  1354. width: '120px',
  1355. formatter: formatterHtml.peoplenum,
  1356. }, {
  1357. type: 'vhtml',
  1358. field: 'child_user_count_2',
  1359. title: '二级团队人数',
  1360. width: '120px',
  1361. formatter: formatterHtml.peoplenum,
  1362. }, {
  1363. type: 'vhtml',
  1364. field: 'child_agent_count',
  1365. outterfield: 'agent',
  1366. title: '分销商人数',
  1367. width: '120px',
  1368. formatter: formatterHtml.peoplenum,
  1369. }, {
  1370. type: 'vhtml',
  1371. field: 'child_agent_count_1',
  1372. outterfield: 'agent',
  1373. title: '一级分销商人数',
  1374. width: '120px',
  1375. formatter: formatterHtml.peoplenum,
  1376. }, {
  1377. type: 'vhtml',
  1378. field: 'child_agent_count_2',
  1379. outterfield: 'agent',
  1380. title: '二级分销商人数',
  1381. width: '120px',
  1382. formatter: formatterHtml.peoplenum,
  1383. }, {
  1384. type: 'vhtml',
  1385. field: 'child_order_money',
  1386. outterfield: 'agent',
  1387. title: '团队分销总额',
  1388. width: '120px',
  1389. formatter: formatterHtml.moneynum,
  1390. }, {
  1391. type: 'vhtml',
  1392. field: 'child_order_money_1',
  1393. outterfield: 'agent',
  1394. title: '一级分销总额',
  1395. width: '120px',
  1396. formatter: formatterHtml.moneynum,
  1397. }, {
  1398. type: 'vhtml',
  1399. field: 'child_order_money_2',
  1400. outterfield: 'agent',
  1401. title: '二级分销总额',
  1402. width: '120px',
  1403. formatter: formatterHtml.moneynum,
  1404. }, {
  1405. type: 'vhtml',
  1406. field: 'order_money',
  1407. outterfield: 'agent',
  1408. title: '直推分销总额',
  1409. width: '120px',
  1410. formatter: formatterHtml.moneynum,
  1411. }, {
  1412. type: 'vhtml',
  1413. field: 'child_order_count',
  1414. outterfield: 'agent',
  1415. title: '团队分销订单',
  1416. width: '120px',
  1417. formatter: formatterHtml.singlenum,
  1418. }, {
  1419. type: 'vhtml',
  1420. field: 'child_order_count_1',
  1421. outterfield: 'agent',
  1422. title: '一级分销订单',
  1423. width: '120px',
  1424. formatter: formatterHtml.singlenum,
  1425. }, {
  1426. type: 'vhtml',
  1427. field: 'child_order_count_2',
  1428. outterfield: 'agent',
  1429. title: '二级分销订单',
  1430. width: '120px',
  1431. formatter: formatterHtml.singlenum,
  1432. }, {
  1433. type: 'vhtml',
  1434. field: 'order_count',
  1435. outterfield: 'agent',
  1436. title: '直推分销订单',
  1437. width: '120px',
  1438. formatter: formatterHtml.singlenum,
  1439. }, {
  1440. type: 'vhtml',
  1441. field: 'total_income',
  1442. outterfield: 'agent',
  1443. title: '累计佣金',
  1444. width: '120px',
  1445. formatter: formatterHtml.moneynum,
  1446. }, {
  1447. type: 'vhtml',
  1448. field: 'delay_money',
  1449. outterfield: 'agent',
  1450. title: '消费金额',
  1451. width: '120px',
  1452. formatter: formatterHtml.moneynum,
  1453. }, {
  1454. type: 'vhtml',
  1455. field: 'total_consume',
  1456. title: '待入账佣金',
  1457. width: '120px',
  1458. formatter: formatterHtml.moneynum,
  1459. }, {
  1460. type: 'vhtml',
  1461. field: 'createtime',
  1462. outterfield: 'agent',
  1463. title: '加入时间',
  1464. width: '160px',
  1465. formatter: formatterHtml.time,
  1466. }]
  1467. }
  1468. },
  1469. created() {
  1470. this.getAgentTeam();
  1471. this.getAgentLevel();
  1472. },
  1473. methods: {
  1474. operation(type, id) {
  1475. let that = this;
  1476. switch (type) {
  1477. case 'clickteam':
  1478. if (!that.tableIdArr.includes(id)) {
  1479. that.searchId = id;
  1480. that.tableIdArr.push(id);
  1481. that.getAgentTeam();
  1482. }
  1483. break;
  1484. case 'clickteamdelete':
  1485. if (id) {
  1486. that.searchId = id;
  1487. that.tableIdArr.splice((that.tableIdArr.indexOf(id) + 1));
  1488. } else {
  1489. that.searchId = that.id;
  1490. that.tableIdArr = []
  1491. }
  1492. that.getAgentTeam();
  1493. break;
  1494. }
  1495. },
  1496. debounceFilter: debounce(function () {
  1497. this.offset = 0
  1498. this.limit = 10;
  1499. this.currentPage = 1;
  1500. this.getAgentTeam()
  1501. }, 1000),
  1502. getAgentLevel() {
  1503. let that = this;
  1504. Fast.api.ajax({
  1505. url: 'shopro/commission/level/index',
  1506. loading: false,
  1507. type: 'GET',
  1508. }, function (ret, res) {
  1509. that.agentLevelList = res.data;
  1510. return false;
  1511. })
  1512. },
  1513. getAgentTeam() {
  1514. let that = this;
  1515. that.teamAjax = true;
  1516. let filter = {}
  1517. let op = {}
  1518. for (key in that.searchForm) {
  1519. if (key == 'form_1_value') {
  1520. if (that.searchForm[key] != '') {
  1521. filter[that.searchForm.form_1_key] = that.searchForm[key];
  1522. }
  1523. } else if (key == 'level') {
  1524. if (that.searchForm[key] != '' && that.searchForm[key] != 'all') {
  1525. filter[key] = that.searchForm[key];
  1526. }
  1527. }
  1528. }
  1529. filter.parent_user_id = that.searchId;
  1530. for (key in filter) {
  1531. op[key] = that.searchOp[key]
  1532. }
  1533. Fast.api.ajax({
  1534. url: 'shopro/commission/agent/team',
  1535. loading: false,
  1536. type: 'GET',
  1537. data: {
  1538. offset: that.offset,
  1539. limit: that.limit,
  1540. filter: JSON.stringify(filter),
  1541. op: JSON.stringify(op)
  1542. },
  1543. }, function (ret, res) {
  1544. that.teamList = res.data.rows;
  1545. that.totalPage = res.data.total;
  1546. that.parent_user = [];
  1547. that.parent_user.push(res.data.parent_user);
  1548. that.teamAjax = false;
  1549. return false;
  1550. }, function (ret, res) {
  1551. that.teamAjax = false;
  1552. return false;
  1553. })
  1554. },
  1555. handleSizeChange(val) {
  1556. this.offset = 0
  1557. this.limit = val;
  1558. this.currentPage = 1;
  1559. this.getAgentTeam()
  1560. },
  1561. handleCurrentChange(val) {
  1562. this.currentPage = val;
  1563. this.offset = (val - 1) * this.limit;
  1564. this.getAgentTeam()
  1565. },
  1566. tableCellClassName({
  1567. columnIndex
  1568. }) {
  1569. if (columnIndex == 1) {
  1570. return 'cell-left';
  1571. }
  1572. return '';
  1573. },
  1574. },
  1575. })
  1576. },
  1577. api: {
  1578. bindevent: function () {
  1579. Form.api.bindevent($("form[role=form]"));
  1580. }
  1581. },
  1582. };
  1583. return Controller;
  1584. });