12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'toastr'], function ($, undefined, Backend, Table, Form, Toastr) {
- var Controller = {
- index: function () {
- var agentIndex = new Vue({
- el: "#agentIndex",
- data() {
- return {
- isAjax: true,
- isAjaxtable: false,
- activeTabsName: 'all',
- tabsList: [{
- name: 'all',
- label: '分销商'
- },
- {
- name: 'pending',
- label: '待审核'
- },
- {
- name: '1',
- label: '待升级'
- }
- ],
- agentLevelList: [],
- agentStatusOptions: [{
- value: 'all',
- label: '全部'
- }, {
- value: 'normal',
- label: '正常'
- }, {
- value: 'forbidden',
- label: '禁用'
- }, {
- value: 'pending',
- label: '审核中'
- }, {
- value: 'freeze',
- label: '冻结'
- }],
- // form搜索
- searchForm: {
- status: "all",
- level: "all",
- updatetime: [],
- form_1_key: "user_id",
- form_1_value: "",
- level_status: "all",
- },
- searchFormInit: {
- status: "all",
- level: "all",
- updatetime: [],
- form_1_key: "user_id",
- form_1_value: "",
- level_status: "all"
- },
- searchOp: {
- status: "=",
- updatetime: 'range',
- level: "=",
- user_id: "=",
- nickname: "like",
- mobile: "like",
- level_status: ">"
- },
- sort: 'createtime',
- listData: [],
- offset: 0,
- limit: 10,
- totalPage: 0,
- currentPage: 1,
- }
- },
- created() {
- this.getListData();
- this.getAgentLevel();
- },
- methods: {
- getListData() {
- let that = this;
- if (!that.isAjax) {
- that.isAjaxtable = true;
- }
- let filter = {}
- let op = {}
- for (key in that.searchForm) {
- if (key == 'form_1_value') {
- if (that.searchForm[key] != '') {
- filter[that.searchForm.form_1_key] = that.searchForm[key];
- }
- } else if (key == 'updatetime') {
- if (that.searchForm[key]) {
- if (that.searchForm[key].length > 0) {
- filter[key] = that.searchForm[key].join(' - ');
- }
- }
- } else if (key == 'status' || key == 'level' || key == 'level_status') {
- if (that.searchForm[key] != '' && that.searchForm[key] != 'all') {
- filter[key] = that.searchForm[key];
- }
- }
- }
- for (key in filter) {
- op[key] = that.searchOp[key]
- }
- Fast.api.ajax({
- url: 'shopro/commission/agent/index',
- loading: false,
- type: 'GET',
- data: {
- offset: that.offset,
- limit: that.limit,
- sort: that.sort,
- order: 'desc',
- filter: JSON.stringify(filter),
- op: JSON.stringify(op)
- },
- }, function (ret, res) {
- that.listData = res.data.rows;
- that.totalPage = res.data.total;
- that.isAjax = false;
- that.isAjaxtable = false;
- return false;
- }, function (ret, res) {
- that.isAjax = false;
- that.isAjaxtable = false;
- return false;
- })
- },
- getAgentLevel() {
- let that = this;
- Fast.api.ajax({
- url: 'shopro/commission/level/index',
- loading: false,
- type: 'GET',
- }, function (ret, res) {
- that.agentLevelList = res.data;
- that.agentLevelList.unshift({
- level: 'all',
- name: "全部"
- })
- return false;
- })
- },
- screenEmpty() {
- let padding=this.searchForm.status
- this.searchForm = JSON.parse(JSON.stringify(this.searchFormInit))
- if(padding=='pending'){
- this.searchForm.status='pending'
- }
- },
- operation(type, id, row) {
- let that = this;
- switch (type) {
- case 'edit':
- Fast.api.open('shopro/commission/agent/profile?id=' + id, '查看', {
- callback() {
- that.getListData();
- }
- })
- break;
- case 'del':
- that.$confirm('此操作将永久直接删除, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- Fast.api.ajax({
- url: 'shopro/commission/agent/del/ids/' + id,
- loading: false,
- type: 'POST',
- }, function (ret, res) {
- that.getListData();
- })
- return false;
- }).catch(() => {
- that.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- break;
- case 'reject':
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + id,
- loading: false,
- type: 'POST',
- data: {
- key: 'info_status',
- value: '-1'
- }
- }, function (ret, res) {
- that.getListData();
- })
- break;
- case 'agree':
- if (row.info_status == 0) {
- that.$confirm('用户还未完善资料, 是否同意申请?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + id,
- loading: false,
- type: 'POST',
- data: {
- key: 'status',
- value: 'normal'
- }
- }, function (ret, res) {
- that.getListData();
- })
- }).catch(() => {
- that.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- } else {
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + id,
- loading: false,
- type: 'POST',
- data: {
- key: 'status',
- value: 'normal'
- }
- }, function (ret, res) {
- that.getListData();
- })
- }
- break;
- case 'agree-null-status':
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + id,
- loading: false,
- type: 'POST',
- data: {
- key: 'status',
- value: 'normal'
- }
- }, function (ret, res) {
- that.getListData();
- })
- break;
- case 'filter':
- var data = {
- value: '',
- color: ''
- }
- switch (id) {
- case 'normal':
- data.value = '正常';
- data.color = '#444';
- break;
- case 'forbidden':
- data.value = '禁用';
- data.color = '#ED655F';
- break;
- case 'pending':
- data.value = '审核中';
- data.color = '#999';
- break;
- case 'freeze':
- data.value = '冻结';
- data.color = '#687FF4';
- break;
- }
- return data;
- break;
- case 'update-agree':
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + id,
- loading: false,
- type: 'POST',
- data: {
- key: 'level_status',
- value: row
- }
- }, function (ret, res) {
- that.getListData();
- })
- break;
- case 'update-refuse':
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + id,
- loading: false,
- type: 'POST',
- data: {
- key: 'level_status',
- value: 0
- }
- }, function (ret, res) {
- that.getListData();
- })
- break;
- }
- },
- handleSizeChange(val) {
- this.offset = 0
- this.limit = val;
- this.currentPage = 1;
- this.getListData()
- },
- handleCurrentChange(val) {
- this.currentPage = val;
- this.offset = (val - 1) * this.limit;
- this.getListData()
- },
- tabshandleClick(value) {
- this.searchForm.status = "";
- this.searchForm.level_status = "";
- if (value.name == 'pending') {
- this.searchForm.status = value.name;
- this.sort = 'updatetime';
- } else if (value.name == '1') {
- this.searchForm.level_status = value.name;
- this.sort = 'updatetime';
- } else {
- this.sort = 'createtime'
- }
- this.listData = [];
- this.isAjaxtable = true;
- this.offset = 0;
- this.limit = 10;
- this.totalPage = 0;
- this.currentPage = 1;
- this.getListData();
- },
- tableCellClassName({
- columnIndex
- }) {
- if (columnIndex == 1 || columnIndex == 7 || columnIndex == 13) {
- return 'cell-left';
- }
- return '';
- },
- tableCellClassName2({
- columnIndex
- }) {
- if (columnIndex == 1 || columnIndex == 4 || columnIndex == 10) {
- return 'cell-left';
- }
- return '';
- },
- tableCellClassName3({
- columnIndex
- }) {
- if (columnIndex == 1 || columnIndex == 7) {
- return 'cell-left';
- }
- return '';
- },
- },
- })
- },
- profile: function () {
- function debounce(handle, delay) {
- let time = null;
- return function () {
- let self = this,
- arg = arguments;
- clearTimeout(time);
- time = setTimeout(function () {
- handle.apply(self, arg);
- }, delay)
- }
- }
- let formatterHtml = {
- order_id: (row) => {
- if(row.order){
- return `${row.order.id}`
- }
- },
- order_sn: (row) => {
- if(row.order){
- return `<span class="theme-cursor">${row.order.order_sn}</span>`
- }
- },
- time: (row) => {
- return `${moment(row.createtime*1000).format('YYYY-MM-DD HH:mm:ss')}`
- },
- user_message: (row) => {
- if(row.buyer){
- return `<div class="display-flex" style="justify-content: flex-start;width: 100%;">
- <div style="width:36px;height:36px;border: 1px solid #E6E6E6;border-radius: 2px;margin-right:10px;overflow: hidden;">
- <img style="width:100%;" src="${Fast.api.cdnurl(row.buyer.avatar)}"/>
- </div>
- <div class="ellipsis-item">${row.buyer.nickname}</div>
- </div>`
- }
- },
- rate: (row) => {
- return `${row.commission_total}元/${row.commissioned_total}元`
- },
- money: (row) => {
- return `${row.amount}元`
- },
- commission_detail: (row) => {
- let ht = ''
- if (row.reward && row.reward.length > 0) {
- row.reward.forEach(it => {
- ht += `<div class="reward-item">
- <div style="width:30px;height:30px;border: 1px solid #E6E6E6;border-radius: 50%;margin-bottom:6px;overflow: hidden;">
- <img style="width:100%;" src="${Fast.api.cdnurl(it.agent.avatar)}"/>
- </div>
- <div style="line-height:12px;font-size:12px">${it.commission}元</div>
- </div>`
- })
- }
- return ht
- },
- oper_id: (row) => {
- let ht = `<div class="display-flex" style="justify-content: flex-start;width: 100%;">系统</div>`
- if (row.oper) {
- ht = `<div class="display-flex" style="justify-content: flex-start;width: 100%;">
- <div style="width:36px;height:36px;border: 1px solid #E6E6E6;border-radius: 2px;margin-right:10px;overflow: hidden;">
- <img style="width:100%;" src="${Fast.api.cdnurl(row.oper.avatar)}"/>
- </div>
- <div class="ellipsis-item">${row.oper.nickname}</div>
- </div>`
- }
- return ht;
- },
- commission_reward_status: (row) => {
- let color = "#999"
- if (row.commission_reward_status == 1) {
- color = "#22D38D"
- } else if (row.commission_reward_status == -1) {
- color = "#EC5B55"
- }
- return `<div class="display-flex" style="color:${color}">
- ${row.commission_reward_status_text}
- </div>`
- },
- status: (row) => {
- let color = "#999"
- if (row.status == 1) {
- color = "#22D38D"
- } else if (row.status == -1) {
- color = "#EC5B55"
- }
- return `<div class="display-flex" style="color:${color}">
- ${row.status_text}
- </div>`
- },
- open: (row) => {
- let ht = "-"
- if (row.event == 'order' || row.event == 'reward' || row.event == 'share') {
- ht = `<div style="color:#7438D5;cursor: pointer;">详情</div>`
- }
- return ht
- },
- }
- var agentDetail = new Vue({
- el: "#agentDetail",
- data() {
- return {
- profileData: {},
- columns: {
- 'log': [{
- type: 'vmodel',
- field: 'id',
- title: 'ID',
- width: '70px',
- }, {
- type: 'vmodel',
- field: 'event_text',
- title: '动态',
- width: '140px',
- header: 'custom-header'
- }, {
- type: 'vmodel',
- field: 'remark',
- title: '内容',
- width: '400',
- }, {
- type: 'vmodel',
- field: 'oper_type_text',
- title: '操作人类型',
- width: '100',
- }, {
- type: 'vhtml',
- field: '',
- title: '操作人',
- width: '160px',
- formatter: formatterHtml.oper_id,
- align: 'left',
- }, {
- type: 'vhtml',
- field: '',
- title: '动态时间',
- width: '160px',
- formatter: formatterHtml.time,
- align: 'left',
- }, {
- type: 'open',
- field: '',
- title: '操作',
- width: '80px',
- formatter: formatterHtml.open,
- align: 'left',
- // fixed: 'right',
- }],
- 'order': [{
- type: 'vhtml',
- field: '',
- title: 'ID',
- width: '70px',
- formatter: formatterHtml.order_id,
- }, {
- type: 'click',
- field: '',
- title: '订单号',
- width: '220px',
- formatter: formatterHtml.order_sn,
- }, {
- type: 'vhtml',
- field: '',
- title: '下单用户信息',
- width: '160px',
- formatter: formatterHtml.user_message,
- align: 'left',
- }, {
- type: 'vhtml',
- field: '',
- title: '分佣状态',
- width: '90px',
- formatter: formatterHtml.commission_reward_status,
- }, {
- type: 'vhtml',
- field: '',
- title: '商品结算金额',
- width: '120px',
- formatter: formatterHtml.money,
- }, {
- type: 'vhtml',
- field: '',
- title: '分佣金额/到账金额',
- width: '144px',
- formatter: formatterHtml.rate,
- }, {
- type: 'vhtml',
- field: '',
- title: '佣金详情',
- width: '260px',
- formatter: formatterHtml.commission_detail,
- }, {
- type: 'vhtml',
- field: '',
- title: '加入时间',
- width: '160px',
- formatter: formatterHtml.time,
- align: 'left',
- }],
- 'reward': [{
- type: 'vhtml',
- field: '',
- title: 'ID',
- width: '70px',
- formatter: formatterHtml.order_id,
- }, {
- type: 'click',
- field: '',
- title: '订单号',
- width: '220px',
- formatter: formatterHtml.order_sn,
- }, {
- type: 'vhtml',
- field: '',
- title: '下单用户信息',
- width: '160px',
- formatter: formatterHtml.user_message,
- align: 'left',
- }, {
- type: 'vmodel',
- field: 'commission',
- title: '分佣金额',
- width: '90px',
- }, {
- type: 'vhtml',
- field: '',
- title: '分佣用户',
- width: '160px',
- formatter: formatterHtml.user_message,
- align: 'left',
- }, {
- type: 'vhtml',
- field: 'type_text',
- title: '入账状态',
- width: '90px',
- formatter: formatterHtml.status,
- }, {
- type: 'vmodel',
- field: 'type_text',
- title: '入账方式',
- width: '90px',
- }, {
- type: 'vhtml',
- field: '',
- title: '分佣时间',
- width: '160px',
- formatter: formatterHtml.time,
- align: 'left',
- }],
- },
- offset: 0,
- limit: 10,
- totalPage: 0,
- currentPage: 1,
- logList: [],
- activeStatus: 'log',
- dialogType: '',
- dialogVisible: false,
- agentLevelList: [],
- selectAgentLevel: '',
- dialogList: [],
- poffset: 0,
- plimit: 5,
- ptotalPage: 0,
- pcurrentPage: 1,
- defaultProps: {
- children: 'children',
- label: 'name',
- multiple: false,
- checkStrictly: true,
- value: 'id',
- },
- agentStatusOptions: [{
- value: 'normal',
- label: '正常'
- }, {
- value: 'forbidden',
- label: '禁用'
- }, {
- value: 'pending',
- label: '审核中'
- }, {
- value: 'freeze',
- label: '冻结'
- }],
- agentInfoOptions: [{
- value: -1,
- label: '驳回'
- }, {
- value: 0,
- label: '未完善'
- }, {
- value: 1,
- label: '已完善'
- }, {
- value: null,
- label: '无需资料'
- }],
- applyInfoList: [],
- isEditInfoStatus: false,
- selectedTeamId: null,
- agentAjax: true,
- logListAjax: true,
- logOptions: [{
- value: -1,
- label: '驳回'
- }, {
- value: 0,
- label: '未完善'
- }, {
- value: 1,
- label: '已完善'
- }],
- logStatus: 'all',
- filterForm: {
- agent_id: Config.row.user_id,
- event: 'all'
- },
- filterOp: {
- agent_id: "=",
- event: "=",
- },
- // 更换上级分销商搜索
- parentFilterForm: {
- status: "normal",
- form_1_key: "user_id",
- form_1_value: ""
- },
- parentFilterFormInit: {
- status: "normal",
- form_1_key: "user_id",
- form_1_value: ""
- },
- parentFilterOp: {
- status: "=",
- user_id: "=",
- nickname: "like",
- mobile: "like",
- },
- selectParentAgentId: null,
- noRecommendationChecked: false
- }
- },
- created() {
- this.getprofile();
- this.selectedTeamId = Config.row.user_id;
- this.getLogStatus();
- this.getListData(this.activeStatus);
- },
- methods: {
- getLogStatus() {
- let that = this;
- Fast.api.ajax({
- url: 'shopro/commission/log/getEventAll',
- loading: false,
- type: 'GET',
- }, function (ret, res) {
- that.logOptions = res.data;
- return false;
- })
- },
- changeLogEvent() {
- this.getListData('log')
- },
- isexpanded(data) {
- data.expanded = !data.expanded
- },
- getApplyInfo() {
- let that = this;
- that.agentAjax = true;
- Fast.api.ajax({
- url: 'shopro/commission/config/index',
- loading: false,
- type: 'GET',
- }, function (ret, res) {
- if (that.profileData.apply_info) {
- that.profileData.apply_info = JSON.parse(that.profileData.apply_info);
- } else {
- that.profileData.apply_info = []
- }
- if (JSON.parse(res.data.agent_form) == 0) {
- that.applyInfoList = JSON.parse(res.data.agent_form)
- } else {
- that.applyInfoList = JSON.parse(res.data.agent_form).content;
- if (that.profileData.apply_info) {
- if (that.profileData.apply_info) {
- that.applyInfoList.forEach(e => {
- let isexist = false;
- that.profileData.apply_info.forEach(j => {
- if (e.name == j.name && e.type == j.type) {
- isexist = true;
- }
- })
- if (!isexist) {
- that.profileData.apply_info.push({
- name: e.name,
- type: e.type,
- value: '',
- isdelete: true
- })
- }
- });
- } else {
- that.profileData.apply_info.push({
- name: e.name,
- type: e.type,
- value: '',
- isdelete: true
- })
- }
- }
- }
- //生成预览
- that.profileData.apply_info.forEach(i => {
- if (i.type == 'image') {
- i.value_arr = [];
- i.value_arr.push(Fast.api.cdnurl(i.value))
- }
- })
- that.agentAjax = false;
- return false;
- }, function (ret, res) {
- that.agentAjax = false;
- })
- },
- openDialog(type) {
- this.dialogType = type;
- this.dialogList = []
- if (this.dialogType == 'change-parent-agent') {
- this.getParentAgentList();
- } else if (this.dialogType == 'change-level') {
- this.getAgentLevel();
- }
- },
- closeDialog(opttype, type) {
- this.dialogVisible = false;
- this.parentFilterForm.form_1_value = "";
- this.parentFilterForm.form_1_key = "user_id";
- if (opttype == true) {
- if (type == 'change-level') {
- this.operation('save', 'level')
- } else if (type == 'change-parent-agent') {
- this.operation('save', 'parent_agent_id')
- }
- }
- },
- getAgentLevel() {
- let that = this;
- Fast.api.ajax({
- url: 'shopro/commission/level/index',
- loading: false,
- type: 'GET',
- }, function (ret, res) {
- that.agentLevelList = res.data;
- that.dialogVisible = true;
- return false;
- })
- },
- getParentAgentList() {
- let that = this;
- let filter = {}
- let op = {}
- for (key in that.parentFilterForm) {
- if (key == 'form_1_value') {
- if (that.parentFilterForm[key] != '') {
- filter[that.parentFilterForm.form_1_key] = that.parentFilterForm[key];
- }
- } else if (key == 'status') {
- if (that.parentFilterForm[key] != '' && that.parentFilterForm[key] != 'all') {
- filter[key] = that.parentFilterForm[key];
- }
- }
- }
- for (key in filter) {
- op[key] = that.parentFilterOp[key]
- }
- Fast.api.ajax({
- url: 'shopro/commission/agent/index',
- loading: false,
- type: 'GET',
- data: {
- offset: that.poffset,
- limit: that.plimit,
- filter: JSON.stringify(filter),
- op: JSON.stringify(op)
- },
- }, function (ret, res) {
- that.dialogList = res.data.rows;
- that.ptotalPage = res.data.total;
- that.dialogVisible = true;
- return false;
- })
- },
- parentDebounceFilter: debounce(function () {
- this.getParentAgentList()
- }, 1000),
- phandleCurrentChange(val) {
- this.pcurrentPage = val;
- this.poffset = (val - 1) * this.plimit;
- this.getParentAgentList()
- },
- getprofile() {
- let that = this;
- Fast.api.ajax({
- url: 'shopro/commission/agent/profile?id=' + Config.row.user_id,
- loading: false,
- type: 'GET',
- data: {},
- }, function (ret, res) {
- that.profileData = res.data;
- that.selectAgentLevel = that.profileData.level;
- that.getApplyInfo();
- return false;
- })
- },
- //列表
- radioChange(val) {
- this.logList = [];
- this.activeStatus = val;
- this.page = 1;
- this.limit = 10;
- this.currentPage = 1;
- this.totalPage = 0;
- this.getListData(val)
- },
- getListData(val) {
- let that = this;
- that.logListAjax = true;
- let filter = {}
- let op = {}
- for (key in that.filterForm) {
- if (key == 'event' && val == 'log') {
- if (that.filterForm[key] != '' && that.filterForm[key] != 'all') {
- filter[key] = that.filterForm[key];
- }
- } else if (key == 'agent_id') {
- if (that.filterForm[key] != '') {
- filter[key] = that.filterForm[key];
- }
- }
- }
- for (key in filter) {
- op[key] = that.filterOp[key]
- }
- Fast.api.ajax({
- url: `shopro/commission/${val}/index`,
- loading: false,
- type: 'GET',
- data: {
- offset: that.offset,
- limit: that.limit,
- op: JSON.stringify(op),
- filter: JSON.stringify(filter),
- },
- }, function (ret, res) {
- that.logList = res.data.rows;
- that.totalPage = res.data.total;
- that.logListAjax = false;
- return false;
- })
- },
- statusChange() {
- this.operation('save', 'status')
- },
- applyInfoStatusChange() {
- this.operation('save', 'info_status')
- },
- lockChange() {
- this.operation('save', 'upgrade_lock')
- },
- operation(type, id, data) {
- let that = this;
- switch (type) {
- case 'view-parent-agent':
- parent.Fast.api.open("shopro/commission/agent/profile?id=" + id, "上级分销商");
- break;
- case 'select-image':
- Fast.api.open("general/attachment/select?multiple=false", "选择", {
- callback: function (data) {
- that.profileData.apply_info[id].value = data.url;
- }
- });
- break;
- case 'delete-apply-info':
- that.profileData.apply_info.splice(id, 1);
- break;
- case 'save':
- let subValue;
- if (id == 'apply_info') {
- subValue = that.profileData.apply_info;
- subValue.forEach(i => {
- if (i.type == 'image') {
- delete i.value_arr;
- }
- delete i.isdelete;
- })
- subValue = JSON.stringify(subValue)
- } else if (id == 'level') {
- subValue = that.selectAgentLevel
- } else if (id == 'parent_agent_id') {
- subValue = that.selectParentAgentId
- } else {
- subValue = that.profileData[id]
- }
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + Config.row.user_id,
- loading: false,
- type: 'POST',
- data: {
- key: id,
- value: subValue
- },
- }, function (ret, res) {
- that.isEditInfoStatus = false;
- that.selectParentAgentId = null;
- that.parentFilterForm.form_1_value = "";
- that.parentFilterForm.form_1_key = "user_id";
- that.getprofile();
- }, function (ret, res) {
- that.isEditInfoStatus = false;
- that.selectParentAgentId = null;
- that.parentFilterForm.form_1_value = "";
- that.parentFilterForm.form_1_key = "user_id";
- })
- break;
- case 'edit-info-status':
- that.isEditInfoStatus = true;
- break;
- case 'filter-color':
- switch (id) {
- case 'normal':
- return 'filter-color-normal'
- break;
- case 'forbidden':
- return 'filter-color-forbidden'
- break;
- case 'pending':
- return 'filter-color-pending'
- break;
- case 'freeze':
- return 'filter-color-freeze'
- break;
- }
- break;
- case 'select-agent-level':
- that.selectAgentLevel = id;
- break;
- case 'open-order':
- parent.Fast.api.open(`shopro/commission/order/index?agent_id=${Config.row.user_id}`, "直推分销订单");
- break;
- case 'open-reward':
- parent.Fast.api.open(`shopro/commission/reward/index?agent_id=${Config.row.user_id}&status=${id}`, "佣金明细");
- break;
- case 'open-user':
- parent.Fast.api.open('shopro/user/user/profile?id=' + id, '查看用户')
- break;
- case 'open-order':
- parent.Fast.api.open('shopro/order/order/detail?id=' + id, "查看详情", {
- callback() {
- that.reqOrderList()
- }
- });
- break;
- case 'list-detail':
- parent.Fast.api.open(`shopro/commission/${that.activeStatus}/index?agent_id=${Config.row.user_id}`, "查看详情", {
- callback() {
- that.reqOrderList();
- }
- });
- break;
- case 'order':
- Fast.api.open(`shopro/commission/order/index?id=${id}`, '详情', {
- callback(data) {
- that.reqOrderList()
- }
- })
- break;
- case 'reward':
- Fast.api.open(`shopro/commission/reward/index?id=${id}`, '详情', {
- callback(data) {
- that.reqOrderList()
- }
- })
- break;
- case 'share':
- Fast.api.open(`shopro/user/user/profile?id=${id}`, '详情', {
- callback(data) {
- that.reqOrderList()
- }
- })
- break;
- case 'select-parent-agent':
- if (id === true) {
- that.selectParentAgentId = 0;
- } else if (id === false) {
- that.selectParentAgentId = null;
- } else {
- that.selectParentAgentId = id;
- that.noRecommendationChecked = false;
- }
- break;
- case 'level-status':
- Fast.api.ajax({
- url: 'shopro/commission/agent/update?id=' + Config.row.user_id,
- loading: false,
- type: 'POST',
- data: {
- key: 'level_status',
- value: id
- },
- }, function (ret, res) {
- that.getprofile();
- })
- break;
- case 'view-team':
- Fast.api.open(`shopro/commission/agent/team?id=${id}`, '查看团队')
- break;
- }
- },
- handleSizeChange(val) {
- this.offset = 0
- this.limit = val;
- this.currentPage = 1;
- this.getListData(this.activeStatus)
- },
- handleCurrentChange(val) {
- this.currentPage = val;
- this.offset = (val - 1) * this.limit;
- this.getListData(this.activeStatus)
- },
- tableCellClassName({
- columnIndex
- }) {
- if (columnIndex == 1) {
- return 'cell-left';
- }
- return '';
- },
- },
- })
- },
- team: function () {
- function debounce(handle, delay) {
- let time = null;
- return function () {
- let self = this,
- arg = arguments;
- clearTimeout(time);
- time = setTimeout(function () {
- handle.apply(self, arg);
- }, delay)
- }
- }
- let formatterHtml = {
- time: (row) => {
- return `${moment(row.createtime*1000).format('YYYY-MM-DD HH:mm:ss')}`
- },
- level: (row) => {
- let ht = `<div>-</div>`
- if (row.agent && row.agent.agent_level) {
- ht = `<div class="display-flex" style="width:100%">
- <div v-if="${row.agent.agent_level.image}"
- style="width:36px;height:36px;border-radius: 2px;margin-right:10px;display:flex;align-items: center;">
- <img style="width:100%" src="${Fast.api.cdnurl(row.agent.agent_level.image)}" />
- </div>
- <div class="ellipsis-item">${row.agent.agent_level.name}</div>
- </div>`
- }
- return ht;
- },
- message: (row) => {
- let ht = '<div>-<div>'
- if (row.avatar) {
- ht = `<div class="display-flex" style="width:100%">
- <div style="width:36px;height:36px;border-radius: 2px;margin-right:10px;overflow: hidden;flex-shrink: 0;">
- <img style="width:100%;" src="${Fast.api.cdnurl(row.avatar)}"/>
- </div>
- <div class="ellipsis-item">-</div>
- </div>`
- }
- if (row.nickname) {
- ht = `<div class="display-flex" style="width:100%">
- <div class="ellipsis-item">${row.nickname}</div>
- </div>`
- }
- if (row.avatar && row.nickname) {
- ht = `<div class="display-flex" style="width:100%">
- <div style="width:36px;height:36px;border-radius: 2px;margin-right:10px;overflow: hidden;flex-shrink: 0;">
- <img style="width:100%;" src="${Fast.api.cdnurl(row.avatar)}"/>
- </div>
- <div class="ellipsis-item">${row.nickname}</div>
- </div>`
- }
- return ht;
- },
- status: (row) => {
- let ht = `<div>-</div>`;
- let className = ''
- if (row.agent) {
- if (row.agent.status == 'normal') {
- className = 'filter-color-normal';
- } else if (row.agent.status == 'forbidden') {
- className = 'filter-color-forbidden';
- } else if (row.agent.status == 'pending') {
- className = 'filter-color-pending';
- } else if (row.agent.status == 'freeze') {
- className = 'filter-color-freeze';
- }
- ht = `<div class="display-flex ${className}">
- ${row.agent.status_text}
- </div>`
- }
- return ht;
- },
- moneynum: (row, outterfield, field) => {
- let ht = `<div>-</div>`
- if (row.agent) {
- ht = `<div class="display-flex">
- ${row[field]}<span class="unit-tip-item">人</span>
- </div>`
- if (outterfield) {
- ht = `<div class="display-flex">
- ${row[outterfield][field]}<span class="unit-tip-item">元</span>
- </div>`
- }
- if(field=='total_consume'){
- ht = `<div class="display-flex">
- ${row[field]}<span class="unit-tip-item">元</span>
- </div>`
- }
- }
- return ht;
- },
- singlenum: (row, outterfield, field) => {
- let ht = `<div>-</div>`
- if (row.agent) {
- ht = `<div class="display-flex">
- ${row[outterfield][field]}<span class="unit-tip-item">单</span>
- </div>`
- }
- return ht;
- },
- peoplenum: (row, outterfield, field) => {
- let ht = `<div class="display-flex">
- ${row[field]}<span class="unit-tip-item">人</span>
- </div>`
- if (outterfield) {
- if(row[outterfield]){
- ht = `<div class="display-flex">
- ${row[outterfield][field]}<span class="unit-tip-item">人</span>
- </div>`
- }else{
- ht ='-'
- }
-
- }
- return ht;
- },
- }
- var agentTeam = new Vue({
- el: "#agentTeam",
- data() {
- return {
- id: new URLSearchParams(location.search).get('id'),
- searchId: new URLSearchParams(location.search).get('id'),
- blockSearchId: new URLSearchParams(location.search).get('id'),
- teamList: [],
- tableIdArr: [],
- offset: 0,
- limit: 10,
- totalPage: 0,
- currentPage: 1,
- teamAjax: false,
- agentLevelList: [],
- // 筛选
- searchForm: {
- level: "",
- form_1_key: "id",
- form_1_value: ""
- },
- searchFormInit: {
- level: "",
- form_1_key: "id",
- form_1_value: ""
- },
- searchOp: {
- parent_user_id: '=',
- level: "=",
- id: "=",
- nickname: "like",
- mobile: "like",
- },
- parent_user: [],
- 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'],
- dashboardList: [{
- label: 'ID',
- value: 'id',
- }, {
- label: '团队用户',
- value: 'avatar-nickname',
- }, {
- label: '等级',
- value: 'level',
- }, {
- label: '状态',
- value: 'status',
- }, {
- label: '团队人数',
- value: 'child_user_count',
- }, {
- label: '一级团队人数',
- value: 'child_user_count_1',
- }, {
- label: '二级团队人数',
- value: 'child_user_count_2',
- }, {
- label: '分销商人数',
- value: 'child_agent_count',
- }, {
- label: '一级分销商人数',
- value: 'child_agent_count_1',
- }, {
- label: '二级分销商人数',
- value: 'child_agent_count_2',
- }, {
- label: '团队分销总额',
- value: 'child_order_money',
- }, {
- label: '一级分销总额',
- value: 'child_order_money_1',
- }, {
- label: '二级分销总额',
- value: 'child_order_money_2',
- }, {
- label: '直推分销总额',
- value: 'order_money',
- }, {
- label: '团队分销订单',
- value: 'child_order_count',
- }, {
- label: '一级分销订单',
- value: 'child_order_count_1',
- }, {
- label: '二级分销订单',
- value: 'child_order_count_2',
- }, {
- label: '直推分销订单',
- value: 'order_count',
- }, {
- label: '累计佣金',
- value: 'total_income',
- }, {
- label: '消费金额',
- value: 'delay_money',
- }, {
- label: '待入账佣金',
- value: 'total_consume',
- }, {
- label: '加入时间',
- value: 'createtime',
- }],
- columns: [{
- type: 'vmodel',
- field: 'id',
- title: 'ID',
- width: '70px',
- }, {
- type: 'click',
- field: 'avatar-nickname',
- title: '团队用户',
- width: '160px',
- formatter: formatterHtml.message,
- align: 'left',
- }, {
- type: 'vhtml',
- field: 'level',
- title: '等级',
- width: '180px',
- formatter: formatterHtml.level,
- align: 'left',
- }, {
- type: 'vhtml',
- field: 'status',
- title: '状态',
- width: '60px',
- formatter: formatterHtml.status,
- }, {
- type: 'vhtml',
- field: 'child_user_count',
- title: '团队人数',
- width: '120px',
- formatter: formatterHtml.peoplenum,
- }, {
- type: 'vhtml',
- field: 'child_user_count_1',
- title: '一级团队人数',
- width: '120px',
- formatter: formatterHtml.peoplenum,
- }, {
- type: 'vhtml',
- field: 'child_user_count_2',
- title: '二级团队人数',
- width: '120px',
- formatter: formatterHtml.peoplenum,
- }, {
- type: 'vhtml',
- field: 'child_agent_count',
- outterfield: 'agent',
- title: '分销商人数',
- width: '120px',
- formatter: formatterHtml.peoplenum,
- }, {
- type: 'vhtml',
- field: 'child_agent_count_1',
- outterfield: 'agent',
- title: '一级分销商人数',
- width: '120px',
- formatter: formatterHtml.peoplenum,
- }, {
- type: 'vhtml',
- field: 'child_agent_count_2',
- outterfield: 'agent',
- title: '二级分销商人数',
- width: '120px',
- formatter: formatterHtml.peoplenum,
- }, {
- type: 'vhtml',
- field: 'child_order_money',
- outterfield: 'agent',
- title: '团队分销总额',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'child_order_money_1',
- outterfield: 'agent',
- title: '一级分销总额',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'child_order_money_2',
- outterfield: 'agent',
- title: '二级分销总额',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'order_money',
- outterfield: 'agent',
- title: '直推分销总额',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'child_order_count',
- outterfield: 'agent',
- title: '团队分销订单',
- width: '120px',
- formatter: formatterHtml.singlenum,
- }, {
- type: 'vhtml',
- field: 'child_order_count_1',
- outterfield: 'agent',
- title: '一级分销订单',
- width: '120px',
- formatter: formatterHtml.singlenum,
- }, {
- type: 'vhtml',
- field: 'child_order_count_2',
- outterfield: 'agent',
- title: '二级分销订单',
- width: '120px',
- formatter: formatterHtml.singlenum,
- }, {
- type: 'vhtml',
- field: 'order_count',
- outterfield: 'agent',
- title: '直推分销订单',
- width: '120px',
- formatter: formatterHtml.singlenum,
- }, {
- type: 'vhtml',
- field: 'total_income',
- outterfield: 'agent',
- title: '累计佣金',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'delay_money',
- outterfield: 'agent',
- title: '消费金额',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'total_consume',
- title: '待入账佣金',
- width: '120px',
- formatter: formatterHtml.moneynum,
- }, {
- type: 'vhtml',
- field: 'createtime',
- outterfield: 'agent',
- title: '加入时间',
- width: '160px',
- formatter: formatterHtml.time,
- }]
- }
- },
- created() {
- this.getAgentTeam();
- this.getAgentLevel();
- },
- methods: {
- operation(type, id) {
- let that = this;
- switch (type) {
- case 'clickteam':
- if (!that.tableIdArr.includes(id)) {
- that.searchId = id;
- that.tableIdArr.push(id);
- that.getAgentTeam();
- }
- break;
- case 'clickteamdelete':
- if (id) {
- that.searchId = id;
- that.tableIdArr.splice((that.tableIdArr.indexOf(id) + 1));
- } else {
- that.searchId = that.id;
- that.tableIdArr = []
- }
- that.getAgentTeam();
- break;
- }
- },
- debounceFilter: debounce(function () {
- this.offset = 0
- this.limit = 10;
- this.currentPage = 1;
- this.getAgentTeam()
- }, 1000),
- getAgentLevel() {
- let that = this;
- Fast.api.ajax({
- url: 'shopro/commission/level/index',
- loading: false,
- type: 'GET',
- }, function (ret, res) {
- that.agentLevelList = res.data;
- return false;
- })
- },
- getAgentTeam() {
- let that = this;
- that.teamAjax = true;
- let filter = {}
- let op = {}
- for (key in that.searchForm) {
- if (key == 'form_1_value') {
- if (that.searchForm[key] != '') {
- filter[that.searchForm.form_1_key] = that.searchForm[key];
- }
- } else if (key == 'level') {
- if (that.searchForm[key] != '' && that.searchForm[key] != 'all') {
- filter[key] = that.searchForm[key];
- }
- }
- }
- filter.parent_user_id = that.searchId;
- for (key in filter) {
- op[key] = that.searchOp[key]
- }
- Fast.api.ajax({
- url: 'shopro/commission/agent/team',
- loading: false,
- type: 'GET',
- data: {
- offset: that.offset,
- limit: that.limit,
- filter: JSON.stringify(filter),
- op: JSON.stringify(op)
- },
- }, function (ret, res) {
- that.teamList = res.data.rows;
- that.totalPage = res.data.total;
- that.parent_user = [];
- that.parent_user.push(res.data.parent_user);
- that.teamAjax = false;
- return false;
- }, function (ret, res) {
- that.teamAjax = false;
- return false;
- })
- },
- handleSizeChange(val) {
- this.offset = 0
- this.limit = val;
- this.currentPage = 1;
- this.getAgentTeam()
- },
- handleCurrentChange(val) {
- this.currentPage = val;
- this.offset = (val - 1) * this.limit;
- this.getAgentTeam()
- },
- tableCellClassName({
- columnIndex
- }) {
- if (columnIndex == 1) {
- return 'cell-left';
- }
- return '';
- },
- },
- })
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- },
- };
- return Controller;
- });
|