yudao-dev/src/views/cost/costStatistics/add-or-updata.vue
2024-09-14 09:02:07 +08:00

143 lines
3.4 KiB
Vue

<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2024-09-11 15:49:14
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-position="top"
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="日期" prop="recTime">
<el-date-picker
v-model="dataForm.recTime"
type="date"
value-format="timestamp"
:style="{ width: '100%' }"
disabled
placeholder="日期"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="总成本" prop="price">
<el-input-number
:min="0"
style="width: 80%"
v-model="dataForm.price"
disabled
placeholder="总成本" />
(元)
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原片下片面积" prop="originArea">
<el-input-number
:min="0"
style="width: 80%"
v-model="dataForm.originArea"
clearable
placeholder="请输入原片下片面积" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="深加工下片面积" prop="deepArea">
<el-input-number
:min="0"
style="width: 80%"
v-model="dataForm.deepArea"
clearable
placeholder="请输入深加工下片面积" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原片成本" prop="originPrice">
<el-input-number
:min="0"
style="width: 80%"
v-model="dataForm.originPrice"
clearable
placeholder="请输入原片成本" />
(元)
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="深加工成本" prop="deepPrice">
<el-input-number
:min="0"
style="width: 80%"
v-model="dataForm.deepPrice"
clearable
placeholder="请输入深加工成本" />
()
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import basicAdd from '@/mixins/basic-add';
import { updateCostSum } from '@/api/cost/allCost';
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
updateURL: updateCostSum,
},
dataForm: {
id: undefined,
originArea: undefined,
deepArea: undefined,
originPrice: undefined,
deepPrice: undefined,
price: undefined,
},
dataRule: {
},
};
},
methods: {
init(val, statisticType) {
this.visible = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
this.dataForm = JSON.parse(JSON.stringify(val));
this.dataForm.statisticType = statisticType;
});
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false;
}
const data = {
id: this.dataForm.id,
statisticType: this.dataForm.statisticType,
modifyOriginArea: this.dataForm.originArea,
modifyOriginPrice: this.dataForm.originPrice,
modifyDeepArea: this.dataForm.deepArea,
modifyDeepPrice: this.dataForm.deepPrice,
modifyPrice: this.dataForm.deepPrice + this.dataForm.originPrice,
};
// 修改的提交
this.urlOptions.updateURL(data).then((response) => {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshDataList');
});
});
},
},
};
</script>