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 `${row.order.order_sn}` } }, time: (row) => { return `${moment(row.createtime*1000).format('YYYY-MM-DD HH:mm:ss')}` }, user_message: (row) => { if(row.buyer){ return `