add 报工预览

This commit is contained in:
lb 2023-08-17 16:28:36 +08:00
parent 725fa19bd1
commit 3adabb68b8
4 changed files with 285 additions and 75 deletions

View File

@ -0,0 +1,201 @@
<!--
filename: ReportDialog.vue
author: liubin
date: 2023-08-17 14:46:32
description: 报工弹窗
-->
<template>
<el-dialog
:visible.sync="visible"
width="700px"
v-bind="$attrs"
@close="close"
@closed="$emit('destroy')"
custom-class="pms-dialog">
<!-- :class="{ 'pms-dialog--rotate-down': startLeave }"> -->
<span slot="title" class="dialog-title">报工预览</span>
<transition class="l" mode="out-in">
<BaseListTable
v-if="mode.includes('table')"
v-loading="loading"
:column-config="tableProps"
:table-data="dataList"
@operate-event="handleOperate"
:current-page="page"
:current-size="size" />
<form action="#" v-if="mode.includes('form')">
<h1>编辑</h1>
<el-button type="text" size="small" @click="mode = 'table'">返回</el-button>
</form>
</transition>
<div slot="footer" class="dialog-footer">
<el-button size="small" @click="close">取消</el-button>
<el-button size="small" type="primary" @click="handleConfirm">确定</el-button>
</div>
</el-dialog>
</template>
<script>
import BaseListTable from "@/components/BaseListTable.vue";
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
export default {
name: "ReportDialog",
components: { BaseListTable },
props: ["ids"],
data() {
return {
mode: "table",
visible: false,
loading: false,
dataList: [],
page: 1,
tableProps: [
{ prop: "orderCode", label: "订单号" },
{ prop: "orderCate", label: "订单子号" },
{ width: 90, prop: "qty", label: "生产量" },
{ width: 90, prop: "goodqty", label: "合格数量" },
{ width: 90, prop: "badqty", label: "报废数量" },
{ width: 90, prop: "badratio", label: "报废率", filter: (val) => (val ?? "-") + "%" },
{
width: 64,
prop: "team",
label: "班次",
filter: (val) => (val != null ? ["早班", "中班", "晚班"][val] : "-"),
},
{
prop: "operations",
name: "操作",
fixed: "right",
width: 90,
subcomponent: TableOperaionComponent,
options: [
{ name: "edit", label: "编辑", icon: "edit-outline" },
// {
// name: "delete",
// icon: "delete",
// label: "",
// emitFull: true,
// permission: "pms:carOrderReport:delete",
// },
],
},
],
};
},
computed: {
size() {
return this.dataList.length;
},
},
methods: {
async init() {
this.visible = true;
this.loading = true;
const { data: res } = await this.$http.post("/pms/workReport/pressReportPre", {
datas: [],
ids: this.ids,
});
if (res.code === 0) {
this.dataList = res.data.map((item) => ({
...item,
qty: item.goodqty + item.badqty,
}));
console.log("this.datalist", this.dataList);
}
this.loading = false;
},
close() {
this.visible = false;
},
handleOperate({ type, data }) {
console.log("payload", type, data);
switch (type) {
case "edit":
this.mode = "form";
break;
}
},
handleConfirm() {},
},
};
</script>
<style scoped>
.dialog-just-form >>> .dialog-title {
}
.dialog-just-form >>> .el-dialog__body {
/* padding-top: 16px !important;
padding-bottom: 16px !important; */
padding-top: 0 !important;
padding-bottom: 0 !important;
}
.el-select,
.el-cascader,
.el-date-editor {
width: 100% !important;
}
.dialog-just-form >>> .el-dialog__header {
padding: 10px 20px 10px;
/* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */
}
</style>
<style>
.pms-dialog {
box-shadow: 0 0 24px 8px rgba(0, 0, 0, 0.125);
border-radius: 4px;
transition: transform 1.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
.pms-dialog .el-dialog__header {
padding: 16px;
border-bottom: 1px solid #eaeaea;
}
.pms-dialog .el-dialog__header .dialog-title {
font-size: 1.2rem;
}
.pms-dialog .el-dialog__body {
padding: 0;
overflow-x: hidden;
}
.pms-dialog .el-dialog__footer {
background: #fafafa;
min-height: 3.2rem;
padding: 0;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
text-align: unset;
display: flex;
justify-content: flex-end;
padding: 8px 16px;
align-items: center;
}
.v-enter,
.v-leave-to {
opacity: 0;
/* transform: translateX(20px); */
transform: scale(0);
}
.v-enter-active,
.v-leave-active {
transition: all 0.3s;
}
.v-enter-to,
.v-leave {
/* transform: translateX(0); */
transform: scale(1);
}
</style>

View File

@ -63,6 +63,12 @@
<Overlay v-if="overlayVisible" />
<PrintDom ref="print" v-if="printDOMmount" @destroy="printDOMmount = false" @refresh-list="getList" />
<ReportDialog
ref="car-report-dialog"
v-if="carReportDialogVisible"
@destroy="carReportDialog = false"
:ids="tableSelectedIds" />
</div>
</template>
@ -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();
},
/** 打开对话框 */

View File

@ -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: [
{

View File

@ -9,6 +9,7 @@
<script>
import initConfig from "./config";
import ListViewWithHead from "@/views/atomViews/ListViewWithHead.vue";
import moment from "moment";
export default {
name: "CarView",
@ -31,12 +32,16 @@ export default {
computed: {
now() {
const curr = this.headFormConfigs.fields.find((item) => item.prop == "timerange").default.value;
const start = new Date(curr[0]);
const end = new Date(curr[1]);
return [
start.toLocaleString().replace(' ', 'T').replace(/\//g, '-'),
end.toLocaleString().replace(' ', 'T').replace(/\//g, '-'),
]
return [
moment(curr[0]).format("YYYY-MM-DDTHH:mm:ss"),
moment(curr[1]).format("YYYY-MM-DDTHH:mm:ss"),
]
// const start = new Date(curr[0]);
// const end = new Date(curr[1]);
// return [
// start.toLocaleString().replace(' ', 'T').replace(/\//g, '-'),
// end.toLocaleString().replace(' ', 'T').replace(/\//g, '-'),
// ]
},
},
methods: {},