<template>
|
<zt-dialog ref="dialog" @confirm="formSubmit" append-to-body :title="title" @close="close()">
|
<el-form :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="120px">
|
|
<zt-form-item label="序号" prop="sort" rules="required" >
|
<el-input v-model="dataForm.sort" placeholder="序号" disabled="true"></el-input>
|
</zt-form-item>
|
<zt-form-item label="专业名称" prop="name" rules="required">
|
<el-input v-model="dataForm.name" placeholder="专业名称"></el-input>
|
</zt-form-item>
|
|
<zt-form-item label="专业简称" prop="shortName" rules="required">
|
<el-input v-model="dataForm.shortName" placeholder="专业简称"></el-input>
|
</zt-form-item>
|
|
<zt-form-item label="型号名称" prop="productId" rules="required">
|
<el-select filterable clearable v-model="dataForm.productId" value-key="value"
|
placeholder="型号名称" style="width: 100%">
|
<el-option v-for="item in productList" :key="item.id" :label="item.name" :value="item.id"
|
:class="{refuseProject:item.refuse=='1'}"></el-option>
|
</el-select>
|
</zt-form-item>
|
<zt-form-item label="描述" prop="comment" >
|
<el-input v-model="dataForm.comment" placeholder="描述"></el-input>
|
</zt-form-item>
|
</el-form>
|
</zt-dialog>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
productList: [],
|
dataForm: {
|
id: '',
|
name: '',
|
comment: '',
|
sort: ''
|
},
|
}
|
},
|
mounted() {
|
|
},
|
methods: {
|
init(row, opt) {
|
this.getProductList()
|
if (opt === 1) {
|
this.dataForm.id = ''
|
this.title = '新增'
|
this.getMaxSort()
|
} else {
|
console.log(row, 'row row')
|
this.dataForm.id = row.id
|
this.title = '修改'
|
this.getInfoSelf()
|
}
|
}
|
,
|
async getProductList() {
|
let res = await this.$http.get(`/ztProduct/getModelList`)
|
this.productList = res.data
|
},
|
// 获取信息
|
async getInfoSelf() {
|
let res = await this.$http.get(`/sys/major/${this.dataForm.id}`)
|
this.dataForm = res.data
|
}
|
,
|
async getMaxSort() {
|
let res = await this.$http.get(`/sys/major/getMaxSort`)
|
this.dataForm.sort = res.data
|
}
|
,
|
|
// 表单提交
|
async formSubmit() {
|
|
let res2 = await this.$http.put('/sys/major/exitsSameMajor/', this.dataForm)
|
if (res2.data > 0) {
|
return this.$tip.alert('此型号下已存在相同工程专业!')
|
}
|
|
console.log(this.dataForm.id, ' this.dataForm.id')
|
let res = await this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/major/', this.dataForm)
|
if (res.success) {
|
await this.$tip.success()
|
this.$refs.dialog.close()
|
this.$emit('refreshDataList')
|
}
|
}
|
,
|
|
close() {
|
this.title = '新增'
|
}
|
}
|
}
|
</script>
|