田源
2024-08-30 9900d07ca84f9a1718f8b8781c567ecae9f232b6
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<template>
  <div v-if="display">
    <vciWebReferClassify
        :key="typeKey" :data-key="typeKey"
        :disabled="disabled"
        :referConfig="rConfig"
        :referType="referType"
        :text="textD"
        :title="titleD"
        :value="valueD"
        :width="width"
        :height="height"
        :reloadFormKey="reloadFormKey"
        @setReferValue="setValue">
    </vciWebReferClassify>
  </div>
</template>
 
<script>
import vciWebReferClassify from "./vciWebReferClassify.vue";
import {verifyNull} from "@/util/validate";
 
export default {
  name: "orgUserRefer",
  props: {
    referConfig: {
      type: Object,
    }, value: {
      type: String,
      default: ''
    }, text: {
      type: String,
      default: ''
    }, disabled: {
      type: Boolean,
      default: false,
    }, display: {
      type: Boolean,
      default: true
    }, typeKey: {
      type: String,
      default: ''
    }, referType: {
      type: String,
      default:''
    }, width: {
      type: String,
      default:'70%'
    }, height: {
      type: String,
      default:(document.body.clientHeight-400)+'px'
    },
    reloadFormKey: {
      type: String,
      default: '',
    }
  },
  components: {vciWebReferClassify },
  data() {
    return {
      emitData: {},
    };
  },
  computed: {
    rConfig() {
      let rConfig = this.referConfig;
      if (!rConfig.options) {
        rConfig.options = {};
      }
      rConfig.options.isMuti = rConfig.options.muti || rConfig.options.isMuti || false;
      rConfig.options.url='/org/userQueryController/referGrid';
      rConfig.options.width=this.referConfig.options.width || '80%';
      rConfig.options.tableConfig={
        cols:[{
          prop: 'code',
          label: (this.$project.user.code || "账号"),
          sortable: true,
          search: true
        },{
          prop: 'name',
          label: '姓名',
          sortable: true,
          search: true
        },  {
          prop: 'deptIdName',
          label: '所属部门',
        },  {
          prop: 'sexText',
          label: '性别',
        }]
      };
      rConfig.options.classifys=[{
        title:'部门',
        treeUrl:'/org/deptController/referGrid', //分类的路径
        queryByClassifyUrl:'/permission/userQueryController/gridUserByDeptIdGet',  //'列表'
        queryField:'deptId', //列表数据中分类的字段
        classifyValueField:'id',  //从树上获取的字段
      },{
        title:'角色',
        treeUrl:'/permission/roleController/referGrid', //分类的路径
        queryByClassifyUrl:'/permission/userQueryController/gridUserInRoleIdGet',  //'列表'
        queryField:'roleId', //列表数据中分类的字段
        classifyValueField:'id',  //从树上获取的字段
      }];
      rConfig.options.onlyTable=false;
      return rConfig;
    },
    titleD(){
      let title = this.referConfig.title || "";
      title = title.replace(":", "");
      title = title
          ? "为【" + title + "】选取值"
          : "为【" + this.referConfig.showProp + "】选取值";
      return title;
    },
    textD(){
      return verifyNull(this.text) ? (this.referConfig.options.defalutText || '') : this.text;
    },
    valueD(){
      return verifyNull(this.value) ? (this.referConfig.options.defalutValue || '') :this.value;
    }
  },
  created() {
  },
  methods: {
    setValue(value) {
      this.emitData = value;
    }
  },
  watch: {
    // 修改反馈到父组件
    emitData: {
      deep: true,
      handler(newV) {
        this.$emit("setReferValue", newV);
      }
    }
  }
};
</script>
 
<style scoped>
 
</style>