- 保存并提交
+ 仅保存
+ 保存并提交
@@ -20,6 +21,7 @@
style="width: 100%;"
:clearable="false"
:editable="false"
+ :picker-options="pickerOptions"
/>
@@ -113,7 +115,13 @@ export default {
},
headerCellStyle: {
backgroundColor: "#f5f7fa",
- }
+ },
+ // 报表日期选项
+ pickerOptions: {
+ disabledDate(date) {
+ return date.getTime() > Date.now();
+ }
+ },
}
},
computed: {
@@ -149,38 +157,43 @@ export default {
})
},
/** 提交按钮 */
- submitForm() {
+ submitForm(submit) {
this.form.totalAmount = this.totalPrice;
this.$refs["form"].validate(valid => {
if (valid) {
// 校验产量是否一致
for (let i = 0; i < this.form.productList.length; i++) {
- let error = this.checkNum(this.form.productList[i]);
+ let error = this.preCheckProd(this.form.productList[i]);
if (!isEmpty(error)) {
return this.$message.warning(`第${i + 1}行工序产量校验未通过:${error}`);
}
}
-
- this.loading = true;
- if (this.form.reportId != null) {
- updateReport(this.form).then(res => {
- if (res.code === 200) {
- this.$modal.msgSuccess("修改成功");
- this.$tab.closeBack();
- }
- }).finally(() => {
- this.loading = false;
- })
- } else {
- addReport(this.form).then(res => {
- if (res.code === 200) {
- this.$modal.msgSuccess("新增成功");
- this.$tab.closeBack();
- }
- }).finally(() => {
- this.loading = false;
- })
- }
+ this.$confirm(`确认${submit ? '保存并提交' : '保存'}当前报表?`, '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(() => {
+ this.loading = true;
+ if (this.form.reportId != null) {
+ updateReport(this.form, submit).then(res => {
+ if (res.code === 200) {
+ this.$modal.msgSuccess("修改成功");
+ this.$tab.closeBack();
+ }
+ }).finally(() => {
+ this.loading = false;
+ })
+ } else {
+ addReport(this.form, submit).then(res => {
+ if (res.code === 200) {
+ this.$modal.msgSuccess("新增成功");
+ this.$tab.closeBack();
+ }
+ }).finally(() => {
+ this.loading = false;
+ })
+ }
+ })
} else {
this.$message.warning("表单校验未通过,请检查")
}
diff --git a/src/views/yh/report/mixins.js b/src/views/yh/report/mixins.js
index 181d5ff..cb962d2 100644
--- a/src/views/yh/report/mixins.js
+++ b/src/views/yh/report/mixins.js
@@ -1,27 +1,50 @@
-import {notNullDecimal} from "@/utils";
+import {isEmpty, notNullDecimal} from "@/utils";
import Decimal from "decimal.js";
+import {ReportPriceType} from "@/utils/constants";
export const $reportCheck = {
methods: {
/**
- * 校验数量是否一致
+ * 提交前校验工序产量
*/
- checkNum(row) {
+ preCheckProd(row) {
let num = notNullDecimal(row.num); // 良品数
- let userNum = new Decimal(0); // 用户良品数
- row.userProdList.forEach(item => {
- userNum = userNum.add(notNullDecimal(item.num));
- })
- console.log(userNum.toNumber(), num.toNumber())
- if (userNum.toNumber() > num.toNumber()) {
+ let totalUserNum = new Decimal(0); // 用户良品数
+
+ if (num.toNumber() < 1) {
+ return "良品数不允许小于1,请检查";
+ }
+
+ // 校验员工产量
+ if (isEmpty(row.userProdList)) {
+ return "至少要填写一条员工产量";
+ }
+ for(let i = 0; i < row.userProdList.length; i++) {
+ let item = row.userProdList[i];
+ let userNum = notNullDecimal(item.num);
+ if (userNum.toNumber() < 1) {
+ return `第${i+1}行员工产量不允许小于1,请检查`;
+ }
+ totalUserNum = totalUserNum.add(userNum);
+ }
+ if (totalUserNum.toNumber() > num.toNumber()) {
return "员工总产量不允许超过工序总产量,请检查"
}
- let orderNum = new Decimal(0); // 订单良品数
- row.orderProdList.forEach(item => {
- orderNum = orderNum.add(notNullDecimal(item.num));
- })
- if (orderNum.toNumber() > num.toNumber()) {
+ // 校验订单产量
+ if (row.priceType === ReportPriceType.BILL && isEmpty(row.orderProdList)) {
+ return "订单工序至少需要关联一个订单"
+ }
+ let totalOrderNum = new Decimal(0); // 订单良品数
+ for(let i = 0; i < row.orderProdList.length; i++) {
+ let item = row.orderProdList[i];
+ let orderNum = notNullDecimal(item.num);
+ if (orderNum.toNumber() < 1) {
+ return `第${i+1}行订单产量不允许小于1,请检查`;
+ }
+ totalOrderNum = totalOrderNum.add(orderNum);
+ }
+ if (totalOrderNum.toNumber() > num.toNumber()) {
return "订单总产量不允许超过工序总产量,请检查"
}
},
diff --git a/src/views/yh/shift/index.vue b/src/views/yh/shift/index.vue
index eef43d8..083830f 100644
--- a/src/views/yh/shift/index.vue
+++ b/src/views/yh/shift/index.vue
@@ -21,6 +21,7 @@
end-placeholder="结束时间"
value-format="yyyy-MM-dd HH:mm:ss"
:default-time="['00:00:00', '23:59:59']"
+ @change="handleQuery"
/>