diff --git a/pages/login/login_.vue b/pages/login/login_.vue index d43d09a..3ba37ec 100644 --- a/pages/login/login_.vue +++ b/pages/login/login_.vue @@ -359,6 +359,7 @@ }, formSubmit(e) { + // debugger; uni.showLoading({ title: '加载中' }); @@ -368,7 +369,8 @@ that.$u.api.login(obj).then(res => { uni.hideLoading(); that.$u.vuex('vuex_token', res.access) - that.$u.vuex('vuex_refresh', res.refresh) + that.$u.vuex('vuex_refresh', res.refresh); + that.getUserRange(); that.$u.api.getUserInfo().then(user => { if(user.avatar){ user.avatar = this.vuex_host + user.avatar @@ -421,16 +423,77 @@ }) }).catch(e=>{}) // #endif - /* let secret = that.ranStr(12) - let mySecret = {'username': obj.username, 'secret': secret} - that.$u.api.bindSecret({secret: secret}).then(res=>{ - uni.setStorageSync('mySecret', JSON.stringify(mySecret)) - }).catch(e=>{}) */ - }).catch(e => { console.log(e) }) }, + getUserRange(){ + let that = this; + that.$u.api.deptList({page: 0,type__in:'rparty,dept'}).then(res => { + let arr = []; + let obj = {}; + res.forEach(item=>{ + obj = {...item}; + obj.children = []; + arr.push(obj) + }) + let userRange0 = that.resetData(arr); + let useArr = userRange0[0].children; + + for (let i=0;i0){ + let childrenArr = useArr[i].children; + for(let j = 0;j { + res1.forEach(item1=>{ + useArr[i].children[j].children.push(item1); + that.$u.vuex('vuex_userRange', useArr) + }) + }) + } + + } + } + that.$u.api.userList({page: 0,belong_dept:useArr[i].id}).then(res0 => { + res0.forEach(item0=>{ + useArr[i].children.push(item0); + that.$u.vuex('vuex_userRange', useArr) + }) + }) + } + setTimeout(function(){ + // debugger; + console.log(useArr); + that.$u.vuex('vuex_userRange', useArr) + },3000) + }) + }, + resetData(params) { + let posts = []; + params.forEach((item) => { + let obj = new Object(); + obj = { + ...item + }; + obj.value = item.id; + obj.text = item.name; + obj.parentId = item.parent; + posts.push(obj); + }); + let obj = posts.reduce((res, v) => ((res[v.id] = v), res), {}); //Object + let arr = []; + for (let item of posts) { + if (item.parentId == null) { + arr.push(item); + continue; + } + let parent = obj[item.parentId]; + parent.children = parent.children ? parent.children : []; + parent.children.push(item); + } + return arr; + }, formSubmit2(e) { var that = this; const obj = e.target.value; @@ -438,8 +501,7 @@ that.$u.api.codeLogin(obj).then(res => { that.$u.vuex('vuex_token', res.access) that.$u.vuex('vuex_refresh', res.refresh) - // let data = {openid: uni.getStorageSync('wxmp_openid')} - // that.$u.api.bindmp(data).then(res=>{}) + that.getUserRange(); that.$u.api.getUserInfo().then(res => { if(res.avatar){ res.avatar = this.vuex_host + res.avatar @@ -466,7 +528,7 @@ }, // 获取验证码 getCode() { - debugger; + // debugger; console.log(this.phoneNumber) if (this.phoneNumber !== '') { if (this.$refs.uCode.canGetCode){ diff --git a/pages/workSpace/operation/operationCreate.vue b/pages/workSpace/operation/operationCreate.vue index ce6b065..4685c59 100644 --- a/pages/workSpace/operation/operationCreate.vue +++ b/pages/workSpace/operation/operationCreate.vue @@ -13,7 +13,6 @@ - 具体地点 @@ -97,7 +96,7 @@ + :localdata="vuex_userRange" valueKey="id" textKey="name" childrenKey="children" :selectParent='false'/> {{dcoordinator_name}} @@ -183,8 +182,6 @@ }, onShow() { this.getdept(); - this.getRange(); - this.getUserRange(); this.range = []; }, methods: { @@ -248,7 +245,7 @@ }, //获取工作operation getOperation() { - debugger; + // debugger; let that = this; that.$u.api.operationItem(that.operationId).then((res) => { that.formData.id = res.id; // @@ -267,6 +264,9 @@ that.formData.vchannel = res.vchannels[0] } that.operationName = res.name; //作业 + that.dept_ter_name = res.dept_ter_.name; //属地部门 + that.dept_bus_name = res.dept_bus_.name; //业务部门 + that.dcoordinator_name = res.coordinator_name; //部门协调员 that.datetimerange = [res.start_time, res.end_time] }); }, @@ -310,48 +310,7 @@ that.depRange = resetData(res); }) }, - //获取作业区域 - getRange() { - this.$u.api.areaLists({page: 0}).then(res => { - let range = []; - let obj = {}; - res.forEach(item => { - obj = {value: null,text: ''}; - obj.value = item.id; - obj.text = item.name; - range.push(obj); - }) - this.range = range - }) - }, - //获取用户 - getUserRange() { - let that = this; - /* that.$u.api.deptList({page: 0}).then(res => { - that.userRange = resetData(res)[0].children; - let depts = that.userRange; - for (let i=0;i { - depts[i].children = res; - that.userRange = depts; - }) - } - that.userRange = depts; - }) */ - that.$u.api.deptList({page: 0}).then(res => { - that.userRange = resetData(res); - let userRange = that.userRange[0]; - let depts = userRange.children; - for (let i=0;i { - depts[i].children = res; - }) - } - that.userRange.children = depts; - that.userRange = depts; - }) - }, + /* 参数验证 */ paramsCheck() { if (!nonNullCheck(this.formData.name)) { diff --git a/pages/workSpace/workSpace.vue b/pages/workSpace/workSpace.vue index c8e0d82..53f3d01 100644 --- a/pages/workSpace/workSpace.vue +++ b/pages/workSpace/workSpace.vue @@ -5,14 +5,6 @@ style="position: absolute;top:0;left:0;bottom:0;right:0;height: 290rpx;background-image: url(../../static/workSpace/bgimg.png);background-position: center bottom;background-size: 100%;"> - @@ -115,7 +107,7 @@ }, onShow() { // debugger; - // console.log(this.vuex_perm) + console.log(this.vuex_userRange) this.limitedRpj = this.vuex_perm.includes('rpj.create')>-1||this.vuex_perm.includes('superuser')>-1; this.limitedOperation = this.vuex_perm.includes('operation.create')>-1||this.vuex_perm.includes('superuser')>-1; }, diff --git a/store/index.js b/store/index.js index 5c1aeda..484e4c6 100644 --- a/store/index.js +++ b/store/index.js @@ -12,7 +12,7 @@ try{ } // 需要永久存储,且下次APP启动需要取出的,在state中的变量名 -let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_appid','vuex_perm','vuex_employee']; +let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_appid','vuex_perm','vuex_employee','vuex_userRange']; // 保存变量到本地存储中 const saveLifeData = function(key, value){ @@ -34,6 +34,7 @@ const store = new Vuex.Store({ vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {}, vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '', vuex_perm: lifeData.vuex_perm ? lifeData.vuex_perm : [], + vuex_userRange: lifeData.vuex_userRange ? lifeData.vuex_userRange : [], vuex_appid: 'wxf7d6140f507466be', vuex_login: 'http://qyjy.ctc-zc.com/h5/', vuex_version: '1.00.08',