jiangping
2024-11-23 8ac30411bb33e406e0ed5a2b6e2edaf7ab59f11f
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
<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="desc">
        <el-input v-model="param.desc" 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.addr" 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 { create, updateById } from '@/api/business/company'
import { Message } from 'element-ui'
export default {
  components: { GlobalWindow, UploadAvatarImage },
  data() {
    return {
      isShowModal: false,
      subLoading: false,
      param: {
        type: 2,
        status: '0'
      },
      cateList: [],
      rules: {
        name: [{ required: true, message: '请输入' }],
        desc: [{ required: true, message: '请输入' }]
      },
 
    }
  },
  created() {
  },
  methods: {
    handleSub() {
      const { param, subLoading } = this
      this.$refs['paramRef'].validate((valid) => {
        if (valid) {
          let fn = param.id ? updateById : create
          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>