<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="80px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="申请编号" prop="applyNo">
|
<el-input v-model="dataForm.applyNo" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="申请类型" prop="applyType">
|
<el-select
|
v-model="dataForm.applyType"
|
placeholder=""
|
filterable
|
style="width: 100%"
|
:disabled="dataForm.id ? true : false"
|
>
|
<el-option
|
v-for="item in applyTypeOptions"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="dataForm.remark" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`dataFormSubmit`"
|
>确定</el-button
|
>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { getApply, addApply, putApply } from '@/api/quality/apply'
|
|
export default {
|
props: {
|
applyTypeOptions: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
data() {
|
return {
|
visible: false,
|
dataForm: {
|
id: 0,
|
applyNo: '',
|
applyType: '',
|
remark: ''
|
},
|
dataRule: {},
|
isSubmit: false
|
}
|
},
|
methods: {
|
init(id) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getApply(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
})
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putApply(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
} else {
|
addApply(this.dataForm).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
}
|
}
|
}
|
</script>
|