Files
laws-sinotruk-client/src/views/standardRegulationLibrary/dynamicMessage/DynamicMessageList.vue
T
2023-11-06 09:50:17 +08:00

223 lines
6.6 KiB
Vue

<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<!--标题-->
<a-col :md="6" :sm="12">
<a-form-item :label="$t('title')">
<a-input :placeholder="$t('pleaseEnter') + $t('title')" v-model="queryParam.dynamicHeading" />
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchReset" icon="reload" ghost>{{ $t('reset') }}</a-button>
<a-button type="primary"
@click="searchQuery"
icon="search"
style="margin-left: 8px"
v-has="'dynamicMessage:search'">
{{ $t('query') }}
</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<div class="table-operator">
<!--新增-->
<a-button icon="plus" type="primary" @click="handleAdd" v-has="'dynamicMessage:add'">{{ $t('newlyAdded') }}</a-button>
</div>
<div>
<j-table
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
rowKey="id"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:pagination="ipagination"
:scroll="{x: 1000, y: yScrollHeight}"
:loading="loading"
:operation-list="operationList"
@change="handleTableChange"
@operationClick="operationClick">
<!-- 标准编号-->
<template v-slot:click="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toDetailPage(record)">{{ text }}</div>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
</template>
</j-table>
</div>
<!-- 分享选人-->
<user-select-modal ref="userSelectModal" type="checkbox" @change="continueShare" />
</a-card>
</template>
<script>
import { JeroListMixin } from '../../../mixins/JeroListMixin.js'
import JTable from '../../../components/jero/JTable.vue'
import { mapGetters } from 'vuex'
import { shareDynamicMessageById } from '../../../api/standardRegulationLibraryApi.js'
import UserSelectModal from '../../../components/selection/UserSelectModal.vue'
export default {
name: 'DynamicMessageList',
components: { UserSelectModal, JTable },
mixins: [JeroListMixin],
computed: {
...mapGetters(['userInfo']),
// 是否管理员
isAdmin () {
const roleList = this.userInfo.roleCode.split(',')
if (roleList && roleList.length > 0 && roleList.some(tt => tt === 'admin')) {
return true
}
return false
}
},
data () {
return {
operationList: [
// 编辑
{
text: this.$t('edit'),
clickEvent: 'handleEdit',
has: 'dynamicMessage:edit',
// 管理员可以编辑/删除所有,编辑人能修改/删除自己发布的,其他用户只能收藏/查看和分享
show: (record) => {
return this.isAdmin || record.writer === this.userInfo.id
}
},
// 分享
{
text: this.$t('share'),
clickEvent: 'handleShare',
has: 'dynamicMessage:share'
},
// 删除
{
text: this.$t('delete'),
clickEvent: 'handleDelete',
has: 'dynamicMessage:delete',
// 管理员可以编辑/删除所有,编辑人能修改/删除自己发布的,其他用户只能收藏/查看和分享
show: (record) => {
return this.isAdmin || record.writer === this.userInfo.id
}
}
],
columns: [
// 动态标题
{
dataIndex: 'dynamicHeading',
title: this.$t('standardRegulationLibrary.dynamicMessage.dynamicHeading'),
width: 200,
scopedSlots: { customRender: 'click' }
},
// 动态分类
{
dataIndex: 'dynamicClassification_dictText',
title: this.$t('standardRegulationLibrary.dynamicMessage.dynamicCataloging'),
width: 150
},
// 编辑人
{
dataIndex: 'writer_dictText',
title: this.$t('docTool.split.editor'),
width: 150
},
// 发布状态
{
dataIndex: 'releaseStatus_dictText',
title: this.$t('standardRegulationLibrary.dynamicMessage.releaseStatus'),
width: 150
},
// 发布时间
{
dataIndex: 'releaseTime',
title: this.$t('standardRegulationLibrary.dynamicMessage.releaseTime'),
width: 150
},
// 操作
{
title: this.$t('operation'),
fixed: 'right',
width: 150,
scopedSlots: { customRender: 'action' }
}
],
url: {
list: '/laws/standard/lawsNewsFeed/page',
delete: '/laws/standard/lawsNewsFeed/delete'
},
nowShareInfo: {}
}
},
methods: {
handleAdd () {
this.$router.push({
path: '/standardRegulationLibrary/DynamicMessageFormPage',
query: {
title: this.$t('newlyAdded')
}
})
},
handleEdit ({ id }) {
this.$router.push({
path: '/standardRegulationLibrary/DynamicMessageFormPage',
query: {
title: this.$t('newlyAdded'),
id
}
})
},
toDetailPage ({ id }) {
this.$router.push({
path: '/standardRegulationLibrary/DynamicMessageDetail',
query: {
id
}
})
},
/**
* 分享
*/
handleShare ({ id }) {
this.nowShareInfo = {
standardId: id
}
this.$refs.userSelectModal.open()
},
/**
* 选择分享的人之后继续分享
* @param ids
*/
continueShare (ids) {
const params = Object.assign(this.nowShareInfo, {
recipientId: ids // 分享给的用户的id
})
this.loading = true
shareDynamicMessageById(params).then(res => {
if (res.success) {
this.$message.success(res.message)
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
</style>