|  | @@ -27,9 +27,11 @@ Page({
 | 
	
		
			
				|  |  |          nickname: null,
 | 
	
		
			
				|  |  |          height: null,
 | 
	
		
			
				|  |  |          //  选择部门
 | 
	
		
			
				|  |  | -        mainActiveIndex: 0,
 | 
	
		
			
				|  |  | -        activeId: null,
 | 
	
		
			
				|  |  | -        items: [],
 | 
	
		
			
				|  |  | +        // mainActiveIndex: 0,
 | 
	
		
			
				|  |  | +        // activeId: null,
 | 
	
		
			
				|  |  | +        // items: [],
 | 
	
		
			
				|  |  | +        Departmentlist:[],
 | 
	
		
			
				|  |  | +        departs:['1','2','3'],
 | 
	
		
			
				|  |  |          //显示遮罩层
 | 
	
		
			
				|  |  |          show: false,
 | 
	
		
			
				|  |  |          selectname: '', //部门名字
 | 
	
	
		
			
				|  | @@ -75,7 +77,8 @@ Page({
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |          this.getname()
 | 
	
		
			
				|  |  |          this.getdep()
 | 
	
		
			
				|  |  | -        this.getDepartment()
 | 
	
		
			
				|  |  | +        // this.getDepartment()
 | 
	
		
			
				|  |  | +        this.getwritedep()
 | 
	
		
			
				|  |  |          this.getUptoken()
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -177,6 +180,27 @@ Page({
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          console.log(this.data.User1List);
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    //获取填写部门信息
 | 
	
		
			
				|  |  | +    async getwritedep() {
 | 
	
		
			
				|  |  | +        let Userquery = new Parse.Query('Department');
 | 
	
		
			
				|  |  | +        Userquery.equalTo('company', company); 
 | 
	
		
			
				|  |  | +        Userquery.equalTo('isEnabled', true);
 | 
	
		
			
				|  |  | +        // Userquery.equalTo('type', 'center');
 | 
	
		
			
				|  |  | +        Userquery.notEqualTo('isDeleted', true);
 | 
	
		
			
				|  |  | +        // Userquery.include('parent');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        let P2 = await Userquery.find();
 | 
	
		
			
				|  |  | +        let Departmentlist = P2.map(item => item.toJSON());
 | 
	
		
			
				|  |  | +        let departs=[]
 | 
	
		
			
				|  |  | +        Departmentlist.forEach((item)=>{
 | 
	
		
			
				|  |  | +            departs.push(item.name)
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        this.setData({
 | 
	
		
			
				|  |  | +            departs,
 | 
	
		
			
				|  |  | +            Departmentlist,
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        console.log('departs',this.data.Departmentlist);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      //获取部门
 | 
	
		
			
				|  |  |      async getdep() {
 | 
	
		
			
				|  |  |          const currentUser = Parse.User.current();
 | 
	
	
		
			
				|  | @@ -194,19 +218,19 @@ Page({
 | 
	
		
			
				|  |  |                  this.setData({
 | 
	
		
			
				|  |  |                      name: dep[0].name,
 | 
	
		
			
				|  |  |                      phone: dep[0].mobile,
 | 
	
		
			
				|  |  | -                    departname: dep[0].department.name,
 | 
	
		
			
				|  |  | -                    selectname: dep[0].center.name,
 | 
	
		
			
				|  |  | -                    selectobjectid: dep[0].center.objectId,
 | 
	
		
			
				|  |  | -                    upiobjectid: dep[0].department.objectId
 | 
	
		
			
				|  |  | +                    // departname: dep[0].department.name,//工会
 | 
	
		
			
				|  |  | +                    // selectname: dep[0].center.name,//部门
 | 
	
		
			
				|  |  | +                    // selectobjectid: dep[0].center.objectId,//部门
 | 
	
		
			
				|  |  | +                    // upiobjectid: dep[0].department.objectId//工会
 | 
	
		
			
				|  |  |                  })
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  this.setData({
 | 
	
		
			
				|  |  |                      name: dep[0].name,
 | 
	
		
			
				|  |  |                      phone: dep[0].mobile,
 | 
	
		
			
				|  |  | -                    departname: dep[0].department.name,
 | 
	
		
			
				|  |  | -                    selectname: dep[0].center.name,
 | 
	
		
			
				|  |  | -                    selectobjectid: dep[0].center.objectId,
 | 
	
		
			
				|  |  | -                    upiobjectid: dep[0].department.objectId
 | 
	
		
			
				|  |  | +                    // departname: dep[0].department.name,
 | 
	
		
			
				|  |  | +                    // selectname: dep[0].center.name,
 | 
	
		
			
				|  |  | +                    // selectobjectid: dep[0].center.objectId,
 | 
	
		
			
				|  |  | +                    // upiobjectid: dep[0].department.objectId
 | 
	
		
			
				|  |  |                  })
 | 
	
		
			
				|  |  |                  wx.showToast({
 | 
	
		
			
				|  |  |                      title: '您之前提交信息在审核当中',
 | 
	
	
		
			
				|  | @@ -276,11 +300,11 @@ Page({
 | 
	
		
			
				|  |  |              Profilerquery.notEqualTo('isDeleted', true)
 | 
	
		
			
				|  |  |              let Profile = await Profilerquery.first();
 | 
	
		
			
				|  |  |              //工会
 | 
	
		
			
				|  |  | -            let Departmentquery = new Parse.Query('Department');
 | 
	
		
			
				|  |  | -            Departmentquery.equalTo('company', company);
 | 
	
		
			
				|  |  | -            Departmentquery.equalTo('objectId', this.data.upiobjectid);
 | 
	
		
			
				|  |  | -            Departmentquery.notEqualTo('isDeleted', true)
 | 
	
		
			
				|  |  | -            let Department = await Departmentquery.first();
 | 
	
		
			
				|  |  | +            // let Departmentquery = new Parse.Query('Department');
 | 
	
		
			
				|  |  | +            // Departmentquery.equalTo('company', company);
 | 
	
		
			
				|  |  | +            // Departmentquery.equalTo('objectId', this.data.upiobjectid);
 | 
	
		
			
				|  |  | +            // Departmentquery.notEqualTo('isDeleted', true)
 | 
	
		
			
				|  |  | +            // let Department = await Departmentquery.first();
 | 
	
		
			
				|  |  |              //部门
 | 
	
		
			
				|  |  |              let unionquery = new Parse.Query('Department');
 | 
	
		
			
				|  |  |              unionquery.equalTo('company', company);
 | 
	
	
		
			
				|  | @@ -289,7 +313,7 @@ Page({
 | 
	
		
			
				|  |  |              let union = await unionquery.first();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (Profile) {
 | 
	
		
			
				|  |  | -                Profile.set('department', Department.toPointer())
 | 
	
		
			
				|  |  | +                // Profile.set('department', Department.toPointer())
 | 
	
		
			
				|  |  |                  Profile.set('center', union.toPointer())
 | 
	
		
			
				|  |  |                  Profile.set('name', this.data.name)
 | 
	
		
			
				|  |  |                  Profile.set('mobile', this.data.phone)
 | 
	
	
		
			
				|  | @@ -321,7 +345,7 @@ Page({
 | 
	
		
			
				|  |  |                  Profile.set('company', companyPointer);
 | 
	
		
			
				|  |  |                  Profile.set('isCheck', false);
 | 
	
		
			
				|  |  |                  Profile.set('user', P2.toPointer());
 | 
	
		
			
				|  |  | -                Profile.set('department', Department.toPointer());
 | 
	
		
			
				|  |  | +                // Profile.set('department', Department.toPointer());
 | 
	
		
			
				|  |  |                  Profile.set('center', union.toPointer());
 | 
	
		
			
				|  |  |                  Profile.set('name', this.data.name)
 | 
	
		
			
				|  |  |                  Profile.set('mobile', this.data.phone)
 | 
	
	
		
			
				|  | @@ -374,89 +398,94 @@ Page({
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      // 获取部门信息
 | 
	
		
			
				|  |  | -    async getDepartment() {
 | 
	
		
			
				|  |  | -        const currentUser = Parse.User.current();
 | 
	
		
			
				|  |  | -        let Userquery = new Parse.Query('Department');
 | 
	
		
			
				|  |  | -        Userquery.equalTo('company', company); // 假设 company 是你要查询的公司对象
 | 
	
		
			
				|  |  | -        Userquery.equalTo('isEnabled', true);
 | 
	
		
			
				|  |  | -        Userquery.notEqualTo('isDeleted', true);
 | 
	
		
			
				|  |  | -        Userquery.include('parent');
 | 
	
		
			
				|  |  | +    // async getDepartment() {
 | 
	
		
			
				|  |  | +    //     const currentUser = Parse.User.current();
 | 
	
		
			
				|  |  | +    //     let Userquery = new Parse.Query('Department');
 | 
	
		
			
				|  |  | +    //     Userquery.equalTo('company', company); // 假设 company 是你要查询的公司对象
 | 
	
		
			
				|  |  | +    //     Userquery.equalTo('isEnabled', true);
 | 
	
		
			
				|  |  | +    //     Userquery.notEqualTo('isDeleted', true);
 | 
	
		
			
				|  |  | +    //     Userquery.include('parent');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        let P2 = await Userquery.find();
 | 
	
		
			
				|  |  | -        let Departmentlist = P2.map(item => item.toJSON());
 | 
	
		
			
				|  |  | +    //     let P2 = await Userquery.find();
 | 
	
		
			
				|  |  | +    //     let Departmentlist = P2.map(item => item.toJSON());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        // 创建一个以工会为键的对象,以便于匹配
 | 
	
		
			
				|  |  | -        const unionsMap = {};
 | 
	
		
			
				|  |  | -        console.log(Departmentlist);
 | 
	
		
			
				|  |  | -        // 遍历部门列表,构建工会映射
 | 
	
		
			
				|  |  | -        Departmentlist.forEach(department => {
 | 
	
		
			
				|  |  | -            //有工会的部门
 | 
	
		
			
				|  |  | -            if (department.parent && department.parent.objectId) {
 | 
	
		
			
				|  |  | -                const unionId = department.parent.objectId; //工会id
 | 
	
		
			
				|  |  | +    //     // 创建一个以工会为键的对象,以便于匹配
 | 
	
		
			
				|  |  | +    //     const unionsMap = {};
 | 
	
		
			
				|  |  | +    //     console.log(Departmentlist);
 | 
	
		
			
				|  |  | +    //     // 遍历部门列表,构建工会映射
 | 
	
		
			
				|  |  | +    //     Departmentlist.forEach(department => {
 | 
	
		
			
				|  |  | +    //         //有工会的部门
 | 
	
		
			
				|  |  | +    //         if (department.parent && department.parent.objectId) {
 | 
	
		
			
				|  |  | +    //             const unionId = department.parent.objectId; //工会id
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                // 如果工会还没有在映射中,创建一个新的工会对象
 | 
	
		
			
				|  |  | -                if (!unionsMap[unionId]) {
 | 
	
		
			
				|  |  | -                    unionsMap[unionId] = {
 | 
	
		
			
				|  |  | -                        text: department.parent.name, // 工会名称
 | 
	
		
			
				|  |  | -                        objectId: department.parent.objectId,
 | 
	
		
			
				|  |  | -                        children: [] // 初始化子部门数组
 | 
	
		
			
				|  |  | -                    };
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                // 将部门添加到对应的工会子项中
 | 
	
		
			
				|  |  | -                unionsMap[unionId].children.push({
 | 
	
		
			
				|  |  | -                    text: department.name, // 部门名称
 | 
	
		
			
				|  |  | -                    id: department.objectId, // 部门 ID
 | 
	
		
			
				|  |  | -                    upid: department.parent.objectId
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                if (!unionsMap[department.objectId]) {
 | 
	
		
			
				|  |  | -                    unionsMap[department.objectId] = {
 | 
	
		
			
				|  |  | -                        text: department.name, // 工会名称
 | 
	
		
			
				|  |  | -                        objectId: department.objectId,
 | 
	
		
			
				|  |  | -                        children: [] // 初始化子部门数组
 | 
	
		
			
				|  |  | -                    };
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | +    //             // 如果工会还没有在映射中,创建一个新的工会对象
 | 
	
		
			
				|  |  | +    //             if (!unionsMap[unionId]) {
 | 
	
		
			
				|  |  | +    //                 unionsMap[unionId] = {
 | 
	
		
			
				|  |  | +    //                     text: department.parent.name, // 工会名称
 | 
	
		
			
				|  |  | +    //                     objectId: department.parent.objectId,
 | 
	
		
			
				|  |  | +    //                     children: [] // 初始化子部门数组
 | 
	
		
			
				|  |  | +    //                 };
 | 
	
		
			
				|  |  | +    //             }
 | 
	
		
			
				|  |  | +    //             // 将部门添加到对应的工会子项中
 | 
	
		
			
				|  |  | +    //             unionsMap[unionId].children.push({
 | 
	
		
			
				|  |  | +    //                 text: department.name, // 部门名称
 | 
	
		
			
				|  |  | +    //                 id: department.objectId, // 部门 ID
 | 
	
		
			
				|  |  | +    //                 upid: department.parent.objectId
 | 
	
		
			
				|  |  | +    //             });
 | 
	
		
			
				|  |  | +    //         } else {
 | 
	
		
			
				|  |  | +    //             if (!unionsMap[department.objectId]) {
 | 
	
		
			
				|  |  | +    //                 unionsMap[department.objectId] = {
 | 
	
		
			
				|  |  | +    //                     text: department.name, // 工会名称
 | 
	
		
			
				|  |  | +    //                     objectId: department.objectId,
 | 
	
		
			
				|  |  | +    //                     children: [] // 初始化子部门数组
 | 
	
		
			
				|  |  | +    //                 };
 | 
	
		
			
				|  |  | +    //             }
 | 
	
		
			
				|  |  | +    //         }
 | 
	
		
			
				|  |  | +    //     });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        // 将映射转换为数组
 | 
	
		
			
				|  |  | -        const result = Object.values(unionsMap);
 | 
	
		
			
				|  |  | +    //     // 将映射转换为数组
 | 
	
		
			
				|  |  | +    //     const result = Object.values(unionsMap);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        console.log(result);
 | 
	
		
			
				|  |  | -        this.setData({
 | 
	
		
			
				|  |  | -            items: result
 | 
	
		
			
				|  |  | -        })
 | 
	
		
			
				|  |  | -        console.log(this.data.items);
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | +    //     console.log(result);
 | 
	
		
			
				|  |  | +    //     this.setData({
 | 
	
		
			
				|  |  | +    //         items: result
 | 
	
		
			
				|  |  | +    //     })
 | 
	
		
			
				|  |  | +    //     console.log(this.data.items);
 | 
	
		
			
				|  |  | +    // },
 | 
	
		
			
				|  |  |      //点击工会
 | 
	
		
			
				|  |  | -    onClickNav({
 | 
	
		
			
				|  |  | -        detail = {}
 | 
	
		
			
				|  |  | -    }) {
 | 
	
		
			
				|  |  | -        this.setData({
 | 
	
		
			
				|  |  | -            mainActiveIndex: detail.index || 0,
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -        console.log(detail);
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | +    // onClickNav({
 | 
	
		
			
				|  |  | +    //     detail = {}
 | 
	
		
			
				|  |  | +    // }) {
 | 
	
		
			
				|  |  | +    //     this.setData({
 | 
	
		
			
				|  |  | +    //         mainActiveIndex: detail.index || 0,
 | 
	
		
			
				|  |  | +    //     });
 | 
	
		
			
				|  |  | +    //     console.log(detail);
 | 
	
		
			
				|  |  | +    // },
 | 
	
		
			
				|  |  |      //点击部门
 | 
	
		
			
				|  |  | -    onClickItem({
 | 
	
		
			
				|  |  | +    onClickItem(
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  |          detail = {}
 | 
	
		
			
				|  |  | -    }) {
 | 
	
		
			
				|  |  | -        const activeId = this.data.activeId === detail.id ? null : detail.id;
 | 
	
		
			
				|  |  | -        this.data.items.forEach((item) => {
 | 
	
		
			
				|  |  | -            if (item.objectId == detail.upid) {
 | 
	
		
			
				|  |  | -                this.setData({
 | 
	
		
			
				|  |  | -                    departname: item.text
 | 
	
		
			
				|  |  | -                })
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        })
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    ) {
 | 
	
		
			
				|  |  | +        // const activeId = this.data.activeId === detail.id ? null : detail.id;
 | 
	
		
			
				|  |  | +        // this.data.items.forEach((item) => {
 | 
	
		
			
				|  |  | +        //     if (item.objectId == detail.upid) {
 | 
	
		
			
				|  |  | +        //         this.setData({
 | 
	
		
			
				|  |  | +        //             departname: item.text
 | 
	
		
			
				|  |  | +        //         })
 | 
	
		
			
				|  |  | +        //     }
 | 
	
		
			
				|  |  | +        // })
 | 
	
		
			
				|  |  | +       const id =  this.data.Departmentlist[detail.index].objectId
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          this.setData({
 | 
	
		
			
				|  |  | -            activeId,
 | 
	
		
			
				|  |  | -            selectname: detail.text,
 | 
	
		
			
				|  |  | -            selectobjectid: detail.id,
 | 
	
		
			
				|  |  | -            upiobjectid: detail.upid
 | 
	
		
			
				|  |  | +            // activeId,
 | 
	
		
			
				|  |  | +            selectname: detail.value,
 | 
	
		
			
				|  |  | +            selectobjectid:id
 | 
	
		
			
				|  |  | +            // selectobjectid: detail.id,
 | 
	
		
			
				|  |  | +            // upiobjectid: detail.upid
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          this.onClickHide()
 | 
	
		
			
				|  |  | -        console.log(detail);
 | 
	
		
			
				|  |  | +        console.log(this.data.selectobjectid);
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      //显示遮罩层
 | 
	
		
			
				|  |  |      onClickShow() {
 | 
	
	
		
			
				|  | @@ -471,7 +500,7 @@ Page({
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      //返回上一页
 | 
	
		
			
				|  |  | -  async  goback() {
 | 
	
		
			
				|  |  | +    async goback() {
 | 
	
		
			
				|  |  |          let pages = getCurrentPages(); //页面对象
 | 
	
		
			
				|  |  |          let prevpage = pages[pages.length - 2]; //上一个页面对象
 | 
	
		
			
				|  |  |          console.log(prevpage);
 |