update 查询条件没应用上的问题
This commit is contained in:
@@ -4,22 +4,50 @@
|
||||
<!-- <head-form :form-config="headFormConfig" @headBtnClick="btnClick" /> -->
|
||||
<BaseSearchForm :head-config="headConfig" @btn-click="handleBtnClick" />
|
||||
|
||||
<BaseListTable v-loading="tableLoading" :table-config="tableConfig.table" :column-config="tableConfig.column"
|
||||
:table-data="dataList" @operate-event="handleOperate" :current-page="page" :current-size="size"
|
||||
<BaseListTable
|
||||
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" />
|
||||
|
||||
<el-pagination 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"
|
||||
<el-pagination
|
||||
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>
|
||||
|
||||
<DialogWithMenu ref="edit-dialog" v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU"
|
||||
: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"
|
||||
<DialogWithMenu
|
||||
ref="edit-dialog"
|
||||
v-if="!!dialogConfigs && dialogType === DIALOG_WITH_MENU"
|
||||
: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" />
|
||||
<DialogCarPayload ref="car-payload-dialog" v-if="!!carPayloadDialogConfigs"
|
||||
:dialog-visible.sync="carPayloadDialogVisible" :configs="carPayloadDialogConfigs" @refreshDataList="getList" />
|
||||
<DialogUpload ref="upload-dialog" v-if="uploadDialogVisible" title="导入配方" filename="bomTemplate.xlsx"
|
||||
<DialogCarPayload
|
||||
ref="car-payload-dialog"
|
||||
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" />
|
||||
<Overlay v-if="overlayVisible" />
|
||||
</div>
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
/** 打开对话框 */
|
||||
|
||||
Reference in New Issue
Block a user