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({ const router = new Router({
mode: 'hash', mode: 'history',
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: pageRoutes.concat(moduleRoutes) 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> <template>
<div class="list-view-with-head"> <div class="main-container">
<!-- TODO: delete these demo links --> <div class="inner-sidebar">
<ul> <a href="#ongoing" :class="{ active: activeTable === '#ongoing' }">进行中的订单</a>
<li><a href="#ongoing">ongoing</a></li> <a href="#pending" :class="{ active: activeTable === '#pending' }">等待订单</a>
<li><a href="#pending">pending</a></li> <a href="#finished" :class="{ active: activeTable === '#finished' }">完成订单</a>
<li><a href="#finished">finished</a></li> </div>
</ul>
<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"> <el-pagination
<BaseSearchForm :head-config="{ fields: headConfigs.ongoingTableSearch }" @btn-click="handleBtnClick('ongoing', $event)" /> class="mt-5 flex justify-end"
<BaseListTable @size-change="handleSizeChange"
key="confirmed" @current-change="handlePageChange"
v-loading="tableLoading" :current-page.sync="page"
:table-config="null" :page-sizes="[1, 5, 10, 20, 50, 100]"
:column-config="tableConfigs.ongoingTable" :page-size="size"
:table-data="dataList" :total="totalPage"
@operate-event="handleOperate" layout="total, sizes, prev, pager, next, jumper"
@load-sub="handleLoadSub" ></el-pagination>
:refresh-layout-key="refreshLayoutKey" </section>
/>
<el-pagination <section class="pending-order" id="pending">
class="mt-5 flex justify-end" <BaseSearchForm
@size-change="handleSizeChange" head-title="等待中的订单"
@current-change="handlePageChange" :head-config="{ fields: headConfigs.pendingTableSearch }"
:current-page.sync="page" @btn-click="handleBtnClick('pending', $event)"
:page-sizes="[1, 5, 10, 20, 50, 100]" />
:page-size="size" <BaseListTable
:total="totalPage" key="unconfirmed"
layout="total, sizes, prev, pager, next, jumper" v-loading="tableLoading"
></el-pagination> :table-config="null"
</section> :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"> <section class="finished-order" id="finished">
<BaseSearchForm :head-config="{ fields: headConfigs.pendingTableSearch }" @btn-click="handleBtnClick('pending', $event)" /> <BaseSearchForm
<BaseListTable head-title="已完成订单"
key="unconfirmed" :head-config="{ fields: headConfigs.finishedTableSearch }"
v-loading="tableLoading" @btn-click="handleBtnClick('finished', $event)"
:table-config="null" />
:column-config="tableConfigs.pendingTable" <BaseListTable
:table-data="dataList" key="ended"
@operate-event="handleOperate" v-loading="tableLoading"
@load-sub="handleLoadSub" :table-config="null"
:refresh-layout-key="refreshLayoutKey" :column-config="tableConfigs.finishedTable"
/> :table-data="dataList"
<el-pagination @operate-event="handleOperate"
class="mt-5 flex justify-end" @load-sub="handleLoadSub"
@size-change="handleSizeChange" :refresh-layout-key="refreshLayoutKey"
@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"> <el-pagination
<BaseSearchForm :head-config="{ fields: headConfigs.finishedTableSearch }" @btn-click="handleBtnClick('finished', $event)" /> class="mt-5 flex justify-end"
<BaseListTable @size-change="handleSizeChange"
key="ended" @current-change="handlePageChange"
v-loading="tableLoading" :current-page.sync="page"
:table-config="null" :page-sizes="[1, 5, 10, 20, 50, 100]"
:column-config="tableConfigs.finishedTable" :page-size="size"
:table-data="dataList" :total="totalPage"
@operate-event="handleOperate" layout="total, sizes, prev, pager, next, jumper"
@load-sub="handleLoadSub" ></el-pagination>
:refresh-layout-key="refreshLayoutKey" <!-- :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" --> :page-size.sync="pageSize" -->
</section> </section>
<!-- <DialogWithMenu <!-- <DialogWithMenu
ref="edit-dialog" ref="edit-dialog"
v-if="dialogType === DIALOG_WITH_MENU" v-if="dialogType === DIALOG_WITH_MENU"
:dialog-visible.sync="dialogVisible" :dialog-visible.sync="dialogVisible"
@ -104,12 +115,13 @@
:configs="subdialogConfigs" :configs="subdialogConfigs"
@refreshDataList="handleRefreshDatalist" @refreshDataList="handleRefreshDatalist"
/> --> /> -->
</div>
</div> </div>
</template> </template>
<script> <script>
import BaseListTable from "./BaseListTable.vue"; import BaseListTable from "./BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue"; import BaseSearchForm from "./BaseSearchForm.vue";
import DialogWithMenu from "@/components/DialogWithMenu.vue"; import DialogWithMenu from "@/components/DialogWithMenu.vue";
import DialogJustForm from "./DialogJustForm.vue"; import DialogJustForm from "./DialogJustForm.vue";
@ -154,8 +166,17 @@ export default {
return this.dialogConfigs.menu ? DIALOG_WITH_MENU : DIALOG_JUST_FORM; 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() { data() {
return { return {
activeTable: "",
refreshLayoutKey: null, refreshLayoutKey: null,
DIALOG_WITH_MENU, DIALOG_WITH_MENU,
DIALOG_JUST_FORM, DIALOG_JUST_FORM,
@ -459,14 +480,51 @@ export default {
</script> </script>
<style scoped> <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 { .list-view-with-head {
background: white; background: white;
/* height: 100%; */ /* height: 100%; */
min-height: inherit; /* min-height: inherit; */
border-radius: 6px; border-radius: 6px;
box-shadow: 0 0 1.125px 0.125px rgba(0, 0, 0, 0.125); 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 { section {
padding: 16px; padding: 16px;
padding-bottom: 3.125rem; padding-bottom: 3.125rem;