提交 20c05fcc 作者: wk

组织切换组织树优化替换

父级 6199a14c
......@@ -3,16 +3,16 @@ const $config = {
loginTemplateNo: "industry-0001",
systemCode: "buildingSite",
/* 授权码 */
// authCode: "477A0661-EF04-11F7-9D69-0BDD73F06500",
authCode: "477A0661-EF04-11F7-9D69-0BDD73F06500",
// authCode: "07EC0FDA-0249-6DB3-7422-0AFFF34E0E90", //测试
authCode: "D0539533-E169-5338-8ED7-3FAD554F4F62", //正式
// authCode: "D0539533-E169-5338-8ED7-3FAD554F4F62", //正式
pageSize: 20,
isPage: 1,
smsCfg: "industry",
/* api域名 */
// base: "https://dev-console-api.hzdingmao.com",
base: "https://dev-console-api.hzdingmao.com",
// base: "https://test-console-api.hzdingmao.com",
base: "https://console-api.hibuilding.cn",
// base: "https://console-api.hibuilding.cn",
/* 工地沟通日 */
// gtrBase:"https://cwcd-h5.huizhucloud.com",//测试
gtrBase: "https://gdt-front-mobile.hibuilding.cn", //生产
......
......@@ -321,8 +321,8 @@
}
.ly-tree-node__icon {
width: 30rpx;
height: 30rpx;
width: 40rpx;
height: 40rpx;
overflow: hidden;
margin-right: 16rpx;
}
......@@ -334,8 +334,8 @@
}
.ly-tree-node__label {
font-size: 32rpx;
color: #333333;
font-size: 28rpx;
color: #606266;
width: 750rpx;
}
......
......@@ -109,7 +109,7 @@
uni.scanCode({
success(res) {
let result = res.result
if (result.indexOf("?") != -1) {
if (result.indexOf("?") != -1) { //一物一码
let param = result.split("?")[1]
let params = param.replace(/&/g, '","').replace(/=/g, '":"')
let paramJson = `{"${params}"}`
......@@ -129,7 +129,8 @@
})
}
} else {
that.$toast.showToast("二维码格式不正确")
that.orgCode(res)
// that.$toast.showToast("二维码格式不正确")
}
},
fail() {
......@@ -137,6 +138,36 @@
}
})
},
orgCode(res) {
try {
let result = JSON.parse(res.result)
if (result && typeof result == 'object') {
let type = result.type
if (type == "company") {
this.code = result.text
uni.navigateTo({
url: `/pages/login/joinDepartment/joinDepartment?code=${this.code}&type=company`
})
} else if (type == "project") {
this.code = result.text
uni.navigateTo({
url: `/pages/login/joinDepartment/joinDepartment?code=${this.code}&type=project&projectId=${result.ext.id}`
})
} else if (type == "department") {
this.code = result.text
uni.navigateTo({
url: `/pages/login/joinDepartment/joinDepartment?code=${this.code}&type=department`
})
} else {
this.$toast.showToast("二维码格式不正确")
}
} else {
this.$toast.showToast("二维码格式不正确")
}
} catch (e) {
this.$toast.showToast("二维码格式不正确")
}
}
}
}
</script>
......
......@@ -473,7 +473,10 @@
"navigationBarTextStyle": "white",
"navigationBarTitleText": "智慧工地一点通",
"navigationBarBackgroundColor": "#3B73FE",
"backgroundColor": "#3B73FE"
"backgroundColor": "#3B73FE",
"usingComponents": {
"ly-tree-node": "/components/ly-tree/ly-tree-node"
}
},
"uniIdRouter": {},
"tabBar": {
......
......@@ -189,7 +189,7 @@
return
}
uni.navigateTo({
url: "/pages/mine/changeOrg/changeOrg"
url: "/pagesSub/mine/changeOrg/changeOrg"
})
},
toIndex(model) {
......
......@@ -568,21 +568,17 @@
//如果是工人 获取工人当前项目
if (this.role == 'PM') {
if (jobs) {
let currentJob = jobs[0]
uni.setStorageSync("org_no", currentJob.org_no)
uni.setStorageSync("org_id", currentJob.org_id)
//当前岗位 判断当前岗位是项目部还是其他
if (this.userInfo.user.dept_type == '2') { //项目级
this.project_id = uni.getStorageSync("project_id")
console.log("当前组织", this.project_id);
if (!this.project_id) {
this.loadProject()
} else {
this.initData()
}
uni.setStorageSync("org_name", currentJob.dept_name)
} else {
let currentJob = jobs[0]
uni.setStorageSync("org_no", currentJob.org_no)
uni.setStorageSync("org_name", currentJob.org_name)
this.initData()
}
this.initData()
}
} else {
this.project_id = uni.getStorageSync("project_id")
......
......@@ -11,8 +11,9 @@
<view class="enter">{{isCurrent(item)?"当前组织":""}}</view>
</view>
<view class="job-content" v-if="item.isOpen">
<view class="j-item" v-for="(job,jIndex) in item.job_list" :key="jIndex">
<view class="j-name" @click="jobSel(item,job)">
<view class="j-item" v-for="(job,jIndex) in item.job_list" :key="jIndex"
@click="jobSel(item,job)">
<view class="j-name">
{{job.dept_name}}-{{job.job_name}}
</view>
<image :src="setSelImage(job)" class="image"></image>
......@@ -221,6 +222,7 @@
.job-content {
display: flex;
flex-direction: column;
margin-left: 40rpx;
.j-item {
padding: 30rpx 30rpx 0 30rpx;
......
......@@ -4,16 +4,25 @@
<view class="search">
<view class="search-content">
<image src="../../../static/ic-search.png" class="image"></image>
<input placeholder="搜索" placeholder-class="placeholderStyle" @input="search" class="inputStyle" />
<input placeholder="搜索" placeholder-class="placeholderStyle" @input="search" class="inputStyle"
v-model="key" />
</view>
</view>
<view class="org-content">
<ly-tree :tree-data="trees" :props="treeProps" node-key="id" @node-expand="handleNodeExpand"
@node-click="handleNodeClick" :showRadio="true" ref="tree" :defaultCheckedKeys="currentKeys"
:defaultExpandedKeys="currentKeys" childVisibleForFilterNode="true" :filter-node-method="filterNode"
:checkOnClickNode="true" :childVisibleForFilterNode="true">
</ly-tree>
<view class="uni-group-button">
<view class="uni-blue-button" @click="toSwitch">确认切换该组织</view>
</view>
<!-- 暂时处理 -->
<view class="org-content" v-if="false">
<view class="org-list">
<view class="org-item" v-for="(tree,index) in trees" :key="index">
<view class="org">
<image
:src="tree.isOpen?'../../../static/icon_up_arrow.png':'../../../static/icon_drop_arrow.png'"
class="image" @click="toNextLevel(tree,index)">
<image v-if="isImgShow(tree)" :src="setImgSrc(tree)" class="image"
@click="toNextLevel(tree,index)">
</image>
<view class="name" @click="toNextLevel(tree,index)">{{tree.name}}</view>
<view class=" enter" @click="itemClick(tree)">进入</view>
......@@ -21,10 +30,8 @@
<view v-if="tree.isOpen" style="margin-top: 20rpx;">
<view class="org-item" v-for="(oneLevel,oneIndex) in tree.children_list" :key="oneIndex">
<view class="org">
<image
v-if="!oneLevel.project_id&&oneLevel.children_list&&oneLevel.children_list.length>0"
:src="oneLevel.isOpen?'../../../static/icon_up_arrow.png':'../../../static/icon_drop_arrow.png'"
class="image" @click="toNextChild(index,oneLevel,oneIndex)"></image>
<image v-if="isImgShow(oneLevel)" :src="setImgSrc(oneLevel)" class="image"
@click="toNextChild(index,oneLevel,oneIndex)"></image>
<view class="name" @click="toNextChild(index,oneLevel,oneIndex)">{{oneLevel.name}}
</view>
<view class="enter" @click="itemClick(oneLevel)">进入</view>
......@@ -51,14 +58,75 @@
export default {
data() {
return {
key: "",
trees: [],
temp: []
temp: [],
treeProps: function() {
return {
label: 'name', // 指把数据中的‘personName’当做label也就是节点名称
children: 'children_list' // 指
}
},
currentKeys: []
}
},
onLoad() {
var currentId = uni.getStorageSync("org_id")
if (currentId) {
this.currentKeys.push(currentId)
}
console.log("当前选中", this.currentKey);
this.getOrgTree()
},
watch: {
key(val) {
this.$refs.tree.filter(val);
}
},
methods: {
handleNodeClick(obj) {
// console.log('handleNodeClick', obj);
},
handleNodeExpand(obj) {
},
filterNode(value, data) {
if (!value) return true;
// if (!data.label) return false
return data.name.indexOf(value) != -1;
},
toSwitch() {
var node = this.$refs.tree.getCheckedNodes()
if (node.length < 0) {
this.$toast.showToast("请选择切换的组织")
return
}
let that = this
uni.showModal({
title: '提示',
content: '确定切换到该组织?',
showCancel: true,
confirmText: "切换",
confirmColor: '#1890FF',
success: res => {
if (res.confirm) {
that.switchOrg(node[0])
}
}
})
},
setImgSrc(item) {
return item.isOpen ? '../../../static/icon_up_arrow.png' : '../../../static/icon_drop_arrow.png'
},
isImgShow(level) {
if (level.project_id) {
return false
}
if (level.children_list && level.children_list.length > 0) {
return true
}
return false
},
dealProject(list) {
var projects = []
list.forEach((item) => {
......@@ -73,7 +141,8 @@
Api.getOrgTree({
data: {
company_id: uni.getStorageSync("company_id"),
org_no: getApp().globalData.userInfo.user.org_no
org_no: getApp().globalData.userInfo.user.org_no,
show_current_level: 1
}
}).then((result) => {
console.log("组织树", result);
......@@ -85,11 +154,11 @@
item.dept_no == getApp().globalData.userInfo.user.dept_no
)
} else {
if (list[0].no == '001') {
this.trees = list[0].children_list
} else {
this.trees = list
}
// if (list[0].no == '001') {
// this.trees = list[0].children_list
// } else {
this.trees = list
// }
}
this.temp = list[0].children_list
}
......@@ -156,62 +225,63 @@
})
},
search(e) {
var key = e.detail.value
if (key) {
var list = []
var sourceData = this.temp
console.log("数据源", sourceData);
sourceData.forEach((item) => {
if (item.name.indexOf(key) != -1) {
item.isOpen = true
list.push(item)
} else {
var children = item.children_list
var childrens = []
if (children) {
children.forEach((child) => {
if (child.name.indexOf(key) != -1) {
child.isOpen = true
var childs = child.children_list
var childList = []
if (childs) {
childs.forEach((childItem) => {
if (childItem.name.indexOf(key) != -1) {
childList.push(childItem)
}
})
}
child.children_list = childList
childrens.push(child)
} else {
var childs = child.children_list
var childList = []
if (childs) {
childs.forEach((childItem) => {
if (childItem.name.indexOf(key) != -1) {
childList.push(childItem)
}
})
}
if (childList.length > 0) {
child.children_list = childList
child.isOpen = true
childrens.push(child)
}
}
})
}
if (childrens.length > 0) {
item.isOpen = true
item.children_list = childrens
list.push(item)
}
}
})
this.trees = list
} else {
this.getOrgTree()
}
// var key = e.detail.value
// this.$refs.tree.filter(key, null)
// if (key) {
// var list = []
// var sourceData = this.temp
// console.log("数据源", sourceData);
// sourceData.forEach((item) => {
// if (item.name.indexOf(key) != -1) {
// item.isOpen = true
// list.push(item)
// } else {
// var children = item.children_list
// var childrens = []
// if (children) {
// children.forEach((child) => {
// if (child.name.indexOf(key) != -1) {
// child.isOpen = true
// var childs = child.children_list
// var childList = []
// if (childs) {
// childs.forEach((childItem) => {
// if (childItem.name.indexOf(key) != -1) {
// childList.push(childItem)
// }
// })
// }
// child.children_list = childList
// childrens.push(child)
// } else {
// var childs = child.children_list
// var childList = []
// if (childs) {
// childs.forEach((childItem) => {
// if (childItem.name.indexOf(key) != -1) {
// childList.push(childItem)
// }
// })
// }
// if (childList.length > 0) {
// child.children_list = childList
// child.isOpen = true
// childrens.push(child)
// }
// }
// })
// }
// if (childrens.length > 0) {
// item.isOpen = true
// item.children_list = childrens
// list.push(item)
// }
// }
// })
// this.trees = list
// } else {
// this.getOrgTree()
// }
}
}
......@@ -227,7 +297,7 @@
display: flex;
flex-direction: row;
align-items: center;
margin: 30rpx 30rpx 0 30rpx;
margin: 30rpx;
.search-content {
display: flex;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment