jinlin
2024-03-20 991a2c14f0e118112a3ea60ff7c464fba1512b5b
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-select v-model="selectValue" :url="url" :multiple="multiple" :disabled="disabled" :placeholder="placeholder"
             :clearable="clearable" />
</template>
<script>
 
  export default {
    name: 'MajorSelector',
    components: {},
    props: {
      value: [String, Array],
      modelId: {
        type: String,
        default: ""
      },
      shipId: {
        type: String,
        default: ""
      },
      projectId: {
        type: String,
        default: ""
      },
      multiple: {
        type: Boolean,
        default: false
      },
      disabled: {
        type: Boolean,
        default: false
      },
      clearable: {
        type: Boolean,
        default: true
      },
      placeholder: String
    },
    data() {
      return {
        url:'/sys/major/getList?modelId='+this.modelId+'&shipId='+this.shipId+'&projectId='+this.projectId,
        selectValue: this.value || ''
      }
    },
    watch: {
      'selectValue'(){
        if (this.multiple) {
          this.$emit('input', (this.selectValue || []).join(','))
        } else {
          this.$emit('input', this.selectValue)
        }
      },
      value(val, oldval) {
        this.selectValue = val
      },
      'projectId'() {
        this.url = '/sys/major/getList?modelId='+this.modelId+'&shipId='+this.shipId+'&projectId='+this.projectId
      }
    },
 
    mounted() {
      this.onSelected()
    },
    methods: {
      onSelected(data) {
        if (this.multiple) {
          this.$emit('input', (this.selectValue || []).join(','))
        } else {
          this.$emit('input', this.selectValue)
        }
      }
    }
  }
</script>