add price list
This commit is contained in:
2025-10-13 18:24:02 +08:00
parent f2d9026a35
commit e0ef897a62
3 changed files with 106 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ import request from '@/axios';
export const getList = (current, size, params) => { export const getList = (current, size, params) => {
return request({ return request({
url: '/kiosk/price-list/list', url: '/kiosk/price-list/page',
method: 'get', method: 'get',
params: { params: {
...params, ...params,
@@ -48,3 +48,13 @@ export const update = (row) => {
}) })
} }
export const init = (id) => {
return request({
url: '/kiosk/price-list/init-price',
method: 'post',
params: {
id,
}
})
}

View File

@@ -1,6 +1,6 @@
export default { export default {
height: 'auto', height: 'auto',
calcHeight: 30, calcHeight: 150,
tip: false, tip: false,
searchShow: true, searchShow: true,
searchMenuSpan: 6, searchMenuSpan: 6,
@@ -10,15 +10,9 @@ export default {
addBtn: false, addBtn: false,
editBtn: false, editBtn: false,
delBtn: false, delBtn: false,
menu: false,
searchBtn: false,
emptyBtn:false,
selection: false, selection: false,
columnBtn: false,
searchShowBtn: false,
refreshBtn: false,
gridBtn: false,
dialogClickModal: false, dialogClickModal: false,
menuWidth: 150,
column: [ column: [
{ {
label: '主键', label: '主键',

View File

@@ -1,6 +1,18 @@
<template> <template>
<el-row v-loading="initLoading">
<el-col :span="5">
<div class="box">
<el-scrollbar>
<basic-container> <basic-container>
<avue-crud :option="option" <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
</basic-container>
</el-scrollbar>
</div>
</el-col>
<el-col :span="19">
<basic-container>
<avue-crud
:option="option"
v-model:search="search" v-model:search="search"
v-model:page="page" v-model:page="page"
v-model="form" v-model="form"
@@ -18,25 +30,39 @@
@current-change="currentChange" @current-change="currentChange"
@size-change="sizeChange" @size-change="sizeChange"
@refresh-change="refreshChange" @refresh-change="refreshChange"
@on-load="onLoad"> @on-load="onLoad"
>
<template #menu-left>
<el-button
type="primary"
plain
icon="el-icon-refresh"
v-if="permission.priceList_refresh_price"
@click="handleRefresh"
>Refresh
</el-button>
</template>
</avue-crud> </avue-crud>
</basic-container> </basic-container>
</el-col>
</el-row>
</template> </template>
<script> <script>
import { getList, getDetail, add, update, remove } from '@/api/kiosk/priceList'; import { getList, getDetail, add, update, remove, init } from '@/api/kiosk/priceList';
import option from '@/option/kiosk/priceList'; import option from '@/option/kiosk/priceList';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import 'nprogress/nprogress.css'; import 'nprogress/nprogress.css';
import { treeOption } from '@/option/system/user';
export default { export default {
data() { data() {
return { return {
form: {}, form: {},
depts: '',
query: {}, query: {},
search: {}, search: {},
loading: true, loading: true,
initLoading: false,
page: { page: {
pageSize: 10, pageSize: 10,
currentPage: 1, currentPage: 1,
@@ -45,7 +71,10 @@ export default {
selectionList: [], selectionList: [],
option: option, option: option,
data: [], data: [],
deptOptions: [], treeDeptId: '0',
treeParentId: '0',
treeData: [],
treeOption: treeOption
}; };
}, },
computed: { computed: {
@@ -67,6 +96,14 @@ export default {
} }
}, },
methods: { methods: {
nodeClick(data) {
this.treeDeptId = data.id;
this.treeParentId = data.parentId;
this.page.currentPage = 1;
if (this.treeParentId !== '0') {
this.onLoad(this.page);
}
},
rowSave(row, done, loading) { rowSave(row, done, loading) {
add(row).then(() => { add(row).then(() => {
this.onLoad(this.page); this.onLoad(this.page);
@@ -149,7 +186,11 @@ export default {
const {} = this.query; const {} = this.query;
let values = {}; let values = {
...this.query,
...params,
deptId: this.treeDeptId
};
getList(page.currentPage, page.pageSize, values).then(res => { getList(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data; const data = res.data.data;
@@ -157,6 +198,32 @@ export default {
this.data = data.records; this.data = data.records;
this.loading = false; this.loading = false;
this.selectionClear(); this.selectionClear();
if (this.treeParentId !== '0' && this.page.currentPage === 1 && this.data.length === 0) {
this.$confirm('Price is not set for this store. Initialize now?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning'
})
.then(() => {
this.initLoading = true;
this.loading = true;
return init(this.treeDeptId);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!'
});
})
.finally(() => {
this.loading = false;
this.initLoading = false;
});
} else {
this.loading = false;
}
}); });
} }
} }