<template>
|
<a-card :bordered="false" title="部门列表">
|
<!-- 查询区域 -->
|
<div class="table-operator">
|
<a-row :gutter="24">
|
<a-col :md="24">
|
<a-button
|
@click="handleAdd"
|
type="primary"
|
icon="plus"
|
:disabled="(versionStatus!=''&&versionStatus!='1'&&versionStatus!='0')"
|
v-if="updatePermission&&updateVersionPermission"
|
>
|
新增
|
</a-button>
|
<a-dropdown v-if="selectedRowKeys.length > 0&&!(versionStatus!='0'&&versionStatus!='1')&&updatePermission">
|
<a-menu slot="overlay">
|
<a-menu-item key="1" @click="batchDelPre"><a-icon type="delete"/>删除</a-menu-item>
|
</a-menu>
|
<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
|
</a-dropdown>
|
<a-button
|
type="primary"
|
icon="arrow-up"
|
style="margin-left:100px"
|
:loading="updataVersionloading"
|
@click="updateVersion"
|
:disabled="(versionStatus=='1'||versionStatus=='0')"
|
v-if="updatePermission&&updateVersionPermission"
|
>
|
升版
|
</a-button>
|
<a-button
|
type="primary"
|
icon="arrow-up"
|
style="margin-left:100px"
|
:loading="updataVersionloading"
|
@click="updateVersionForChange"
|
v-if="updatePermission&&!updateVersionPermission&&booleanTag"
|
>
|
升版维护
|
</a-button>
|
<a-dropdown
|
:disabled="(versionStatus!='1'&&versionStatus!='0')||usablePermission"
|
v-if="updatePermission&&updateVersionPermission"
|
>
|
<a-menu slot="overlay">
|
<a-menu-item key="1" @click="setTime" ><a-icon type="dashboard" />断点生效</a-menu-item>
|
<a-menu-item key="2" @click="updateVersionStatusToUsable" ><a-icon type="check" />立即生效</a-menu-item>
|
</a-menu>
|
<a-button type="primary" :loading="usableLoading"> 生效 <a-icon type="down" /></a-button>
|
</a-dropdown>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24" style="margin-top:15px">
|
<a-col
|
:md="6"
|
>
|
版本:
|
<a-select
|
style="width:47%;"
|
placeholder="选择版本"
|
v-model="departInfo.version"
|
@change="handleChange"
|
:disabled="versionSelectDisabled"
|
>
|
<a-select-option v-for="item of this.versionList" :value="item" :key="item" >
|
{{"V"+item+".0"}}
|
</a-select-option>
|
</a-select>
|
</a-col>
|
<a-col
|
:md="6"
|
>
|
版本状态:
|
<a-input
|
style="width:47%;"
|
placeholder="版本状态展示区"
|
:disabled="true"
|
v-model="versionStatusDetail"
|
>
|
</a-input>
|
</a-col>
|
<a-col
|
:md="6"
|
>
|
当前生效版本:
|
<a-input
|
style="width:47%;"
|
placeholder="版本"
|
:disabled="true"
|
v-model="nowUsableVersion"
|
>
|
</a-input>
|
</a-col>
|
<a-col
|
:md="6"
|
>
|
上次生效版本:
|
<a-input
|
style="width:47%;"
|
placeholder="版本"
|
:disabled="true"
|
v-model="lastUsableVersion"
|
>
|
</a-input>
|
</a-col>
|
</a-row>
|
</div>
|
|
<!-- table区域-begin -->
|
<div>
|
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
|
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
|
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
|
</div>
|
|
<a-table
|
ref="table"
|
size="middle"
|
:scroll="{x:true}"
|
bordered
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
class="j-table-force-nowrap"
|
@change="handleTableChange">
|
|
<template slot="htmlSlot" slot-scope="text">
|
<div v-html="text"></div>
|
</template>
|
<template slot="imgSlot" slot-scope="text,record">
|
<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
|
<img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
|
</template>
|
<template slot="fileSlot" slot-scope="text">
|
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
|
<a-button
|
v-else
|
:ghost="true"
|
type="primary"
|
icon="download"
|
size="small"
|
@click="downloadFile(text)">
|
下载
|
</a-button>
|
</template>
|
|
<span slot="action" slot-scope="text, record">
|
<a-button
|
type="primary"
|
icon="edit"
|
@click="handleEdit(record)"
|
:disabled="(versionStatus!='0'&&versionStatus!='1')"
|
v-if="updatePermission"
|
>
|
编辑
|
</a-button>
|
<a-divider type="vertical"/>
|
<a-popconfirm
|
title="确定删除吗?"
|
@confirm="() => handleDeletePre(record.id)"
|
:disabled="(versionStatus!='0'&&versionStatus!='1')"
|
>
|
<a-button
|
type="primary"
|
icon="delete"
|
:disabled="(versionStatus!='0'&&versionStatus!='1')"
|
v-if="updatePermission"
|
>
|
删除
|
</a-button>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
</div>
|
<depart-modal
|
:parentId="parentId"
|
:enterpriseId="departInfo.enterpriseId"
|
:version="departInfo.version"
|
ref="modalForm"
|
@ok="modalFormOk"
|
@reloadUi="reloadUi"
|
></depart-modal>
|
<j-modal
|
:visible="visible"
|
switchFullscreen
|
@ok="handleOk"
|
@cancel="handleCancel"
|
:confirmLoading="timeLoading"
|
cancelText="关闭">
|
<j-date
|
v-model="dateStr"
|
placeholder="请设置生效时间"
|
:showTime="true"
|
dateFormat="YYYY-MM-DD HH:mm:ss"
|
>
|
</j-date>
|
</j-modal>
|
</a-card>
|
</template>
|
<script>
|
import JDate from '@/components/jeecg/JDate'
|
import '@/assets/less/TableExpand.less'
|
import { mixinDevice } from '@/utils/mixin'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import DepartModal from './DepartModal'
|
import { getAction, postAction } from '../../../../api/manage'
|
import dayjs from 'dayjs'
|
export default {
|
name: 'DepartList',
|
mixins:[JeecgListMixin, mixinDevice],
|
components: {
|
DepartModal,
|
JDate,
|
dayjs
|
},
|
props:{
|
parentId:{
|
type:String,
|
default:'',
|
required:false
|
},
|
updatePermission:{
|
type:Boolean,
|
required:false
|
},
|
},
|
data () {
|
return {
|
description: '部门管理管理页面',
|
disableMixinCreated:true,
|
versionStatus:'',
|
versionStatusDetail:'',
|
versionSelectDisabled:false,
|
updataVersionloading:false,
|
usableLoading:false,
|
visible:false,
|
loading:false,
|
timeLoading:false,
|
newVerssionPermission:false,
|
usablePermission:false,
|
updateVersionPermission:true,
|
booleanTag:true,
|
versionList:[],
|
dateStr:'',
|
nowUsableVersion:'',
|
lastUsableVersion:'',
|
originVersionLength:0,
|
departInfo:{},
|
// 表头
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'部门编码',
|
align:"center",
|
dataIndex: 'orgCode',
|
width:100,
|
},
|
{
|
title:'部门名称',
|
align:"center",
|
dataIndex: 'departName',
|
ellipsis:true,
|
width:100,
|
},
|
{
|
title:'部门类型',
|
align:"center",
|
dataIndex: 'departmentCategoryName',
|
width:100,
|
},
|
{
|
title:'上级部门',
|
align:"center",
|
dataIndex: 'parentName',
|
width:100,
|
},
|
{
|
title:'创建人',
|
align:"center",
|
dataIndex: 'createBy',
|
width:100,
|
},
|
{
|
title:'创建日期',
|
align:"center",
|
dataIndex: 'createTime',
|
width:100,
|
},
|
{
|
title:'更新人',
|
align:"center",
|
dataIndex: 'updateBy',
|
width:100,
|
},
|
{
|
title:'更新日期',
|
align:"center",
|
dataIndex: 'updateTime',
|
width:100,
|
},
|
{
|
title:'备注',
|
align:"center",
|
dataIndex: 'memo',
|
ellipsis:true,
|
customRender:function(text){
|
if(text=='null'){
|
return '';
|
}else {
|
return text
|
}
|
|
},
|
width:150
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align:"center",
|
fixed:"right",
|
width:220,
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
url: {
|
getDepartInfo:"/base/depart/getDepartInfo",
|
list: "/base/depart/list",
|
delete: "/base/depart/delete",
|
deleteBatch: "/base/depart/deleteBatch",
|
exportXlsUrl: "/base/depart/exportXls",
|
importExcelUrl: "/base/depart/importExcel",
|
getVersionList: "/base/depart/getVersionList",
|
getInitVersion: "/base/depart/getInitVersion",
|
updateVersion: "base/depart/updateVersion",
|
updateVersionStatusToUsable:"/base/depart/updateVersionStatusToUsable",
|
updateVersionStatusToUsableBySetTime:"/base/depart/updateVersionStatusToUsableBySetTime",
|
getNowAndLastUsableVersion:"/base/depart/getNowAndLastUsableVersion",
|
getVersionStatusByVersion:"/base/depart/getVersionStatusByVersion",
|
getNewVersionPermission: '/base/depart/getNewVersionPermission',
|
getUpdateVersionPermission:'/base/depart/getUpdateVersionPermission',
|
getBooleanTag:'/base/depart/getBooleanTag'
|
},
|
dictOptions:{},
|
superFieldList:[],
|
}
|
},
|
created() {
|
this.loading=true;
|
this.getDepartInfo();
|
this.getVersionList();
|
this.getNowAndLastUsableVersion();
|
this.getInitInfo();
|
},
|
computed: {
|
importExcelUrl: function(){
|
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
|
},
|
},
|
methods: {
|
getDepartInfo(){
|
getAction(this.url.getDepartInfo).then(res=>{
|
if(res.success){
|
this.departInfo = res.result;
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
},
|
clearSelectList(){
|
this.selectedRowKeys=[];
|
this.selectionRows=[];
|
},
|
handleOk(){
|
this.timeLoading=true;
|
if(dayjs(this.dateStr).isBefore(dayjs().add(10,'minute').format('YYYY-MM-DD HH:mm:ss'))){
|
this.timeLoading=false;
|
this.$message.warning("生效时间至少为当前时间10分钟以后,请重新设置")
|
}else{
|
postAction(this.url.updateVersionStatusToUsableBySetTime,{
|
jobClassName:"org.jeecg.modules.quartz.job.DepartSetUsableJob",
|
cronExpression:this.dateStr,
|
parameter:this.departInfo.version,
|
description:"部门管理数据定时生效",
|
status:"0"
|
}).then(res=>{
|
if(res.success){
|
this.reloadUi();
|
this.$message.success("定时生效触发成功");
|
this.quartzJobId = res.result.id;
|
console.log(this.quartzJobId);
|
}
|
else{
|
this.$message.error("定时生效出现异常")
|
}
|
}).finally(res=>{
|
this.timeLoading=false;
|
this.visible=false;
|
})
|
}
|
},
|
handleCancel(){
|
this.visible = false;
|
},
|
setTime(){
|
this.visible = true;
|
},
|
updateVersionStatusToUsable(){
|
var that = this;
|
this.$confirm({
|
title:"确认立即生效",
|
content:"数据量较大时,会导致生效时间过长(建议断点生效),确认立即生效吗?",
|
onOk:function(){
|
that.usableLoading=true;
|
postAction(that.url.updateVersionStatusToUsable,{version:that.departInfo.version}).then(res=>{
|
if(res.success){
|
that.$message.success("生效成功");
|
that.loadData(1);
|
that.getNowAndLastUsableVersion();
|
}else{
|
that.$message.error("生效出现异常");
|
}
|
}).finally(res=>{
|
that.usableLoading=false;
|
})
|
}
|
});
|
|
},
|
updateVersion(){
|
var that = this;
|
this.$confirm({
|
title:"确认升版操作",
|
content:"数据量较大时,会导致升版时间过长,确认升版吗?",
|
onOk: function () {
|
that.updataVersionloading=true;
|
postAction(that.url.updateVersion,{version:that.departInfo.version}).then(res=>{
|
if(res.success){
|
that.$message.success("升版成功");
|
that.departInfo.version=res.result;
|
that.getVersionList();
|
}else{
|
that.$message.error("升版出现异常");
|
}
|
}).finally(res=>{
|
that.updataVersionloading=false;
|
that.clearSelectList();
|
})
|
}
|
});
|
|
},
|
loadData(arg) {
|
if(!this.url.list){
|
this.$message.error("请设置url.list属性!")
|
return
|
}
|
//加载数据 若传入参数1则加载第一页的内容
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
this.queryParam.parentId = this.parentId;
|
this.queryParam.version = this.departInfo.version;
|
var params = this.getQueryParams();//查询条件
|
this.loading = true;
|
getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
//update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
this.dataSource = res.result.records||res.result;
|
if(res.result.records[0]){
|
this.versionStatus = res.result.records[0].versionStatus;
|
this.versionStatusDetail = this.getVersionStatusDetail(this.versionStatus);
|
}
|
else{
|
this.getVersionStatusByVersion();
|
}
|
if(res.result.total)
|
{
|
this.ipagination.total = res.result.total;
|
}else{
|
this.ipagination.total = 0;
|
}
|
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
}else{
|
this.$message.warning(res.message)
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
handleChange(){
|
this.clearSelectList();
|
},
|
getVersionList(){
|
getAction(this.url.getVersionList).then(res=>{
|
if(res.success){
|
this.versionList = res.result;
|
this.originVersionLength = res.result.length;
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
},
|
getNowAndLastUsableVersion(){
|
getAction(this.url.getNowAndLastUsableVersion).then(res=>{
|
if(res.result.usableVersion){
|
this.nowUsableVersion = "V"+res.result.usableVersion+".0";
|
}
|
if(res.result.lastUsableVersion){
|
this.lastUsableVersion = "V"+res.result.lastUsableVersion+".0"
|
}
|
})
|
},
|
getVersionStatusByVersion(){
|
getAction(this.url.getVersionStatusByVersion,{version:this.departInfo.version}).then(res=>{
|
if(res.result[0]){
|
this.versionStatus = res.result[0];
|
this.versionStatusDetail = this.getVersionStatusDetail(this.versionStatus);
|
}
|
else{
|
this.versionStatus='1';
|
this.versionStatusDetail='编辑';
|
}
|
})
|
},
|
handleDeletePre(id){
|
this.handleDelete(id);
|
this.reloadUi();
|
},
|
batchDelPre(){
|
if (this.selectedRowKeys.length <= 0) {
|
this.$message.warning('请选择一条记录!');
|
return;
|
} else {
|
var ids = "";
|
for (var a = 0; a < this.selectedRowKeys.length; a++) {
|
ids += this.selectedRowKeys[a] + ",";
|
}
|
var that = this;
|
this.$confirm({
|
title: "确认删除",
|
content: "是否删除选中数据?",
|
onOk: function () {
|
that.loading = true;
|
deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(that.selectedRowKeys.length)
|
that.$message.success(res.message);
|
that.reloadUi();
|
that.onClearSelected();
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.loading = false;
|
});
|
}
|
});
|
}
|
|
},
|
reloadUi(){
|
if(this.departInfo.version){
|
this.$emit('reloadUi');
|
this.loadData(1);
|
}else{
|
this.departInfo.version=1;
|
}
|
this.getVersionList();
|
this.usablePermission=false;
|
this.versionSelectDisabled=false
|
},
|
getVersionStatusDetail(data){
|
if(data=='0'){
|
return '编辑'
|
}else if(data=='1'){
|
return '编辑'
|
}else if(data=='2'){
|
return '生效'
|
}else if(data=='3'){
|
return '失效'
|
}else if(data=='3'){
|
return '待生效'
|
}
|
},
|
updateVersionForChange(){
|
var that = this;
|
this.$confirm({
|
title:"确认升版操作",
|
content:"确认因为生效企业变更而进行的升版维护操作码?",
|
onOk: function () {
|
that.versionSelectDisabled=true;
|
that.updataVersionloading=true;
|
that.usablePermission=true;
|
postAction(that.url.updateVersion,{version:that.departInfo.version}).then(res=>{
|
if(res.success){
|
that.$message.success("升版成功");
|
that.versionList.unshift(res.result);
|
that.departInfo.version=res.result;
|
that.newVerssionPermission=false;
|
}else{
|
that.$message.error("升版出现异常");
|
}
|
}).finally(res=>{
|
that.updataVersionloading=false;
|
that.clearSelectList();
|
})
|
}
|
});
|
|
},
|
getInitInfo(){
|
getAction(this.url.getNewVersionPermission).then(res=>{
|
if(res.result.length==0){
|
this.usablePermission=true;
|
this.booleanTag=true;
|
this.$message.warning("企业生效版本已经变更,请选择生效企业,对部门进行维护升版操作")
|
}else{
|
this.usablePermission=false;
|
this.booleanTag=false;
|
}
|
})
|
},
|
|
},
|
watch:{
|
parentId:{
|
handler(val) {
|
if(this.parentId){
|
this.clearSelectList();
|
this.loadData(1);
|
this.queryParam={}
|
}
|
}
|
},
|
departInfo:{
|
deep:true,
|
handler(val) {
|
this.$emit('getDepartInfo',val)
|
}
|
},
|
versionStatus:{
|
handler(val) {
|
this.$emit('changeVersionStatus',val)
|
}
|
},
|
'departInfo.version'(val){
|
getAction(this.url.getUpdateVersionPermission,{version:val}).then(res=>{
|
if(res.result.length==0&&this.versionList.length==this.originVersionLength){
|
this.updateVersionPermission=false;
|
}
|
else{
|
this.booleanTag = false;
|
this.updateVersionPermission=true;
|
}
|
})
|
|
}
|
}
|
}
|
</script>
|
<style scoped>
|
@import '~@assets/less/common.less';
|
</style>
|