diff --git a/src/views/atomViews/ListViewWithHead.vue b/src/views/atomViews/ListViewWithHead.vue index 9cce7b7..7423b28 100644 --- a/src/views/atomViews/ListViewWithHead.vue +++ b/src/views/atomViews/ListViewWithHead.vue @@ -4,22 +4,50 @@ - - - - + - - + @@ -32,7 +60,7 @@ import DialogWithMenu from "@/components/DialogWithMenu.vue"; import DialogJustForm from "@/components/DialogJustForm.vue"; import DialogCarPayload from "@/components/DialogCarPayload.vue"; import DialogUpload from "@/components/DialogUpload.vue"; -import Overlay from '@/components/Overlay.vue'; +import Overlay from "@/components/Overlay.vue"; import moment from "moment"; const DIALOG_WITH_MENU = "DialogWithMenu"; @@ -41,7 +69,15 @@ const DIALOG_CARPAYLOAD = "DialogCarPayload"; export default { name: "ListViewWithHead", - components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm, DialogCarPayload, DialogUpload, Overlay }, + components: { + BaseSearchForm, + BaseListTable, + DialogWithMenu, + DialogJustForm, + DialogCarPayload, + DialogUpload, + Overlay, + }, props: { tableConfig: { type: Object, @@ -92,7 +128,7 @@ export default { if (val && val !== oldVal) { // get list 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(); } }, @@ -113,12 +149,13 @@ export default { refreshLayoutKey: null, uploadDialogVisible: false, overlayVisible: false, + cachedSearchCondition: {} }; }, inject: ["urls"], mounted() { // 更新页面默认 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.initDataWhenLoad && this.getList(); @@ -131,9 +168,9 @@ export default { const params = queryParams ? { ...queryParams, page: this.page, limit: this.size } : { - page: this.page, - limit: this.size, - }; + page: this.page, + limit: this.size, + }; if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { this.listQueryExtra.map((nameOrObj) => { @@ -150,11 +187,11 @@ export default { this.urls.page, this.urls.pageIsPostApi ? { - ...params, - } + ...params, + } : { - params, - } + params, + } ) .then(({ data: res }) => { console.log("[http response] res is: ", res); @@ -239,7 +276,8 @@ export default { this.$message.success("删除成功!"); 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(); } else { this.$message({ @@ -250,7 +288,7 @@ export default { } }); }) - .catch((err) => { }); + .catch((err) => {}); } case "edit": { this.openDialog(data); /** data is ==> id */ @@ -316,18 +354,20 @@ export default { } case "copy": { // - let shouldShowOverlay = false - let payload = '' - console.log('copying...', type, data) - if (typeof data === 'object') { - const head = data.head - const copyOpt = ('options' in head && Array.isArray(head.options) && head.options.find(item => item.name === 'copy')) || null - if (copyOpt && 'showOverlay' in copyOpt && copyOpt.showOverlay) { - this.overlayVisible = true - shouldShowOverlay = true - payload = data.id + let shouldShowOverlay = false; + let payload = ""; + console.log("copying...", type, data); + if (typeof data === "object") { + const head = data.head; + const copyOpt = + ("options" in head && Array.isArray(head.options) && head.options.find((item) => item.name === "copy")) || + null; + if (copyOpt && "showOverlay" in copyOpt && copyOpt.showOverlay) { + this.overlayVisible = true; + shouldShowOverlay = true; + payload = data.id; } - } else payload = data + } else payload = data; return this.$http .post(this.urls.copyUrl, payload, { @@ -350,7 +390,7 @@ export default { duration: 1500, }); } - if (shouldShowOverlay) this.overlayVisible = false + if (shouldShowOverlay) this.overlayVisible = false; }) .catch((errMsg) => { this.$message({ @@ -358,7 +398,7 @@ export default { type: "error", duration: 1500, }); - if (shouldShowOverlay) this.overlayVisible = false + if (shouldShowOverlay) this.overlayVisible = false; }); } case "change-category": { @@ -450,21 +490,23 @@ export default { break; } case "sync": { - let shouldShowOverlay = false - let payload = '' - console.log('sync...', type, data) - if (typeof data === 'object') { - const head = data.head - const syncOpt = ('options' in head && Array.isArray(head.options) && head.options.find(item => item.name === 'sync')) || null - if (syncOpt && 'showOverlay' in syncOpt && syncOpt.showOverlay) { - this.overlayVisible = true - shouldShowOverlay = true - payload = data.id + let shouldShowOverlay = false; + let payload = ""; + console.log("sync...", type, data); + if (typeof data === "object") { + const head = data.head; + const syncOpt = + ("options" in head && Array.isArray(head.options) && head.options.find((item) => item.name === "sync")) || + null; + if (syncOpt && "showOverlay" in syncOpt && syncOpt.showOverlay) { + this.overlayVisible = true; + shouldShowOverlay = true; + payload = data.id; } - } else payload = data + } else payload = data; this.$message({ - message: '正在发起同步...', + message: "正在发起同步...", type: "success", }); @@ -478,10 +520,10 @@ export default { .then(({ data: res }) => { this.$message({ message: res.msg, - type: res.code === 0 ? "success" : 'error', + type: res.code === 0 ? "success" : "error", }); this.getList(); - if (shouldShowOverlay) this.overlayVisible = false + if (shouldShowOverlay) this.overlayVisible = false; }); } } @@ -507,18 +549,20 @@ export default { this.openDialog(); return; } - case "查询": { - const params = {}; + case "查询": { if (typeof payload === "object") { // BaseSearchForm 给这个组件传递了数据 - Object.assign(params, payload); - if ("timerange" in params) { - if (!!params.timerange) { + Object.assign(this.cachedSearchCondition, payload); + if ("timerange" in payload) { + if (!!payload.timerange) { const [startTime, endTime] = params["timerange"]; - params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); - params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); + this.cachedSearchCondition.startTime = moment(startTime).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) => { if (typeof cond === "string") { if (!!payload[cond]) { - params[cond] = payload[cond]; + this.cachedSearchCondition[cond] = payload[cond]; } else { - params[cond] = ""; + this.cachedSearchCondition[cond] = ""; } } else if (typeof cond === "object") { Object.keys(cond).forEach((key) => { - params[key] = cond[key]; + this.cachedSearchCondition[key] = cond[key]; }); } }); - console.log("查询", params); - this.getList(params); + console.log("查询", this.cachedSearchCondition); + this.getList(this.cachedSearchCondition); break; } case "同步": case "全部同步": this.$http.post(this.urls.syncUrl).then(({ data: 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(); }); break; @@ -556,12 +600,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */ diff --git a/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue b/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue index 1ebff94..e49ada5 100644 --- a/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue +++ b/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue @@ -3,20 +3,35 @@
- - - -
@@ -24,7 +39,7 @@ import BaseListTable from "@/components/BaseListTable.vue"; import BaseSearchForm from "@/components/BaseSearchForm.vue"; import DialogJustForm from "./edit-dialog.vue"; -import Overlay from '@/components/Overlay.vue'; +import Overlay from "@/components/Overlay.vue"; import moment from "moment"; @@ -69,7 +84,8 @@ export default { tableLoading: false, refreshLayoutKey: null, dialogBomCode: "", - overlayVisible: false + overlayVisible: false, + cachedSearchCondition: {} }; }, inject: ["urls"], @@ -84,9 +100,9 @@ export default { const params = queryParams ? { ...queryParams, page: this.page, limit: this.size } : { - page: this.page, - limit: this.size, - }; + page: this.page, + limit: this.size, + }; if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { this.listQueryExtra.map((nameOrObj) => { @@ -106,11 +122,11 @@ export default { this.urls.page, this.urls.pageIsPostApi ? { - ...params, - } + ...params, + } : { - params, - } + params, + } ) .then(({ data: res }) => { console.log("[http response] res is: ", res); @@ -187,7 +203,7 @@ export default { } }); }) - .catch((err) => { }); + .catch((err) => {}); } case "edit": { this.openDialog(data); /** data is ==> id */ @@ -211,36 +227,44 @@ export default { case "pause-blender": case "start-blender": { // 下发订单 - this.$confirm(`确定${(type === 'detach') ? '下发' : (type === 'pause-blender') ? '暂停' : '开始'}该订单吗?`, "提示", { - confirmButtonText: "确认", - cancelButtonText: "我再想想", - type: "warning", - }) - .then(() => { - this.overlayVisible = true; - const realUrl = type === 'detach' ? this.urls.detach : type === 'pause-blender' ? this.urls.pauseBlender : this.urls.startBlender - return this.$http - .post(realUrl, data /* { id: data } */, { headers: { "Content-Type": "application/json" } }) - .then(({ data: res }) => { - if (res.code === 0) { - this.$message({ - message: `${(type === 'detach') ? '下发' : (type === 'pause-blender') ? '暂停' : '开始'}成功`, - type: "success", - duration: 1500, - onClose: () => { - this.getList(); - }, - }); - } else { - this.$message({ - message: `${res.code}: ${res.msg}`, - type: "error", - duration: 1500, - }); - } - this.overlayVisible = false; - }); - }); + this.$confirm( + `确定${type === "detach" ? "下发" : type === "pause-blender" ? "暂停" : "开始"}该订单吗?`, + "提示", + { + confirmButtonText: "确认", + cancelButtonText: "我再想想", + type: "warning", + } + ).then(() => { + this.overlayVisible = true; + const realUrl = + type === "detach" + ? this.urls.detach + : type === "pause-blender" + ? this.urls.pauseBlender + : this.urls.startBlender; + return this.$http + .post(realUrl, data /* { id: data } */, { headers: { "Content-Type": "application/json" } }) + .then(({ data: res }) => { + if (res.code === 0) { + this.$message({ + message: `${type === "detach" ? "下发" : type === "pause-blender" ? "暂停" : "开始"}成功`, + type: "success", + duration: 1500, + onClose: () => { + this.getList(); + }, + }); + } else { + this.$message({ + message: `${res.code}: ${res.msg}`, + type: "error", + duration: 1500, + }); + } + this.overlayVisible = false; + }); + }); } } }, @@ -252,17 +276,20 @@ export default { this.openDialog(); break; case "查询": { - const params = {}; - /** 处理 payload 里的数据 */ if (typeof payload === "object") { // BaseSearchForm 给这个组件传递了数据 - Object.assign(params, payload); - if ("timerange" in params && !!params.timerange) { - const [startTime, endTime] = params["timerange"]; - delete params.timerange; - params.startTime = moment(startTime).format("YYYY-MM-DD HH:mm:ss"); - params.endTime = moment(endTime).format("YYYY-MM-DD HH:mm:ss"); + Object.assign(this.cachedSearchCondition, payload); + if ("timerange" in payload) { + if (!!payload.timerange) { + const [startTime, endTime] = payload["timerange"]; + this.cachedSearchCondition.startTime = moment(startTime).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 this.cachedSearchCondition.timerange; } } @@ -270,18 +297,18 @@ export default { this.listQueryExtra?.map((cond) => { if (typeof cond === "string") { if (!!payload[cond]) { - params[cond] = payload[cond]; + this.cachedSearchCondition[cond] = payload[cond]; } else { - params[cond] = ""; + this.cachedSearchCondition[cond] = ""; } } else if (typeof cond === "object") { Object.keys(cond).forEach((key) => { - params[key] = cond[key]; + this.cachedSearchCondition[key] = cond[key]; }); } }); - console.log("查询", params); - this.getList(params); + console.log("查询", this.cachedSearchCondition); + this.getList(this.cachedSearchCondition); break; } } @@ -292,12 +319,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */ diff --git a/src/views/modules/pms/carHistory/components/ListViewWithHead.vue b/src/views/modules/pms/carHistory/components/ListViewWithHead.vue index c1de553..52a05bb 100644 --- a/src/views/modules/pms/carHistory/components/ListViewWithHead.vue +++ b/src/views/modules/pms/carHistory/components/ListViewWithHead.vue @@ -4,20 +4,44 @@ - - - - - + + + @@ -106,7 +130,7 @@ export default { dataList: [], tableLoading: false, refreshLayoutKey: null, - cachedSearchCondition: {} + cachedSearchCondition: {}, }; }, inject: ["urls"], @@ -121,9 +145,9 @@ export default { const params = queryParams ? { ...queryParams, page: this.page, limit: this.size } : { - page: this.page, - limit: this.size, - }; + page: this.page, + limit: this.size, + }; if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { this.listQueryExtra.map((nameOrObj) => { @@ -143,11 +167,11 @@ export default { this.urls.page, this.urls.pageIsPostApi ? { - ...params, - } + ...params, + } : { - params, - } + params, + } ) .then(({ data: res }) => { console.log("[http response] res is: ", res); @@ -243,7 +267,7 @@ export default { } }); }) - .catch((err) => { }); + .catch((err) => {}); } case "edit": { this.openDialog(data); /** data is ==> id */ diff --git a/src/views/modules/pms/detectionPlatform/components/ListViewWithHead.vue b/src/views/modules/pms/detectionPlatform/components/ListViewWithHead.vue index d979504..e9c1d10 100644 --- a/src/views/modules/pms/detectionPlatform/components/ListViewWithHead.vue +++ b/src/views/modules/pms/detectionPlatform/components/ListViewWithHead.vue @@ -146,6 +146,7 @@ export default { tableLoading: false, refreshLayoutKey: null, updateCarPayloadKey: 1, + cachedSearchCondition: {} }; }, inject: ["urls"], @@ -468,14 +469,17 @@ export default { const params = {}; if (typeof payload === "object") { // BaseSearchForm 给这个组件传递了数据 - Object.assign(params, payload); - if ("timerange" in params) { - if (!!params.timerange) { - const [startTime, endTime] = params["timerange"]; - params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); - params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); + Object.assign(this.cachedSearchCondition, payload); + if ("timerange" in payload) { + if (!!payload.timerange) { + const [startTime, endTime] = payload["timerange"]; + this.cachedSearchCondition.startTime = moment(startTime).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) => { if (typeof cond === "string") { if (!!payload[cond]) { - params[cond] = payload[cond]; + this.cachedSearchCondition[cond] = payload[cond]; } else { - params[cond] = ""; + this.cachedSearchCondition[cond] = ""; } } else if (typeof cond === "object") { Object.keys(cond).forEach((key) => { - params[key] = cond[key]; + this.cachedSearchCondition[key] = cond[key]; }); } }); - console.log("查询", params); - this.getList(params); + console.log("查询", this.cachedSearchCondition); + this.getList(this.cachedSearchCondition); break; } @@ -513,12 +517,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */ diff --git a/src/views/modules/pms/finishedOrder/components/ListViewWithHead.vue b/src/views/modules/pms/finishedOrder/components/ListViewWithHead.vue index 9ba7e8c..755de44 100644 --- a/src/views/modules/pms/finishedOrder/components/ListViewWithHead.vue +++ b/src/views/modules/pms/finishedOrder/components/ListViewWithHead.vue @@ -4,18 +4,32 @@ - - - - - - + + @@ -102,6 +116,7 @@ export default { dataList: [], tableLoading: false, refreshLayoutKey: null, + cachedSearchCondition: {}, }; }, inject: ["urls"], @@ -116,9 +131,9 @@ export default { const params = queryParams ? { ...queryParams, page: this.page, limit: this.size } : { - page: this.page, - limit: this.size, - }; + page: this.page, + limit: this.size, + }; if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { this.listQueryExtra.map((nameOrObj) => { @@ -135,11 +150,11 @@ export default { this.urls.page, this.urls.pageIsPostApi ? { - ...params, - } + ...params, + } : { - params, - } + params, + } ) .then(({ data: res }) => { if (res.code === 0) { @@ -223,7 +238,7 @@ export default { } }); }) - .catch((err) => { }); + .catch((err) => {}); } case "edit": { this.openDialog(data); /** data is ==> id */ @@ -249,17 +264,19 @@ export default { return; } case "查询": { - const params = {}; if (typeof payload === "object") { // BaseSearchForm 给这个组件传递了数据 - Object.assign(params, payload); - if ("timerange" in params) { - if (!!params.timerange) { - const [startTime, endTime] = params["timerange"]; - params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); - params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); + Object.assign(this.cachedSearchCondition, payload); + if ("timerange" in payload) { + if (!!payload.timerange) { + const [startTime, endTime] = payload["timerange"]; + this.cachedSearchCondition.startTime = moment(startTime).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) => { if (typeof cond === "string") { if (!!payload[cond]) { - params[cond] = payload[cond]; + this.cachedSearchCondition[cond] = payload[cond]; } else { - params[cond] = ""; + this.cachedSearchCondition[cond] = ""; } } else if (typeof cond === "object") { Object.keys(cond).forEach((key) => { - params[key] = cond[key]; + this.cachedSearchCondition[key] = cond[key]; }); } }); - console.log("查询", params); - this.getList(params); + console.log("查询", this.cachedSearchCondition); + this.getList(this.cachedSearchCondition); break; } case "同步": case "全部同步": this.$http.post(this.urls.syncUrl).then(({ data: res }) => { - console.log('全部同步', res) + console.log("全部同步", res); if (res.code === 0) { - this.$message({ message: '同步成功', type: 'success' }) + this.$message({ message: "同步成功", type: "success" }); this.getList(); } }); @@ -299,20 +316,20 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */ openDialog(row, detail) { this.dialogVisible = true; - console.log("row detail", row, detail) - + console.log("row detail", row, detail); + let extraParams = null; if (this.attachListQueryExtra && this.listQueryExtra.length) { this.listQueryExtra.forEach((item) => { diff --git a/src/views/modules/pms/kilnWaitingRoom/components/ListViewWithHead.vue b/src/views/modules/pms/kilnWaitingRoom/components/ListViewWithHead.vue index eb4b98a..36a6c17 100644 --- a/src/views/modules/pms/kilnWaitingRoom/components/ListViewWithHead.vue +++ b/src/views/modules/pms/kilnWaitingRoom/components/ListViewWithHead.vue @@ -143,6 +143,7 @@ export default { dataList: [], tableLoading: false, refreshLayoutKey: null, + cachedSearchCondition: {} }; }, inject: ["urls"], @@ -462,17 +463,19 @@ export default { } case "查询": { - const params = {}; if (typeof payload === "object") { // BaseSearchForm 给这个组件传递了数据 - Object.assign(params, payload); - if ("timerange" in params) { - if (!!params.timerange) { - const [startTime, endTime] = params["timerange"]; - params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); - params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); + Object.assign(this.cachedSearchCondition, payload); + if ("timerange" in payload) { + if (!!payload.timerange) { + const [startTime, endTime] = payload["timerange"]; + this.cachedSearchCondition.startTime = moment(startTime).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) => { if (typeof cond === "string") { if (!!payload[cond]) { - params[cond] = payload[cond]; + this.cachedSearchCondition[cond] = payload[cond]; } else { - params[cond] = ""; + this.cachedSearchCondition[cond] = ""; } } else if (typeof cond === "object") { Object.keys(cond).forEach((key) => { - params[key] = cond[key]; + this.cachedSearchCondition[key] = cond[key]; }); } }); - console.log("查询", params); - this.getList(params); + console.log("查询", this.cachedSearchCondition); + this.getList(this.cachedSearchCondition); break; } @@ -510,12 +513,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */ diff --git a/src/views/modules/pms/material/components/ListViewWithHead.vue b/src/views/modules/pms/material/components/ListViewWithHead.vue index c3f187a..3a122be 100644 --- a/src/views/modules/pms/material/components/ListViewWithHead.vue +++ b/src/views/modules/pms/material/components/ListViewWithHead.vue @@ -9,23 +9,45 @@ - - - - - - + + @@ -159,6 +181,7 @@ export default { ], }, }, + cachedSearchCondition: {} }; }, inject: ["urls"], @@ -197,9 +220,9 @@ export default { const params = queryParams ? { ...queryParams, page: this.page, limit: this.size } : { - page: this.page, - limit: this.size, - }; + page: this.page, + limit: this.size, + }; if (!queryParams && this.listQueryExtra.length) { this.listQueryExtra.map((name) => { @@ -263,7 +286,7 @@ export default { } }); }) - .catch((err) => { }); + .catch((err) => {}); } case "edit": { this.openDialog(data); /** data is ==> id */ @@ -302,7 +325,7 @@ export default { handleRefreshDatalist() { // location.reload(); - this.getList() + this.getList(); }, openUploadDialog() { @@ -320,7 +343,8 @@ export default { this.openDialog(); break; case "查询": { - this.getList(payload); + Object.assign(this.cachedSearchCondition, payload) + this.getList(this.cachedSearchCondition); break; } case "导入": @@ -328,23 +352,23 @@ export default { break; case "同步": this.$message({ - message: '正在同步...', - type: 'success', - duration: 1000 - }) - this.$refs['cursor-loading-ref'].style.cursor = 'wait' + message: "正在同步...", + type: "success", + duration: 1000, + }); + this.$refs["cursor-loading-ref"].style.cursor = "wait"; return this.$http.post(this.urls.syncUrl).then(({ data: res }) => { this.$message({ message: res.msg, - type: res.code === 0 ? 'succes' : 'error', - duration: 1500 - , onClose: () => { - this.getList() - this.$refs['cursor-loading-ref'].style.cursor = 'unset' - } - }) - }) + type: res.code === 0 ? "succes" : "error", + duration: 1500, + onClose: () => { + this.getList(); + this.$refs["cursor-loading-ref"].style.cursor = "unset"; + }, + }); + }); } }, @@ -353,12 +377,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */ diff --git a/src/views/modules/pms/palletizingLine/components/ListViewWithHead.vue b/src/views/modules/pms/palletizingLine/components/ListViewWithHead.vue index e55f285..68cdf0b 100644 --- a/src/views/modules/pms/palletizingLine/components/ListViewWithHead.vue +++ b/src/views/modules/pms/palletizingLine/components/ListViewWithHead.vue @@ -146,6 +146,7 @@ export default { tableLoading: false, refreshLayoutKey: null, updateCarPayloadKey: 1, + cachedSearchCondition: {} }; }, inject: ["urls"], @@ -468,14 +469,17 @@ export default { const params = {}; if (typeof payload === "object") { // BaseSearchForm 给这个组件传递了数据 - Object.assign(params, payload); - if ("timerange" in params) { - if (!!params.timerange) { - const [startTime, endTime] = params["timerange"]; - params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); - params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); + Object.assign(this.cachedSearchCondition, payload); + if ("timerange" in payload) { + if (!!payload.timerange) { + const [startTime, endTime] = payload["timerange"]; + this.cachedSearchCondition.startTime = moment(startTime).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) => { if (typeof cond === "string") { if (!!payload[cond]) { - params[cond] = payload[cond]; + this.cachedSearchCondition[cond] = payload[cond]; } else { - params[cond] = ""; + this.cachedSearchCondition[cond] = ""; } } else if (typeof cond === "object") { Object.keys(cond).forEach((key) => { - params[key] = cond[key]; + this.cachedSearchCondition[key] = cond[key]; }); } }); - console.log("查询", params); - this.getList(params); + console.log("查询", this.cachedSearchCondition); + this.getList(this.cachedSearchCondition); break; } @@ -513,12 +517,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(); + this.getList(this.cachedSearchCondition); }, handlePageChange(val) { // val 是新值 - this.getList(); + this.getList(this.cachedSearchCondition); }, /** 打开对话框 */