|
@@ -0,0 +1,120 @@
|
|
|
+import { getDingTalkDepartmentList, queryDingTalkDeptUser } from '@/api/expenseManagement'
|
|
|
+const DingDepartUser = {
|
|
|
+ template: `
|
|
|
+ <a-tree-select
|
|
|
+ :value="defaultVal"
|
|
|
+ tree-data-simple-mode
|
|
|
+ style="width: 100%"
|
|
|
+ :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
|
|
+ :tree-data="treeData"
|
|
|
+ :placeholder="placeholder"
|
|
|
+ :load-data="onLoadData"
|
|
|
+ multiple
|
|
|
+ treeCheckable
|
|
|
+ treeNodeFilterProp="title"
|
|
|
+ @change="handleChange"
|
|
|
+ />
|
|
|
+ `,
|
|
|
+ props: {
|
|
|
+ value: {
|
|
|
+ type: Array,
|
|
|
+ defatut: function(){
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ placeholder: {
|
|
|
+ type: String,
|
|
|
+ default: '请选择人员'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ defaultVal: this.value,
|
|
|
+ treeData: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.genTreeNode(1)
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ value(newValue, oldValue) {
|
|
|
+ this.defaultVal = newValue
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ filterOption (input, option) {
|
|
|
+ return (
|
|
|
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
+ )
|
|
|
+ },
|
|
|
+ handleChange(value) {
|
|
|
+ console.log(value);
|
|
|
+ this.defaultVal = value;
|
|
|
+ const row = this.treeData.find(item => item.brandSn == value)
|
|
|
+ this.$emit('change', value, this.id, row);
|
|
|
+ this.$emit('input', value);
|
|
|
+ },
|
|
|
+
|
|
|
+ formatData(data,type){
|
|
|
+ const ret = []
|
|
|
+ data.map(item => {
|
|
|
+ if(type == 'bm'){
|
|
|
+ ret.push({
|
|
|
+ title: item.name,
|
|
|
+ id:item.deptId,
|
|
|
+ value: item.deptId,
|
|
|
+ pId: item.parentId,
|
|
|
+ autoAddUser: item.autoAddUser,
|
|
|
+ createDeptGroup: item.createDeptGroup,
|
|
|
+ disableCheckbox: true,
|
|
|
+ checkable: false
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ ret.push({
|
|
|
+ title: item.name,
|
|
|
+ id:item.userid,
|
|
|
+ value: item.userid,
|
|
|
+ pId: item.parentId,
|
|
|
+ avatar: item.avatar,
|
|
|
+ leader: item.leader,
|
|
|
+ boss: item.boss,
|
|
|
+ admin: item.admin,
|
|
|
+ active: item.active,
|
|
|
+ userid: item.userid,
|
|
|
+ isLeaf: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return ret
|
|
|
+ },
|
|
|
+
|
|
|
+ genTreeNode(parentId, isLeaf = false) {
|
|
|
+ Promise.all([
|
|
|
+ getDingTalkDepartmentList({deptId:parentId}),
|
|
|
+ queryDingTalkDeptUser({deptId:parentId,pageNo:1,pageSize:10})
|
|
|
+ ]).then(res => {
|
|
|
+ const res1 = res[0].data||[]
|
|
|
+ const res2 = res[1].data||[]
|
|
|
+ this.treeData = this.treeData.concat(this.formatData(res1,'bm')).concat(this.formatData(res2,'yg'));
|
|
|
+ if(res1.length==0&&res2.length==0){
|
|
|
+ this.$message.info("没有下一级了")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onLoadData(treeNode) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ const { value } = treeNode.dataRef;
|
|
|
+ this.genTreeNode(value)
|
|
|
+ setTimeout(()=>{
|
|
|
+ resolve();
|
|
|
+ },1000)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+export default DingDepartUser
|