renkang
2024-12-23 26b93e84d4153039ef3600355308d2a743dc3be7
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
<template>
  <GlobalWindow :title="param.id ? '编辑公司' : '新建公司'" :confirmWorking="subLoading" :visible.sync="isShowModal"
    width="600px" @close="close" @confirm="handleSub">
    <el-form :model="param" ref="paramRef" :rules="rules">
      <el-form-item label="公司名称" prop="name">
        <el-input v-model="param.name" placeholder="请输入" v-trim />
      </el-form-item>
      <el-form-item label="公司简称" prop="shortName">
        <el-input v-model="param.shortName" placeholder="请输入" v-trim />
      </el-form-item>
      <el-form-item label="纳税识别号">
        <el-input v-model="param.code" placeholder="请输入" v-trim />
      </el-form-item>
      <el-form-item label="联系地址">
        <el-input v-model="param.address" placeholder="请输入" v-trim />
      </el-form-item>
      <el-form-item label="状态" prop="code">
        <el-switch v-model="param.status" active-value="0" inactive-value="1">
        </el-switch>
      </el-form-item>
    </el-form>
  </GlobalWindow>
</template>
 
<script>
import GlobalWindow from '@/components/common/GlobalWindow'
import UploadAvatarImage from '@/components/common/UploadAvatarImage'
import { createFinanceCompany, updateFinanceCompany, getById } from '@/api/business/company'
import { Message } from 'element-ui'
export default {
  components: { GlobalWindow, UploadAvatarImage },
  data() {
    return {
      isShowModal: false,
      subLoading: false,
      param: {
        id: null,
        name: '',
        shortName: '',
        code: '',
        address: '',
        type: 2,
        status: '0'
      },
      cateList: [],
      rules: {
        name: [{ required: true, message: '请输入' }],
        desc: [{ required: true, message: '请输入' }]
      },
 
    }
  },
  methods: {
    getDetail (id) {
      getById(id)
        .then(res => {
          for (const key in this.param) {
            this.param[key] = res[key]
          }
        })
    },
    handleSub() {
      const { param, subLoading } = this
      this.$refs['paramRef'].validate((valid) => {
        if (valid) {
          let fn = param.id ? updateFinanceCompany : createFinanceCompany
          this.subLoading = true
          fn(param).then(res => {
            this.subLoading = false
            this.$emit('success')
            Message.success('保存成功')
            this.close()
          }).catch(() => {
            this.subLoading = false
          })
        }
      })
    },
    changeSel(e) {
      if (e && e.length == 1) {
        this.$set(this.param, 'catePId', e[0])
        this.$set(this.param, 'cateId', '')
      } else if (e && e.length == 2) {
        this.$set(this.param, 'catePId', e[0])
        this.$set(this.param, 'cateId', e[1])
      } else {
        this.$set(this.param, 'catePId', '')
        this.$set(this.param, 'cateId', '')
      }
      this.search()
    },
    uploadAvatarSuccess(file) {
      this.$set(this.param, 'imgurl', file.imgurl)
      this.$set(this.param, 'imgurlfull', file.imgurlfull)
    },
    close() {
      this.isShowModal = false
      this.$emit('close')
    }
  }
}
</script>
 
<style lang="scss" scoped></style>