2024-10-21 18:05:51 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<edit-header :title="title">
|
2024-10-22 18:07:53 +08:00
|
|
|
<el-button type="primary" @click="submitForm" icon="el-icon-check">保存并提交</el-button>
|
2024-10-21 18:05:51 +08:00
|
|
|
</edit-header>
|
|
|
|
|
|
|
|
<div class="app-container" v-loading="loading">
|
2024-10-31 17:59:23 +08:00
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px" size="mini">
|
2024-10-21 18:05:51 +08:00
|
|
|
<div class="edit-title">基础信息</div>
|
|
|
|
<el-row>
|
|
|
|
<form-col :span="span" label="部门" prop="deptId">
|
2024-10-31 17:59:23 +08:00
|
|
|
<dept-tree-select v-model="form.deptId" class="mini-tree-select"/>
|
2024-10-21 18:05:51 +08:00
|
|
|
</form-col>
|
2024-10-22 18:07:53 +08:00
|
|
|
<form-col :span="span" label="报表日期" prop="reportDate">
|
2024-10-31 17:59:23 +08:00
|
|
|
<el-date-picker v-model="form.reportDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" style="width: 100%;" :clearable="false"/>
|
2024-10-21 18:05:51 +08:00
|
|
|
</form-col>
|
2024-10-31 17:59:23 +08:00
|
|
|
<form-col :span="span" label="总金额">
|
2024-10-22 18:07:53 +08:00
|
|
|
{{totalPrice.toNumber() | dv}} 元
|
|
|
|
</form-col>
|
|
|
|
</el-row>
|
|
|
|
<el-row>
|
2024-10-21 18:05:51 +08:00
|
|
|
</el-row>
|
|
|
|
|
2024-10-31 17:59:23 +08:00
|
|
|
<div class="edit-title">工序产量</div>
|
|
|
|
<report-product-edit
|
|
|
|
:data="form.productList"
|
|
|
|
:rules="productRules"
|
2024-10-22 18:07:53 +08:00
|
|
|
:header-cell-style="headerCellStyle"
|
|
|
|
/>
|
|
|
|
|
2024-10-21 18:05:51 +08:00
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import FormCol from "@/components/FormCol/index.vue";
|
|
|
|
import PriceInput from "@/components/Business/Price/PriceInput.vue";
|
|
|
|
import DeptTreeSelect from "@/components/Business/Dept/DeptTreeSelect.vue";
|
|
|
|
import {addReport, getReport, updateReport} from "@/api/yh/report";
|
|
|
|
import EditHeader from "@/components/EditHeader/index.vue";
|
2024-10-22 18:07:53 +08:00
|
|
|
import {isEmpty, notNullDecimal} from "@/utils";
|
|
|
|
import {mapGetters} from "vuex";
|
|
|
|
import Decimal from "decimal.js";
|
2024-10-31 17:59:23 +08:00
|
|
|
import ReportProductEdit from "@/views/yh/report/components/ReportProductEdit.vue";
|
|
|
|
import {parseTime} from "@/utils/ruoyi";
|
2024-10-21 18:05:51 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "ReportEdit",
|
2024-10-22 18:07:53 +08:00
|
|
|
dicts: ['income_mode'],
|
2024-10-31 17:59:23 +08:00
|
|
|
components: {ReportProductEdit, EditHeader, DeptTreeSelect, PriceInput, FormCol},
|
2024-10-21 18:05:51 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
title: null,
|
|
|
|
loading: false,
|
|
|
|
gutter: 16,
|
|
|
|
span: 6,
|
|
|
|
// 表单参数
|
|
|
|
form: {},
|
|
|
|
// 表单校验
|
|
|
|
rules: {
|
|
|
|
deptId: [
|
|
|
|
{ required: true, message: "部门不能为空", trigger: "blur" }
|
|
|
|
],
|
2024-10-22 18:07:53 +08:00
|
|
|
reportDate: [
|
|
|
|
{ required: true, message: "报表日期不能为空", trigger: "blur" }
|
2024-10-21 18:05:51 +08:00
|
|
|
],
|
2024-10-22 18:07:53 +08:00
|
|
|
incomeMode: [
|
|
|
|
{ required: true, message: "工资模式不能为空", trigger: "blur" }
|
|
|
|
]
|
2024-10-21 18:05:51 +08:00
|
|
|
},
|
2024-10-31 17:59:23 +08:00
|
|
|
productRules: {
|
|
|
|
priceId: [
|
|
|
|
{ required: true, message: "工序不能为空", trigger: "change" }
|
2024-10-22 18:07:53 +08:00
|
|
|
],
|
2024-10-31 17:59:23 +08:00
|
|
|
num: [
|
|
|
|
{ required: true, message: "产量不能为空", trigger: "change" }
|
|
|
|
],
|
|
|
|
priceType: [
|
|
|
|
{ required: true, message: "工序类型不能为空", trigger: "change" }
|
|
|
|
],
|
|
|
|
userProductList: {
|
|
|
|
userId: [
|
|
|
|
{ required: true, message: "用户不能为空", trigger: "change" }
|
|
|
|
],
|
|
|
|
num: [
|
|
|
|
{ required: true, message: "产量不能为空", trigger: "change" }
|
|
|
|
]
|
|
|
|
}
|
2024-10-22 18:07:53 +08:00
|
|
|
},
|
|
|
|
headerCellStyle: {
|
|
|
|
backgroundColor: "#f5f7fa",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters(['deptId']),
|
|
|
|
// 总价
|
|
|
|
totalPrice() {
|
|
|
|
let total = new Decimal(0);
|
2024-10-31 17:59:23 +08:00
|
|
|
if (this.form != null && !isEmpty(this.form.productList)) {
|
|
|
|
this.form.productList.forEach(item => {
|
2024-10-22 18:07:53 +08:00
|
|
|
total = total.plus(notNullDecimal(item.price).mul(notNullDecimal(item.num)))
|
|
|
|
})
|
2024-10-21 18:05:51 +08:00
|
|
|
}
|
2024-10-22 18:07:53 +08:00
|
|
|
return total;
|
2024-10-21 18:05:51 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.form.reportId = this.$route.params.reportId;
|
|
|
|
if (this.form.reportId == null) {
|
|
|
|
this.title = "新增报表";
|
|
|
|
this.reset();
|
|
|
|
} else {
|
|
|
|
this.title = "修改报表";
|
|
|
|
this.getDetail(this.form.reportId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getDetail(reportId) {
|
|
|
|
this.loading = true;
|
|
|
|
getReport(reportId).then(response => {
|
|
|
|
this.form = response.data;
|
|
|
|
}).finally(() => {
|
|
|
|
this.loading = false;
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/** 提交按钮 */
|
|
|
|
submitForm() {
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
if (valid) {
|
|
|
|
if (this.form.reportId != null) {
|
|
|
|
updateReport(this.form).then(response => {
|
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
addReport(this.form).then(response => {
|
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
|
});
|
|
|
|
}
|
2024-10-22 18:07:53 +08:00
|
|
|
} else {
|
|
|
|
this.$message.warning("表单校验未通过,请检查")
|
2024-10-21 18:05:51 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 表单重置
|
|
|
|
reset() {
|
|
|
|
this.form = {
|
|
|
|
reportId: null,
|
2024-10-22 18:07:53 +08:00
|
|
|
deptId: this.deptId,
|
2024-10-21 18:05:51 +08:00
|
|
|
num: null,
|
|
|
|
status: null,
|
|
|
|
priceId: null,
|
|
|
|
priceCategory: null,
|
|
|
|
priceSize: null,
|
|
|
|
priceName: null,
|
|
|
|
priceSubName: null,
|
|
|
|
pricePattern: null,
|
|
|
|
priceSpec: null,
|
|
|
|
pricePrice: null,
|
|
|
|
priceUnit: null,
|
|
|
|
priceClassify: null,
|
|
|
|
priceQuantity: null,
|
|
|
|
createTime: null,
|
|
|
|
createId: null,
|
|
|
|
createBy: null,
|
|
|
|
verifyTime: null,
|
|
|
|
verifyId: null,
|
|
|
|
verifyBy: null,
|
|
|
|
updateTime: null,
|
|
|
|
updateId: null,
|
|
|
|
updateBy: null,
|
2024-10-31 17:59:23 +08:00
|
|
|
reportDate: parseTime(new Date(), '{y}-{m}-{d}'),
|
|
|
|
productList: [],
|
2024-10-21 18:05:51 +08:00
|
|
|
};
|
|
|
|
this.resetForm("form");
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|