xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
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
<template>
  <zt-dialog ref="dialog" @confirm="formSubmit" append-to-body>
    <el-form :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="120px">
      <zt-form-item prop="name" :label="$t('company.name')" rules='required'>
        <el-input v-model="dataForm.name" :placeholder="$t('company.name')"></el-input>
      </zt-form-item>
      <zt-form-item prop="code" :label="$t('company.code')" rules='required'>
        <el-input v-model="dataForm.code" :placeholder="$t('company.code')"></el-input>
      </zt-form-item>
      <zt-form-item prop="shortName" :label="$t('company.shortName')" rules='required'>
        <el-input v-model="dataForm.shortName" :placeholder="$t('company.shortName')"></el-input>
      </zt-form-item>
      <zt-form-item prop="pid" :label="$t('company.parentCompany')" rules='required'>
        <zt-combo-tree v-model="dataForm.pid" :datas="deptList"/>
      </zt-form-item>
      <zt-form-item prop="nature" :label="$t('company.type')" rules='required'>
        <zt-dict v-model="dataForm.nature" dict="company_type" :radio="true" :placeholder="$t('company.type')"></zt-dict>
      </zt-form-item>
      <zt-form-item prop="sort" :label="$t('dept.sort')">
        <el-input-number v-model="dataForm.sort" controls-position="right" :min="0" :label="$t('dept.sort')"></el-input-number>
      </zt-form-item>
    </el-form>
  </zt-dialog>
</template>
 
<script>
  export default {
    data() {
      return {
        deptList: [],
        deptListVisible: false,
        dataForm: {
          id: '',
          name: '',
          pid: '',
          shortName: '',
          code: '',
          parentName: '',
          sort: 0
        }
      }
    },
    computed: {
    },
    methods: {
      init() {
        this.getDeptList()
      },
      // 获取公司列表
      async getDeptList() {
        let res = await this.$http.get('/sys/company/tree')
        this.deptList = res.data
      },
      // 获取信息
      async getInfo() {
        let res = await this.$http.get(`/sys/company/${this.dataForm.id}`)
        this.dataForm = {
          ...this.dataForm,
          ...res.data
        }
      },
      // 表单提交
      async formSubmit() {
        let res = await this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/company', this.dataForm)
        if (res.success) {
          await this.$tip.success()
          this.$refs.dialog.close()
          this.$emit('refreshDataList')
        }
      }
    }
  }
</script>