Commit e5f4b2f3 authored by sixiaofeng's avatar sixiaofeng

1

parent 8c777462
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
:placeholder="placeholder" :placeholder="placeholder"
@input="handleInput" @input="handleInput"
@blur="handleChange" @blur="handleChange"
@compositionstart="onCompositionStart"
@compositionend="onCompositionEnd"
> >
<textarea <textarea
v-else v-else
...@@ -50,6 +52,8 @@ ...@@ -50,6 +52,8 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue' import Vue from 'vue'
import { Field } from 'vant'
Vue.use(Field)
export default Vue.extend({ export default Vue.extend({
components:{ components:{
...@@ -90,18 +94,32 @@ export default Vue.extend({ ...@@ -90,18 +94,32 @@ export default Vue.extend({
return { return {
// value: '', // value: '',
length: 0, length: 0,
showError: false showError: false,
compsitionCheck: true
} }
}, },
created() {
this.length = this.value?.length || 0
},
methods: { methods: {
onCompositionStart() {
this.compsitionCheck = false
},
onCompositionEnd(e: InputEvent) {
this.compsitionCheck = true
const value = (e.target as HTMLInputElement).value
this.showError = this.showError ? !this.checkIfEmpty(value) : this.showError
this.length = value.length
if (this.limit > 0 && this.length >= this.limit) {
this.$emit('input', value.slice(0, this.limit))
this.length = this.limit
} else {
this.$emit('input', value)
}
},
checkIfEmpty(string: string) { checkIfEmpty(string: string) {
if (typeof string === 'undefined') return false if (typeof string === 'undefined') return false
return string.replace(/(^\s*)|(\s*$)/g, '') !== '' return string.replace(/(^\s*)|(\s*$)/g, '') !== ''
}, },
handleInput(e: InputEvent) { handleInput(e: InputEvent) {
if (!this.compsitionCheck) return
const value = (e.target as HTMLInputElement).value const value = (e.target as HTMLInputElement).value
this.showError = this.showError ? !this.checkIfEmpty(value) : this.showError this.showError = this.showError ? !this.checkIfEmpty(value) : this.showError
this.length = value.length this.length = value.length
...@@ -118,6 +136,11 @@ export default Vue.extend({ ...@@ -118,6 +136,11 @@ export default Vue.extend({
this.showError = true this.showError = true
} }
} }
},
watch: {
value(val) {
this.length = val.length
}
} }
}) })
</script> </script>
......
...@@ -81,7 +81,7 @@ export interface GetDepDTO { ...@@ -81,7 +81,7 @@ export interface GetDepDTO {
export interface UpdateDepDTO { export interface UpdateDepDTO {
"name": string, "name": string,
"parentId": string, // "parentId": string,
"entId": string, "entId": string,
"id": string, "id": string,
"leaderId": string "leaderId": string
......
...@@ -7,22 +7,12 @@ Vue.use(Vuex) ...@@ -7,22 +7,12 @@ Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
enterpriseInfo: undefined,
acceptJoin: undefined, acceptJoin: undefined,
addDep: undefined, addDep: undefined,
selectedStaff: undefined, selectedStaff: undefined,
selectedDep: undefined selectedDep: undefined
}, },
mutations: { mutations: {
setEnterpriseInfo(state, payload) {
state.enterpriseInfo = payload
},
setAcceptJoin(state, payload) {
state.acceptJoin = payload
},
setAddDep(state, payload) {
state.addDep = payload
},
setSelectedStaff(state, payload) { setSelectedStaff(state, payload) {
state.selectedStaff = payload state.selectedStaff = payload
}, },
......
...@@ -91,10 +91,19 @@ export function getContacts(arr: Array<Staff>) { ...@@ -91,10 +91,19 @@ export function getContacts(arr: Array<Staff>) {
const contacts: Contact = {} const contacts: Contact = {}
arr.forEach(item => { arr.forEach(item => {
const firstPy = makePy(item.name)[0].slice(0, 1).toUpperCase() const firstPy = makePy(item.name)[0].slice(0, 1).toUpperCase()
if (typeof contacts[firstPy] === 'undefined') { const test = /[0-9`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]/
contacts[firstPy] = [item] if (test.test(firstPy)) {
if (typeof contacts['#'] === 'undefined') {
contacts['#'] = [item]
} else {
contacts['#'].push(item)
}
} else { } else {
contacts[firstPy].push(item) if (typeof contacts[firstPy] === 'undefined') {
contacts[firstPy] = [item]
} else {
contacts[firstPy].push(item)
}
} }
}) })
return contacts return contacts
......
...@@ -128,7 +128,7 @@ export default Vue.extend({ ...@@ -128,7 +128,7 @@ export default Vue.extend({
depId: '', depId: '',
entId: '', entId: '',
hash: 'mock-hash', hash: 'mock-hash',
joinTime: 0, joinTime: new Date().getTime(),
phone: '', phone: '',
position: '' position: ''
} }
......
<template>
<!-- 选择成员 -->
<van-overlay :show="show" z-index="2000">
<div class="select-team w-screen h-screen overflow-auto">
<main-page
main-bg="bg-white"
header-bg="bg-white"
:title="title"
:loading="loading"
left-arrow
@click-left="goBack"
>
<div class="px-4 pt-14">
<!-- <div class="py-2">{{currentDep.name}}</div> -->
<!-- 通讯录 -->
<div class="py-2 font-medium">{{dep.name}}</div>
<div class="pb-16">
<div class="text-text-secondary py-1">成员</div>
<team-contacts
:radio="true"
:multiple="multiple"
:checked.sync="checkedMember"
:contacts="contacts"
/>
</div>
<!-- 底部操作 -->
<div class="py-2 px-4 bg-white w-screen fixed bottom-0 left-0 z-30">
<c-button round @click="confirm">确定</c-button>
</div>
</div>
</main-page>
</div>
</van-overlay>
</template>
<script lang="ts">
import Vue, {PropType} from 'vue'
import { Department, Staff } from '@/Interface'
export default Vue.extend({
name: 'ContactSelector',
components: {
'main-page': () => import('@/layout/main-page.vue'),
'app-icon': () => import('@/components/common/Icon.vue'),
'team-tree': () => import('@/views/team/components/team-tree.vue'),
'team-contacts': () => import('@/views/team/components/team-contacts.vue'),
'c-button': () => import('@/components/common/c-button.vue'),
'switch-cell': () => import('@/components/common/switch-cell.vue')
},
props: {
show: Boolean,
entId: String,
dep: Object,
multiple: {
type: Boolean,
default: false
},
checkedMemberId: {
type: Array as PropType<Array<String>>
},
title: {
type: String,
default: '团队成员'
},
contacts: Object,
actionType: String
},
data() {
let changedVal: Array<string> = []
return {
loading: false,
changed: false,
changedVal
}
},
computed: {
checkedMember: {
get(): Array<String> {
if (!this.changed) {
return this.checkedMemberId
} else {
return this.changedVal
}
},
set(val:Array<string>) {
this.changed = true
this.changedVal = val
}
}
},
methods: {
// 确认选择
confirm() {
this.loading=true
const data = {
entId: this.entId,
depId: '',
ids: this.checkedMember as Array<string>
}
if (this.actionType === 'add') {
data.depId = this.dep.id
}
if (this.actionType === 'remove') {
const rootDepId = JSON.parse(localStorage.getItem('ENT_INFO') || '{}').rootDepId
data.depId = rootDepId
}
this.$service.staff.changeDep(data).then((res:any) => {
this.loading=false
const {data} = res
if (data.code===this.$global.success) {
if (this.actionType === 'remove') {
this.$toast('移除成功')
} else {
this.$toast('添加成功')
}
} else {
this.$toast(data.msg)
}
})
this.$emit('update:checkedMemberId', this.checkedMember)
this.$emit('update:show', false)
this.checkedMember=[]
},
goBack(){
this.$emit('update:show', false)
}
}
})
</script>
<style lang="less">
</style>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<main-page <main-page
main-bg="bg-white" main-bg="bg-white"
header-bg="bg-white" header-bg="bg-white"
title="选择主管" :title="title"
:loading="loading" :loading="loading"
left-arrow left-arrow
@click-left="goBack" @click-left="goBack"
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
:checked.sync="ifContainChildDep" :checked.sync="ifContainChildDep"
@change="handleSwitchChange" @change="handleSwitchChange"
/> />
<!-- <div class="py-2">{{currentDep.name}}</div> -->
<!-- 通讯录 --> <!-- 通讯录 -->
<div class="pb-16"> <div class="pb-16">
<div class="text-text-secondary py-1">成员</div> <div class="text-text-secondary py-1">成员</div>
...@@ -41,7 +42,6 @@ ...@@ -41,7 +42,6 @@
:multiple="multiple" :multiple="multiple"
:checked.sync="checkedMember" :checked.sync="checkedMember"
:contacts="contacts" :contacts="contacts"
@click-member="clickMember"
/> />
</div> </div>
<!-- 底部操作 --> <!-- 底部操作 -->
...@@ -84,6 +84,10 @@ export default Vue.extend({ ...@@ -84,6 +84,10 @@ export default Vue.extend({
}, },
checkedMemberId: { checkedMemberId: {
type: Array as PropType<Array<String>> type: Array as PropType<Array<String>>
},
title: {
type: String,
default: '选择主管'
} }
}, },
data() { data() {
...@@ -97,13 +101,12 @@ export default Vue.extend({ ...@@ -97,13 +101,12 @@ export default Vue.extend({
} }
let changedVal: Array<string> = [] let changedVal: Array<string> = []
return { return {
title: '导航',
team, team,
loading: false, loading: false,
contacts: {}, contacts: {},
parentId: '', parentId: '',
entId: '166961152260050944', entId: '',
ifContainChildDep: true, ifContainChildDep: false,
enterpriseInfo: {}, enterpriseInfo: {},
currentDep, currentDep,
preDep: {}, preDep: {},
...@@ -115,6 +118,7 @@ export default Vue.extend({ ...@@ -115,6 +118,7 @@ export default Vue.extend({
} }
}, },
mounted() { mounted() {
this.entId = JSON.parse(localStorage.getItem('ENT_INFO') || '{}').id
this.getEntInfo() this.getEntInfo()
}, },
computed: { computed: {
...@@ -130,7 +134,6 @@ export default Vue.extend({ ...@@ -130,7 +134,6 @@ export default Vue.extend({
} }
}, },
set(val:Array<string>) { set(val:Array<string>) {
console.log(val, 'val')
this.changed = true this.changed = true
this.changedVal = val this.changedVal = val
} }
...@@ -143,7 +146,6 @@ export default Vue.extend({ ...@@ -143,7 +146,6 @@ export default Vue.extend({
}, },
// 确认选择 // 确认选择
confirmSelect() { confirmSelect() {
// this.$store.commit('setAddDepLeader', this.checkedMemberId)
this.$emit('update:checkedMemberId', this.checkedMember) this.$emit('update:checkedMemberId', this.checkedMember)
this.$emit('update:show', false) this.$emit('update:show', false)
}, },
...@@ -188,7 +190,7 @@ export default Vue.extend({ ...@@ -188,7 +190,7 @@ export default Vue.extend({
parentId: this.parentId, parentId: this.parentId,
entId: this.entId, entId: this.entId,
hasStaff: true, hasStaff: true,
isDirect: this.ifContainChildDep isDirect: !this.ifContainChildDep
}).then((res: any) => { }).then((res: any) => {
const { data } = res const { data } = res
this.loading = false this.loading = false
...@@ -205,10 +207,6 @@ export default Vue.extend({ ...@@ -205,10 +207,6 @@ export default Vue.extend({
} }
}) })
}, },
clickMember(member: Staff) {
// openCompanyUserInfo(JSON.stringify(member))
// this.$router.push(`/team/team-member/${member.id}`)
},
clickItem(val: Department) { clickItem(val: Department) {
this.parentId = val.id this.parentId = val.id
this.getStaff() this.getStaff()
......
...@@ -147,9 +147,13 @@ export default Vue.extend({ ...@@ -147,9 +147,13 @@ export default Vue.extend({
navs() { navs() {
let arr: Array<string> = [] let arr: Array<string> = []
for (let key in this.contacts) { for (let key in this.contacts) {
arr.push(key) if (key !== '#'){
arr.push(key)
} else {
arr.sort().push('#')
}
} }
return arr.sort() return arr
}, },
list() { list() {
const obj: Contacts = {} const obj: Contacts = {}
......
...@@ -5,6 +5,21 @@ ...@@ -5,6 +5,21 @@
:loading="loading" :loading="loading"
@click-left="$router.go(-1)" @click-left="$router.go(-1)"
> >
<member-selector
:title="memberSelectorTitle"
:show.sync="showMemberSelector"
:multiple="multiple"
:checked-member-id.sync="selectedMemberId"
/>
<contact-selector
:ent-id="entId"
:dep="depInfo"
:title="contactSelectorTitle"
:show.sync="showContactSelector"
:multiple="multiple"
:action-type="actionType"
:contacts="contacts"
/>
<div class="pt-14 px-4"> <div class="pt-14 px-4">
<input-cell <input-cell
v-model="depInfo.name" v-model="depInfo.name"
...@@ -17,30 +32,39 @@ ...@@ -17,30 +32,39 @@
<c-cell <c-cell
dot dot
title="部门主管" title="部门主管"
content="部门主管名称" :content="leaderInfo.name"
class="mt-4" class="mt-4"
@click="selectLeader"
/> />
<c-cell <c-cell
dot dot
title="上级部门" title="上级部门"
content="产品设计部" content="产品设计部"
class="mt-4"
/> />
<switch-cell title="该部门包含子部门成员" :checked.sync="check" /> <!-- <switch-cell title="该部门包含子部门成员" :checked.sync="check" /> -->
<c-cell <c-cell
dot dot
title="添加成员" title="添加成员"
class="mt-4" class="mt-4"
@click="$router.push('/team/add-member')" @click="addMember"
/> />
<c-cell <c-cell
dot dot
title="删除成员" title="移除成员"
@click="removeMember"
/> />
<c-button <c-button
round round
type="secondary"
class="mt-10" class="mt-10"
@click="save"
>
保存
</c-button>
<c-button
round
type="secondary"
class="mt-2.5"
@click="deleteDep"
> >
删除部门 删除部门
</c-button> </c-button>
...@@ -49,7 +73,9 @@ ...@@ -49,7 +73,9 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Department, Staff } from '@/Interface'
import Vue from 'vue' import Vue from 'vue'
import { getContacts } from '@/util/Contact'
export default Vue.extend({ export default Vue.extend({
name: 'DepartmentManagement', name: 'DepartmentManagement',
...@@ -59,16 +85,30 @@ export default Vue.extend({ ...@@ -59,16 +85,30 @@ export default Vue.extend({
'input-cell': () => import('@/components/common/input-cell.vue'), 'input-cell': () => import('@/components/common/input-cell.vue'),
'c-cell': () => import('@/components/common/c-cell.vue'), 'c-cell': () => import('@/components/common/c-cell.vue'),
'c-button': () => import('@/components/common/c-button.vue'), 'c-button': () => import('@/components/common/c-button.vue'),
'switch-cell': () => import('@/components/common/switch-cell.vue') 'switch-cell': () => import('@/components/common/switch-cell.vue'),
'member-selector': () => import('@/views/team/components/member-selector.vue'),
'contact-selector': () => import('@/views/team/components/contact-selector.vue')
}, },
data() { data() {
const selectedMemberId: Array<string> = []
return { return {
name: '产品部', name: '产品部',
check: false,
loading: false, loading: false,
depId: '', depId: '',
entId: '', entId: '',
depInfo: {} depInfo: {} as Department,
leaderInfo: {} as Staff,
showMemberSelector: false,
containChild: true,
selectedMemberId,
memberSelectorTitle: '',
multiple: false,
contacts: {},
showContactSelector: false,
contactSelectorTitle: '',
actionType: 'add'
} }
}, },
created() { created() {
...@@ -87,10 +127,118 @@ export default Vue.extend({ ...@@ -87,10 +127,118 @@ export default Vue.extend({
this.loading = false this.loading = false
if (data.code === this.$global.success) { if (data.code === this.$global.success) {
this.depInfo = data.data this.depInfo = data.data
this.selectedMemberId = [this.depInfo.leaderId]
this.getStaffInfo(this.depInfo.leaderId)
} else {
this.$toast(data.msg)
}
})
},
getStaffInfo(id: string) {
this.loading = true
this.$service.staff.getInfo({
entId: this.entId,
id
}).then((res: any) => {
const {data} = res
this.loading = false
if (data.code === this.$global.success) {
this.leaderInfo = data.data
}else {
this.$toast(data.msg)
}
})
},
// 获取通讯录
getStaff(id: string, isDirect: boolean) {
this.loading = true
this.$service.department.getSub({
parentId: id,
entId: this.entId,
hasStaff: true,
isDirect: isDirect
}).then((res: any) => {
const { data } = res
this.loading = false
if (data.code === this.$global.success) {
// 通讯录
this.contacts = getContacts(data.data.staffList || [])
console.log(this.contacts, data.data.staffList, 'this.contacts')
// 部门树
} else { } else {
this.$toast(data.msg) this.$toast(data.msg)
} }
}) })
},
selectLeader() {
this.showMemberSelector = true
this.multiple=false
this.selectedMemberId = [this.leaderInfo.id]
},
addMember() {
this.showContactSelector = true
this.actionType="add"
this.contactSelectorTitle = '添加成员'
this.multiple = true
const rootDepId = JSON.parse(localStorage.getItem('ENT_INFO') || '{}').rootDepId
this.getStaff(rootDepId, false)
},
removeMember() {
this.showContactSelector = true
this.actionType="remove"
this.contactSelectorTitle = '移除成员'
this.multiple = true
this.getStaff(this.depInfo.id, true)
},
deleteDep() {
this.$dialog.confirm({
title: '提示',
message: '确定要删除当前部门吗?'
// confirmButtonText: '解散'
}).then(() => {
const data = {
entId: this.entId,
id: this.depInfo.id
}
this.loading=true
this.$service.department.deleteDep(data).then((res:any) => {
const {data} = res
this.loading=false
if (data.code === this.$global.success) {
this.$toast('删除成功')
this.$router.go(-1)
} else {
this.$toast(data.msg)
}
})
}).catch(() => {
console.log('取消解散')
})
},
save() {
this.loading = true
const dep = this.depInfo
const data = {
name: dep.name,
id: dep.id,
leaderId: this.leaderInfo.id,
entId: this.entId
}
this.$service.department.updateDep(data).then((res: any) => {
const {data} = res
this.loading = false
if (data.code === this.$global.success) {
this.$toast('保存成功')
this.$router.push('/team/team-frame')
} else {
this.$toast(data.msg)
}
})
}
},
watch: {
selectedMemberId(newVal) {
this.getStaffInfo(newVal[0])
} }
} }
}) })
......
...@@ -116,7 +116,7 @@ export default Vue.extend({ ...@@ -116,7 +116,7 @@ export default Vue.extend({
parentId: id, parentId: id,
entId: this.entId, entId: this.entId,
hasStaff: true, hasStaff: true,
isDirect: this.ifContainChildDep isDirect: !this.ifContainChildDep
}).then((res: any) => { }).then((res: any) => {
this.loading = false this.loading = false
const { data } = res const { data } = res
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
<div class="pb-16"> <div class="pb-16">
<div class="text-text-secondary py-1">成员</div> <div class="text-text-secondary py-1">成员</div>
<team-contacts <team-contacts
:radio="showRadio"
:multiple="multiple"
:checked.sync="checkedMemberId" :checked.sync="checkedMemberId"
:contacts="contacts" :contacts="contacts"
@click-member="clickMember" @click-member="clickMember"
...@@ -43,16 +41,11 @@ ...@@ -43,16 +41,11 @@
</div> </div>
<!-- 底部操作 --> <!-- 底部操作 -->
<div class="py-2 px-4 bg-white w-screen fixed bottom-0 left-0 z-30"> <div class="py-2 px-4 bg-white w-screen fixed bottom-0 left-0 z-30">
<template v-if="showRadio"> <div class="grid grid-cols-3 gap-2.5">
<c-button round @click="confirmSelect">确定</c-button> <c-button round @click="addMember">添加成员</c-button>
</template> <c-button round @click="addDep">添加部门</c-button>
<template v-else> <c-button round @click="setDepartment">部门设置</c-button>
<div class="grid grid-cols-3 gap-2.5"> </div>
<c-button round @click="addMember">添加成员</c-button>
<c-button round @click="addDep">添加部门</c-button>
<c-button round @click="setDepartment">部门设置</c-button>
</div>
</template>
</div> </div>
</div> </div>
</main-page> </main-page>
...@@ -104,14 +97,9 @@ export default Vue.extend({ ...@@ -104,14 +97,9 @@ export default Vue.extend({
preDep: {}, preDep: {},
// 是否显示check // 是否显示check
checkedMemberId: [], checkedMemberId: [],
showRadio: false, fromPath: ''
fromPath: '',
multiple: false
} }
}, },
created() {
this.showRadio = this.$route.query.showRadio === '1'
},
mounted() { mounted() {
// useLocalStorageState('USER_INFO',getUserInfo()) // useLocalStorageState('USER_INFO',getUserInfo())
this.getEntInfo() this.getEntInfo()
...@@ -126,11 +114,6 @@ export default Vue.extend({ ...@@ -126,11 +114,6 @@ export default Vue.extend({
this.parentId = dep.id this.parentId = dep.id
this.getStaff() this.getStaff()
}, },
// 确认选择
confirmSelect() {
this.$store.commit('setAddDepLeader', this.checkedMemberId)
this.$router.push(this.fromPath)
},
appNavBack(){ appNavBack(){
this.$router.go(-1) this.$router.go(-1)
// appNavBack() // appNavBack()
...@@ -174,7 +157,7 @@ export default Vue.extend({ ...@@ -174,7 +157,7 @@ export default Vue.extend({
parentId: this.parentId, parentId: this.parentId,
entId: this.entId, entId: this.entId,
hasStaff: true, hasStaff: true,
isDirect: this.ifContainChildDep isDirect: !this.ifContainChildDep
}).then((res: any) => { }).then((res: any) => {
const { data } = res const { data } = res
this.loading = false this.loading = false
...@@ -193,7 +176,6 @@ export default Vue.extend({ ...@@ -193,7 +176,6 @@ export default Vue.extend({
}, },
clickMember(member: Staff) { clickMember(member: Staff) {
openCompanyUserInfo(JSON.stringify(member)) openCompanyUserInfo(JSON.stringify(member))
// this.$router.push(`/team/team-member/${member.id}`)
}, },
clickItem(val: Department) { clickItem(val: Department) {
this.parentId = val.id this.parentId = val.id
...@@ -205,7 +187,7 @@ export default Vue.extend({ ...@@ -205,7 +187,7 @@ export default Vue.extend({
}, },
// 部门设置 // 部门设置
setDepartment() { setDepartment() {
const id = JSON.parse(localStorage.getItem('ENT_INFO') || '{}').rootDepId const id = this.currentDep.id
this.$router.push(`/team/department-management/${id}`) this.$router.push(`/team/department-management/${id}`)
}, },
// 添加成员 // 添加成员
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment