feat: add order

This commit is contained in:
2025-10-08 04:39:40 +08:00
parent 86a309cda0
commit a290db8b35
6 changed files with 742 additions and 1 deletions

50
src/api/kiosk/order.js Normal file
View File

@@ -0,0 +1,50 @@
import request from '@/axios';
export const getList = (current, size, params) => {
return request({
url: '/kiosk/order/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getDetail = (id) => {
return request({
url: '/kiosk/order/detail',
method: 'get',
params: {
id
}
})
}
export const remove = (ids) => {
return request({
url: '/kiosk/order/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/kiosk/order/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/kiosk/order/submit',
method: 'post',
data: row
})
}

View File

@@ -0,0 +1,50 @@
import request from '@/axios';
export const getList = (current, size, params) => {
return request({
url: '/kiosk/orderDetail/list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getDetail = (id) => {
return request({
url: '/kiosk/orderDetail/detail',
method: 'get',
params: {
id
}
})
}
export const remove = (ids) => {
return request({
url: '/kiosk/orderDetail/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/kiosk/orderDetail/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/kiosk/orderDetail/submit',
method: 'post',
data: row
})
}

120
src/option/kiosk/order.js Normal file
View File

@@ -0,0 +1,120 @@
export default {
height:'auto',
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
addBtn: true,
delBtn: false,
editBtn: false,
viewBtn: false,
selection: true,
menuWidth: 300,
column: [
{
label: "Id",
prop: "id",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "TenantId",
prop: "tenantId",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "SerialNumber",
prop: "serialNumber",
type: "input",
},
{
label: "Phone",
prop: "userPhone",
type: "input",
},
{
label: "Email",
prop: "userEmail",
type: "input",
},
{
label: "Amount",
prop: "totalAmount",
type: "input",
},
{
label: "创建人",
prop: "createUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建部门",
prop: "createDept",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建时间",
prop: "createTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改人",
prop: "updateUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改时间",
prop: "updateTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "Status",
prop: "status",
type: 'radio',
dicUrl: '/blade-system/dict-biz/dictionary?code=order_status',
props: {
label: 'dictValue',
value: 'dictKey'
},
dataType: 'number',
},
{
label: "是否已删除",
prop: "isDeleted",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
]
}

View File

@@ -0,0 +1,161 @@
export default {
height:'auto',
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: false,
addBtn: false,
delBtn: false,
editBtn: false,
selection: true,
menuWidth: 300,
column: [
{
label: "Id",
prop: "id",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "TenantId",
prop: "tenantId",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "oid",
prop: "orderId",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "cid",
prop: "categoryId",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "CategoryType",
prop: "categoryType",
type: 'radio',
dicUrl: '/blade-system/dict-biz/dictionary?code=category_type',
props: {
label: 'dictValue',
value: 'dictKey'
},
dataType: 'number',
},
{
label: "Material",
prop: "material",
type: "input",
},
{
label: "Size",
prop: "size",
type: "input",
},
{
label: "Shape",
prop: "shape",
type: "input",
},
{
label: "Snapshot",
prop: "snapshotLink",
type: 'upload',
listType: 'picture-img',
dataType: 'string',
action: '/blade-resource/oss/endpoint/put-file',
propsHttp: {
res: 'data',
url: 'link'
}
},
{
label: "Amount",
prop: "totalAmount",
type: "number",
},
{
label: "创建人",
prop: "createUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建部门",
prop: "createDept",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建时间",
prop: "createTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改人",
prop: "updateUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改时间",
prop: "updateTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "Status",
prop: "status",
type: 'radio',
dicUrl: '/blade-system/dict-biz/dictionary?code=production_status',
props: {
label: 'dictValue',
value: 'dictKey'
},
dataType: 'number',
},
{
label: "是否已删除",
prop: "isDeleted",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
]
}

View File

@@ -120,7 +120,7 @@ export default {
});
},
rowDel(row) {
this.$confirm('Confirmation for Delete?', {
this.$confirm('Confirmation for delete?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning'

360
src/views/kiosk/order.vue Normal file
View File

@@ -0,0 +1,360 @@
<template>
<basic-container>
<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"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@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="danger"
icon="el-icon-delete"
plain
v-if="permission.order_delete"
@click="handleDelete">Delete
</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="`[${orderName}${orderId}] Detail`" v-model="subVisible" :direction="direction" append-to-body
:before-close="handleSubClose" size="80%">
<basic-container>
<avue-crud :option="optionSub"
:data="dataSub"
v-model:page="pageSub"
v-model="formSub"
:table-loading="loadingSub"
ref="crudSub"
@row-del="rowDelSub"
@row-update="rowUpdateSub"
@row-save="rowSaveSub"
: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>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/kiosk/order';
import {
getList as getListSub,
getDetail as getDetailSub,
add as addSub,
update as updateSub,
remove as removeSub
} from '@/api/kiosk/orderDetail';
import option from '@/option/kiosk/order';
import optionSub from '@/option/kiosk/orderDetail';
import { mapGetters } from 'vuex';
import 'nprogress/nprogress.css';
export default {
data() {
return {
form: {},
query: {},
search: {},
loading: true,
data: [],
selectionList: [],
page: {
pageSize: 10,
currentPage: 1,
total: 0
},
option: option,
subVisible: false,
direction: 'ttb',
orderId: 0,
serialNumber: '',
orderName: 'KioskOrder:',
formSub: {},
querySub: {},
loadingSub: true,
dataSub: [],
selectionListSub: [],
pageSub: {
pageSize: 10,
currentPage: 1,
total: 0
},
optionSub: optionSub
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.order_add, false),
viewBtn: this.validData(this.permission.order_view, false),
delBtn: this.validData(this.permission.order_delete, false),
editBtn: this.validData(this.permission.order_edit, false)
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
subIds() {
let ids = [];
this.selectionListSub.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
}
},
methods: {
// 主表模块
rowSave(row, done, loading) {
add(row).then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!'
});
done();
}, error => {
window.console.log(error);
loading();
});
},
rowUpdate(row, index, done, loading) {
update(row).then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!'
});
done();
}, error => {
window.console.log(error);
loading();
});
},
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!'
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('Please select one or more');
return;
}
this.$confirm('Confirmation for delete?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning'
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!'
});
this.$refs.crud.toggleSelection();
});
},
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;
},
onLoad(page, params = {}) {
this.loading = true;
const {} = this.query;
let values = {};
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();
});
},
// 子表模块
handleDataSub(row) {
this.subVisible = true;
this.orderId = row.id;
this.serialNumber = row.serialNumber;
this.onLoadSub(this.pageSub);
},
handleSubClose(hide) {
hide();
},
rowSaveSub(row, loading, done) {
row = {
...row,
orderId: this.orderId
};
addSub(row).then(() => {
loading();
this.onLoadSub(this.pageSub);
this.$message({
type: 'success',
message: 'Success!'
});
}, error => {
done();
window.console.log(error);
});
},
rowUpdateSub(row, index, loading, done) {
row = {
...row,
orderId: this.orderId
};
updateSub(row).then(() => {
loading();
this.onLoadSub(this.pageSub);
this.$message({
type: 'success',
message: 'Success!'
});
}, error => {
done();
window.console.log(error);
});
},
rowDelSub(row) {
this.$confirm('Confirmation for delete?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning'
})
.then(() => {
return removeSub(row.id);
})
.then(() => {
this.onLoadSub(this.pageSub);
this.$message({
type: 'success',
message: 'Success!'
});
});
},
beforeOpenSub(done, type) {
if (['edit', 'view'].includes(type)) {
getDetailSub(this.formSub.id).then(res => {
this.formSub = res.data.data;
});
}
done();
},
searchResetSub() {
this.querySub = {};
this.onLoadSub(this.pageSub);
},
searchChangeSub(params) {
this.querySub = params;
this.onLoadSub(this.pageSub, params);
},
selectionChangeSub(list) {
this.selectionListSub = list;
},
currentChangeSub(currentPage) {
this.pageSub.currentPage = currentPage;
},
sizeChangeSub(pageSize) {
this.pageSub.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoadSub(page, params = {}) {
this.loadingSub = true;
let values = {
orderId: this.orderId
};
const {} = this.querySub;
values = {
...values
};
getListSub(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data;
this.pageSub.total = data.total;
this.dataSub = data.records;
this.selectionListSub = [];
this.loadingSub = false;
});
}
}
};
</script>
<style>
</style>