jinlin
2024-05-28 7c723bef7e4d9aaf1ac07da4a369b28f572e551c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<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>