yudao-dev/src/views/cost/raw/costOthercostHis/add-or-updata.vue
2024-09-10 15:19:44 +08:00

116 lines
2.5 KiB
Vue

<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2024-09-05 15:36:45
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="成本名称" prop="name">
<el-select
v-model="dataForm.name"
disabled
:style="{ width: '100%' }"
placeholder="请选择成本名称">
<el-option
v-for="item in nameArr"
:key="item.name"
:label="item.label"
:value="item.name"></el-option>
</el-select>
</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"
clearable
placeholder="请输入总价" />
(元)
</el-form-item>
</el-col>
<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-row>
</el-form>
</template>
<script>
import basicAdd from '@/mixins/basic-add';
import {
updateRawOthercostHis,
} from '@/api/cost/costOthercostHis';
export default {
mixins: [basicAdd],
props: {
nameArr: {
type: Array,
default: () => [],
},
},
data() {
return {
urlOptions: {
updateURL: updateRawOthercostHis,
},
dataForm: {
id: undefined,
price: undefined,
name: undefined,
recTime: undefined,
},
dataRule: {
price: [
{ required: true, message: '总价不能为空', trigger: 'blur' },
],
},
};
},
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;
}
this.dataForm.modifyPrice = this.dataForm.price
// 修改的提交
this.urlOptions.updateURL(this.dataForm).then((response) => {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshDataList');
});
});
},
},
};
</script>