update 查询条件没应用上的问题

This commit is contained in:
lb 2023-04-23 17:03:01 +08:00
parent c38da0f205
commit c371516064
8 changed files with 402 additions and 255 deletions

View File

@ -4,22 +4,50 @@
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> --> <!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" /> <BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column" <BaseListTable
:table-data="dataList" @operate-event="handleOperate" :current-page="page" :current-size="size" v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
:current-page="page"
:current-size="size"
:refresh-layout-key="refreshLayoutKey" /> :refresh-layout-key="refreshLayoutKey" />
<el-pagination class="mt-5 flex justify-end" @size-change="handleSizeChange" @current-change="handlePageChange" <el-pagination
:current-page.sync="page" :page-sizes="[10, 20, 50, 100]" :page-size="size" :total="totalPage" class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"></el-pagination> layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<DialogWithMenu ref="edit-dialog" v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU" <DialogWithMenu
:dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> ref="edit-dialog"
<DialogJustForm ref="edit-dialog" v-if="!!dialogConfigs && dialogType === DIALOG_JUST_FORM" v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU"
:dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" :dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList" />
<DialogJustForm
ref="edit-dialog"
v-if="!!dialogConfigs && dialogType === DIALOG_JUST_FORM"
:dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList"
@emit-data="handleOperate" /> @emit-data="handleOperate" />
<DialogCarPayload ref="car-payload-dialog" v-if="!!carPayloadDialogConfigs" <DialogCarPayload
:dialog-visible.sync="carPayloadDialogVisible" :configs="carPayloadDialogConfigs" @refreshDataList="getList" /> ref="car-payload-dialog"
<DialogUpload ref="upload-dialog" v-if="uploadDialogVisible" title="导入配方" filename="bomTemplate.xlsx" v-if="!!carPayloadDialogConfigs"
:dialog-visible.sync="carPayloadDialogVisible"
:configs="carPayloadDialogConfigs"
@refreshDataList="getList" />
<DialogUpload
ref="upload-dialog"
v-if="uploadDialogVisible"
title="导入配方"
filename="bomTemplate.xlsx"
@refresh-list="getList" /> @refresh-list="getList" />
<Overlay v-if="overlayVisible" /> <Overlay v-if="overlayVisible" />
</div> </div>
@ -32,7 +60,7 @@ import DialogWithMenu from "@/components/DialogWithMenu.vue";
import DialogJustForm from "@/components/DialogJustForm.vue"; import DialogJustForm from "@/components/DialogJustForm.vue";
import DialogCarPayload from "@/components/DialogCarPayload.vue"; import DialogCarPayload from "@/components/DialogCarPayload.vue";
import DialogUpload from "@/components/DialogUpload.vue"; import DialogUpload from "@/components/DialogUpload.vue";
import Overlay from '@/components/Overlay.vue'; import Overlay from "@/components/Overlay.vue";
import moment from "moment"; import moment from "moment";
const DIALOG_WITH_MENU = "DialogWithMenu"; const DIALOG_WITH_MENU = "DialogWithMenu";
@ -41,7 +69,15 @@ const DIALOG_CARPAYLOAD = "DialogCarPayload";
export default { export default {
name: "ListViewWithHead", name: "ListViewWithHead",
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm, DialogCarPayload, DialogUpload, Overlay }, components: {
BaseSearchForm,
BaseListTable,
DialogWithMenu,
DialogJustForm,
DialogCarPayload,
DialogUpload,
Overlay,
},
props: { props: {
tableConfig: { tableConfig: {
type: Object, type: Object,
@ -92,7 +128,7 @@ export default {
if (val && val !== oldVal) { if (val && val !== oldVal) {
// get list // get list
this.page = 1; this.page = 1;
this.size = 'defaultPageSize' in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20; this.size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
this.getList(); this.getList();
} }
}, },
@ -113,12 +149,13 @@ export default {
refreshLayoutKey: null, refreshLayoutKey: null,
uploadDialogVisible: false, uploadDialogVisible: false,
overlayVisible: false, overlayVisible: false,
cachedSearchCondition: {}
}; };
}, },
inject: ["urls"], inject: ["urls"],
mounted() { mounted() {
// size // size
const size = 'defaultPageSize' in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20; const size = "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
this.size = size; this.size = size;
this.initDataWhenLoad && this.getList(); this.initDataWhenLoad && this.getList();
@ -131,9 +168,9 @@ export default {
const params = queryParams const params = queryParams
? { ...queryParams, page: this.page, limit: this.size } ? { ...queryParams, page: this.page, limit: this.size }
: { : {
page: this.page, page: this.page,
limit: this.size, limit: this.size,
}; };
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.map((nameOrObj) => { this.listQueryExtra.map((nameOrObj) => {
@ -150,11 +187,11 @@ export default {
this.urls.page, this.urls.page,
this.urls.pageIsPostApi this.urls.pageIsPostApi
? { ? {
...params, ...params,
} }
: { : {
params, params,
} }
) )
.then(({ data: res }) => { .then(({ data: res }) => {
console.log("[http response] res is: ", res); console.log("[http response] res is: ", res);
@ -239,7 +276,8 @@ export default {
this.$message.success("删除成功!"); this.$message.success("删除成功!");
this.page = 1; this.page = 1;
this.size = 'defaultPageSize' in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20; this.size =
"defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20;
this.getList(); this.getList();
} else { } else {
this.$message({ this.$message({
@ -250,7 +288,7 @@ export default {
} }
}); });
}) })
.catch((err) => { }); .catch((err) => {});
} }
case "edit": { case "edit": {
this.openDialog(data); /** data is ==> id */ this.openDialog(data); /** data is ==> id */
@ -316,18 +354,20 @@ export default {
} }
case "copy": { case "copy": {
// //
let shouldShowOverlay = false let shouldShowOverlay = false;
let payload = '' let payload = "";
console.log('copying...', type, data) console.log("copying...", type, data);
if (typeof data === 'object') { if (typeof data === "object") {
const head = data.head const head = data.head;
const copyOpt = ('options' in head && Array.isArray(head.options) && head.options.find(item => item.name === 'copy')) || null const copyOpt =
if (copyOpt && 'showOverlay' in copyOpt && copyOpt.showOverlay) { ("options" in head && Array.isArray(head.options) && head.options.find((item) => item.name === "copy")) ||
this.overlayVisible = true null;
shouldShowOverlay = true if (copyOpt && "showOverlay" in copyOpt && copyOpt.showOverlay) {
payload = data.id this.overlayVisible = true;
shouldShowOverlay = true;
payload = data.id;
} }
} else payload = data } else payload = data;
return this.$http return this.$http
.post(this.urls.copyUrl, payload, { .post(this.urls.copyUrl, payload, {
@ -350,7 +390,7 @@ export default {
duration: 1500, duration: 1500,
}); });
} }
if (shouldShowOverlay) this.overlayVisible = false if (shouldShowOverlay) this.overlayVisible = false;
}) })
.catch((errMsg) => { .catch((errMsg) => {
this.$message({ this.$message({
@ -358,7 +398,7 @@ export default {
type: "error", type: "error",
duration: 1500, duration: 1500,
}); });
if (shouldShowOverlay) this.overlayVisible = false if (shouldShowOverlay) this.overlayVisible = false;
}); });
} }
case "change-category": { case "change-category": {
@ -450,21 +490,23 @@ export default {
break; break;
} }
case "sync": { case "sync": {
let shouldShowOverlay = false let shouldShowOverlay = false;
let payload = '' let payload = "";
console.log('sync...', type, data) console.log("sync...", type, data);
if (typeof data === 'object') { if (typeof data === "object") {
const head = data.head const head = data.head;
const syncOpt = ('options' in head && Array.isArray(head.options) && head.options.find(item => item.name === 'sync')) || null const syncOpt =
if (syncOpt && 'showOverlay' in syncOpt && syncOpt.showOverlay) { ("options" in head && Array.isArray(head.options) && head.options.find((item) => item.name === "sync")) ||
this.overlayVisible = true null;
shouldShowOverlay = true if (syncOpt && "showOverlay" in syncOpt && syncOpt.showOverlay) {
payload = data.id this.overlayVisible = true;
shouldShowOverlay = true;
payload = data.id;
} }
} else payload = data } else payload = data;
this.$message({ this.$message({
message: '正在发起同步...', message: "正在发起同步...",
type: "success", type: "success",
}); });
@ -478,10 +520,10 @@ export default {
.then(({ data: res }) => { .then(({ data: res }) => {
this.$message({ this.$message({
message: res.msg, message: res.msg,
type: res.code === 0 ? "success" : 'error', type: res.code === 0 ? "success" : "error",
}); });
this.getList(); this.getList();
if (shouldShowOverlay) this.overlayVisible = false if (shouldShowOverlay) this.overlayVisible = false;
}); });
} }
} }
@ -507,18 +549,20 @@ export default {
this.openDialog(); this.openDialog();
return; return;
} }
case "查询": { case "查询": {
const params = {};
if (typeof payload === "object") { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload); Object.assign(this.cachedSearchCondition, payload);
if ("timerange" in params) { if ("timerange" in payload) {
if (!!params.timerange) { if (!!payload.timerange) {
const [startTime, endTime] = params["timerange"]; const [startTime, endTime] = params["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
} else {
delete this.cachedSearchCondition.startTime;
delete this.cachedSearchCondition.endTime;
} }
delete params.timerange; delete this.cachedSearchCondition.timerange;
} }
} }
@ -526,25 +570,25 @@ export default {
this.listQueryExtra?.map((cond) => { this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") { if (typeof cond === "string") {
if (!!payload[cond]) { if (!!payload[cond]) {
params[cond] = payload[cond]; this.cachedSearchCondition[cond] = payload[cond];
} else { } else {
params[cond] = ""; this.cachedSearchCondition[cond] = "";
} }
} else if (typeof cond === "object") { } else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => { Object.keys(cond).forEach((key) => {
params[key] = cond[key]; this.cachedSearchCondition[key] = cond[key];
}); });
} }
}); });
console.log("查询", params); console.log("查询", this.cachedSearchCondition);
this.getList(params); this.getList(this.cachedSearchCondition);
break; break;
} }
case "同步": case "同步":
case "全部同步": case "全部同步":
this.$http.post(this.urls.syncUrl).then(({ data: res }) => { this.$http.post(this.urls.syncUrl).then(({ data: res }) => {
console.log("同步", res); console.log("同步", res);
this.$message({ message: res.msg, type: res.code === 0 ? "success" : 'error' }); this.$message({ message: res.msg, type: res.code === 0 ? "success" : "error" });
this.getList(); this.getList();
}); });
break; break;
@ -556,12 +600,12 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */

View File

@ -3,20 +3,35 @@
<div class="list-view-with-head"> <div class="list-view-with-head">
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" /> <BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column" <BaseListTable
:table-data="dataList" @operate-event="handleOperate" :current-page="page" :current-size="size" v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
:current-page="page"
:current-size="size"
:refresh-layout-key="refreshLayoutKey" /> :refresh-layout-key="refreshLayoutKey" />
<el-pagination class="mt-5 flex justify-end" @size-change="handleSizeChange" @current-change="handlePageChange" <el-pagination
:current-page.sync="page" :page-sizes="[1, 5, 10, 20, 50, 100]" :page-size="size" :total="totalPage" 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> layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<DialogJustForm ref="edit-dialog" v-if="!!dialogConfigs" :dialog-visible.sync="dialogVisible" :configs="dialogConfigs" <DialogJustForm
ref="edit-dialog"
v-if="!!dialogConfigs"
:dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList" /> @refreshDataList="getList" />
<!-- :bom-code="dialogBomCode" --> <!-- :bom-code="dialogBomCode" -->
<Overlay v-if="overlayVisible" /> <Overlay v-if="overlayVisible" />
</div> </div>
</template> </template>
@ -24,7 +39,7 @@
import BaseListTable from "@/components/BaseListTable.vue"; import BaseListTable from "@/components/BaseListTable.vue";
import BaseSearchForm from "@/components/BaseSearchForm.vue"; import BaseSearchForm from "@/components/BaseSearchForm.vue";
import DialogJustForm from "./edit-dialog.vue"; import DialogJustForm from "./edit-dialog.vue";
import Overlay from '@/components/Overlay.vue'; import Overlay from "@/components/Overlay.vue";
import moment from "moment"; import moment from "moment";
@ -69,7 +84,8 @@ export default {
tableLoading: false, tableLoading: false,
refreshLayoutKey: null, refreshLayoutKey: null,
dialogBomCode: "", dialogBomCode: "",
overlayVisible: false overlayVisible: false,
cachedSearchCondition: {}
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -84,9 +100,9 @@ export default {
const params = queryParams const params = queryParams
? { ...queryParams, page: this.page, limit: this.size } ? { ...queryParams, page: this.page, limit: this.size }
: { : {
page: this.page, page: this.page,
limit: this.size, limit: this.size,
}; };
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.map((nameOrObj) => { this.listQueryExtra.map((nameOrObj) => {
@ -106,11 +122,11 @@ export default {
this.urls.page, this.urls.page,
this.urls.pageIsPostApi this.urls.pageIsPostApi
? { ? {
...params, ...params,
} }
: { : {
params, params,
} }
) )
.then(({ data: res }) => { .then(({ data: res }) => {
console.log("[http response] res is: ", res); console.log("[http response] res is: ", res);
@ -187,7 +203,7 @@ export default {
} }
}); });
}) })
.catch((err) => { }); .catch((err) => {});
} }
case "edit": { case "edit": {
this.openDialog(data); /** data is ==> id */ this.openDialog(data); /** data is ==> id */
@ -211,36 +227,44 @@ export default {
case "pause-blender": case "pause-blender":
case "start-blender": { case "start-blender": {
// //
this.$confirm(`确定${(type === 'detach') ? '下发' : (type === 'pause-blender') ? '暂停' : '开始'}该订单吗?`, "提示", { this.$confirm(
confirmButtonText: "确认", `确定${type === "detach" ? "下发" : type === "pause-blender" ? "暂停" : "开始"}该订单吗?`,
cancelButtonText: "我再想想", "提示",
type: "warning", {
}) confirmButtonText: "确认",
.then(() => { cancelButtonText: "我再想想",
this.overlayVisible = true; type: "warning",
const realUrl = type === 'detach' ? this.urls.detach : type === 'pause-blender' ? this.urls.pauseBlender : this.urls.startBlender }
return this.$http ).then(() => {
.post(realUrl, data /* { id: data } */, { headers: { "Content-Type": "application/json" } }) this.overlayVisible = true;
.then(({ data: res }) => { const realUrl =
if (res.code === 0) { type === "detach"
this.$message({ ? this.urls.detach
message: `${(type === 'detach') ? '下发' : (type === 'pause-blender') ? '暂停' : '开始'}成功`, : type === "pause-blender"
type: "success", ? this.urls.pauseBlender
duration: 1500, : this.urls.startBlender;
onClose: () => { return this.$http
this.getList(); .post(realUrl, data /* { id: data } */, { headers: { "Content-Type": "application/json" } })
}, .then(({ data: res }) => {
}); if (res.code === 0) {
} else { this.$message({
this.$message({ message: `${type === "detach" ? "下发" : type === "pause-blender" ? "暂停" : "开始"}成功`,
message: `${res.code}: ${res.msg}`, type: "success",
type: "error", duration: 1500,
duration: 1500, onClose: () => {
}); this.getList();
} },
this.overlayVisible = false; });
}); } else {
}); this.$message({
message: `${res.code}: ${res.msg}`,
type: "error",
duration: 1500,
});
}
this.overlayVisible = false;
});
});
} }
} }
}, },
@ -252,17 +276,20 @@ export default {
this.openDialog(); this.openDialog();
break; break;
case "查询": { case "查询": {
const params = {};
/** 处理 payload 里的数据 */ /** 处理 payload 里的数据 */
if (typeof payload === "object") { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload); Object.assign(this.cachedSearchCondition, payload);
if ("timerange" in params && !!params.timerange) { if ("timerange" in payload) {
const [startTime, endTime] = params["timerange"]; if (!!payload.timerange) {
delete params.timerange; const [startTime, endTime] = payload["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DD HH:mm:ss"); this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DD HH:mm:ss"); this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
} else {
delete this.cachedSearchCondition.startTime;
delete this.cachedSearchCondition.endTime;
}
delete this.cachedSearchCondition.timerange;
} }
} }
@ -270,18 +297,18 @@ export default {
this.listQueryExtra?.map((cond) => { this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") { if (typeof cond === "string") {
if (!!payload[cond]) { if (!!payload[cond]) {
params[cond] = payload[cond]; this.cachedSearchCondition[cond] = payload[cond];
} else { } else {
params[cond] = ""; this.cachedSearchCondition[cond] = "";
} }
} else if (typeof cond === "object") { } else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => { Object.keys(cond).forEach((key) => {
params[key] = cond[key]; this.cachedSearchCondition[key] = cond[key];
}); });
} }
}); });
console.log("查询", params); console.log("查询", this.cachedSearchCondition);
this.getList(params); this.getList(this.cachedSearchCondition);
break; break;
} }
} }
@ -292,12 +319,12 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */

View File

@ -4,20 +4,44 @@
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> --> <!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" /> <BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column" <BaseListTable
:table-data="dataList" @operate-event="handleOperate" :current-page="page" :current-size="size" v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
:current-page="page"
:current-size="size"
:refresh-layout-key="refreshLayoutKey" /> :refresh-layout-key="refreshLayoutKey" />
<el-pagination class="mt-5 flex justify-end" @size-change="handleSizeChange" @current-change="handlePageChange" <el-pagination
:current-page.sync="page" :page-sizes="[20, 50, 100]" :page-size="size" :total="totalPage" class="mt-5 flex justify-end"
@size-change="handleSizeChange"
@current-change="handlePageChange"
:current-page.sync="page"
:page-sizes="[20, 50, 100]"
:page-size="size"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"></el-pagination> layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<DialogWithMenu ref="edit-dialog" v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU" <DialogWithMenu
:dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> ref="edit-dialog"
<DialogJustForm ref="edit-dialog" v-if="!!dialogConfigs && dialogType === DIALOG_JUST_FORM" v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU"
:dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> :dialog-visible.sync="dialogVisible"
<DialogCarPayload ref="car-payload-dialog" v-if="!!carPayloadDialogConfigs" :configs="dialogConfigs"
:dialog-visible.sync="carPayloadDialogVisible" :configs="carPayloadDialogConfigs" @refreshDataList="getList" /> @refreshDataList="getList" />
<DialogJustForm
ref="edit-dialog"
v-if="!!dialogConfigs && dialogType === DIALOG_JUST_FORM"
:dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList" />
<DialogCarPayload
ref="car-payload-dialog"
v-if="!!carPayloadDialogConfigs"
:dialog-visible.sync="carPayloadDialogVisible"
:configs="carPayloadDialogConfigs"
@refreshDataList="getList" />
</div> </div>
</template> </template>
@ -106,7 +130,7 @@ export default {
dataList: [], dataList: [],
tableLoading: false, tableLoading: false,
refreshLayoutKey: null, refreshLayoutKey: null,
cachedSearchCondition: {} cachedSearchCondition: {},
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -121,9 +145,9 @@ export default {
const params = queryParams const params = queryParams
? { ...queryParams, page: this.page, limit: this.size } ? { ...queryParams, page: this.page, limit: this.size }
: { : {
page: this.page, page: this.page,
limit: this.size, limit: this.size,
}; };
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.map((nameOrObj) => { this.listQueryExtra.map((nameOrObj) => {
@ -143,11 +167,11 @@ export default {
this.urls.page, this.urls.page,
this.urls.pageIsPostApi this.urls.pageIsPostApi
? { ? {
...params, ...params,
} }
: { : {
params, params,
} }
) )
.then(({ data: res }) => { .then(({ data: res }) => {
console.log("[http response] res is: ", res); console.log("[http response] res is: ", res);
@ -243,7 +267,7 @@ export default {
} }
}); });
}) })
.catch((err) => { }); .catch((err) => {});
} }
case "edit": { case "edit": {
this.openDialog(data); /** data is ==> id */ this.openDialog(data); /** data is ==> id */

View File

@ -146,6 +146,7 @@ export default {
tableLoading: false, tableLoading: false,
refreshLayoutKey: null, refreshLayoutKey: null,
updateCarPayloadKey: 1, updateCarPayloadKey: 1,
cachedSearchCondition: {}
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -468,14 +469,17 @@ export default {
const params = {}; const params = {};
if (typeof payload === "object") { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload); Object.assign(this.cachedSearchCondition, payload);
if ("timerange" in params) { if ("timerange" in payload) {
if (!!params.timerange) { if (!!payload.timerange) {
const [startTime, endTime] = params["timerange"]; const [startTime, endTime] = payload["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
} else {
delete this.cachedSearchCondition.startTime;
delete this.cachedSearchCondition.endTime;
} }
delete params.timerange; delete this.cachedSearchCondition.timerange;
} }
} }
@ -483,18 +487,18 @@ export default {
this.listQueryExtra?.map((cond) => { this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") { if (typeof cond === "string") {
if (!!payload[cond]) { if (!!payload[cond]) {
params[cond] = payload[cond]; this.cachedSearchCondition[cond] = payload[cond];
} else { } else {
params[cond] = ""; this.cachedSearchCondition[cond] = "";
} }
} else if (typeof cond === "object") { } else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => { Object.keys(cond).forEach((key) => {
params[key] = cond[key]; this.cachedSearchCondition[key] = cond[key];
}); });
} }
}); });
console.log("查询", params); console.log("查询", this.cachedSearchCondition);
this.getList(params); this.getList(this.cachedSearchCondition);
break; break;
} }
@ -513,12 +517,12 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */

View File

@ -4,18 +4,32 @@
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> --> <!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" /> <BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column" <BaseListTable
:table-data="dataList" @operate-event="handleOperate" :current-page="page" :current-size="size" v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
:current-page="page"
:current-size="size"
:refresh-layout-key="refreshLayoutKey" /> :refresh-layout-key="refreshLayoutKey" />
<el-pagination class="mt-5 flex justify-end" @size-change="handleSizeChange" @current-change="handlePageChange" <el-pagination
:current-page.sync="page" :page-sizes="[1, 5, 10, 20, 50, 100]" :page-size="size" :total="totalPage" 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> layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<DialogWithMenu ref="edit-dialog" v-if="!!dialogConfigs && dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> <DialogWithMenu
<!-- :dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> --> ref="edit-dialog"
v-if="!!dialogConfigs && dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList" />
<!-- :dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> -->
</div> </div>
</template> </template>
@ -102,6 +116,7 @@ export default {
dataList: [], dataList: [],
tableLoading: false, tableLoading: false,
refreshLayoutKey: null, refreshLayoutKey: null,
cachedSearchCondition: {},
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -116,9 +131,9 @@ export default {
const params = queryParams const params = queryParams
? { ...queryParams, page: this.page, limit: this.size } ? { ...queryParams, page: this.page, limit: this.size }
: { : {
page: this.page, page: this.page,
limit: this.size, limit: this.size,
}; };
if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.map((nameOrObj) => { this.listQueryExtra.map((nameOrObj) => {
@ -135,11 +150,11 @@ export default {
this.urls.page, this.urls.page,
this.urls.pageIsPostApi this.urls.pageIsPostApi
? { ? {
...params, ...params,
} }
: { : {
params, params,
} }
) )
.then(({ data: res }) => { .then(({ data: res }) => {
if (res.code === 0) { if (res.code === 0) {
@ -223,7 +238,7 @@ export default {
} }
}); });
}) })
.catch((err) => { }); .catch((err) => {});
} }
case "edit": { case "edit": {
this.openDialog(data); /** data is ==> id */ this.openDialog(data); /** data is ==> id */
@ -249,17 +264,19 @@ export default {
return; return;
} }
case "查询": { case "查询": {
const params = {};
if (typeof payload === "object") { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload); Object.assign(this.cachedSearchCondition, payload);
if ("timerange" in params) { if ("timerange" in payload) {
if (!!params.timerange) { if (!!payload.timerange) {
const [startTime, endTime] = params["timerange"]; const [startTime, endTime] = payload["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
} else {
delete this.cachedSearchCondition.startTime;
delete this.cachedSearchCondition.endTime;
} }
delete params.timerange; delete this.cachedSearchCondition.timerange;
} }
} }
@ -267,26 +284,26 @@ export default {
this.listQueryExtra?.map((cond) => { this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") { if (typeof cond === "string") {
if (!!payload[cond]) { if (!!payload[cond]) {
params[cond] = payload[cond]; this.cachedSearchCondition[cond] = payload[cond];
} else { } else {
params[cond] = ""; this.cachedSearchCondition[cond] = "";
} }
} else if (typeof cond === "object") { } else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => { Object.keys(cond).forEach((key) => {
params[key] = cond[key]; this.cachedSearchCondition[key] = cond[key];
}); });
} }
}); });
console.log("查询", params); console.log("查询", this.cachedSearchCondition);
this.getList(params); this.getList(this.cachedSearchCondition);
break; break;
} }
case "同步": case "同步":
case "全部同步": case "全部同步":
this.$http.post(this.urls.syncUrl).then(({ data: res }) => { this.$http.post(this.urls.syncUrl).then(({ data: res }) => {
console.log('全部同步', res) console.log("全部同步", res);
if (res.code === 0) { if (res.code === 0) {
this.$message({ message: '同步成功', type: 'success' }) this.$message({ message: "同步成功", type: "success" });
this.getList(); this.getList();
} }
}); });
@ -299,20 +316,20 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */
openDialog(row, detail) { openDialog(row, detail) {
this.dialogVisible = true; this.dialogVisible = true;
console.log("row detail", row, detail) console.log("row detail", row, detail);
let extraParams = null; let extraParams = null;
if (this.attachListQueryExtra && this.listQueryExtra.length) { if (this.attachListQueryExtra && this.listQueryExtra.length) {
this.listQueryExtra.forEach((item) => { this.listQueryExtra.forEach((item) => {

View File

@ -143,6 +143,7 @@ export default {
dataList: [], dataList: [],
tableLoading: false, tableLoading: false,
refreshLayoutKey: null, refreshLayoutKey: null,
cachedSearchCondition: {}
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -462,17 +463,19 @@ export default {
} }
case "查询": { case "查询": {
const params = {};
if (typeof payload === "object") { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload); Object.assign(this.cachedSearchCondition, payload);
if ("timerange" in params) { if ("timerange" in payload) {
if (!!params.timerange) { if (!!payload.timerange) {
const [startTime, endTime] = params["timerange"]; const [startTime, endTime] = payload["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
} else {
delete this.cachedSearchCondition.startTime;
delete this.cachedSearchCondition.endTime;
} }
delete params.timerange; delete this.cachedSearchCondition.timerange;
} }
} }
@ -480,18 +483,18 @@ export default {
this.listQueryExtra?.map((cond) => { this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") { if (typeof cond === "string") {
if (!!payload[cond]) { if (!!payload[cond]) {
params[cond] = payload[cond]; this.cachedSearchCondition[cond] = payload[cond];
} else { } else {
params[cond] = ""; this.cachedSearchCondition[cond] = "";
} }
} else if (typeof cond === "object") { } else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => { Object.keys(cond).forEach((key) => {
params[key] = cond[key]; this.cachedSearchCondition[key] = cond[key];
}); });
} }
}); });
console.log("查询", params); console.log("查询", this.cachedSearchCondition);
this.getList(params); this.getList(this.cachedSearchCondition);
break; break;
} }
@ -510,12 +513,12 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */

View File

@ -9,23 +9,45 @@
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> --> <!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" /> <BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column" <BaseListTable
:table-data="dataList" @operate-event="handleOperate" @load-sub="handleLoadSub" v-loading="tableLoading"
:table-config="tableConfig.table"
:column-config="tableConfig.column"
:table-data="dataList"
@operate-event="handleOperate"
@load-sub="handleLoadSub"
:refresh-layout-key="refreshLayoutKey" /> :refresh-layout-key="refreshLayoutKey" />
<el-pagination class="mt-5 flex justify-end" @size-change="handleSizeChange" @current-change="handlePageChange" <el-pagination
:current-page.sync="page" :page-sizes="[1, 5, 10, 20, 50, 100]" :page-size="size" :total="totalPage" 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> layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<!-- :current-page.sync="currentPage" <!-- :current-page.sync="currentPage"
:page-size.sync="pageSize" --> :page-size.sync="pageSize" -->
<DialogWithMenu ref="edit-dialog" v-if="dialogType === DIALOG_WITH_MENU" :dialog-visible.sync="dialogVisible" <DialogWithMenu
:configs="dialogConfigs" @refreshDataList="handleRefreshDatalist" /> ref="edit-dialog"
v-if="dialogType === DIALOG_WITH_MENU"
<DialogJustForm ref="add-sub-dialog" :dialog-visible.sync="subdialogVisible" :configs="subdialogConfigs" :dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="handleRefreshDatalist" /> @refreshDataList="handleRefreshDatalist" />
<DialogUpload ref="upload-dialog" v-if="uploadDialogVisible" title="导入原料" filename="bomTemplate.xlsx" <DialogJustForm
ref="add-sub-dialog"
:dialog-visible.sync="subdialogVisible"
:configs="subdialogConfigs"
@refreshDataList="handleRefreshDatalist" />
<DialogUpload
ref="upload-dialog"
v-if="uploadDialogVisible"
title="导入原料"
filename="bomTemplate.xlsx"
@refresh-list="getList" /> @refresh-list="getList" />
</div> </div>
</template> </template>
@ -159,6 +181,7 @@ export default {
], ],
}, },
}, },
cachedSearchCondition: {}
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -197,9 +220,9 @@ export default {
const params = queryParams const params = queryParams
? { ...queryParams, page: this.page, limit: this.size } ? { ...queryParams, page: this.page, limit: this.size }
: { : {
page: this.page, page: this.page,
limit: this.size, limit: this.size,
}; };
if (!queryParams && this.listQueryExtra.length) { if (!queryParams && this.listQueryExtra.length) {
this.listQueryExtra.map((name) => { this.listQueryExtra.map((name) => {
@ -263,7 +286,7 @@ export default {
} }
}); });
}) })
.catch((err) => { }); .catch((err) => {});
} }
case "edit": { case "edit": {
this.openDialog(data); /** data is ==> id */ this.openDialog(data); /** data is ==> id */
@ -302,7 +325,7 @@ export default {
handleRefreshDatalist() { handleRefreshDatalist() {
// location.reload(); // location.reload();
this.getList() this.getList();
}, },
openUploadDialog() { openUploadDialog() {
@ -320,7 +343,8 @@ export default {
this.openDialog(); this.openDialog();
break; break;
case "查询": { case "查询": {
this.getList(payload); Object.assign(this.cachedSearchCondition, payload)
this.getList(this.cachedSearchCondition);
break; break;
} }
case "导入": case "导入":
@ -328,23 +352,23 @@ export default {
break; break;
case "同步": case "同步":
this.$message({ this.$message({
message: '正在同步...', message: "正在同步...",
type: 'success', type: "success",
duration: 1000 duration: 1000,
}) });
this.$refs['cursor-loading-ref'].style.cursor = 'wait' this.$refs["cursor-loading-ref"].style.cursor = "wait";
return this.$http.post(this.urls.syncUrl).then(({ data: res }) => { return this.$http.post(this.urls.syncUrl).then(({ data: res }) => {
this.$message({ this.$message({
message: res.msg, message: res.msg,
type: res.code === 0 ? 'succes' : 'error', type: res.code === 0 ? "succes" : "error",
duration: 1500 duration: 1500,
, onClose: () => { onClose: () => {
this.getList() this.getList();
this.$refs['cursor-loading-ref'].style.cursor = 'unset' this.$refs["cursor-loading-ref"].style.cursor = "unset";
} },
}) });
}) });
} }
}, },
@ -353,12 +377,12 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */

View File

@ -146,6 +146,7 @@ export default {
tableLoading: false, tableLoading: false,
refreshLayoutKey: null, refreshLayoutKey: null,
updateCarPayloadKey: 1, updateCarPayloadKey: 1,
cachedSearchCondition: {}
}; };
}, },
inject: ["urls"], inject: ["urls"],
@ -468,14 +469,17 @@ export default {
const params = {}; const params = {};
if (typeof payload === "object") { if (typeof payload === "object") {
// BaseSearchForm // BaseSearchForm
Object.assign(params, payload); Object.assign(this.cachedSearchCondition, payload);
if ("timerange" in params) { if ("timerange" in payload) {
if (!!params.timerange) { if (!!payload.timerange) {
const [startTime, endTime] = params["timerange"]; const [startTime, endTime] = payload["timerange"];
params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss");
params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); this.cachedSearchCondition.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss");
} else {
delete this.cachedSearchCondition.startTime;
delete this.cachedSearchCondition.endTime;
} }
delete params.timerange; delete this.cachedSearchCondition.timerange;
} }
} }
@ -483,18 +487,18 @@ export default {
this.listQueryExtra?.map((cond) => { this.listQueryExtra?.map((cond) => {
if (typeof cond === "string") { if (typeof cond === "string") {
if (!!payload[cond]) { if (!!payload[cond]) {
params[cond] = payload[cond]; this.cachedSearchCondition[cond] = payload[cond];
} else { } else {
params[cond] = ""; this.cachedSearchCondition[cond] = "";
} }
} else if (typeof cond === "object") { } else if (typeof cond === "object") {
Object.keys(cond).forEach((key) => { Object.keys(cond).forEach((key) => {
params[key] = cond[key]; this.cachedSearchCondition[key] = cond[key];
}); });
} }
}); });
console.log("查询", params); console.log("查询", this.cachedSearchCondition);
this.getList(params); this.getList(this.cachedSearchCondition);
break; break;
} }
@ -513,12 +517,12 @@ export default {
// val // val
this.page = 1; this.page = 1;
this.size = val; this.size = val;
this.getList(); this.getList(this.cachedSearchCondition);
}, },
handlePageChange(val) { handlePageChange(val) {
// val // val
this.getList(); this.getList(this.cachedSearchCondition);
}, },
/** 打开对话框 */ /** 打开对话框 */