【add】我的收藏代码迁移

This commit is contained in:
fengchenchen
2023-08-18 10:47:11 +08:00
parent 9f86c9bbb7
commit b6c91bd17e
18 changed files with 2494 additions and 14 deletions
+231
View File
@@ -0,0 +1,231 @@
<template>
<div>
<a-drawer
:title="title"
:maskClosable="false"
:width="600"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;">
<a-spin :spinning="confirmLoading">
<a-input-search style="margin-bottom: 8px" v-model="searchModel"
@search="onSearch"
allowClear
:placeholder="$t('NodeQuickLookup')" />
<div class="drawer-content">
<a-tree
v-if="visibleTree"
style="margin-bottom: 60px;height: 600px"
checkable
:autoExpandParent="false"
:tree-data="gData"
@select="onSelect"
@check="checkChange"
@expand="onExpand"
:defaultExpandedKeys="defaultExpandedKeys"
>
</a-tree>
</div>
</a-spin>
<div class="drawer-bootom-button">
<a-button @click="handleCancel" style="margin-right: 16px">{{ $t('cancel') }}</a-button>
<a-button @click="handleSubmit" type="primary" :loading="submitLoading">{{ $t('submit') }}</a-button>
</div>
</a-drawer>
</div>
</template>
<script>
import { getAction, postAction } from '@/api/manage'
export default {
name: 'index',
props: {
title: {
type: String,
default: ''
},
isSingleChoice: {
type: Boolean,
default: false
},
flag: {
type: Number,
default: 0
}
},
data () {
return {
gData: [],
searchModel: '',
autoExpandParent: true,
expandedKeys: [],
visible: false,
confirmLoading: false,
selectedKey: [],
tableKey: [],
userIds: [],
departId: '',
defaultExpandedKeys: [],
submitLoading: false,
visibleTree: false,
userName: []
}
},
mounted () {
},
methods: {
getPush () {
this.searchModel = ''
this.visible = true
this.visibleTree = false
this.$nextTick(() => {
this.departId = ''
this.queryDepartUserTreeList()
})
},
onSelect (selectedKeys) {
this.selectedKey = selectedKeys
},
onExpand (selectedKeys, val) {
if (this.searchModel === '' || !this.searchModel) {
if (val.expanded) {
if (this.departId === val.node.value) {
} else {
this.departId = val.node.value
this.queryDepartUserTreeList()
}
}
}
},
handleCancel () {
this.visible = false
this.visibleTree = false
},
handleSubmit () {
if (this.isSingleChoice) {
if (this.userIds.length > 1) {
this.$message.warning(this.$t('onlyOnePersonCanBeSelected'))
return
}
}
this.confirmLoading = true
if (this.userIds && this.userIds.length > 0) {
this.submitLoading = true
this.$emit('SelectedByForm', this.userIds.join(','), this.userName.join(','))
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
onSearch (e) {
this.gData = []
this.departId = ''
this.visibleTree = false
if (e) {
this.getUserAndDepart()
} else {
this.queryDepartUserTreeList()
}
},
getUserAndDepart () {
getAction('sys/user/getUserAndDepart', { name: this.searchModel }).then((res) => {
if (res) {
this.gData = res.filter(ele => ele.flag === 'DEPART')
} else {
this.gData = []
}
this.visibleTree = true
})
},
queryDepartUserTreeList () {
let gData = JSON.parse(JSON.stringify(this.gData))
if (gData && gData.length > 0) {
gData = JSON.stringify(gData)
} else {
gData = ''
}
let query = {}
if (this.flag === 1) {
query = {
departId: this.departId,
json: gData
}
} else {
query = {
departId: this.departId,
json: gData,
flag: '1'
}
}
this.confirmLoading = true
postAction('sys/user/queryDepartUserTreeList', query).then((res) => {
this.confirmLoading = false
if (res.success) {
this.gData = res.result
this.gData = [...this.gData]
this.defaultExpandedKeys = [this.departId]
this.visibleTree = true
} else {
this.gData = []
}
})
},
checkChange (e, name) {
this.userName = []
this.userIds = e
if (name.checkedNodes && name.checkedNodes.length > 0) {
name.checkedNodes.forEach(res => {
this.userName.push(res.data.props.dataRef.title)
})
}
if (this.isSingleChoice) {
if (this.userIds.length > 1) {
this.userIds.shift()
this.userName.shift()
}
}
}
}
}
</script>
<style scoped>
.box-title-text {
line-height: 1.4;
display: flex;
}
.box-input {
display: inline-block;
height: 38px;
width: 100%;
}
.button-box {
margin-left: 10px;
height: 38px;
line-height: 38px;
}
.drawer-bootom-button {
position: absolute;
bottom: 0;
z-index: 100;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
.drawer-content {
height: calc(100% - 60px);
overflow: auto;
}
</style>
+87
View File
@@ -0,0 +1,87 @@
<template>
<div class="loading-box" :style="style" v-if="loading">
<div class="loading-content">
<a-icon class="loading" type="loading" />
<div class="loading-tips">
<slot></slot>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'JLoading',
props: {
// 是否显示隐藏
loading: {
type: Boolean,
default: false
},
// 是否固定
fixed: {
type: Boolean,
default: false
}
},
data () {
return {
style: {}
}
},
mounted () {
if (this.fixed) {
const el = $(this.el)
const top = `${el.offset().top}px`
const left = `${el.offset().left}px`
const width = `${el.outerWidth()}px`
const height = `${el.outerHeight()}px`
this.style = {
position: 'fixed',
top,
left,
width,
height,
'z-index': 1000
}
}
}
}
</script>
<style lang="less">
.loading-box {
position: absolute;
top: 0;
left: 0;
z-index: 1009;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 8px;
user-select: none;
.loading-content {
position: absolute;
top: 50%;
left: 50%;
color: #21c9cc;
transform: translate(-50%, -50%);
text-align: center;
.loading {
font-size: 28px;
}
.spin-loading {
animation: rotating 2s linear infinite;
}
.loading-tips {
margin-top: 5px;
font-size: 16px;
color: #21c9cc;
}
}
}
</style>