Blame view

src/components/org/EditOrg.vue 3.05 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
      <el-dialog
        :title="$t('org.editOrg')"
        :visible.sync="visible"
        width="50%"
        @close="handleClose"
      >
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-form-item :label="$t('org.orgName')" prop="orgName">
            <el-input v-model="form.orgName" :placeholder="$t('org.orgName')" />
          </el-form-item>
          <el-form-item :label="$t('org.parentOrg')" prop="parentOrgName">
            <el-input v-model="form.parentOrgName" disabled />
          </el-form-item>
          <el-form-item :label="$t('org.description')" prop="description">
            <el-input
              v-model="form.description"
              type="textarea"
              :placeholder="$t('org.description')"
            />
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="visible = false">{{ $t('org.cancel') }}</el-button>
          <el-button type="primary" @click="handleSubmit">{{ $t('org.save') }}</el-button>
        </span>
      </el-dialog>
    </template>
    
    <script>
    import { updateOrg, listOrgs } from '@/api/org/orgApi'
    
    export default {
      name: 'EditOrg',
      data() {
        return {
          visible: false,
          form: {
            orgId: '',
            orgName: '',
            orgLevel:'',
            parentOrgId: '',
            parentOrgName: '',
            description: ''
          },
          rules: {
            orgName: [
              { required: true, message: this.$t('org.orgNameRequired'), trigger: 'blur' },
              { min: 2, max: 50, message: this.$t('org.orgNameLength'), trigger: 'blur' }
            ],
            parentOrgId: [
              { required: true, message: this.$t('org.parentOrgRequired') }
            ],
            description: [
              { required: true, message: this.$t('org.descriptionRequired'), trigger: 'blur' },
              { max: 200, message: this.$t('org.descriptionMaxLength'), trigger: 'blur' }
            ],
            orgId: [
              { required: true, message: this.$t('org.orgIdRequired') }
            ]
          }
        }
      },
      methods: {
        show(data) {
          console.log(data)
          this.form = {
            orgId: data.id,
            orgName: data.text,
            orgLevel: '',
5077115f   wuxw   v1.9 优化组织修改显示不正确bug
71
72
73
           // parentOrgId: data.parentId,
           // parentOrgName: data.parentText || '',
            //description: data.text || ''
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
74
75
76
77
78
          }
          this.visible = true
          this.getList()
        },
        async getList() {
5077115f   wuxw   v1.9 优化组织修改显示不正确bug
79
         const {orgs} = await listOrgs({
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
80
81
82
83
           page: 1,
           row: 1,
           orgId: this.form.orgId
         })
5077115f   wuxw   v1.9 优化组织修改显示不正确bug
84
85
         this.form = {...orgs[0]}
         console.log(orgs)
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
86
87
88
89
90
91
        },
        handleSubmit() {
          this.$refs.form.validate(valid => {
            if (valid) {
              updateOrg(this.form).then(response => {
                  console.log(response)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
92
                this.$message.success(this.$t('common.operationSuccess'))
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
93
94
95
96
97
98
99
100
101
102
103
104
                this.visible = false
                this.$emit('refresh')
              })
            }
          })
        },
        handleClose() {
          this.$refs.form.resetFields()
        }
      }
    }
    </script>