Blame view

antis-ncc-admin/src/views/system/menu/components/columnAuthorize/Form.vue 3.53 KB
de2bd2f9   “wangming”   项目初始化
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
101
102
103
104
105
106
107
108
109
110
  <template>
    <el-dialog :title="!dataForm.id ? '新建字段' : '编辑字段'" :close-on-click-modal="false"
      :close-on-press-escape="false" :visible.sync="visible" lock-scroll
      class="NCC-dialog NCC-dialog_center" width="600px">
      <el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="80px"
        v-loading="formLoading" class="menuForm">
        <!--      <el-form-item label="绑定表格" prop="bindTable">-->
        <!--        <el-input v-model="dataForm.bindTable" placeholder="输入绑定表格" />-->
        <!--      </el-form-item>-->
        <!--      <el-form-item label="表格描述" prop="bindTableName">-->
        <!--        <el-input v-model="dataForm.bindTableName" placeholder="绑定表格描述" />-->
        <!--      </el-form-item>-->
        <el-form-item label="字段名称" prop="enCode">
          <el-input v-model="dataForm.enCode" placeholder="输入字段名称" />
        </el-form-item>
        <el-form-item label="字段说明" prop="fullName">
          <el-input v-model="dataForm.fullName" placeholder="输入字段说明" />
        </el-form-item>
        <el-form-item label="状态" prop="enabledMark">
          <el-switch v-model="dataForm.enabledMark" :active-value="1" :inactive-value="0" />
        </el-form-item>
        <el-form-item label="备注" prop="description">
          <el-input v-model="dataForm.description" type="textarea" :rows="6" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{$t('common.cancelButton')}}</el-button>
        <el-button type="primary" :loading="btnLoading" @click="dataFormSubmit()">
          {{$t('common.confirmButton')}}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import {
    createColumn,
    updateColumn,
    getColumnInfo
  } from '@/api/system/columnAuthorize'
  
  export default {
    data() {
      return {
        visible: false,
        formLoading: false,
        btnLoading: false,
        dataForm: {
          id: '',
          moduleId: '',
          bindTable: '',
          bindTableName: '',
          fullName: '',
          enCode: '',
          enabledMark: 1,
          description: ''
        },
        dataRule: {
          enCode: [
            { required: true, message: '字段名称不能为空', trigger: 'blur' }
          ],
          fullName: [
            { required: true, message: '字段说明不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init(moduleId, id) {
        this.dataForm.id = id || ''
        this.dataForm.moduleId = moduleId
        this.visible = true
        this.formLoading = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          // 获取字段数据
          if (this.dataForm.id) {
            getColumnInfo(this.dataForm.id).then(res => {
              this.dataForm = res.data
            })
          }
          this.formLoading = false
        })
      },
      dataFormSubmit() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.btnLoading = true
            const formMethod = this.dataForm.id ? updateColumn : createColumn
            formMethod(this.dataForm).then(res => {
              this.$message({
                message: res.msg,
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.visible = false
                  this.btnLoading = false
                  this.$emit('refreshDataList')
                }
              })
            }).catch(() => {
              this.btnLoading = false
            })
          }
        })
      }
    }
  }
  </script>
  <style lang="scss" scoped>
  </style>