123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <template>
- <view>
- <view class="box-head"><uni-mall-head ref="refUniMallHead" @change="tabChange"></uni-mall-head></view>
- <pinapp-empty-page title="暂无部门或成员" v-if="currentData.length === 0 && userData.length === 0"></pinapp-empty-page>
- <view class="box-list">
- <view class="box-list-item"
- :class="[item.children && item.children.length ? 'box-list-item-department-icon' : '','box-list-item-department']"
- :key="item.id" @click="handelClickItem('depart',item)" v-for="item in currentData">
- <view class="box-list-item-department-pic">
- <uni-icons type="staff-filled" color="#08979c" size="24"></uni-icons>
- </view>
- <view class="box-list-item-right">
- <view class="box-list-item-text">{{ item.name }}</view>
- <uni-icons class="inherit-icons" type="right" color="#8c8c8c"></uni-icons>
- </view>
- </view>
- <view class="box-list-item box-list-item-user" :key="item.id" @click="handelClickItem('user',item)"
- v-for="item in userData">
- <view class="box-list-item-user-pic">
- <image v-if="item.pic" :src="item.portrait"></image>
- <text v-else>{{getUserName(item.name)}}</text>
- </view>
- <view class="box-list-item-right">
- <view class="box-list-item-text">{{ item.name }}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import uniMallHead from '@/components/uni-mall-head/uni-mall-head.vue';
- import pinappEmptyPage from "@/components/pinapp-empty-page/pinapp-empty-page.vue"
- export default {
- props: {
- dataList: {
- type: Array,
- default: () => []
- },
- defaultHeadList: {
- type: Object,
- default: () => {}
- }
- },
- components: {
- uniMallHead,
- pinappEmptyPage
- },
- data() {
- return {
- currentData: [],
- userData: []
- };
- },
- mounted() {
- this.init();
- },
- watch: {
- dataList() {
- this.currentData = this.dataList;
- }
- },
- methods: {
- init() {
- if (Object.keys(this.defaultHeadList).length > 0) {
- this.$refs.refUniMallHead.addTab(this.defaultHeadList);
- }
- this.currentData = this.dataList;
- this.userData = [];
- },
- tabChange(obj) {
- this.getCurrentData(obj.id, this.dataList);
- },
- handelClickItem(type, item) {
- console.log(type);
- if (type === 'depart') {
- if (item.children) {
- this.$refs.refUniMallHead.addTab({
- name: item.name,
- id: item.id
- });
- this.currentData = item.children;
- this.userData = item.users || [];
- }
- }
- this.$emit('change', item);
- },
- getUserName(name) {
- if (name.length === 0) {
- return '';
- } else if (name.length <= 2) {
- return name;
- } else if (name.length >= 3) {
- return name.substring(name.length - 2);
- }
- },
- getCurrentData(id, data) {
- if (id === this.defaultHeadList.id) {
- this.currentData = this.dataList;
- this.userData = [];
- } else {
- if (data.length > 0) {
- data.map(item => {
- if (item.id === id) {
- this.currentData = item.children || [];
- this.userData = item.users || [];
- }
- if (item.children && item.children.length > 0) {
- this.getCurrentData(id, item.children);
- }
- });
- }
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .box-head {
- position: fixed;
- left: 0px;
- width: 100%;
- height: 96rpx;
- background: #ffffff;
- padding-left: 34rpx;
- box-sizing: border-box;
- overflow-y: hidden;
- z-index: 999;
- border-top: 1px solid $uni-border-1;
- }
- .box-list {
- padding-top: 52px;
- .box-list-item {
- position: relative;
- height: 60px;
- display: flex;
- align-items: center;
- padding: 0 14px;
- box-sizing: border-box;
- background: #ffffff;
- margin-bottom: 1px;
- &:active {
- background: #f2f3f4;
- }
- &:last-child {
- margin-bottom: 0px;
- }
- .box-list-item-department-pic {
- width: 40px;
- height: 40px;
- background: rgba(8, 151, 156, 0.1);
- border-radius: 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 14px;
- overflow: hidden;
- image {
- width: 20px;
- height: 20px;
- }
- }
- .box-list-item-user-pic {
- width: 40px;
- height: 40px;
- background: $uni-primary;
- border-radius: 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 14px;
- overflow: hidden;
- image {
- width: 40px;
- height: 40px;
- }
- text {
- color: #ffffff;
- font-size: 12px;
- }
- }
- .box-list-item-right {
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex: 1;
- }
- .box-list-item-user-tag {
- text {
- box-sizing: border-box;
- border-radius: 8px;
- padding: 4px 8px;
- font-size: 10px;
- margin-left: 5px;
- &:first-child {
- margin-left: 0px;
- }
- &:nth-child(1) {
- background: rgba(49, 210, 144, 0.05);
- border: 1px solid #31d290;
- color: #31d290;
- }
- &:nth-child(2) {
- background: rgba(55, 127, 255, 0.05);
- border: 1px solid #377fff;
- color: #377fff;
- }
- }
- }
- }
- .box-list-item-department+.box-list-item-user {
- margin-top: 10px;
- }
- }
- </style>
|