资料维护--资料树联调,会议树联调,资料分页联调,批量删除联调,单一删除联调

This commit is contained in:
姚亚男
2021-09-08 18:16:59 +08:00
parent bed965653b
commit 5372161e2f
3 changed files with 539 additions and 3 deletions
+5 -3
View File
@@ -138,9 +138,11 @@ export const JeroListMixin = {
getQueryField() {
//TODO 字段权限控制
var str = 'id,'
this.columns.forEach(function (value) {
str += ',' + value.dataIndex
})
if (this.columns && this.columns.length){
this.columns.forEach(function (value) {
str += ',' + value.dataIndex
})
}
return str
},
@@ -0,0 +1,401 @@
<template>
<div>
<page-header-title :img-for-icon="IconImg"></page-header-title>
<a-card :bordered="false">
<div class="maintenance-flex">
<div class="maintenance-tree">
<a-tree
:tree-data="treeData"
:replaceFields="replaceFields"
@select="select"
:selectedKeys.sync="selectedKeys"
/>
<a-tree
:tree-data="treeMeetData"
:replaceFields="replaceFields"
@select="selectMeet"
:selectedKeys.sync="selectedMeetKeys"
/>
</div>
<div class="maintenance-table">
<!--操作栏start-->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row>
<a-col :xl="8" :lg="8" :md="24" :sm="24">
<a-form-item label="文件名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入文件名称" v-model="queryParam.fileName"></a-input>
</a-form-item>
</a-col>
<a-col v-if="!isData" :xl="8" :lg="8" :md="24" :sm="24">
<a-form-item label="会议名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入会议名称" v-model="queryParam.meetingName"></a-input>
</a-form-item>
</a-col>
<a-col v-if="!isData" :xl="8" :lg="24" :md="24" :sm="24">
<a-form-item label="会议时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-range-picker
format="YYYY-MM-DD HH:mm"
:show-time="{ format: 'HH:mm:00' }"
v-model="queryParam.meetingTime"
:trigger-change="true"/>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :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>
<div class="table-page-search-submitButtons">
<a-button type="primary" icon="download" class="opera-btn">上传</a-button>
<a-button icon="delete" type="danger" class="opera-btn" @click="batchDel">批量删除</a-button>
<a-button icon="download" type="primary" class="opera-btn">批量分发</a-button>
<a-button icon="export" type="primary" class="opera-btn">导出</a-button>
</div>
</a-form>
</div>
<!--操作栏end-->
<!--table start-->
<a-table
:data-source="dataSource"
:row-key="record => record.keyId"
:pagination="ipagination"
:loading="loading"
:columns="isData ? column : columnMeet"
@change="handleTableChange"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
>
<span slot="action" class="action-span-cell" slot-scope="text, record">
<a-button @click="handleEdit(record)" type="primary" style="margin-right:10px">编辑</a-button>
<a-button type="primary" style="margin-right:10px">分发</a-button>
<a-button @click="handleDelete(record.keyId, record.dataId)" type="danger">删除</a-button>
</span>
</a-table>
<!--table start-->
</div>
</div>
<maintenance-modal ref="modalForm" @ok="modalFormOk"></maintenance-modal>
</a-card>
</div>
</template>
<script>
import { getAction } from '@/api/manage'
import PageHeaderTitle from '@comp/layouts/PageHeaderTitle'
import { JeroListMixin } from '@/mixins/JeroListMixin'
import IconImg from '@/assets/imgs/icon/icon_committee.png'
import MaintenanceModal from './modules/MaintenanceModal'
export default {
name: 'DataMaintenance',
components: { PageHeaderTitle, MaintenanceModal },
mixins: [JeroListMixin],
data() {
return {
IconImg,
disableMixinCreated: true,
isData: true, // 默认是资料目录
filters: {
id: '', // 目录id,查询该目录下文件
column: '',
order: ''
},
treeData: [], // 资料树数据
treeMeetData: [], // 会议树数据
replaceFields: {
children: 'children',
title: 'name',
key: 'id'
},
labelCol: {
xl: { span: 8 },
xs: { span: 24 },
sm: { span: 24 }
},
wrapperCol: {
xl: { span: 8 },
xs: { span: 24 },
sm: { span: 24 }
},
url: {
add: 'payDataFile/payDataFile/add', // 资料和会议的添加 post
edit: 'payDataFile/payDataFile/edit', // 资料和会议的编辑 post
delete: 'payDataFile/payDataFile/delete', // 资料和会议通过id删除一项
upload: 'payDataFile/payDataFile/addMeetingFile', // 资料和会议的上传
deleteBatch: 'payDataFile/payDataFile/deleteBatch', // 资料和会议批量删除
list: 'payDataFile/payDataFile/list', // 资料列表
distribute: 'payDataFile/payDataFile/distribute', // 分发
distributeBatch: 'payDataFile/payDataFile/distributes', // 批量分发
export: 'payDataFile/payDataFile/importFile', // 导出
treeList: 'payDataDirectory/payDataDirectory/tree', // 资料树
treeMeetList: 'payDataDirectory/payDataDirectory/meetingTree' // 会议树
},
selectedKeys: [], // (受控) 资料树选中的key
selectedMeetKeys: [], // (受控) 会议树选中的key
column: [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 80,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '文件名称',
dataIndex: 'fileName',
align: 'center'
},
{
title: '目录层级',
dataIndex: 'filePath',
align: 'center'
},
{
title: '下载次数',
dataIndex: 'downLodeTime',
align: 'center'
},
{
title: '上传时间',
dataIndex: 'upLodeTime',
align: 'center',
customRender: function(text) {
if (text) {
return text.split(' ')[0]
}else {
return ''
}
}
},
{
title: '上传人',
dataIndex: 'upLodePeople',
align: 'center'
},
{
title: '操作',
dataIndex: '',
align: 'center',
scopedSlots: { customRender: 'action' }
},
],
columnMeet: [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 80,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '文件名称',
dataIndex: 'fileName',
align: 'center'
},
{
title: '目录层级',
dataIndex: 'filePath',
align: 'center'
},
{
title: '会议名称',
dataIndex: 'meetingName',
align: 'center'
},
{
title: '会议时间',
dataIndex: 'meetingTime',
align: 'center',
customRender: function(text) {
if (text) {
return text.split(' ')[0]
}else {
return ''
}
}
},
{
title: '下载次数',
dataIndex: 'downLodeTime',
align: 'center'
},
{
title: '上传时间',
dataIndex: 'upLodeTime',
align: 'center',
customRender: function(text) {
if (text) {
return text.split(' ')[0]
}else {
return ''
}
}
},
{
title: '上传人',
dataIndex: 'upLodePeople',
align: 'center'
},
{
title: '操作',
dataIndex: '',
align: 'center',
scopedSlots: { customRender: 'action' }
},
],
selectedDataIds: []
}
},
created() {
this.treeDataList()
},
methods: {
treeDataList (){
getAction(this.url.treeList).then(res => {
if (res.success) {
this.treeData = res.result
if (this.treeData && this.treeData.length){
this.filters.id = this.treeData[0].id
this.selectedKeys.push(this.treeData[0].id)
this.loadData()
}
}
})
getAction(this.url.treeMeetList).then(res => {
if (res.success) {
this.treeMeetData = res.result
if (this.treeMeetData && this.treeMeetData.length){
this.filters.id = this.treeMeetData[0].id
}
}
})
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedDataIds = []
this.selectedRowKeys = selectedRowKeys
selectionRows.forEach(item=>{
this.selectedDataIds.push(item.dataId)
})
this.selectionRows = selectionRows
},
// 批量删除
batchDel: function () {
if (!this.url.deleteBatch) {
this.$message.error('请设置url.deleteBatch属性!')
return
}
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!')
return
} else {
var ids = ''
var dataIds = ''
for (var a = 0; a < this.selectedRowKeys.length; a++) {
ids += this.selectedRowKeys[a] + ',' // 主键id
}
for (var b = 0; b < this.selectedDataIds.length; b++) {
dataIds += this.selectedDataIds[b] + ',' // 主键id
}
var that = this
this.$confirm({
title: '确认删除',
content: '是否删除选中数据?',
onOk: function () {
that.loading = true
getAction(that.url.deleteBatch, {ids, dataIds}).then((res) => {
if (res.success) {
that.$message.success(res.message)
// 判断当前删除的数据是否是最后一页的全部数据,如果是的话页码减一
if (that.ipagination.current > 1 && (that.ipagination.current === Math.ceil(that.ipagination.total / that.ipagination.pageSize)) &&
that.selectedRowKeys.length === that.dataSource.length
) {
that.ipagination.current -= 1
}
that.loadData()
that.onClearSelected()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.loading = false
})
}
})
}
},
// 删除
handleDelete: function (id, dataId) {
if (!this.url.delete) {
this.$message.error('请设置url.delete属性!')
return
}
var that = this
this.$confirm({
title: '确认删除',
content: '确定要删除此条数据吗?',
onOk: function () {
getAction(that.url.delete, {id: id, dataId: dataId}).then((res) => {
if (res.success) {
that.$message.success(res.message)
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
if (that.ipagination.current > 1 && ((that.ipagination.current - 1) * that.ipagination.pageSize) + 1 === that.ipagination.total) {
that.ipagination.current -= 1
}
that.loadData()
} else {
that.$message.warning(res.message)
}
})
}
})
},
// 资料树选中事件
select(selectedKeys) {
this.selectedMeetKeys = []
this.isData = true
this.url.list = 'payDataFile/payDataFile/list'
if (this.filters.id !== selectedKeys[0]){ // 目录id发生改变,重新获取表格数据
this.filters.id = selectedKeys[0]
this.loadData()
}
},
// 会议树选中事件
selectMeet(selectedKeys) {
this.selectedKeys = []
this.isData = false
this.url.list = 'payDataFile/payDataFile/listMeeting'
if (this.filters.id !== selectedKeys[0]){ // 目录id发生改变,重新获取表格数据
this.filters.id = selectedKeys[0]
this.loadData()
}
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
.maintenance-flex{
display: flex;
.maintenance-tree{
margin-right: 10px;
border-right: 1px solid #ddd;
width: 300px;
overflow-x: auto;
}
.maintenance-table{
flex: 1;
}
}
.table-page-search-wrapper .table-page-search-submitButtons{
margin-left: 0;
}
</style>
@@ -0,0 +1,133 @@
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-row>
<a-col>
<a-form-item label="目录名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select placeholder="请选择目录名称"
v-decorator="['name',validatorRules.name]"
:maxLength='50'></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col>
<a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-textarea
placeholder="请输入备注"
v-decorator="['remarks']"
:auto-size="{ minRows: 3, maxRows: 6 }"
:maxLength='200'
@change="e => {e.target.value = (e.target.value + '').trim()}"/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</j-modal>
</template>
<script>
import pick from 'lodash.pick'
import { httpAction } from '@api/manage'
export default {
name: 'MaintenanceModal',
data() {
return {
title: '编辑',
width: 800,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 3 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 21 }
},
validatorRules: {
name: {
rules: [{ required: true, message: '请输入分标委名称' }],
validateTrigger: 'blur'
}
},
url: {
add: '/payCaseCommittee/payCaseCommittee/add',
edit: '/payCaseCommittee/payCaseCommittee/edit'
}
}
},
methods: {
add() {
this.edit({})
},
edit(record) {
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'name', 'remark'))
})
},
close() {
this.$emit('close')
this.visible = false
},
handleOk() {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
let httpurl = ''
let method = 'post'
if (!this.model.id) {
httpurl += this.url.add
} else {
httpurl += this.url.edit
}
console.log(values, '============')
const formData = Object.assign(this.model, values)
console.log('表单提交数据', formData)
httpAction(httpurl, formData, method).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
that.close()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
})
}
})
},
handleCancel() {
this.close()
},
// 下拉框的搜索
filterOption(input, option) {
return (
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
)
},
}
}
</script>
<style scoped>
</style>