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,17 +5,20 @@
**/ **/
--> -->
<template> <template>
<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"> <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>
<section class="ongoing-order" id="ongoing"> <section class="ongoing-order" id="ongoing">
<BaseSearchForm :head-config="{ fields: headConfigs.ongoingTableSearch }" @btn-click="handleBtnClick('ongoing', $event)" /> <BaseSearchForm
head-title="进行中的订单"
:head-config="{ fields: headConfigs.ongoingTableSearch }"
@btn-click="handleBtnClick('ongoing', $event)"
/>
<BaseListTable <BaseListTable
key="confirmed" key="confirmed"
v-loading="tableLoading" v-loading="tableLoading"
@ -40,7 +43,11 @@
</section> </section>
<section class="pending-order" id="pending"> <section class="pending-order" id="pending">
<BaseSearchForm :head-config="{ fields: headConfigs.pendingTableSearch }" @btn-click="handleBtnClick('pending', $event)" /> <BaseSearchForm
head-title="等待中的订单"
:head-config="{ fields: headConfigs.pendingTableSearch }"
@btn-click="handleBtnClick('pending', $event)"
/>
<BaseListTable <BaseListTable
key="unconfirmed" key="unconfirmed"
v-loading="tableLoading" v-loading="tableLoading"
@ -64,7 +71,11 @@
</section> </section>
<section class="finished-order" id="finished"> <section class="finished-order" id="finished">
<BaseSearchForm :head-config="{ fields: headConfigs.finishedTableSearch }" @btn-click="handleBtnClick('finished', $event)" /> <BaseSearchForm
head-title="已完成订单"
:head-config="{ fields: headConfigs.finishedTableSearch }"
@btn-click="handleBtnClick('finished', $event)"
/>
<BaseListTable <BaseListTable
key="ended" key="ended"
v-loading="tableLoading" v-loading="tableLoading"
@ -105,11 +116,12 @@
@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;