const _Http = getApp().globalData.http; Component({ properties: { isdep: { type: Boolean, value: true }, isusers: { type: Boolean, value: true }, defaultMy: { type: Boolean, value: true }, exclution: { type: Boolean, value: true }, dimissionF: { type: Boolean } }, lifetimes: { attached: function () { getApp().globalData.Language.getLanguagePackage(this) } }, data: { takeEffect: "", //生效筛选项 result: {}, isleave: 0, tabs: [{ value: 0, name: "全部" }, { value: 1, name: "在职" }, { value: 2, name: "离职" }], searchValue: "" }, methods: { searchChange({ detail }) { if (detail.length == 0) return this.searchClear() let list = JSON.parse(JSON.stringify(this.data.users.copyList)); this.setData({ 'users.list': list.filter(v => v.name.includes(detail) || v.accountno.includes(detail)) }) }, searchClear() { this.setData({ 'users.list': JSON.parse(JSON.stringify(this.data.users.copyList)) }) }, changLeave(e) { this.setData({ isleave: e.currentTarget.dataset.value, 'result.isleave': e.currentTarget.dataset.value }) }, initDepAndUser() { this.setData({ result: {}, takeEffect: "" }) return new Promise((resolve) => { _Http.basic({ "id": 20230620102004, "content": {} }).then(res => { console.log("获取部门", res) if (this.data.isdep) this.setData({ depGroud: [{ label: "部门", list: res.data.dep, active: "" }] }) if (this.data.isusers) { let active = '' if (this.data.defaultMy) { let user = res.data.hr.find(v => v.userid == wx.getStorageSync('userMsg').userid) if (user) { active = user.userid; resolve(user) this.setData({ takeEffect: "user", result: user }) } } this.setData({ users: { label: "业务员", list: res.data.hr, copyList: res.data.hr, active } }) } resolve({}) }) }) }, selectDep(e) { const { item, index } = e.currentTarget.dataset; let depGroud = this.data.depGroud.slice(0, index + 1); depGroud[index].active = item.departmentid; if (item.subdep.length) { item.subdep.unshift(JSON.parse(JSON.stringify(item))) item.subdep[0].depname = getApp().globalData.Language.getMapText('全部'); item.subdep[0].subdep = []; depGroud.push({ label: item.depname + getApp().globalData.Language.getMapText('下级部门'), list: item.subdep, active: item.departmentid }) } item.name = item.depname item.isleave = this.data.isleave; this.setData({ depGroud, takeEffect: "dep", result: item }) }, selectUser(e) { const { item } = e.currentTarget.dataset; this.setData({ 'users.active': item.userid, takeEffect: "user", result: item }) }, } })