update:
fix bugs
This commit is contained in:
333
src/views/kiosk/priceList-bak.vue
Normal file
333
src/views/kiosk/priceList-bak.vue
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
<template>
|
||||||
|
<el-row v-loading="initLoading">
|
||||||
|
<el-col :span="5">
|
||||||
|
<div class="box">
|
||||||
|
<el-scrollbar>
|
||||||
|
<basic-container>
|
||||||
|
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
|
||||||
|
</basic-container>
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="19">
|
||||||
|
<basic-container>
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<el-tag effect="dark">{{ deptName || 'Please select dept from left side' }}</el-tag>
|
||||||
|
</div>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
v-model:search="search"
|
||||||
|
v-model:page="page"
|
||||||
|
v-model="form"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
ref="crud"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
v-if="permission.priceList_sync"
|
||||||
|
@click="handleSync"
|
||||||
|
>Sync
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="{row}">
|
||||||
|
<el-button type="text"
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click.stop="handleDataSub(row)">Detail
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-drawer :title="`[${categoryName}] Detail`" v-model="subVisible" :direction="direction"
|
||||||
|
append-to-body
|
||||||
|
:before-close="handleSubClose" size="90%">
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud :option="optionSub"
|
||||||
|
:data="dataSub"
|
||||||
|
v-model:page="pageSub"
|
||||||
|
v-model="formSub"
|
||||||
|
:table-loading="loadingSub"
|
||||||
|
ref="crudSub"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
:before-open="beforeOpenSub"
|
||||||
|
@search-change="searchChangeSub"
|
||||||
|
@search-reset="searchResetSub"
|
||||||
|
@selection-change="selectionChangeSub"
|
||||||
|
@current-change="currentChangeSub"
|
||||||
|
@size-change="sizeChangeSub"
|
||||||
|
@on-load="onLoadSub">
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</el-drawer>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { add, getDetail, getList, getSubList, init, remove, update } from '@/api/kiosk/priceList';
|
||||||
|
import option from '@/option/kiosk/priceListSummary';
|
||||||
|
import optionSub from '@/option/kiosk/priceList';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import 'nprogress/nprogress.css';
|
||||||
|
import { treeOption } from '@/option/system/user';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
search: {},
|
||||||
|
loading: true,
|
||||||
|
initLoading: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 30,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: option,
|
||||||
|
subVisible: false,
|
||||||
|
direction: 'rtl',
|
||||||
|
data: [],
|
||||||
|
treeDeptId: 0,
|
||||||
|
treeParentId: 0,
|
||||||
|
categoryId: 0,
|
||||||
|
categoryName: '',
|
||||||
|
treeData: [],
|
||||||
|
treeOption: treeOption,
|
||||||
|
deptName: '',
|
||||||
|
formSub: {},
|
||||||
|
querySub: {},
|
||||||
|
loadingSub: false,
|
||||||
|
dataSub: [],
|
||||||
|
selectionListSub: [],
|
||||||
|
pageSub: {
|
||||||
|
pageSize: 30,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
optionSub: optionSub,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.priceList_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.priceList_view, false),
|
||||||
|
delBtn: this.validData(this.permission.priceList_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.priceList_edit, false)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
nodeClick(data) {
|
||||||
|
this.treeDeptId = data.id;
|
||||||
|
this.treeParentId = data.parentId;
|
||||||
|
this.deptName = data.title;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
if (this.treeParentId !== '0') {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!'
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
}, error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(() => {
|
||||||
|
this.onLoadSub(this.pageSub);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!'
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
}, error => {
|
||||||
|
loading();
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('Confirmation for Delete?', {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
const {} = this.query;
|
||||||
|
|
||||||
|
let values = {
|
||||||
|
...this.query,
|
||||||
|
...params,
|
||||||
|
deptId: this.treeDeptId
|
||||||
|
};
|
||||||
|
getList(page.currentPage, page.pageSize, values).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSubClose(hide) {
|
||||||
|
this.querySub = {};
|
||||||
|
hide();
|
||||||
|
},
|
||||||
|
beforeOpenSub(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.formSub.id).then(res => {
|
||||||
|
this.formSub = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchChangeSub(params, done) {
|
||||||
|
this.querySub = params;
|
||||||
|
this.onLoadSub(this.pageSub, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
onLoadSub(page, params = {}) {
|
||||||
|
this.loadingSub = true;
|
||||||
|
|
||||||
|
let values = {
|
||||||
|
...params,
|
||||||
|
categoryId: this.categoryId,
|
||||||
|
deptId: this.treeDeptId,
|
||||||
|
};
|
||||||
|
getSubList(page.currentPage, page.pageSize, Object.assign(values, this.querySub)).then(res => {
|
||||||
|
this.dataSub = res.data.data;
|
||||||
|
this.selectionListSub = [];
|
||||||
|
this.loadingSub = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetSub() {
|
||||||
|
this.querySub = {};
|
||||||
|
this.onLoadSub(this.pageSub);
|
||||||
|
},
|
||||||
|
selectionChangeSub(list) {
|
||||||
|
this.selectionListSub = list;
|
||||||
|
},
|
||||||
|
currentChangeSub(currentPage) {
|
||||||
|
this.pageSub.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeSub(pageSize) {
|
||||||
|
this.pageSub.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
handleDataSub(row) {
|
||||||
|
this.subVisible = true;
|
||||||
|
this.categoryId = row.categoryId;
|
||||||
|
this.categoryName = row.categoryName;
|
||||||
|
this.onLoadSub(this.pageSub);
|
||||||
|
},
|
||||||
|
handleSync(){
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-row v-loading="initLoading">
|
<el-row v-loading="initLoading">
|
||||||
<el-col :span="5">
|
<!-- <el-col :span="5">-->
|
||||||
<div class="box">
|
<!-- <div class="box">-->
|
||||||
<el-scrollbar>
|
<!-- <el-scrollbar>-->
|
||||||
<basic-container>
|
<!-- <basic-container>-->
|
||||||
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
|
<!-- <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />-->
|
||||||
</basic-container>
|
<!-- </basic-container>-->
|
||||||
</el-scrollbar>
|
<!-- </el-scrollbar>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</el-col>
|
<!-- </el-col>-->
|
||||||
<el-col :span="19">
|
<el-col :span="19">
|
||||||
<basic-container>
|
<basic-container>
|
||||||
<div style="margin-bottom: 20px;">
|
<!-- <div style="margin-bottom: 20px;">-->
|
||||||
<el-tag effect="dark">{{ deptName || 'Please select dept from left side' }}</el-tag>
|
<!-- <el-tag effect="dark">{{ deptName || 'Please select dept from left side' }}</el-tag>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
<avue-crud
|
<avue-crud
|
||||||
:option="option"
|
:option="option"
|
||||||
v-model:search="search"
|
v-model:search="search"
|
||||||
@@ -32,16 +32,16 @@
|
|||||||
@refresh-change="refreshChange"
|
@refresh-change="refreshChange"
|
||||||
@on-load="onLoad"
|
@on-load="onLoad"
|
||||||
>
|
>
|
||||||
<template #menu-left>
|
<!-- <template #menu-left>-->
|
||||||
<el-button
|
<!-- <el-button-->
|
||||||
type="primary"
|
<!-- type="primary"-->
|
||||||
plain
|
<!-- plain-->
|
||||||
icon="el-icon-refresh"
|
<!-- icon="el-icon-refresh"-->
|
||||||
v-if="permission.priceList_sync"
|
<!-- v-if="permission.priceList_sync"-->
|
||||||
@click="handleSync"
|
<!-- @click="handleSync"-->
|
||||||
>Sync
|
<!-- >Sync-->
|
||||||
</el-button>
|
<!-- </el-button>-->
|
||||||
</template>
|
<!-- </template>-->
|
||||||
<template #menu="{row}">
|
<template #menu="{row}">
|
||||||
<el-button type="text"
|
<el-button type="text"
|
||||||
icon="el-icon-setting"
|
icon="el-icon-setting"
|
||||||
@@ -103,7 +103,7 @@ export default {
|
|||||||
subVisible: false,
|
subVisible: false,
|
||||||
direction: 'rtl',
|
direction: 'rtl',
|
||||||
data: [],
|
data: [],
|
||||||
treeDeptId: 0,
|
treeDeptId: -1,
|
||||||
treeParentId: 0,
|
treeParentId: 0,
|
||||||
categoryId: 0,
|
categoryId: 0,
|
||||||
categoryName: '',
|
categoryName: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user