前台新增存酒功能

This commit is contained in:
SjS 2025-06-06 18:21:59 +08:00
parent 3b1142ab18
commit 4b7edf5407
9 changed files with 1416 additions and 3 deletions

44
src/api/bst/location.js Normal file
View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询存放位置列表
export function listLocation(query) {
return request({
url: '/bst/location/list',
method: 'get',
params: query
})
}
// 查询存放位置详细
export function getLocation(id) {
return request({
url: '/bst/location/' + id,
method: 'get'
})
}
// 新增存放位置
export function addLocation(data) {
return request({
url: '/bst/location',
method: 'post',
data: data
})
}
// 修改存放位置
export function updateLocation(data) {
return request({
url: '/bst/location',
method: 'put',
data: data
})
}
// 删除存放位置
export function delLocation(id) {
return request({
url: '/bst/location/' + id,
method: 'delete'
})
}

44
src/api/bst/storage.js Normal file
View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询存酒列表
export function listStorage(query) {
return request({
url: '/bst/storage/list',
method: 'get',
params: query
})
}
// 查询存酒详细
export function getStorage(id) {
return request({
url: '/bst/storage/' + id,
method: 'get'
})
}
// 新增存酒
export function addStorage(data) {
return request({
url: '/bst/storage',
method: 'post',
data: data
})
}
// 修改存酒
export function updateStorage(data) {
return request({
url: '/bst/storage',
method: 'put',
data: data
})
}
// 删除存酒
export function delStorage(id) {
return request({
url: '/bst/storage/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询取酒记录列表
export function listStorageRecord(query) {
return request({
url: '/bst/storageRecord/list',
method: 'get',
params: query
})
}
// 查询取酒记录详细
export function getStorageRecord(id) {
return request({
url: '/bst/storageRecord/' + id,
method: 'get'
})
}
// 新增取酒记录
export function addStorageRecord(data) {
return request({
url: '/bst/storageRecord',
method: 'post',
data: data
})
}
// 修改取酒记录
export function updateStorageRecord(data) {
return request({
url: '/bst/storageRecord',
method: 'put',
data: data
})
}
// 删除取酒记录
export function delStorageRecord(id) {
return request({
url: '/bst/storageRecord/' + id,
method: 'delete'
})
}

View File

@ -23,7 +23,6 @@
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-if="isSysAdmin()"
v-has-permi="['bst:agreement:add']"
>新增</el-button>
</el-col>
@ -113,7 +112,7 @@
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<form-col label="小程序" prop="appId" v-if="isSysAdmin()">
<form-col label="小程序" prop="appId">
<el-select
v-model="form.appId"
placeholder="请选择小程序"

View File

@ -95,7 +95,7 @@
</template>
</el-table-column>
</template>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" v-if="isSysAdmin()" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"

View File

@ -0,0 +1,241 @@
<template>
<div v-loading="loading">
<!-- 搜索框 -->
<div style="margin-bottom: 10px;">
<el-input v-model="searchValue" placeholder="请输入位置名称" @input="handleSearch" size="small"/>
</div>
<!-- 树形结构 -->
<el-tree
:data="treeData"
:props="defaultProps"
node-key="id"
default-expand-all
:filter-node-method="filterNode"
ref="tree"
@node-click="handleNodeClick"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ node.label }}</span>
<!-- 店铺节点显示新增按钮 -->
<span class="operation-group" v-if="data.type === 'store'">
<el-button type="text" size="mini" icon="el-icon-plus" @click.stop="handleAdd(data)"></el-button>
</span>
<!-- 位置节点显示修改和删除按钮 -->
<span class="operation-group" v-if="data.type === 'location'">
<el-button type="text" size="mini" icon="el-icon-edit" @click.stop="handleEdit(data)"></el-button>
<el-button type="text" size="mini" icon="el-icon-delete" @click.stop="handleDelete(data)"></el-button>
</span>
</span>
</el-tree>
<!-- 新增/编辑对话框 -->
<el-dialog :title="form.id ? '编辑位置' : '新增位置'" :visible.sync="dialogVisible" width="400px">
<el-form :model="form" label-width="80px" ref="formRef">
<el-form-item label="所属店铺" prop="storeId">
<div class="category-wrapper">
<el-select
v-model="form.storeId"
placeholder="请选择店铺"
clearable
>
<el-option
v-for="item in stores"
:key="item.storeId"
:label="item.storeName"
:value="item.storeId"
/>
</el-select>
</div>
</el-form-item>
<el-form-item label="位置名称" prop="name">
<el-input v-model="form.name" placeholder="请输入位置名称"/>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitForm">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {listStore} from "@/api/bst/store";
import {listLocation, addLocation, updateLocation, delLocation} from "@/api/bst/location";
export default {
name: "LocationTree",
props: {
storeId: {
type: [String, Number],
default: null
}
},
data() {
return {
stores :[], //
loading: false,
searchValue: "",
treeData: [],
defaultProps: {
children: "children",
label: "name"
},
dialogVisible: false,
form: {
id: null,
storeId: null,
storeName: "",
name: ""
}
};
},
mounted() {
this.getList();
},
methods: {
handleSearch() {
this.$refs.tree.filter(this.searchValue);
},
filterNode(value, data) {
if (!value) {
return true;
}
return data.name.indexOf(value) !== -1;
},
async getList() {
this.loading = true;
try {
//
const storeRes = await listStore();
this.stores = storeRes.rows;
// storeIdstoreId
const params = { storeId: this.storeId };
const locationRes = await listLocation(params);
const locations = locationRes.rows;
// ->
this.treeData = this.stores.map(store => ({
id: store.storeId,
name: store.storeName,
storeId: store.storeId,
type: "store",
children: locations
.filter(location => location.storeId === store.storeId)
.map(location => ({
id: location.id,
name: location.name,
storeId: location.storeId,
storeName: store.storeName,
locationId: location.id,
type: "location"
}))
}));
console.log("this.treeData:", this.treeData);
} catch (error) {
console.error("获取数据失败:", error);
} finally {
this.loading = false;
}
},
handleNodeClick(data) {
this.$emit('node-click', data);
},
//
handleAdd(data) {
this.form = {
storeId: data.storeId,
name: ""
};
this.dialogVisible = true;
},
//
handleEdit(data) {
console.log("data:", data);
this.form = {
id: data.locationId || data.id,
storeId: data.storeId,
name: data.name
};
this.dialogVisible = true;
},
//
handleDelete(data) {
this.$confirm(`是否确认删除【${data.name}】?`, "提示", {
type: "warning"
}).then(async () => {
await delLocation(data.locationId);
this.$message.success("删除成功");
this.getList(); //
}).catch(() => {
});
},
//
submitForm() {
if (!this.form.name.trim()) {
this.$message.warning("请输入位置名称");
return;
}
const api = this.form.id ? updateLocation : addLocation;
const params = {
id: this.form.id || undefined,
storeId: this.form.storeId,
name: this.form.name
};
api(params)
.then(() => {
this.$message.success(this.form.id ? "更新成功" : "新增成功");
this.dialogVisible = false;
this.getList(); //
})
.catch(err => {
this.$message.error("操作失败:" + err.message);
});
}
},
watch: {
storeId: {
handler() {
this.getList();
}
}
}
};
</script>
<style lang="scss" scoped>
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
.operation-group {
.el-button {
margin-left: 8px;
&:first-child {
margin-left: 0;
}
&[class*="el-icon-delete"] {
color: #f56c6c;
}
}
}
</style>

View File

@ -0,0 +1,258 @@
<template>
<div class="app-container">
<el-row :gutter="40">
<el-col :lg="4" :md="8" :xs="24" style="border-right: 1px solid #ebeef5;">
<location-tree @node-click="handleLocationNodeClick" />
</el-col>
<el-col :lg="20" :md="16" :xs="24">
<storage :store-id="queryParams.storeId" :location-id="queryParams.locationId" ref="storageIndex"/>
</el-col>
</el-row>
<!-- 添加或修改存放位置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<form-col :span="span" label="店铺ID" prop="storeId">
<el-input v-model="form.storeId" placeholder="请输入店铺ID"/>
</form-col>
<form-col :span="span" label="位置名称" prop="name">
<el-input v-model="form.name" placeholder="请输入位置名称"/>
</form-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {listLocation, getLocation, delLocation, addLocation, updateLocation} from "@/api/bst/location";
import {$showColumns} from '@/utils/mixins';
import FormCol from "@/components/FormCol/index.vue";
import Storage from "@/views/bst/storage/index.vue";
import LocationTree from "@/views/bst/location/components/LocationTree.vue";
//
const defaultSort = {
prop: "createTime",
order: "descending"
}
export default {
name: "Location",
mixins: [$showColumns],
components: {LocationTree, Storage, FormCol},
data() {
return {
span: 24,
//
columns: [
{
key: 'id',
visible: true,
label: 'ID',
minWidth: null,
sortable: true,
overflow: false,
align: 'center',
width: null
},
{
key: 'storeId',
visible: true,
label: '店铺ID',
minWidth: null,
sortable: true,
overflow: false,
align: 'center',
width: null
},
{
key: 'name',
visible: true,
label: '位置名称',
minWidth: null,
sortable: true,
overflow: false,
align: 'center',
width: null
},
],
//
orderSorts: ['ascending', 'descending', null],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
locationList: [],
//
title: "",
//
open: false,
defaultSort,
//
queryParams: {
pageNum: 1,
pageSize: 20,
orderByColumn: defaultSort.prop,
isAsc: defaultSort.order,
id: null,
storeId: null,
locationId: null,
name: null,
},
//
form: {},
//
rules: {
storeId: [
{required: true, message: "店铺ID不能为空", trigger: "blur"}
],
name: [
{required: true, message: "位置名称不能为空", trigger: "blur"}
],
createTime: [
{required: true, message: "创建时间不能为空", trigger: "blur"}
]
}
};
},
created() {
this.getList();
},
methods: {
handleLocationNodeClick(node) {
if (node.type === "store") {
this.queryParams.storeId = node.storeId;
this.queryParams.locationId = null;
} else if (node.type === "location") {
this.queryParams.storeId = node.storeId;
this.queryParams.locationId = node.locationId;
}
console.log(this.queryParams.storeId)
console.log(this.queryParams.locationId)
this.$nextTick(() => {
this.$refs.storageIndex.getList();
});
},
/** 当排序按钮被点击时触发 **/
onSortChange(column) {
if (column.order == null) {
this.queryParams.orderByColumn = defaultSort.prop;
this.queryParams.isAsc = defaultSort.order;
} else {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
}
this.getList();
},
/** 查询存放位置列表 */
getList() {
this.loading = true;
listLocation(this.queryParams).then(response => {
this.locationList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
storeId: null,
name: null,
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加存放位置";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getLocation(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改存放位置";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateLocation(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addLocation(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除存放位置编号为"' + ids + '"的数据项?').then(function () {
return delLocation(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
/** 导出按钮操作 */
handleExport() {
this.download('bst/location/export', {
...this.queryParams
}, `location_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -0,0 +1,423 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="存放位置" prop="locationName">
<el-input
v-model="queryParams.locationName"
placeholder="请输入存放位置ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="店铺名称" prop="storeName">
<el-input
v-model="queryParams.storeName"
placeholder="请输入店铺名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户名称" prop="userName">
<el-input
v-model="queryParams.userId"
placeholder="请输入用户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="商品名称" prop="goodsName">
<el-input
v-model="queryParams.goodsName"
placeholder="请输入商品名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="存放期限" prop="deadline">
<el-date-picker clearable
v-model="queryParams.deadline"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择存放期限">
</el-date-picker>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
v-model="queryParams.remark"
placeholder="请输入备注"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-has-permi="['bst:storage:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-has-permi="['bst:storage:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-has-permi="['bst:storage:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="storageList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="onSortChange">
<el-table-column type="selection" width="55" align="center" />
<template v-for="column of showColumns">
<el-table-column
:key="column.key"
:label="column.label"
:prop="column.key"
:align="column.align"
:min-width="column.minWidth"
:sort-orders="orderSorts"
:sortable="column.sortable"
:show-overflow-tooltip="column.overflow"
:width="column.width"
>
<template slot-scope="d">
<template v-if="column.key === 'id'">
{{d.row[column.key]}}
</template>
<template v-else>
{{d.row[column.key]}}
</template>
</template>
</el-table-column>
</template>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-has-permi="['bst:storage:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-has-permi="['bst:storage:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改存酒对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<form-col :span="span" label="存放位置ID" prop="locationId">
<el-input v-model="form.locationId" placeholder="请输入存放位置ID" />
</form-col>
<form-col :span="span" label="店铺ID" prop="storeId">
<el-input v-model="form.storeId" placeholder="请输入店铺ID" />
</form-col>
<form-col :span="span" label="用户ID" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户ID" />
</form-col>
<form-col :span="span" label="商品skuID" prop="skuId">
<el-input v-model="form.skuId" placeholder="请输入商品skuID" />
</form-col>
<form-col :span="span" label="商品名称" prop="goodsName">
<el-input v-model="form.goodsName" placeholder="请输入商品名称" />
</form-col>
<form-col :span="span" label="存放数量" prop="totalNum">
<el-input v-model="form.totalNum" placeholder="请输入存放数量" />
</form-col>
<form-col :span="span" label="已取数量" prop="takenNum">
<el-input v-model="form.takenNum" placeholder="请输入已取数量" />
</form-col>
<form-col :span="span" label="存放期限" prop="deadline">
<el-date-picker clearable
v-model="form.deadline"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择存放期限">
</el-date-picker>
</form-col>
<form-col :span="span" label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</form-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listStorage, getStorage, delStorage, addStorage, updateStorage } from "@/api/bst/storage";
import { $showColumns } from '@/utils/mixins';
import FormCol from "@/components/FormCol/index.vue";
import {listBooth} from "@/api/bst/booth";
import {listLocation} from "@/api/bst/location";
//
const defaultSort = {
prop: "createTime",
order: "descending"
}
export default {
name: "Storage",
mixins: [$showColumns],
props: {
storeId: {
type: [Number, String],
default: null
},
locationId: {
type: [Number, String],
default: null
},
},
components: {FormCol},
data() {
return {
span: 24,
//
columns: [
{key: 'locationName', visible: true, label: '存放位置', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'storeName', visible: true, label: '店铺名称', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'userName', visible: true, label: '用户名称', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'goodsName', visible: true, label: '商品名称', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'totalNum', visible: true, label: '存放数量', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'takenNum', visible: true, label: '已取数量', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'deadline', visible: true, label: '存放期限', minWidth: null, sortable: false, overflow: false, align: 'center', width: "100"},
{key: 'specValue', visible: true, label: '规格值JSON', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'remark', visible: true, label: '备注', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
],
//
orderSorts: ['ascending', 'descending', null],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
storageList: [],
//
title: "",
//
open: false,
defaultSort,
//
queryParams: {
pageNum: 1,
pageSize: 20,
orderByColumn: defaultSort.prop,
isAsc: defaultSort.order,
id: null,
locationId: null,
storeId: null,
userId: null,
skuId: null,
goodsName: null,
totalNum: null,
takenNum: null,
deadline: null,
specValue: null,
remark: null,
},
//
form: {},
//
rules: {
locationId: [
{ required: true, message: "存放位置ID不能为空", trigger: "blur" }
],
storeId: [
{ required: true, message: "店铺ID不能为空", trigger: "blur" }
],
userId: [
{ required: true, message: "用户ID不能为空", trigger: "blur" }
],
skuId: [
{ required: true, message: "商品skuID不能为空", trigger: "blur" }
],
goodsName: [
{ required: true, message: "商品名称不能为空", trigger: "blur" }
],
specValue: [
{ required: true, message: "规格值JSON不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 当排序按钮被点击时触发 **/
onSortChange(column) {
if (column.order == null) {
this.queryParams.orderByColumn = defaultSort.prop;
this.queryParams.isAsc = defaultSort.order;
} else {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
}
this.getList();
},
/** 查询存酒列表 */
getList() {
this.loading = true;
// storeIdpartId
const params = {
...this.queryParams,
storeId: this.storeId,
locationId: this.locationId,
};
listStorage(params).then(response => {
this.storageList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
locationId: null,
storeId: null,
userId: null,
skuId: null,
goodsName: null,
totalNum: null,
takenNum: null,
deadline: null,
specValue: null,
remark: null,
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加存酒";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getStorage(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改存酒";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateStorage(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addStorage(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除存酒编号为"' + ids + '"的数据项?').then(function() {
return delStorage(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('bst/storage/export', {
...this.queryParams
}, `storage_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -0,0 +1,360 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="存放明细ID" prop="storageId">
<el-input
v-model="queryParams.storageId"
placeholder="请输入存放明细ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="店铺ID" prop="storeId">
<el-input
v-model="queryParams.storeId"
placeholder="请输入店铺ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户ID" prop="userId">
<el-input
v-model="queryParams.userId"
placeholder="请输入用户ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="原因" prop="reason">
<el-input
v-model="queryParams.reason"
placeholder="请输入原因"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="取酒数量" prop="number">
<el-input
v-model="queryParams.number"
placeholder="请输入取酒数量"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-has-permi="['bst:storageRecord:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-has-permi="['bst:storageRecord:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-has-permi="['bst:storageRecord:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="storageRecordList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="onSortChange">
<el-table-column type="selection" width="55" align="center" />
<template v-for="column of showColumns">
<el-table-column
:key="column.key"
:label="column.label"
:prop="column.key"
:align="column.align"
:min-width="column.minWidth"
:sort-orders="orderSorts"
:sortable="column.sortable"
:show-overflow-tooltip="column.overflow"
:width="column.width"
>
<template slot-scope="d">
<template v-if="column.key === 'id'">
{{d.row[column.key]}}
</template>
<template v-else>
{{d.row[column.key]}}
</template>
</template>
</el-table-column>
</template>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-has-permi="['bst:storageRecord:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-has-permi="['bst:storageRecord:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改取酒记录对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<form-col :span="span" label="存放明细ID" prop="storageId">
<el-input v-model="form.storageId" placeholder="请输入存放明细ID" />
</form-col>
<form-col :span="span" label="店铺ID" prop="storeId">
<el-input v-model="form.storeId" placeholder="请输入店铺ID" />
</form-col>
<form-col :span="span" label="用户ID" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户ID" />
</form-col>
<form-col :span="span" label="原因" prop="reason">
<el-input v-model="form.reason" placeholder="请输入原因" />
</form-col>
<form-col :span="span" label="取酒数量" prop="number">
<el-input v-model="form.number" placeholder="请输入取酒数量" />
</form-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listStorageRecord, getStorageRecord, delStorageRecord, addStorageRecord, updateStorageRecord } from "@/api/bst/storageRecord";
import { $showColumns } from '@/utils/mixins';
import FormCol from "@/components/FormCol/index.vue";
//
const defaultSort = {
prop: "createTime",
order: "descending"
}
export default {
name: "StorageRecord",
mixins: [$showColumns],
components: {FormCol},
data() {
return {
span: 24,
//
columns: [
{key: 'id', visible: true, label: 'ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'storageId', visible: true, label: '存放明细ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'storeId', visible: true, label: '店铺ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'userId', visible: true, label: '用户ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'reason', visible: true, label: '原因', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
{key: 'number', visible: true, label: '取酒数量', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
],
//
orderSorts: ['ascending', 'descending', null],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
storageRecordList: [],
//
title: "",
//
open: false,
defaultSort,
//
queryParams: {
pageNum: 1,
pageSize: 20,
orderByColumn: defaultSort.prop,
isAsc: defaultSort.order,
storageId: null,
storeId: null,
userId: null,
reason: null,
number: null,
},
//
form: {},
//
rules: {
storageId: [
{ required: true, message: "存放明细ID不能为空", trigger: "blur" }
],
storeId: [
{ required: true, message: "店铺ID不能为空", trigger: "blur" }
],
userId: [
{ required: true, message: "用户ID不能为空", trigger: "blur" }
],
number: [
{ required: true, message: "取酒数量不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 当排序按钮被点击时触发 **/
onSortChange(column) {
if (column.order == null) {
this.queryParams.orderByColumn = defaultSort.prop;
this.queryParams.isAsc = defaultSort.order;
} else {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
}
this.getList();
},
/** 查询取酒记录列表 */
getList() {
this.loading = true;
listStorageRecord(this.queryParams).then(response => {
this.storageRecordList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
storageId: null,
storeId: null,
userId: null,
reason: null,
number: null,
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加取酒记录";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getStorageRecord(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改取酒记录";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateStorageRecord(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addStorageRecord(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除取酒记录编号为"' + ids + '"的数据项?').then(function() {
return delStorageRecord(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('bst/storageRecord/export', {
...this.queryParams
}, `storageRecord_${new Date().getTime()}.xlsx`)
}
}
};
</script>