Commit fda702be by xinla

Merge branch 'master' into develop

2 parents deb247d6 43764a5c
import request from '@/utils/request' import request from '@/utils/request'
const service = window.lwConfig.services.wecom const service = window.lwConfig.services.wecom
const weChat = window.lwConfig.services.weChat
/** /**
* 获取应用的jsapi_ticket * 获取应用的jsapi_ticket
...@@ -17,7 +18,7 @@ export function getAgentTicket (url) { ...@@ -17,7 +18,7 @@ export function getAgentTicket (url) {
export function getWxTicket (data) { export function getWxTicket (data) {
return request({ return request({
url: service + '/ticket/getWxTicket', url: weChat + '/ticket/getWxTicket',
params: { params: {
url: data, url: data,
}, },
......
...@@ -91,57 +91,36 @@ import { getUserOpenid, getWechatUserInfo, getWxRedirect, wxLogin } from '@/api/ ...@@ -91,57 +91,36 @@ import { getUserOpenid, getWechatUserInfo, getWxRedirect, wxLogin } from '@/api/
// 微信端授权登录 // 微信端授权登录
export async function getWxCode () { export async function getWxCode () {
let userinfo = sessionStorage.getItem('userinfo') let userinfo = sessionStorage.getItem('userinfo')
//取缓存中的用户信息 //取缓存中的用户信息
if (userinfo) { if (userinfo) {
try {
userinfo = JSON.parse(userinfo)
} catch (error) {
// alert(error)
}
return userinfo
}
//缓存中没有用户信息,进入授权流程
// let appId = 'wxa57479bcd3f15461'
let appId = window.lwConfig.appId // 微信公众号id
// let appId = 'wxa57479bcd3f15461' // 公众号appid
let code = getQueryValue('code') //是否存在code
// let query = param2Obj() //
// let { code, appId, secret } = query
let local = window.location.origin.includes('localhost')
? 'http://h5.linkwechat.cn/test.html'
: window.location.href
if (!code) {
//不存在就打开上面的地址进行授权
let url = ''
if (appId) {
url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURIComponent(
local
)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
} else {
url = (await getWxRedirect()).data
let id = getQueryValue('appid', url)
sessionStorage.setItem('weAppId', id)
}
window.location.href = url
// return new Promise(() => { })
// window.location.href =
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
}
try { try {
if (code) { userinfo = JSON.parse(userinfo)
let { data: dataLogin } = await wxLogin(code)
sessionStorage.setItem('token', dataLogin.access_token)
let { data: dataUser } = await getWechatUserInfo()
sessionStorage.setItem('userinfo', JSON.stringify(dataUser))
return dataUser
}
} catch (error) { } catch (error) {
// alert(JSON.stringify(error)) // alert(error)
return Promise.reject() }
return userinfo
}
let code = getQueryValue('code') //是否存在code
if (!code) {
let url = (await getWxRedirect()).data
let id = getQueryValue('appid', url)
sessionStorage.setItem('weAppId', id)
window.location.href = url
}
try {
if (code) {
let { data: dataLogin } = await wxLogin(code)
sessionStorage.setItem('token', dataLogin.access_token)
let { data: dataUser } = await getWechatUserInfo()
sessionStorage.setItem('userinfo', JSON.stringify(dataUser))
return dataUser
} }
} catch (error) {
return Promise.reject()
}
} }
// 日期时间格式化 // 日期时间格式化
export function dateFormat (dateString, fmt = 'yyyy-MM-dd hh:mm:ss') { export function dateFormat (dateString, fmt = 'yyyy-MM-dd hh:mm:ss') {
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
"benz-amr-recorder": "^1.1.3", "benz-amr-recorder": "^1.1.3",
"clipboard": "2.0.4", "clipboard": "2.0.4",
"core-js": "^3.20.2", "core-js": "^3.20.2",
"cos-js-sdk-v5": "^1.4.11",
"crypto-js": "^4.1.1",
"driver.js": "^0.9.8", "driver.js": "^0.9.8",
"echarts": "^5.3.0", "echarts": "^5.3.0",
"element-ui": "^2.15.7", "element-ui": "^2.15.7",
...@@ -63,9 +65,11 @@ ...@@ -63,9 +65,11 @@
"nprogress": "0.2.0", "nprogress": "0.2.0",
"path-to-regexp": "2.4.0", "path-to-regexp": "2.4.0",
"promise.prototype.finally": "^3.1.2", "promise.prototype.finally": "^3.1.2",
"qrcodejs2": "0.0.2",
"screenfull": "4.2.0", "screenfull": "4.2.0",
"sortablejs": "1.8.4", "sortablejs": "1.8.4",
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vant": "^2.12.50",
"video.js": "^7.11.4", "video.js": "^7.11.4",
"videojs-contrib-hls": "^5.15.0", "videojs-contrib-hls": "^5.15.0",
"vue": "2.6.10", "vue": "2.6.10",
...@@ -76,6 +80,7 @@ ...@@ -76,6 +80,7 @@
"vue-quill-editor": "3.0.6", "vue-quill-editor": "3.0.6",
"vue-router": "3.5.3", "vue-router": "3.5.3",
"vue-super-flow": "^1.3.8", "vue-super-flow": "^1.3.8",
"vuedraggable": "^2.24.3",
"vuex": "3.1.0" "vuex": "3.1.0"
}, },
"devDependencies": { "devDependencies": {
...@@ -99,6 +104,7 @@ ...@@ -99,6 +104,7 @@
"lint-staged": "8.1.5", "lint-staged": "8.1.5",
"mockjs": "1.0.1-beta3", "mockjs": "1.0.1-beta3",
"plop": "2.3.0", "plop": "2.3.0",
"quill-image-extend-module": "^1.1.2",
"runjs": "4.3.2", "runjs": "4.3.2",
"sass": "^1.47.0", "sass": "^1.47.0",
"sass-loader": "8.0.2", "sass-loader": "8.0.2",
......
<script> <script>
import { getDeptTree, getDeptUser } from '@/api/organization' import { getDeptTree, getDeptUser } from '@/api/organization'
import { createUniqueString } from '@/utils'
export default { export default {
name: 'SelectUser', name: 'SelectUser',
components: {}, components: {},
...@@ -49,7 +47,12 @@ ...@@ -49,7 +47,12 @@
return { return {
treeData: [], treeData: [],
userList: [], userList: [],
defaultKeys: [] defaultKeys: [],
deptId: '', //根部门Id
keywords: '',
searchResult: [],
searchState: false,
checked: []
} }
}, },
watch: { watch: {
...@@ -86,11 +89,7 @@ ...@@ -86,11 +89,7 @@
label: 'name', label: 'name',
children: 'children', children: 'children',
disabled(data, node) { disabled(data, node) {
return ( return (that.isOnlyLeaf && data.isParty) || that.disabledValues.some((e) => e == (data.userId || data.id))
(that.isOnlyLeaf && data.isParty) ||
that.disabledValues.some((e) => e == (data.userId || data.id)) ||
data.userId === ''
)
}, },
isLeaf(data, node) { isLeaf(data, node) {
return !data.id return !data.id
...@@ -101,6 +100,45 @@ ...@@ -101,6 +100,45 @@
created() {}, created() {},
mounted() {}, mounted() {},
methods: { methods: {
setChange(e) {
if (!e) {
this.searchState = false
this.$refs.tree.setCheckedKeys(this.userList.map((e) => e.userId || e.id))
}
},
setSearch() {
if (!this.keywords) return
this.searchResult = []
this.searchState = true
this.checked = this.userList.map((dd) => {
return dd.userId
})
getDeptUser({
deptId: this.deptId,
userName: this.keywords
}).then((res) => {
this.searchResult = this.handleUser(res.rows)
})
},
setSelectChange(e, index) {
if (e) {
if (this.isSigleSelect) {
this.userList[0] = this.searchResult[index]
} else {
this.userList.push(this.searchResult[index])
}
this.checked = this.userList.map((dd) => {
return dd.userId
})
this.$forceUpdate()
} else {
this.cancle(this.searchResult[index].userId)
}
setTimeout(() => {
this.keywords = ''
this.setChange()
}, 500)
},
treeFormat(list) { treeFormat(list) {
let dealOptions = [] let dealOptions = []
list.forEach((one) => { list.forEach((one) => {
...@@ -126,21 +164,15 @@ ...@@ -126,21 +164,15 @@
this.userList = [] this.userList = []
} }
getDeptTree().then(({ data }) => { getDeptTree().then(({ data }) => {
// data.forEach((element) => {
// element.key = createUniqueString()
// })
let _data = this.handleDepart(data) let _data = this.handleDepart(data)
resolve(this.treeFormat(_data)) let value = this.treeFormat(_data)
// api.getList({ department: _data[0].id }).then(({ rows, total }) => { if (value.length) {
// _data && rows.unshift(..._data); this.deptId = value[0].deptId
// resolve(rows); }
// }); resolve(value)
}) })
} else { } else {
getDeptUser({ deptId: node.data.id }).then(({ rows }) => { getDeptUser({ deptId: node.data.id }).then(({ rows }) => {
// rows.forEach((element) => {
// element.key = createUniqueString()
// })
let arr = this.handleUser(rows) let arr = this.handleUser(rows)
node.data.children && arr.push(...node.data.children) node.data.children && arr.push(...node.data.children)
resolve(arr) resolve(arr)
...@@ -223,22 +255,46 @@ ...@@ -223,22 +255,46 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12" :xs="24"> <el-col :span="12" :xs="24">
<div class="head-container"> <div class="head-container">
<el-tree <div class="search-input">
node-key="nodeKey" <el-input
ref="tree" size="mini"
lazy v-model="keywords"
accordion @keyup.enter.native="setSearch"
show-checkbox placeholder="请输入员工名称"
:check-on-click-node="false" clearable
:expand-on-click-node="true" @change="setChange"
:load="loadNode" >
:props="defaultProps" <el-button slot="append" icon="el-icon-search" @click="setSearch"></el-button>
:check-strictly="isOnlyLeaf" </el-input>
@check-change="handleCheckChange" </div>
></el-tree> <div class="search-list user-list" v-show="searchState">
<!-- :default-checked-keys=" <el-checkbox-group v-model="checked">
defaultValues.map((e) => (isOnlyLeaf ? e.userId : e.userId || e.id)) <el-row v-for="(item, index) in searchResult" :key="index">
" --> <el-checkbox :label="item.userId" :key="index" @change="setSelectChange($event, index)">
<div>
{{ item.name }}
</div>
</el-checkbox>
</el-row>
</el-checkbox-group>
</div>
<transition name="fade">
<div class="head-container" v-show="!searchState">
<el-tree
node-key="nodeKey"
ref="tree"
lazy
accordion
show-checkbox
:check-on-click-node="false"
:expand-on-click-node="true"
:load="loadNode"
:props="defaultProps"
:check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"
></el-tree>
</div>
</transition>
</div> </div>
</el-col> </el-col>
<el-col :span="12" :xs="24" class="user-list"> <el-col :span="12" :xs="24" class="user-list">
...@@ -258,9 +314,32 @@ ...@@ -258,9 +314,32 @@
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.content {
min-height: 400px;
}
.search-input {
margin-top: 5px;
margin-bottom: 10px;
}
.user-list { .user-list {
.el-row { .el-row {
line-height: 26px; line-height: 26px;
} }
} }
.search-list {
margin-top: 20px;
padding: 0 10px;
}
.fade-enter-active {
transition: opacity 0.5s;
}
.fade-enter {
opacity: 0;
}
.fade-leave-active {
transition: opacity 0.5s;
}
.fade-leave-to {
opacity: 0;
}
</style> </style>
<script> <script>
import { getDeptTree, getDeptUser } from '@/api/organization' import { getDeptTree, getDeptUser } from '@/api/organization'
import { createUniqueString } from '@/utils'
export default { export default {
name: 'SelectWeUser', name: 'SelectWeUser',
components: {}, components: {},
...@@ -45,7 +43,12 @@ ...@@ -45,7 +43,12 @@
return { return {
treeData: [], treeData: [],
userList: [], userList: [],
defaultKeys: [] defaultKeys: [],
deptId: '', //根部门Id
keywords: '',
searchResult: [],
searchState: false,
checked: []
} }
}, },
watch: { watch: {
...@@ -90,11 +93,7 @@ ...@@ -90,11 +93,7 @@
label: 'name', label: 'name',
children: 'children', children: 'children',
disabled(data, node) { disabled(data, node) {
return ( return (that.isOnlyLeaf && data.isParty) || that.disabledValues.some((e) => e == (data.userId || data.id))
(that.isOnlyLeaf && data.isParty) ||
that.disabledValues.some((e) => e == (data.userId || data.id)) ||
data.userId === ''
)
}, },
isLeaf(data, node) { isLeaf(data, node) {
return !data.id return !data.id
...@@ -105,6 +104,45 @@ ...@@ -105,6 +104,45 @@
created() {}, created() {},
mounted() {}, mounted() {},
methods: { methods: {
setChange(e) {
if (!e) {
this.searchState = false
this.$refs.tree.setCheckedKeys(this.userList.map((e) => e.userId || e.id))
}
},
setSearch() {
if (!this.keywords) return
this.searchResult = []
this.searchState = true
this.checked = this.userList.map((dd) => {
return dd.userId
})
getDeptUser({
deptId: this.deptId,
userName: this.keywords
}).then((res) => {
this.searchResult = this.handleName(res.rows)
})
},
setSelectChange(e, index) {
if (e) {
if (this.isSigleSelect) {
this.userList[0] = this.searchResult[index]
} else {
this.userList.push(this.searchResult[index])
}
this.checked = this.userList.map((dd) => {
return dd.userId
})
this.$forceUpdate()
} else {
this.cancle(this.searchResult[index].userId)
}
setTimeout(() => {
this.keywords = ''
this.setChange()
}, 500)
},
treeFormat(list) { treeFormat(list) {
let dealOptions = [] let dealOptions = []
list.forEach((one) => { list.forEach((one) => {
...@@ -129,23 +167,16 @@ ...@@ -129,23 +167,16 @@
if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) { if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
this.userList = [] this.userList = []
} }
console.log(this.defaultValues)
getDeptTree().then(({ data }) => { getDeptTree().then(({ data }) => {
// data.forEach((element) => {
// element.key = createUniqueString()
// })
let _data = this.handleTree(data) let _data = this.handleTree(data)
resolve(this.treeFormat(_data)) let value = this.treeFormat(_data)
// api.getList({ department: _data[0].id }).then(({ rows, total }) => { if (value.length) {
// _data && rows.unshift(..._data); this.deptId = value[0].deptId
// resolve(rows); }
// }); resolve(value)
}) })
} else { } else {
getDeptUser({ deptId: node.data.id }).then(({ rows }) => { getDeptUser({ deptId: node.data.id }).then(({ rows }) => {
// rows.forEach((element) => {
// element.key = createUniqueString()
// })
let arr = this.handleName(rows) let arr = this.handleName(rows)
node.data.children && arr.push(...node.data.children) node.data.children && arr.push(...node.data.children)
resolve(arr) resolve(arr)
...@@ -166,7 +197,7 @@ ...@@ -166,7 +197,7 @@
handleName(data) { handleName(data) {
return data.map((i) => { return data.map((i) => {
if (i.userName) { if (i.userName) {
i.userId = i.weUserId ? i.weUserId : '' i.userId = i.weUserId
i.name = i.userName i.name = i.userName
} }
return i return i
...@@ -174,7 +205,6 @@ ...@@ -174,7 +205,6 @@
}, },
// 选择变化 // 选择变化
handleCheckChange(data, checked, indeterminate) { handleCheckChange(data, checked, indeterminate) {
// console.log(arguments)
if (checked) { if (checked) {
if (this.isSigleSelect) { if (this.isSigleSelect) {
// 单选情况 // 单选情况
...@@ -189,11 +219,9 @@ ...@@ -189,11 +219,9 @@
!isExist && this.userList.push(data) !isExist && this.userList.push(data)
} }
} else { } else {
// let index = this.userList.indexOf(data)
let index = this.userList.findIndex((i) => i.userId === data.userId) let index = this.userList.findIndex((i) => i.userId === data.userId)
index > -1 && this.userList.splice(index, 1) index > -1 && this.userList.splice(index, 1)
} }
// console.log(data, checked, indeterminate);
this.userList = this.unique(this.userList) this.userList = this.unique(this.userList)
}, },
unique(arr) { unique(arr) {
...@@ -225,26 +253,48 @@ ...@@ -225,26 +253,48 @@
</script> </script>
<template> <template>
<el-dialog :title="title" :visible.sync="Pvisible" :close-on-click-modal="false" :destroy-on-close="destroyOnClose"> <el-dialog :title="title" :visible.sync="Pvisible" :close-on-click-modal="false" :destroy-on-close="destroyOnClose">
<el-row :gutter="20"> <el-row :gutter="20" class="content">
<el-col :span="12" :xs="24"> <el-col :span="12" :xs="24">
<div class="head-container"> <div class="search-input">
<el-tree <el-input
node-key="userId" size="mini"
ref="tree" v-model="keywords"
lazy @keyup.enter.native="setSearch"
accordion placeholder="请输入员工名称"
show-checkbox clearable
:check-on-click-node="false" @change="setChange"
:expand-on-click-node="true" >
:load="loadNode" <el-button slot="append" icon="el-icon-search" @click="setSearch"></el-button>
:props="defaultProps" </el-input>
:check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"
></el-tree>
<!-- :default-checked-keys="
defaultValues.map((e) => (isOnlyLeaf ? e.userId : e.userId || e.id))
" -->
</div> </div>
<div class="search-list user-list" v-show="searchState">
<el-checkbox-group v-model="checked">
<el-row v-for="(item, index) in searchResult" :key="index">
<el-checkbox :label="item.userId" :key="index" @change="setSelectChange($event, index)">
<div>
{{ item.name }}
</div>
</el-checkbox>
</el-row>
</el-checkbox-group>
</div>
<transition name="fade">
<div class="head-container" v-show="!searchState">
<el-tree
node-key="userId"
ref="tree"
lazy
accordion
show-checkbox
:check-on-click-node="false"
:expand-on-click-node="true"
:load="loadNode"
:props="defaultProps"
:check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"
></el-tree>
</div>
</transition>
</el-col> </el-col>
<el-col :span="12" :xs="24" class="user-list"> <el-col :span="12" :xs="24" class="user-list">
<el-row :gutter="10">选择人员列表</el-row> <el-row :gutter="10">选择人员列表</el-row>
...@@ -263,9 +313,32 @@ ...@@ -263,9 +313,32 @@
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.content {
min-height: 400px;
}
.search-input {
margin-top: 5px;
margin-bottom: 10px;
}
.user-list { .user-list {
.el-row { .el-row {
line-height: 26px; line-height: 26px;
} }
} }
.search-list {
margin-top: 20px;
padding: 0 10px;
}
.fade-enter-active {
transition: opacity 0.5s;
}
.fade-enter {
opacity: 0;
}
.fade-leave-active {
transition: opacity 0.5s;
}
.fade-leave-to {
opacity: 0;
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!