define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backend, Form) { var Controller = { index: function () { new Vue({ el: '#splitReceiverIndex', data: { listData: [], loading: false, splitHuifuOnly: !!(typeof Config !== 'undefined' && Config.splitHuifuOnly), }, mounted() { this.getList(); }, methods: { getList() { this.loading = true; Fast.api.ajax({ url: 'shopro/split/receiver/index', type: 'GET', data: { limit: 100 } }, (ret, res) => { this.listData = (res.data && res.data.rows) || []; this.loading = false; return false; }, () => { this.loading = false; }); }, openAdd() { Backend.api.open('shopro/split/receiver/add', '添加接收方', { callback: () => this.getList() }); }, syncWx(id) { Fast.api.ajax({ url: 'shopro/split/receiver/syncWx/ids/' + id, type: 'POST' }, () => this.getList()); }, wxStatusText(s) { return { 0: '待同步', 1: '已同步', 2: '失败' }[s] || '-'; }, channelText(c) { return c === 'huifu' ? '汇付' : '微信'; }, roleTypeText(type) { const map = { platform: '平台', promoter: '推广员', regional_agent: '区域公司', }; return map[type] || type; }, matchTagClass(text) { if (!text || text === '—') return 'match-tag neutral'; if (text === '与进件一致') return 'match-tag ok'; if (text === '未进件' || text === '未填账号' || text === '未配置') return 'match-tag warn'; return 'match-tag err'; }, scrollCellWheel(e) { var el = e.currentTarget; if (!el || el.scrollWidth <= el.clientWidth) return; if (Math.abs(e.deltaY) >= Math.abs(e.deltaX)) { e.preventDefault(); el.scrollLeft += e.deltaY; } } } }); }, add: function () { Form.api.bindevent($('form[role=form]')); } }; return Controller; });