Files
cmanager/src/views/tenant/main/serve/Dialog/pushService.vue

434 lines
13 KiB
Vue
Raw Normal View History

2024-03-18 21:15:52 +08:00
<template>
<el-drawer
size="100%"
append-to-body
title="推送服务"
2024-03-19 17:23:29 +08:00
:visible.sync="viewDrawer"
2024-03-18 21:15:52 +08:00
>
<div>
<div class="content">
<!-- 用户板块 -->
<div class="content-left relative">
2024-03-18 21:15:52 +08:00
<avue-crud
2024-03-19 20:26:14 +08:00
height="900"
2024-03-18 21:15:52 +08:00
ref="crud1"
:data="leftUserDataList"
:option="leftUserOptions"
:page.sync="leftPages"
@current-change="leftCurrentPageChange"
2024-03-19 17:23:29 +08:00
@size-change="leftSizePageChange"
2024-03-18 21:15:52 +08:00
@selection-change="leftSelectionChange"
>
<template slot="menuLeft">
2024-03-19 20:26:14 +08:00
<div class="leftInput">
<el-input size="small" v-model="formInline.userName" class="input-with-select" placeholder="用户名">
<el-select size="small" v-model="formInline.groupId" slot="prepend" class="selectWidth" placeholder="请选择">
<el-option
v-for="item in leftServeOptions"
:key="item.id"
:label="item.groupName"
2024-03-25 22:06:36 +08:00
:value="item.value">
2024-03-19 20:26:14 +08:00
</el-option>
</el-select>
<el-button size="small" slot="append" class="input-search" @click="leftSearch">搜索</el-button>
</el-input>
</div>
2024-03-19 17:23:29 +08:00
</template>
<template slot="labelsBase" slot-scope="{row}">
<TextTooltip :content="row.labelsBase" length="20"></TextTooltip>
2024-03-18 21:15:52 +08:00
</template>
</avue-crud>
<CustomLoading :visible="leftLoading" loading-text="用户数据加载中"></CustomLoading>
2024-03-18 21:15:52 +08:00
</div>
<!-- 操作 -->
<div class="content-center">
2024-03-19 17:23:29 +08:00
<div><el-button type="primary" size="small" @click="changeTabs(0)">匹配政策</el-button></div>
<div style="margin-top: 30px"><el-button type="primary" @click="changeTabs(1)" size="small">匹配岗位</el-button></div>
2024-03-18 21:15:52 +08:00
</div>
<!-- 列表 -->
<div class="content-right relative">
2024-03-19 17:23:29 +08:00
<avue-crud
2024-03-19 20:26:14 +08:00
height="900"
2024-03-19 17:23:29 +08:00
ref="crud2"
:data="rightDataList"
:option="rightTabs ? rightPostOptions : rightPolicyOptions"
:page.sync="rightPages"
@selection-change="rightSelectionChange"
>
<template slot="menuLeft" >
<el-input
style="width: 300px"
placeholder="搜索岗位"
v-show="rightTabs === 1"
prefix-icon="el-icon-search"
@input="searchInputChange"
v-model="searchInput"
clearable>
</el-input>
</template>
<template slot="labelName" slot-scope="{row}">
<TextTooltip :content="row.labelName" length="40"></TextTooltip>
</template>
<template slot="jobDescription" slot-scope="{row}">
<TextTooltip :content="row.jobDescription" length="40"></TextTooltip>
</template>
</avue-crud>
<CustomLoading :visible="rightLoading" loading-text="智能分析匹配中"></CustomLoading>
2024-03-18 21:15:52 +08:00
</div>
</div>
</div>
2024-03-19 20:26:14 +08:00
<div class="content-footer">
<el-button type="primary" style="width: 80px" size="small" :disabled="pushState" @click="onSubmit">
{{pushState ? '推送中...' : rightTabs ? '推送岗位' : '推送政策' }}
</el-button>
</div>
2024-03-18 21:15:52 +08:00
</el-drawer>
</template>
<script>
2024-03-25 22:06:36 +08:00
import {
getListAllByLabels,
getListGroupByLabels,
getServeAllPolicyList,
getListByids,
getSearchAll,
pushPolicyUserServe,
pushPostUserServe,
getListAllByPolicy
} from "@/api/tenant/serve.js";
2024-03-19 17:23:29 +08:00
import TextTooltip from "@/components/text-tooltip/index.vue";
import {debounce} from '@/util/util'
import {DateTime} from "@/util/dateTime";
import CustomLoading from "@/components/Custom-Loading/index.vue";
2024-03-25 22:06:36 +08:00
const pages = { pagerCount: 3, total: 0, size: 10, currentPage: 1 }
2024-03-19 17:23:29 +08:00
const baseOptions = {
size: 'medium',
2024-03-18 21:15:52 +08:00
dateBtn: false,
addBtn: false,
editBtn: false,
delBtn: false,
height: "auto",
reserveSelection: false,
border: true,
columnBtn: false,
refreshBtn: false,
menu:false,
tip: false,
selection: true,
2024-03-19 17:23:29 +08:00
}
let leftUserOptions = {
...baseOptions,
2024-03-18 21:15:52 +08:00
column: [{
2024-03-19 17:23:29 +08:00
label: '姓名',
2024-03-18 21:15:52 +08:00
prop: 'name',
},{
label: '身份证',
prop: 'idNumber',
2024-03-19 17:23:29 +08:00
},{
label: '手机号',
prop: 'telphone',
},{
2024-03-22 09:59:56 +08:00
label: '个人标签',
2024-03-19 17:23:29 +08:00
prop: 'labelsBase',
slot: true,
}]
}
let rightPolicyOptions = {
...baseOptions,
column: [{
label: '政策名称',
prop: 'name',
}, {
label: '政策标签',
prop: 'labelName',
slot: true,
}]
}
let rightPostOptions = {
...baseOptions,
column: [{
label: '岗位名称',
prop: 'jobName',
}, {
label: '企业名称',
prop: 'companyName',
}, {
label: '岗位描述',
prop: 'jobDescription',
slot: true,
2024-03-18 21:15:52 +08:00
}]
}
export default {
components: {TextTooltip, CustomLoading},
2024-03-18 21:15:52 +08:00
data() {
return {
formInline: {},
leftServeOptions: [],
leftUserDataList: [],
leftUserPages: {},
leftUserSelections: [],
leftPages: Object.assign({}, pages),
leftUserOptions: Object.assign({}, leftUserOptions),
leftLoading: false,
2024-03-19 17:23:29 +08:00
rightLoading: false,
rightDataList: [],
rightDataSelections: [],
rightPages: Object.assign({}, pages),
rightPolicyOptions: Object.assign({}, rightPolicyOptions),
rightPostOptions: Object.assign({}, rightPostOptions),
searchInput: '',
rightTabs: 0, // 0 政策, 1 岗位
pushState: false,
2024-03-18 21:15:52 +08:00
}
},
props: {
2024-03-19 17:23:29 +08:00
visible: Boolean,
2024-03-18 21:15:52 +08:00
rowData: { default: null, type: Function },
changeVisible: { default: null, type: Function },
},
2024-03-19 17:23:29 +08:00
computed: {
viewDrawer: {
get() {
return this.visible;
},
set(val) {
this.$emit("update:visible", val);
},
},
},
2024-03-18 21:15:52 +08:00
watch: {
2024-03-19 17:23:29 +08:00
viewDrawer(val) { val ? this.onPageLoad() : this.onPageInit()}
2024-03-18 21:15:52 +08:00
},
methods: {
onPageLoad() {
console.log('row', this.rowData)
if(!this.rowData) return
2024-03-25 22:06:36 +08:00
this.getLeftSignGroupList()
2024-03-18 21:15:52 +08:00
this.getLeftUserList()
2024-03-21 20:58:44 +08:00
// this.getRightListPolicy()
2024-03-18 21:15:52 +08:00
},
onPageInit() {
this.formInline = {}
this.leftServeOptions = []
this.leftUserDataList = []
this.leftUserSelections = []
this.leftUserPages = Object({}, pages)
2024-03-19 17:23:29 +08:00
this.leftPages = Object.assign({}, pages)
this.leftUserOptions = Object.assign({}, leftUserOptions)
this.leftLoading = false
this.rightLoading = false
this.rightDataList = []
this.rightDataSelections = []
this.rightPages = Object.assign({}, pages)
this.rightPolicyOptions = Object.assign({}, rightPolicyOptions)
this.rightPostOptions = Object.assign({}, rightPostOptions)
this.searchInput = ''
this.rightTabs = 0 // 0 政策
this.pushState = false
this.$refs.crud1.selectClear()
this.$refs.crud2.selectClear()
2024-03-18 21:15:52 +08:00
},
2024-03-19 17:23:29 +08:00
changeTabs(type) {
this.rightDataList = []
this.rightTabs = type
this.rightDataSelections = []
this.$message.success('智能分析匹配中');
2024-03-19 17:23:29 +08:00
type === 0 && this.getRightListPolicy()
2024-03-21 20:58:44 +08:00
type === 1 && this.getRightSearch()
2024-03-19 17:23:29 +08:00
},
searchInputChange: debounce(function (val) {
this.getRightSearch()
}, 1000),
2024-03-18 21:15:52 +08:00
leftSearch() {
2024-03-25 22:06:36 +08:00
this.leftPages.currentPage = 1
2024-03-19 17:23:29 +08:00
this.getLeftUserList('serve')
2024-03-25 22:06:36 +08:00
console.log('leftpages:', this.leftPages)
2024-03-18 21:15:52 +08:00
},
leftCurrentPageChange(current) {
2024-03-25 22:06:36 +08:00
this.leftPages.currentPage = current
2024-03-18 21:15:52 +08:00
this.getLeftUserList()
2024-03-25 22:06:36 +08:00
console.log('leftpages:', this.leftPages)
2024-03-18 21:15:52 +08:00
},
2024-03-19 17:23:29 +08:00
leftSizePageChange(current) {
this.leftPages.size = current
this.getLeftUserList()
2024-03-25 22:06:36 +08:00
console.log('leftpages:', this.leftPages)
2024-03-19 17:23:29 +08:00
},
2024-03-18 21:15:52 +08:00
leftSelectionChange(val) {
this.leftUserSelections = val
},
2024-03-19 17:23:29 +08:00
rightSelectionChange(val) {
this.rightDataSelections = val
},
onSubmit() {
if( !this.leftUserSelections.length ) return this.$message.info('请选择推送用户')
if( !this.rightDataSelections.length ) return this.$message.info('请选择推送政策或岗位')
if(this.rightTabs === 0) {
this.pushPolicyAndUser()
} else {
this.pushPostAndUser()
}
},
2024-03-18 21:15:52 +08:00
groupNameChange() {
this.getLeftUserList('serve')
},
2024-03-19 17:23:29 +08:00
async pushPostAndUser() {
this.pushState = true
const createTime = Date.now() + 2000
let params = {
serveId: this.rowData.id,
posts: this.rightDataSelections.map((item) => ({id: item.id, type: item.type1})),
users: this.leftUserSelections.map((item) => ({idNumber: item.idNumber, talentsId: item.id}))
}
let resData = await pushPostUserServe(params)
if(resData.data.code === 200) {
const timed = createTime - Date.now() > 0 ? createTime - Date.now() : 0
setTimeout(() => {
this.$message.success('岗位推送成功')
this.$refs.crud1.selectClear()
this.$refs.crud2.selectClear()
this.pushState = false
}, timed)
2024-03-18 21:15:52 +08:00
2024-03-19 17:23:29 +08:00
}
},
async pushPolicyAndUser() {
this.pushState = true
const createTime = Date.now() + 2000
let params = {
serveId: this.rowData.id,
policyIds: this.rightDataSelections.map((item) => item.id),
users: this.leftUserSelections.map((item) => ({idNumber: item.idNumber, talentsId: item.id}))
}
let resData = await pushPolicyUserServe(params)
if(resData.data.code === 200) {
const timed = createTime - Date.now() > 0 ? createTime - Date.now() : 0
setTimeout(() => {
this.$message.success('政策推送成功')
this.$refs.crud1.selectClear()
this.$refs.crud2.selectClear()
this.pushState = false
}, timed)
}
},
async getRightSearch() {
2024-03-21 20:58:44 +08:00
let params = {keywords: this.searchInput || '1'}
2024-03-22 09:20:54 +08:00
const createTime = Date.now() + 3000
2024-03-19 17:23:29 +08:00
this.rightLoading = true
let resData = await getSearchAll(params)
if(resData.data.code === 200){
2024-03-21 20:58:44 +08:00
const timed = createTime - Date.now() > 0 ? createTime - Date.now() : 0
setTimeout(() => {
this.rightLoading = false
this.rightDataList = resData.data.data
}, timed)
2024-03-19 17:23:29 +08:00
}
},
async getRightListPolicy() {
let params = {ids: this.rowData.policyIds}
2024-03-22 09:20:54 +08:00
const createTime = Date.now() + 3000
2024-03-19 17:23:29 +08:00
this.rightLoading = true
let resData = await getListByids(params)
if(resData.data.code === 200){
2024-03-21 20:58:44 +08:00
const timed = createTime - Date.now() > 0 ? createTime - Date.now() : 0
setTimeout(() => {
this.rightLoading = false
this.rightDataList = resData.data.data
}, timed)
2024-03-19 17:23:29 +08:00
}
},
2024-03-18 21:15:52 +08:00
async getLeftUserList(type) {
2024-03-25 22:06:36 +08:00
const {currentPage, size} = this.leftPages
2024-03-22 09:20:54 +08:00
const createTime = Date.now() + 3000
2024-03-18 21:15:52 +08:00
let params = {
...this.formInline,
2024-03-25 22:06:36 +08:00
current: currentPage,
size,
labels: this.rowData.talentsNames.join(','),
2024-03-18 21:15:52 +08:00
}
2024-03-25 22:06:36 +08:00
console.log('params', params)
2024-03-18 21:15:52 +08:00
// params.labels = '未分组'
this.leftLoading = true
2024-03-25 22:06:36 +08:00
let resData = await getListAllByPolicy(params)
2024-03-18 21:15:52 +08:00
if ( resData.data.code === 200 ) {
2024-03-21 20:58:44 +08:00
const timed = createTime - Date.now() > 0 ? createTime - Date.now() : 0
setTimeout(() => {
const { records, total, size, current } = resData.data.data
this.leftUserDataList = records
2024-03-25 22:06:36 +08:00
this.leftPages = { total, size, currentPage: current }
console.log('leftpages:', this.leftPages)
2024-03-21 20:58:44 +08:00
this.leftLoading = false
}, timed)
2024-03-18 21:15:52 +08:00
}
},
2024-03-25 22:06:36 +08:00
async getLeftSignGroupList() {
const arr = this.rowData.talentsNames.map((v) => ({ groupName: v, value: v }))
this.leftServeOptions = [{groupName: '全部' }, ...arr]
// let params = { labels: this.rowData.talentsNames.join(',') }
2024-03-18 21:15:52 +08:00
// params.labels = '未分组'
2024-03-25 22:06:36 +08:00
// let resData = await getListAllByPolicy(params)
// if ( resData.data.code === 200 ) {
// this.leftServeOptions = [{groupName: '全部', value: ''}, ...resData.data.data]
// }
2024-03-18 21:15:52 +08:00
}
}
}
</script>
<style lang="scss" scoped>
.content{
display: grid;
2024-03-19 17:23:29 +08:00
grid-template-columns: 1fr 60px 1fr;
2024-03-18 21:15:52 +08:00
grid-gap: 20px;
.content-left{
}
.content-center{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.content-right{
2024-03-21 20:58:44 +08:00
//修改动画的大小 给文字加粗效果
2024-03-19 17:23:29 +08:00
.right-search{
width: 100%;
}
2024-03-21 20:58:44 +08:00
2024-03-18 21:15:52 +08:00
}
2024-03-19 20:26:14 +08:00
.leftInput{
width: 500px;
.selectWidth{
width: 160px !important;
}
.el-input__inner{
2024-03-21 20:58:44 +08:00
width: 300px;
2024-03-19 20:26:14 +08:00
}
.input-search{
margin-right: -15px;
margin-bottom: -10px;
}
}
}
2024-03-21 20:58:44 +08:00
/deep/.el-loading-spinner{
font-size: 80px;
font-weight: bold;
}
/deep/.el-loading-spinner .circular{
width: 80px;
height: 80px;
}
2024-03-19 20:26:14 +08:00
.content-footer{
float: right;
2024-03-18 21:15:52 +08:00
}
.relative{
position: relative;
}
2024-03-18 21:15:52 +08:00
</style>