Files
income_payments_client/src/views/draftingGroup/modules/DraftingGroupDistributeModule.vue
T
2024-01-04 09:26:49 +08:00

508 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<template v-if="dataSourceInit.length > 0">
<!--查询条件 单个文件分发的时候才存在-->
<div class="table-page-search-wrapper" v-if="!isBatch">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row>
<a-col :xl="8" :lg="8" :md="8" :sm="24">
<a-form-item label="已提醒" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-dict-select-tag style="width: 100%"
dict-code="yn"
v-model="queryParam.remind"
placeholder="请选择提醒类型"></j-dict-select-tag>
</a-form-item>
</a-col>
<a-col :xl="4" :lg="8" :md="8" :sm="24" >
<span class="table-page-search-submitButtons">
<a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
<a-button icon="reload" @click="searchReset" class="reset-button">重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!-- 操作按钮区域-->
<div class="table-operator">
<a-button type="primary" @click="checkAll()">全选</a-button>
</div>
<a-table
size="middle"
ref="table"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="false"
:scroll="{x: 500}"
@change="handleTableChange"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
class="j-table-force-nowrap main-table">
<template slot="text" slot-scope="text">
<a-tooltip>
<template slot="title">{{ text }}</template>
<div class="table-text">{{ text }}</div>
</a-tooltip>
</template>
</a-table>
</template>
<a-empty v-else></a-empty>
</a-spin>
<email-error-msg-modal ref="emailError"/>
</j-modal>
</template>
<script>
import { distribute, batchDistribute, distributeMemberList, judgeEmailStatus } from '../../../api/incomePaymentsApi'
import EmailErrorMsgModal from '@views/projectManagement/modules/EmailErrorMsgModal.vue'
// 工作组发布提醒 表头
const columns = [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '联系人',
align: 'center',
width: 200,
dataIndex: 'name',
scopedSlots: {customRender: 'text'}
},
{
title: '成员单位',
align: 'center',
dataIndex: 'companyName',
width: 280,
scopedSlots: { customRender: 'text' }
},
{
title: '邮件通知',
align: 'center',
width: 200,
dataIndex: 'remind_dictText',
scopedSlots: {customRender: 'text'}
}
]
// 分标委发布提醒 表头
const commitColumns = [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '联系人',
align: 'center',
width: 200,
dataIndex: 'name',
scopedSlots: {customRender: 'text'}
},
{
title: '成员单位',
align: 'center',
dataIndex: 'companyName',
width: 280,
scopedSlots: { customRender: 'text' }
},
{
title: '邮件通知',
align: 'center',
width: 200,
dataIndex: 'remind_dictText',
scopedSlots: {customRender: 'text'}
}
]
// 理事会成员的表头
const councilColumns = [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '联系人',
align: 'center',
width: 200,
dataIndex: 'name',
scopedSlots: {customRender: 'text'}
},
{
title: '成员单位',
align: 'center',
dataIndex: 'companyName',
width: 280,
scopedSlots: { customRender: 'text' }
},
{
title: '邮件通知',
align: 'center',
width: 200,
dataIndex: 'remind_dictText',
scopedSlots: {customRender: 'text'}
}
]
export default {
name: 'DraftingGroupDistributeModule',
components: { EmailErrorMsgModal },
props: {
// 项目id
projectId: {
type: String,
required: false,
default: ''
},
// 项目类型:1--工作组;2--分标委;3--理事会
projectType: {
type: Number,
required: false,
default: null
},
// 分发资料id
recordId: {
type: String,
required: false,
default: null
},
// 是否批量分发
isBatch: {
type: Boolean,
required: false,
default: false
},
visible: {
type: Boolean,
required: false,
default: false
}
},
watch: {
visible(val) {
if (val) {
this.initData()
}
}
},
data() {
return {
title: '分发',
width: 1000,
confirmLoading: false,
columns: [],
dataSource: [], // 表格中显示的数据
dataSourceInit: [], // 所有分发单位的数据
dataSourceInitShow: [], // 拥有过滤条件后显示的所有数据
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30', '50', '100'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' 共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
/* table选中keys*/
selectedRowKeys: [],
// 查询条件
queryParam: {},
lastQueryParam: {},
labelCol: {
xs: {span: 24},
sm: {span: 6}
},
wrapperCol: {
xs: {span: 24},
sm: {span: 18}
},
needMail: false // 消息模板中是否设置了可以发邮件 重要
}
},
methods: {
/**
* 获取成员列表
*/
getMemberList() {
this.confirmLoading = true
let param = {
projectId: this.projectId,
projectType: this.projectType
}
// 非批量上传的时候传当前选中的文件id
if(!this.isBatch) {
param.fileId = this.recordId
}
distributeMemberList(param).then(res => {
if (res.success) {
this.dataSourceInit = res.result || []
this.dataSourceInitShow = res.result || []
this.loadData(1)
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
},
onCheck(checkedKeys) {
this.checkedKeys = checkedKeys
},
/**
* 初始化数据
*/
initData() {
console.log("-----------------")
this.checkedKeys = []
this.selectedRowKeys = []
this.ipagination.current = 1
this.ipagination.pageSize = 10
// 通过不同的项目类型 展示不同的columns 目前里面的信息是一致的
// 项目类型:1--工作组;2--分标委;3--理事会
if(this.projectType === 1) {
this.columns = [...columns]
} else if(this.projectType === 2) {
this.columns = [...commitColumns]
} else {
this.columns = [...councilColumns]
}
// 选择多个资料的时候不需要提醒字段 这样写是因为无法精准定位每一个人对应的每一个资料 这个人是否被提醒
if (this.isBatch) {
// 去掉列表的提醒字段
this.columns = this.columns.filter(item => item.dataIndex !== 'remind_dictText')
}
this.getMemberList()
this.judgeEmailStatusFunc()
},
handleTableChange(pagination) {
//分页、排序、筛选变化时触发
this.ipagination = pagination
this.loadData()
},
onSelectChange(selectedRowKeys) {
this.selectedRowKeys = selectedRowKeys
},
getQueryParams() {
//获取查询条件
let sqp = {}
var param = Object.assign(sqp, this.lastQueryParam)
param.pageNo = this.ipagination.current
param.pageSize = this.ipagination.pageSize
return param
},
loadData(arg) {
//加载数据 若传入参数1则加载第一页的内容
if (arg === 1) {
this.ipagination.current = 1
if(this.lastQueryParam.remind === undefined) {
this.dataSourceInitShow = this.dataSourceInit
} else {
this.dataSourceInitShow = this.dataSourceInit.filter(tt => tt.remind + '' === this.lastQueryParam.remind + '')
}
}
var params = this.getQueryParams()//查询条件
this.ipagination.total = this.dataSourceInitShow.length
this.dataSource = this.dataSourceInitShow.slice((params.pageNo - 1) * params.pageSize, (params.pageNo * params.pageSize))
},
searchQuery() {
this.lastQueryParam = {...this.queryParam}
this.loadData(1)
},
searchReset() {
this.lastQueryParam = {}
this.queryParam = {}
this.loadData(1)
},
checkAll() {
this.selectedRowKeys = this.dataSourceInitShow.map(tt => tt.id)
},
close() {
this.$emit('update:visible', false)
this.$emit('close')
},
handleOk() {
if (this.confirmLoading) {
return
}
this.confirmLoading = true
if (this.dataSourceInit.length === 0) {
this.$message.warn('当前工作组暂无成员,无法分发文件')
this.confirmLoading = false
return
}
if (this.selectedRowKeys.length === 0) {
this.$message.warn('请选择成员单位')
this.confirmLoading = false
return
}
// 定义请求成功的方法 sendEmailFlag 0-不发送 1-发送
const callbackFunc = (sendEmailFlag) => {
if (this.isBatch) {
let str = this.selectedRowKeys.join(',')
// 批量分发
const formData = {
contactsIds: str,
dataIds: this.recordId,
projectId: this.projectId,
projectType: this.projectType,
sendEmailFlag
}
batchDistribute(formData).then(res => {
if (res.success) {
// 发送邮件的时候才提醒 是否有邮件发送失败 有就给出提示信息
if (sendEmailFlag && Array.isArray(res.result) && res.result.length > 0) {
// msgWarn(this,res.result,0)
this.$refs.emailError.open()
this.$refs.emailError.msgList = res.result
console.log(this.$refs.emailError.msgList, 'this.$refs.emailError.msgList ')
} else {
this.$message.success(res.message)
}
this.close()
this.$emit('ok')
} else {
this.$message.warn(res.message)
}
}).finally(() => {
setTimeout(() => {
this.confirmLoading = false
}, 1000)
})
} else {
// 单个分发
const formData = {
contactsIds: this.selectedRowKeys.join(','),
dataId: this.recordId,
projectId: this.projectId,
projectType: this.projectType,
sendEmailFlag
}
distribute(formData).then(res => {
if (res.success) {
if (sendEmailFlag && Array.isArray(res.result) && res.result.length > 0) {
// msgWarn(this,res.result,0)
this.$refs.emailError.open()
this.$refs.emailError.msgList = res.result
console.log(this.$refs.emailError.msgList, 'this.$refs.emailError.msgList ')
} else {
this.$message.success(res.message)
}
this.close()
this.$emit('ok')
} else {
this.$message.warn(res.message)
}
}).finally(() => {
setTimeout(() => {
this.confirmLoading = false
}, 1000)
})
}
}
if(this.needMail) {
this.$confirm({
title: '消息确认',
content: '确认要向选择的成员发送邮件吗?',
cancelText: '不发送',
okText: '确认发送',
onOk: function () {
callbackFunc(1)
},
onCancel: function() {
callbackFunc(0)
}
})
} else {
// 若全局没有配置则不发送邮件信息
callbackFunc(0)
}
},
handleCancel() {
this.close()
},
// 判断全局设置的是否需要发邮件
judgeEmailStatusFunc() {
this.needMail = false
// 非工作组项目的情况 不进行请求
// if(this.projectType !== 1) return
const params = {
code: 'QY_12_WJTZ_WORK_GROUP_SEND'
}
judgeEmailStatus(params).then(res => {
if(res.success) {
// 发送邮件的类型 1-短信 2-邮件 3-系统 数据字典codem sgType
this.needMail = (res.result || {}).templateType.indexOf(2) > -1
}
})
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
.no-upload {
/deep/ .ant-upload-select-text {
display: none;
}
}
/deep/ .ant-form-explain {
margin-top: 10px;
}
/deep/ .ant-checkbox-group {
width: 100%;
}
.choose-member {
/deep/ #memberName {
display: none;
}
}
/deep/ .ant-tree li .ant-tree-node-content-wrapper {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
/deep/ .ant-table-body {
overflow-x: auto !important;
}
</style>