diff --git a/src/components/ReportDialog.vue b/src/components/ReportDialog.vue
index 05f2785..748499c 100644
--- a/src/components/ReportDialog.vue
+++ b/src/components/ReportDialog.vue
@@ -16,6 +16,14 @@
报工预览
+
+
+
+ 预报工单
+ 编辑
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 预保存
+ 取消
+
+
+
@@ -53,6 +113,18 @@ export default {
loading: false,
dataList: [],
page: 1,
+ dataForm: {
+ id: null,
+ orderCate: null,
+ orderCode: null,
+ qty: null,
+ goodqty: null,
+ badqty: null,
+ badratio: null,
+ team: null,
+ },
+ formLoading: false,
+ dataFormList: [],
tableProps: [
{ prop: "orderCode", label: "订单号" },
{ prop: "orderCate", label: "订单子号" },
@@ -73,7 +145,7 @@ export default {
width: 90,
subcomponent: TableOperaionComponent,
options: [
- { name: "edit", label: "编辑", icon: "edit-outline" },
+ { name: "edit", label: "编辑", icon: "edit-outline", emitFull: true },
// {
// name: "delete",
// icon: "delete",
@@ -84,6 +156,7 @@ export default {
],
},
],
+ currentEditing: null,
};
},
computed: {
@@ -91,6 +164,18 @@ export default {
return this.dataList.length;
},
},
+ watch: {
+ "dataForm.goodqty"(val) {
+ const qty = +val + +this.dataForm.badqty;
+ this.dataForm.qty = qty;
+ this.dataForm.badratio = ((+this.dataForm.badqty / qty) * 100).toFixed(2);
+ },
+ "dataForm.badqty"(val) {
+ const qty = +val + +this.dataForm.goodqty;
+ this.dataForm.qty = qty;
+ this.dataForm.badratio = ((+val / qty) * 100).toFixed(2);
+ },
+ },
methods: {
async init() {
this.visible = true;
@@ -100,32 +185,87 @@ export default {
ids: this.ids,
});
if (res.code === 0) {
- this.dataList = res.data.map((item) => ({
+ this.dataList = res.data.map((item, index) => ({
...item,
qty: item.goodqty + item.badqty,
+ // 该 __LOCAL_INDEX 用于更新本地缓存数据
+ __LOCAL_INDEX: index,
}));
- 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";
+ this.currentEditing = data.__LOCAL_INDEX;
+ const { id, orderCate, orderCode, qty, goodqty, badqty, badratio, team } = data;
+ this.dataForm = {
+ id,
+ orderCate,
+ orderCode,
+ qty,
+ goodqty,
+ badqty,
+ badratio,
+ team,
+ };
break;
}
},
- handleConfirm() {},
+
+ async handleConfirm() {
+ this.loading = true;
+ const { data: res } = await this.$http.post("/pms/workReport/pressReport", {
+ datas: this.dataList,
+ ids: this.ids,
+ });
+ this.loading = false;
+ if (res.code === 0) {
+ this.$message.success("提交成功");
+ this.$emit('refresh-list')
+ this.close();
+ }
+ },
+
+ // 本地缓存编辑过的数据,保存时一并提交给服务器
+ handleSaveEdit() {
+ Object.keys(this.dataForm).forEach((key) => {
+ this.dataList[this.currentEditing][key] = this.dataForm[key];
+ });
+ this.mode = "table";
+ this.$nextTick(() => {
+ this.clearDataForm();
+ });
+ },
+
+ // 清空输入数据
+ clearDataForm() {
+ this.currentEditing = null;
+ this.dataForm = {
+ id: null,
+ orderCate: null,
+ orderCode: null,
+ qty: null,
+ goodqty: null,
+ badqty: null,
+ badratio: null,
+ team: null,
+ };
+ },
},
};