79 行
3.6 KiB
JavaScript
79 行
3.6 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: () => {
|
|
const { reactive, onMounted } = Vue
|
|
const index = {
|
|
setup() {
|
|
const state = reactive({ data: [], kpi: {} })
|
|
const pagination = reactive({ page: 1, list_rows: 10, total: 0 })
|
|
const previewDialog = reactive({
|
|
visible: false,
|
|
loading: false,
|
|
date: '',
|
|
result: null
|
|
})
|
|
|
|
function getData() {
|
|
Fast.api.ajax({
|
|
url: 'shopro/partner/daily',
|
|
type: 'GET',
|
|
data: { page: pagination.page, list_rows: pagination.list_rows },
|
|
}, function (ret, res) {
|
|
state.data = res.data.data
|
|
state.kpi = res.data.kpi || {}
|
|
pagination.total = res.data.total
|
|
return false
|
|
}, function () { })
|
|
}
|
|
function onDetail(row) {
|
|
Fast.api.open(`shopro/partner/reward/index?settle_date=${row.settle_date}`, '当日流水')
|
|
}
|
|
function onRerun(row) {
|
|
const { ElMessageBox } = ElementPlus
|
|
ElMessageBox.confirm('将删除当天日结流水后重算,即时奖(推三返一等)不重跑。确定?', '重跑日结', {
|
|
confirmButtonText: '确定重跑',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
}).then(() => {
|
|
Fast.api.ajax({
|
|
url: 'shopro/partner/daily/rerun',
|
|
type: 'POST',
|
|
data: { settle_date: row.settle_date },
|
|
}, function () { getData() })
|
|
}).catch(() => {})
|
|
}
|
|
function onOpenPreview() {
|
|
const yesterday = new Date(Date.now() - 86400000).toISOString().slice(0, 10)
|
|
previewDialog.date = yesterday
|
|
previewDialog.visible = true
|
|
runPreview()
|
|
}
|
|
function runPreview() {
|
|
if (!previewDialog.date) {
|
|
ElementPlus.ElMessage.warning('请选择试算日期')
|
|
return
|
|
}
|
|
previewDialog.loading = true
|
|
Fast.api.ajax({
|
|
url: 'shopro/partner/daily/preview',
|
|
type: 'GET',
|
|
data: { settle_date: previewDialog.date },
|
|
}, function (ret, res) {
|
|
previewDialog.loading = false
|
|
previewDialog.result = res.data || null
|
|
return false
|
|
}, function () {
|
|
previewDialog.loading = false
|
|
})
|
|
}
|
|
onMounted(() => { getData() })
|
|
return { state, pagination, getData, onDetail, onRerun, previewDialog, onOpenPreview, runPreview }
|
|
}
|
|
}
|
|
createApp('index', index);
|
|
},
|
|
};
|
|
return Controller;
|
|
});
|