From 3adabb68b8a28b22185d672d63fc1262795965f5 Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 17 Aug 2023 16:28:36 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=8A=A5=E5=B7=A5=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReportDialog.vue | 201 ++++++++++++++++++ src/views/atomViews/ListViewWithHead.vue | 124 +++++------ .../modules/pms/carOrderReport/config.js | 18 +- .../modules/pms/carOrderReport/index.vue | 17 +- 4 files changed, 285 insertions(+), 75 deletions(-) create mode 100644 src/components/ReportDialog.vue diff --git a/src/components/ReportDialog.vue b/src/components/ReportDialog.vue new file mode 100644 index 0000000..05f2785 --- /dev/null +++ b/src/components/ReportDialog.vue @@ -0,0 +1,201 @@ + + + + + + + + + diff --git a/src/views/atomViews/ListViewWithHead.vue b/src/views/atomViews/ListViewWithHead.vue index fee7d5e..f17c156 100644 --- a/src/views/atomViews/ListViewWithHead.vue +++ b/src/views/atomViews/ListViewWithHead.vue @@ -63,6 +63,12 @@ + + @@ -77,6 +83,7 @@ import Overlay from "@/components/Overlay.vue"; import moment from "moment"; import AttachmentDialog from "@/components/attachmentDialog.vue"; import PrintDom from "../../components/PrintDom.vue"; +import ReportDialog from "../../components/ReportDialog.vue"; const DIALOG_WITH_MENU = "DialogWithMenu"; const DIALOG_JUST_FORM = "DialogJustForm"; @@ -94,6 +101,7 @@ export default { Overlay, AttachmentDialog, PrintDom, + ReportDialog, }, props: { navigator: { @@ -181,6 +189,8 @@ export default { needAttachmentDialog: false, tableSelectedIds: [], printDOMmount: false, + queryParams: {}, + carReportDialogVisible: false, }; }, inject: ["urls"], @@ -190,6 +200,20 @@ export default { "defaultPageSize" in this.tableConfig.column ? this.tableConfig.column.defaultPageSize : 20; this.size = size; + // 如果设置了 listQueryExtra,就合并到 queryParams + if (this.listQueryExtra && Array.isArray(this.listQueryExtra)) { + this.listQueryExtra.map((item) => { + if (typeof item === "string") this.$set(this.queryParams, item, ""); + else if (typeof item === "object") { + Object.keys(item).forEach((key) => { + this.$set(this.queryParams, key, item[key]); + }); + } + }); + } + + console.log("this.queryParams is: ", JSON.stringify(this.queryParams)); + this.initDataWhenLoad && this.getList(); }, methods: { @@ -204,27 +228,18 @@ export default { limit: this.size, }; - if (!queryParams && this.listQueryExtra && this.listQueryExtra.length) { - this.listQueryExtra.map((nameOrObj) => { - if (typeof nameOrObj === "string") params[nameOrObj] = ""; - else if (typeof nameOrObj === "object") { - Object.keys(nameOrObj).forEach((key) => { - params[key] = nameOrObj[key]; - }); - } - }); - this.cachedSearchCondition = Object.assign({}, params); - } - - console.log("[http request] params is: ", params); this.$http[this.urls.pageIsPostApi ? "post" : "get"]( this.urls.page, this.urls.pageIsPostApi ? { + ...this.queryParams, ...params, } : { - params, + params: { + ...this.queryParams, + ...params, + }, } ) .then(({ data: res }) => { @@ -233,14 +248,6 @@ export default { if (res.code === 0) { // page 场景: if ("list" in res.data) { - // if (res.data.list.length == 0 && res.data.total != 0) { - // // refresh list - // if (this.page > 1) { - // this.page -= 1 - // this.getList() - // return - // } else return - // } /** 破碎记录的特殊需求:数据要结合单位 material + materialUnitDictValue */ if ("attachDictValue" in this.tableConfig.column) { this.dataList = res.data.list.map((row) => { @@ -249,12 +256,6 @@ export default { }); } else this.dataList = res.data.list; - this.totalPage = res.data.total; - } else if ("records" in res.data) { - this.dataList = res.data.records.map((item) => ({ - ...item, - id: item._id ?? item.id, - })); this.totalPage = res.data.total; } else if (Array.isArray(res.data)) { this.dataList = res.data; @@ -659,38 +660,34 @@ export default { return; } case "查询": { - if (typeof payload === "object") { - /** 必须先处理 listQueryExtra 里的数据 */ - this.listQueryExtra?.map((cond) => { - if (typeof cond === "string") { - if (!!payload[cond]) { - this.cachedSearchCondition[cond] = payload[cond]; - } else { - this.cachedSearchCondition[cond] = ""; - } - } else if (typeof cond === "object") { - Object.keys(cond).forEach((key) => { - this.cachedSearchCondition[key] = cond[key]; - }); - } - }); - // 再处理 payload 里的数据,用于刷新 上面的 数据 - 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; + const params = Object.assign({}, 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"); + } else { + params.startTime = null; + params.endTime = null; } + delete params.timerange; } - console.log("查询", this.cachedSearchCondition); - this.getList(this.cachedSearchCondition); + // console.log( + // "查询 params", + // JSON.stringify({ + // // ...this.queryParams, + // ...params, + // }) + // ); + + this.queryParams = { + ...this.queryParams, + ...params, + }; + + this.getList(); break; } case "同步": @@ -727,11 +724,18 @@ export default { // }) this.tableSelectedIds.forEach(async (id) => { await this.printOnce(id); - }) + }); }) .catch((err) => { this.$message.error(`批量打印出错: ${err}`); }); + case "报工": + console.log("报工ids:", this.tableSelectedIds); + this.carReportDialogVisible = true; + this.$nextTick(() => { + this.$refs['car-report-dialog'].init(); + }); + break; } }, @@ -752,12 +756,12 @@ export default { // val 是新值 this.page = 1; this.size = val; - this.getList(this.cachedSearchCondition); + this.getList(); }, handlePageChange(val) { // val 是新值 - this.getList(this.cachedSearchCondition); + this.getList(); }, /** 打开对话框 */ diff --git a/src/views/modules/pms/carOrderReport/config.js b/src/views/modules/pms/carOrderReport/config.js index 7d26ab5..d69b78f 100644 --- a/src/views/modules/pms/carOrderReport/config.js +++ b/src/views/modules/pms/carOrderReport/config.js @@ -39,7 +39,7 @@ export default function () { width: 90, subcomponent: TableOperaionComponent, options: [ - { name: "edit", label: "编辑", icon: "edit-outline" }, + { name: "edit", label: "编辑", icon: "edit-outline", enable: row => row.report == 0 }, // { // name: "delete", // icon: "delete", @@ -196,14 +196,14 @@ export default function () { elparams: { placeholder: "请输入报废数量" }, }, ], - [ - { - richInput: true, - label: "描述信息", - prop: "description", - }, - ], - [{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], + // [ + // { + // richInput: true, + // label: "描述信息", + // prop: "description", + // }, + // ], + // [{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], ], operations: [ { diff --git a/src/views/modules/pms/carOrderReport/index.vue b/src/views/modules/pms/carOrderReport/index.vue index 64a7f8f..c9bdaae 100644 --- a/src/views/modules/pms/carOrderReport/index.vue +++ b/src/views/modules/pms/carOrderReport/index.vue @@ -9,6 +9,7 @@