Files

158 lines
5.5 KiB
Vue

<template>
<view class="page-body">
<vk-data-table-query v-model="queryForm1.formData" :columns="queryForm1.columns"
@search="search"></vk-data-table-query>
<vk-data-table ref="table1" :action="table1.action" :columns="table1.columns" :query-form-param="queryForm1"
:pagination="true"
@current-change="currentChange"
@selection-change="selectionChange"></vk-data-table>
</view>
</template>
<script>
var that;
var vk = uni.vk;
const typeData = [
{ value: "spend", label: "消耗" },
{ value: "earn", label: "充值/收入" }
];
const bizTypeData = [
{ value: "contract_review", label: "合同审查" },
{ value: "recharge", label: "积分充值" },
{ value: "other", label: "其他" }
];
export default {
data() {
return {
table1: {
action: "admin/points/sys/getList",
columns: [
{
key: "userInfo",
title: "用户",
type: "html",
align: "left",
width: 200,
formatter: (val, row) => {
// vk 联表 limit:1 返回对象而非数组,两种形态兼容
const raw = row.userInfo;
const user = Array.isArray(raw) ? (raw[0] || null) : (raw || null);
const mobile = user && user.mobile ? user.mobile : "-";
if (user) {
const name = user.nickname || user.username || "未设置昵称";
return `<div>${name}</div><div style="color:#999;font-size:12px;">${mobile}</div>`;
}
// 联表未匹配:显示 user_id 原值便于排查(anonymous 为历史脏数据)
const uid = row.user_id || "-";
const label = uid === "anonymous" ? "未登录(anonymous)" : uid.slice(0, 12) + "…";
return `<div style="color:#f56c6c;">未匹配用户</div><div style="color:#999;font-size:12px;">${label}</div>`;
}
},
{
key: "type",
title: "类型",
type: "select",
align: "center",
width: 110,
data: typeData
},
{
key: "amount",
title: "变动积分",
type: "html",
align: "center",
width: 120,
formatter: (val) => {
const num = Number(val || 0);
const color = num >= 0 ? "#67c23a" : "#f56c6c";
return `<span style="color:${color};font-weight:bold;">${num >= 0 ? "+" : ""}${num}</span>`;
}
},
{
key: "balance_after",
title: "变动后余额",
type: "text",
align: "center",
width: 120
},
{
key: "reason",
title: "事由",
type: "text",
align: "left",
minWidth: 260
},
{
key: "biz_type",
title: "业务类型",
type: "select",
align: "center",
width: 120,
data: bizTypeData
},
{
key: "_add_time",
title: "时间",
type: "time",
width: 180,
sortable: "custom"
}
],
multipleSelection: [],
selectItem: ""
},
queryForm1: {
formData: {},
columns: [
{
key: "type",
title: "类型",
type: "select",
mode: "=",
data: typeData
},
{
key: "biz_type",
title: "业务类型",
type: "select",
mode: "=",
data: bizTypeData
},
{
key: "_add_time",
title: "时间",
type: "datetimerange",
width: 380,
mode: "[]"
}
]
}
};
},
onLoad(options = {}) {
that = this;
vk = that.vk;
},
methods: {
search() {
that.$refs.table1.search();
},
currentChange(val) {
that.table1.selectItem = val;
},
selectionChange(list) {
that.table1.multipleSelection = list;
}
}
};
</script>
<style lang="scss" scoped>
.page-body {
padding: 15px;
}
</style>