190 lines
5.0 KiB
Vue
Raw Normal View History

2022-08-06 20:03:35 +08:00
<template>
<div>
2022-08-12 18:26:27 +08:00
<!-- 筛选框 -->
2022-08-06 20:03:35 +08:00
<el-card class="box-card">
2022-08-12 18:26:27 +08:00
<div class="goods" style="margin: 20px">
<el-form ref="form" :inline="true" :model="form">
2022-08-06 20:03:35 +08:00
<el-form-item label="查询类别:">
2022-08-12 18:26:27 +08:00
<el-select v-model="form.targetField" placeholder="全部">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
2022-08-06 20:03:35 +08:00
</el-option>
</el-select>
</el-form-item>
2022-08-12 18:26:27 +08:00
<el-form-item label="操作用户">
<el-select v-model="form.userId" placeholder="输入操作用户">
<el-option
v-for="item in options1"
:key="item.id"
:label="item.name"
:value="item.id"
>
2022-08-06 20:03:35 +08:00
</el-option>
</el-select>
</el-form-item>
<el-form-item label="操作时间:">
2022-08-12 18:26:27 +08:00
<el-date-picker
v-model="value1"
type="datetimerange"
range-separator="-"
start-placeholder="起"
end-placeholder="止"
value-format="yyyy-MM-dd HH:mm:ss"
>
2022-08-06 20:03:35 +08:00
</el-date-picker>
</el-form-item>
<el-form-item>
2022-08-12 18:26:27 +08:00
<el-button type="primary" @click="query()">查询</el-button>
2022-08-06 20:03:35 +08:00
</el-form-item>
</el-form>
</div>
</el-card>
2022-08-12 18:26:27 +08:00
<!-- 表格 -->
<el-card style="margin-top: 30px" class="box-card">
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="id" label="序号" width="100"> </el-table-column>
<el-table-column prop="created_at" label="时间" width="200">
2022-08-06 20:03:35 +08:00
</el-table-column>
2022-08-12 18:26:27 +08:00
<el-table-column prop="target_field" label="类别" width="100">
2022-08-06 20:03:35 +08:00
</el-table-column>
2022-08-12 18:26:27 +08:00
<el-table-column prop="before_update" label="操作前"> </el-table-column>
<el-table-column prop="after_update" label="操作后"> </el-table-column>
<el-table-column prop="user.name" label="操作人" width="100">
2022-08-06 20:03:35 +08:00
</el-table-column>
</el-table>
</el-card>
2022-08-12 18:26:27 +08:00
<!-- 分页功能 -->
<div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="current_page"
:page-sizes="[15, 50, 100]"
:page-size="per_page"
layout="total, sizes, prev, pager, next, jumper"
:total="Paginationdata.total"
>
</el-pagination>
</div>
2022-08-06 20:03:35 +08:00
</div>
</template>
<script>
2022-08-12 18:26:27 +08:00
import { userList } from "../../api/user";
import { recordList } from "../../api/record";
2022-08-06 20:03:35 +08:00
export default {
data() {
return {
options: [
{
2022-08-12 18:26:27 +08:00
value: "cost",
label: "成本",
2022-08-06 20:03:35 +08:00
},
{
2022-08-12 18:26:27 +08:00
value: "stock",
label: "库存",
2022-08-06 20:03:35 +08:00
},
{
2022-08-12 18:26:27 +08:00
value: "inventory",
label: "库存盘点",
2022-08-06 20:03:35 +08:00
},
{
2022-08-12 18:26:27 +08:00
value: "status",
label: "状态",
2022-08-06 20:03:35 +08:00
},
{
2022-08-12 18:26:27 +08:00
value: "set",
label: "设置",
2022-08-06 20:03:35 +08:00
},
2022-08-12 18:26:27 +08:00
], //查询类别
options1: [], //查询用户列表
2022-08-06 20:03:35 +08:00
form: {
2022-08-12 18:26:27 +08:00
targetField: "",
userId: "",
2022-08-06 20:03:35 +08:00
},
2022-08-12 18:26:27 +08:00
value1: "", //筛选时间变量
tableData: [], //列表数据
Paginationdata: {}, //分页相关数据
current_page: 1, //当前页
per_page: 15, //每页显示数量
moudule: "goods",
};
2022-08-06 20:03:35 +08:00
},
methods: {
2022-08-12 18:26:27 +08:00
//请求列表数据
getList() {
let queryData = {
userId: this.form.userId,
targetField: this.form.targetField,
moudule: this.moudule,
target_id: this.$route.query.id,
startTime: this.value1[0],
endTime: this.value1[1],
page: this.current_page,
per_page: this.per_page,
};
recordList(queryData).then((res) => {
console.log(1111, res);
this.tableData = res.data.data;
this.Paginationdata = res.data.meta;
});
},
//分页功能
2022-08-06 20:03:35 +08:00
handleSizeChange(val) {
2022-08-12 18:26:27 +08:00
//当前条数
this.per_page = val;
this.getList();
2022-08-06 20:03:35 +08:00
},
handleCurrentChange(val) {
2022-08-12 18:26:27 +08:00
//当前页
this.current_page = val;
this.getList();
},
// 获取用户列表
getUser() {
userList().then((res) => {
this.options1 = res.data.data;
console.log("我是用户", this.options1);
});
},
// 查询
query() {
console.log(this.form.userId, this.form.targetField);
let queryData = {
userId: this.form.userId,
targetField: this.form.targetField,
page: this.current_page,
per_page: this.per_page,
moudule: this.moudule,
target_id: this.$route.query.id,
startTime: this.value1[0],
endTime: this.value1[1],
};
recordList(queryData).then((res) => {
this.tableData = res.data.data;
this.Paginationdata = res.data.meta;
});
2022-08-06 20:03:35 +08:00
},
},
2022-08-12 18:26:27 +08:00
mounted() {
this.getList();
this.getUser();
},
};
2022-08-06 20:03:35 +08:00
</script>
<style>
2022-08-12 18:26:27 +08:00
.block {
margin-top: 30px;
}
2022-08-06 20:03:35 +08:00
</style>