update order

This commit is contained in:
lb 2023-03-08 14:25:19 +08:00
parent af69a4d53f
commit bbfd450c9f
3 changed files with 337 additions and 82 deletions

View File

@ -73,7 +73,7 @@ export function addDynamicRoute (routeParams, router) {
}
const router = new Router({
mode: 'hash',
mode: 'history',
scrollBehavior: () => ({ y: 0 }),
routes: pageRoutes.concat(moduleRoutes)
})

View File

@ -0,0 +1,197 @@
<template>
<div class="base-search-form">
<div class="brand-color-line"><span style="">{{ headTitle }}</span></div>
<div class="actual-form">
<el-form :inline="true" :model="dataForm" :rules="headConfig.rules">
<!-- <el-col :span="opt.span ? +opt.span : 4" v-for="opt in options" :key="opt.id"> -->
<el-form-item
v-for="(opt, index) in headConfig.fields"
:key="opt.prop"
:label="opt.label ? opt.label : null"
:prop="opt.prop ?? '' + index"
:rules="opt.bind?.rules ? opt.bind.rules : undefined"
>
<el-input v-if="opt.input" v-model="dataForm[opt.prop]" v-bind="opt.bind" clearable size="small" />
<el-select v-if="opt.select" v-model="dataForm[opt.prop]" v-bind="opt.bind" clearable size="small">
<el-option v-for="item in opt.select" :key="item.value + Math.random().toString()" :label="item.label" :value="item.value" />
</el-select>
<el-date-picker v-if="opt.timerange" v-model="dataForm[opt.prop]" v-bind="opt.bind" clearable size="small" />
<el-upload
v-if="opt.upload"
size="small"
:key="'upload_' + Math.random().toString()"
class="inline-block pl-3"
action="https://jsonplaceholder.typicode.com/posts/"
>
<el-button type="primary">上传文件</el-button>
</el-upload>
<el-button
v-if="opt.button && (!opt.button.permission || $hasPermission(opt.button.permission))"
:key="'button' + Math.random().toString()"
size="small"
:type="opt.button.type"
v-bind="opt.bind"
@click="handleBtnClick(opt.button.name)"
>{{ opt.button.name }}</el-button
>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
export default {
name: "BaseSearchForm",
props: {
headConfig: {
type: Object,
default: () => ({}),
},
headTitle: {
type: String,
default: '',
},
},
data() {
return {
dataForm: {},
};
},
// watch ......
// watch: {
// dataForm: {
// handler: (val) => {
// console.log("[BaseSearchForm::watcher::dataForm]", val);
// },
// deep: true,
// },
// },
created() {},
mounted() {
console.log("[BaseSearchForm] configs:", JSON.parse(JSON.stringify(this.headConfig)));
this.headConfig.fields.forEach((field, index) => {
// field.prop
if (!field.prop) return;
if (!this.dataForm[field.prop]) {
this.$set(this.dataForm, field.prop, null);
}
if (field.default) {
// default value input
this.dataForm[field.prop] = field.default.value;
}
//
if (!field.watch && field.fn && typeof field.fn === "function") {
const optionLabel = field.fieldOptionLabel;
const optionValue = field.fieldOptionValue;
//
field.fn().then(({ data: res }) => {
if (res.code === 0 && res.data) {
// TODO:
if ("list" in res.data) {
this.$set(
field,
"select",
res.data.list.map((item) => ({
label: optionLabel ? item[optionLabel] : item.name,
value: optionValue ? item[optionValue] : item.id,
}))
);
}
} else {
this.$message({
message: `${field.label} 数据获取出错: ${res.code} - ${res.msg}`,
type: "error",
duration: 1500,
});
}
});
}
// field.watch ===> watch prop
// TODO: ...
if (field.watch) {
// const { index: innerIdx, condition } = field.watch;
// console.log("=====field.watch=====", innerIdx, this.searchForm[innerIdx], this.headConfig.fields[innerIdx].default);
// //
// this.$watch(
// () => this.searchForm[innerIdx],
// (val) => {
// const queryParams = { [condition]: val };
// // field.watch.condition.forEach(c => {
// // queryParams
// // })
// this.$http(field.url, queryParams).then((res) => {
// console.log("[==>] !!!", queryParams, res);
// // index
// this.searchForm[index] = Math.floor(Math.random() * 10);
// });
// }
// );
// console.log("[BaseSearchForm] mounted(): ", this.searchForm);
// //
// if (this.searchForm[innerIdx]) {
// // TODO: ...
// console.log("TODO: ...");
// } else {
// console.log("TODO: ...");
// }
}
});
},
methods: {
handleBtnClick(name) {
this.$emit("btn-click", { btnName: name, payload: this.dataForm });
},
},
};
</script>
<style scoped>
.base-search-form {
/* display: flex; */
/* align-items: center; */
/* position: relative; */
}
.brand-color-line {
position: relative;
/* background: red; */
/* margin-top: 10px; */
height: 20px;
margin-bottom: 12px;
}
.brand-color-line span {
display: inline-block;
height: 100%;
padding: 2px 0;
margin-left: 14px;
line-height: 1;
}
.brand-color-line::before {
display: inline-block;
position: absolute;
content: "";
top: 0;
left: 0;
width: 6px;
height: 100%;
border-radius: 2px;
background: #0b58ff;
/* margin-right: 8px; */
/* position: absolute; */
}
.actual-form >>> .el-form-item {
margin-bottom: 8px;
}
</style>

View File

@ -5,92 +5,103 @@
**/
-->
<template>
<div class="list-view-with-head">
<!-- TODO: delete these demo links -->
<ul>
<li><a href="#ongoing">ongoing</a></li>
<li><a href="#pending">pending</a></li>
<li><a href="#finished">finished</a></li>
</ul>
<div class="main-container">
<div class="inner-sidebar">
<a href="#ongoing" :class="{ active: activeTable === '#ongoing' }">进行中的订单</a>
<a href="#pending" :class="{ active: activeTable === '#pending' }">等待订单</a>
<a href="#finished" :class="{ active: activeTable === '#finished' }">完成订单</a>
</div>
<div class="list-view-with-head">
<section class="ongoing-order" id="ongoing">
<BaseSearchForm
head-title="进行中的订单"
:head-config="{ fields: headConfigs.ongoingTableSearch }"
@btn-click="handleBtnClick('ongoing', $event)"
/>
<BaseListTable
key="confirmed"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfigs.ongoingTable"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey"
/>
<section class="ongoing-order" id="ongoing">
<BaseSearchForm :head-config="{ fields: headConfigs.ongoingTableSearch }" @btn-click="handleBtnClick('ongoing', $event)" />
<BaseListTable
key="confirmed"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfigs.ongoingTable"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
</section>
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
</section>
<section class="pending-order" id="pending">
<BaseSearchForm
head-title="等待中的订单"
:head-config="{ fields: headConfigs.pendingTableSearch }"
@btn-click="handleBtnClick('pending', $event)"
/>
<BaseListTable
key="unconfirmed"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfigs.pendingTable"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
</section>
<section class="pending-order" id="pending">
<BaseSearchForm :head-config="{ fields: headConfigs.pendingTableSearch }" @btn-click="handleBtnClick('pending', $event)" />
<BaseListTable
key="unconfirmed"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfigs.pendingTable"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
</section>
<section class="finished-order" id="finished">
<BaseSearchForm
head-title="已完成订单"
:head-config="{ fields: headConfigs.finishedTableSearch }"
@btn-click="handleBtnClick('finished', $event)"
/>
<BaseListTable
key="ended"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfigs.finishedTable"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey"
/>
<section class="finished-order" id="finished">
<BaseSearchForm :head-config="{ fields: headConfigs.finishedTableSearch }" @btn-click="handleBtnClick('finished', $event)" />
<BaseListTable
key="ended"
v-loading="tableLoading"
:table-config="null"
:column-config="tableConfigs.finishedTable"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey"
/>
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<!-- :current-page.sync="currentPage"
<el-pagination
class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[1, 5, 10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<!-- :current-page.sync="currentPage"
:page-size.sync="pageSize" -->
</section>
</section>
<!-- <DialogWithMenu
<!-- <DialogWithMenu
ref="edit-dialog"
v-if="dialogType === DIALOG_WITH_MENU"
:dialog-visible.sync="dialogVisible"
@ -104,12 +115,13 @@
:configs="subdialogConfigs"
@refreshDataList="handleRefreshDatalist"
/> -->
</div>
</div>
</template>
<script>
import BaseListTable from "./BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue";
import BaseSearchForm from "./BaseSearchForm.vue";
import DialogWithMenu from "@/components/DialogWithMenu.vue";
import DialogJustForm from "./DialogJustForm.vue";
@ -154,8 +166,17 @@ export default {
return this.dialogConfigs.menu ? DIALOG_WITH_MENU : DIALOG_JUST_FORM;
},
},
watch: {
$route: function (route) {
if (route.hash) {
console.log("acitive hash", route.hash);
this.activeTable = route.hash;
}
},
},
data() {
return {
activeTable: "",
refreshLayoutKey: null,
DIALOG_WITH_MENU,
DIALOG_JUST_FORM,
@ -459,14 +480,51 @@ export default {
</script>
<style scoped>
.main-container {
min-height: inherit;
display: flex;
}
.inner-sidebar {
position: fixed;
width: 240px;
margin-right: 16px;
padding: 8px 0;
/* min-height: inherit; */
display: flex;
flex-direction: column;
align-items: center;
}
.inner-sidebar a {
text-decoration: unset;
color: #777c;
padding: 12px;
width: 100%;
text-align: center;
}
.inner-sidebar a.active,
.inner-sidebar a:hover {
background-color: #f5f7fa;
color: #000;
}
.inner-sidebar,
.list-view-with-head {
background: white;
/* height: 100%; */
min-height: inherit;
/* min-height: inherit; */
border-radius: 6px;
box-shadow: 0 0 1.125px 0.125px rgba(0, 0, 0, 0.125);
}
.list-view-with-head {
width: 1px;
margin-left: 256px;
flex-grow: 1;
}
section {
padding: 16px;
padding-bottom: 3.125rem;