<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="!addUsable || versionStatus != '0' && versionStatus != '1'">新增</a-button>
|
<a-dropdown v-if="selectedRowKeys.length > 0 && !(versionStatus != '0' && versionStatus != '1')">
|
<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'">
|
升版
|
</a-button>
|
<a-dropdown :disabled="versionStatus != '1' && versionStatus != '0'">
|
<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="version" @change="handleChange">
|
<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')">
|
编辑
|
</a-button>
|
<a-divider type="vertical" />
|
<a-button type="primary" icon="delete" :disabled="(versionStatus != '0' && versionStatus != '1')"
|
@click="deleteOnePre(record.id)">删除
|
</a-button>
|
</span>
|
</a-table>
|
</div>
|
<enterprise-modal ref="modalForm" @ok="modalFormOk" @reloadUi="reloadUi" :version="version" :parentId="parentId"
|
:versionStatus="versionStatus">
|
</enterprise-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-tabs defaultActiveKey="1">
|
<a-tab-pane tab="公司管理员" key="1">
|
<administrator-list :mainId="administratorMainId" />
|
</a-tab-pane>
|
</a-tabs>
|
</a-card>
|
</template>
|
|
<script>
|
|
import '@/assets/less/TableExpand.less'
|
import JDate from '@/components/jeecg/JDate'
|
import { mixinDevice } from '@/utils/mixin'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import EnterpriseModal from './EnterpriseModal'
|
import { deleteAction, getAction, postAction } from '../../../../api/manage'
|
import AdministratorList from './AdminiList'
|
import dayjs from 'dayjs'
|
export default {
|
name: 'EnterpriseList',
|
mixins: [JeecgListMixin, mixinDevice],
|
components: {
|
EnterpriseModal,
|
AdministratorList,
|
JDate,
|
dayjs
|
},
|
props: {
|
parentId: {
|
type: String,
|
default: '',
|
required: false
|
},
|
addUsable: {
|
type: Boolean,
|
default: true,
|
required: false
|
}
|
},
|
data() {
|
return {
|
description: '企业架构管理页面',
|
disableMixinCreated: true,
|
// 表头
|
version: null,
|
versionList: [],
|
versionStatus: '',
|
versionStatusDetail: '',
|
updataVersionloading: false,
|
usableLoading: false,
|
visible: false,
|
timeLoading: false,
|
quartzJobId: '',
|
dateStr: '',
|
nowUsableVersion: '',
|
lastUsableVersion: '',
|
delMessage: '',
|
delOneMessage: '',
|
delIndexList: [],
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: "center",
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1;
|
},
|
},
|
{
|
title: '公司编码',
|
align: "center",
|
dataIndex: 'code',
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '公司名称(简称)',
|
align: "center",
|
dataIndex: 'name',
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '上级公司',
|
align: "center",
|
dataIndex: 'parentName',
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '版本状态',
|
align: "center",
|
dataIndex: 'versionStatus',
|
width: 110,
|
ellipsis: true,
|
customRender: function (text) {
|
if (text == "0") {
|
return "新增";
|
} else if (text == "1") {
|
return "编辑";
|
} else if (text == "2") {
|
return "生效";
|
} else if (text == "3") {
|
return "失效";
|
} else if (text == "4") {
|
return "待生效";
|
} else {
|
return ""
|
}
|
},
|
},
|
{
|
title: '状态',
|
align: "center",
|
dataIndex: 'status',
|
width: 110,
|
ellipsis: true,
|
customRender: function (text) {
|
if (text == "1") {
|
return "正常";
|
} else if (text == "0") {
|
return "冻结";
|
} else {
|
return ""
|
}
|
},
|
},
|
{
|
title: '创建人',
|
align: "center",
|
dataIndex: 'createBy',
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '创建时间',
|
align: "center",
|
dataIndex: 'createTime',
|
customRender: function (text) {
|
return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
|
},
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '更新人',
|
align: "center",
|
dataIndex: 'updateBy',
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '更新时间',
|
align: "center",
|
dataIndex: 'updateTime',
|
customRender: function (text) {
|
return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
|
},
|
width: 110,
|
ellipsis: true,
|
},
|
{
|
title: '备注',
|
align: "center",
|
dataIndex: 'remark',
|
ellipsis: true,
|
customRender: function (text) {
|
if (text == 'null') {
|
return '';
|
} else {
|
return text
|
}
|
|
},
|
width: 200,
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align: "center",
|
fixed: "right",
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
url: {
|
list: "/base/enterprise/list",
|
delete: "/base/enterprise/delete",
|
deleteBatch: "/base/enterprise/deleteBatch",
|
exportXlsUrl: "/base/enterprise/exportXls",
|
importExcelUrl: "base/enterprise/importExcel",
|
getVersionList: "base/enterprise/getVersionList",
|
getInitVersion: "base/enterprise/getInitVersion",
|
updateVersion: "base/enterprise/updateVersion",
|
updateVersionStatusToUsable: "/base/enterprise/updateVersionStatusToUsable",
|
updateVersionStatusToUsableBySetTime: "/base/enterprise/updateVersionStatusToUsableBySetTime",
|
getNowAndLastUsableVersion: "/base/enterprise/getNowAndLastUsableVersion",
|
checkDel: "/base/enterprise/checkDel"
|
},
|
dictOptions: {},
|
superFieldList: [],
|
administratorMainId: '',
|
selectedMainId: '',
|
}
|
},
|
created() {
|
this.getVersionList();
|
this.getInitVersion();
|
this.getNowAndLastUsableVersion();
|
},
|
computed: {
|
importExcelUrl: function () {
|
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
|
},
|
},
|
methods: {
|
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.EnterpriseSetUsableJob",
|
cronExpression: this.dateStr,
|
parameter: this.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;
|
})
|
}
|
},
|
setTime() {
|
this.visible = true;
|
},
|
handleCancel() {
|
this.visible = false;
|
},
|
updateVersionStatusToUsable() {
|
var that = this;
|
this.$confirm({
|
title: "确认立即生效",
|
content: "数据量较大时,会导致生效时间过长(建议断点生效),确认立即生效吗?",
|
onOk: function () {
|
that.usableLoading = true;
|
postAction(that.url.updateVersionStatusToUsable, { version: that.version }).then(res => {
|
if (res.success) {
|
that.$message.success("生效成功");
|
that.queryParam.parentId = that.parentId;
|
that.queryParam.version = that.version;
|
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.version }).then(res => {
|
if (res.success) {
|
that.$message.success("升版成功");
|
that.getVersionList();
|
that.version = res.result;
|
} else {
|
that.$message.error("升版出现异常");
|
}
|
}).finally(res => {
|
that.updataVersionloading = false;
|
that.clearSelectList();
|
})
|
}
|
});
|
},
|
getVersionList() {
|
getAction(this.url.getVersionList).then(res => {
|
if (res.success) {
|
this.versionList = res.result;
|
}
|
else {
|
this.$message.error(res.message);
|
}
|
})
|
},
|
getInitVersion() {
|
getAction(this.url.getInitVersion).then(res => {
|
if (res.success) {
|
this.version = res.result;
|
}
|
else {
|
this.$message.error(res.message);
|
}
|
})
|
|
},
|
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.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);
|
}
|
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
|
})
|
},
|
onSelectChange(selectedRowKeys, selectionRows) {
|
this.selectedRowKeys = selectedRowKeys;
|
this.selectionRows = selectionRows;
|
if (selectedRowKeys.length == 1) {
|
this.administratorMainId = selectedRowKeys[0];
|
}
|
else {
|
this.administratorMainId = '';
|
}
|
this.delIndexList = this.getDelIndex(selectionRows)
|
if (selectedRowKeys.length > 0) {
|
postAction(this.url.checkDel, this.delIndexList).then(res => {
|
this.delMessage = res.message;
|
});
|
}
|
},
|
getDelIndex(selectionRows) {
|
console.log(selectionRows)
|
var list = [];
|
for (var i = 0; i < selectionRows.length; i++) {
|
list.push(selectionRows[i].id)
|
}
|
console.log(list)
|
return list;
|
},
|
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;
|
});
|
}
|
});
|
}
|
|
},
|
handleDeletePre(id) {
|
deleteAction(this.url.delete, { id: id }).then(res => {
|
if (res.success) {
|
this.$message.success(res.message);
|
} else {
|
this.$message.error(res.message);
|
}
|
}).finally(res => {
|
this.reloadUi();
|
})
|
},
|
clearSelectList() {
|
this.selectedRowKeys = [];
|
this.selectionRows = [];
|
this.administratorMainId = ''
|
},
|
reloadUi() {
|
if (this.version) {
|
this.$emit('reloadUi');
|
this.queryParam.version = this.version;
|
this.queryParam.parentId = this.parentId;
|
this.loadData(1);
|
} else {
|
this.getVersionList();
|
this.getInitVersion();
|
}
|
},
|
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 '待生效'
|
}
|
},
|
getNowAndLastUsableVersion(parentId) {
|
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"
|
}
|
})
|
},
|
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: that.delMessage,
|
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;
|
that.clearSelectList();
|
});
|
}
|
});
|
}
|
},
|
deleteOnePre(id) {
|
postAction(this.url.checkDel, [id]).then(res => {
|
if (res.success) {
|
this.delOneMessage = res.result
|
this.handleDeletePre(id);
|
} else {
|
|
}
|
});
|
},
|
handleDeletePre(id) {
|
if (!this.url.delete) {
|
this.$message.error("请设置url.delete属性!")
|
return
|
}
|
var that = this;
|
this.$confirm({
|
title: "确认删除",
|
content: that.delOneMessage,
|
onOk: function () {
|
that.loading = true;
|
deleteAction(that.url.delete, { id: id }).then((res) => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(1)
|
that.$message.success(res.message);
|
that.reloadUi();
|
} else {
|
that.$message.warning(res.message);
|
}
|
});
|
}
|
});
|
},
|
handleChange() {
|
this.clearSelectList();
|
}
|
},
|
watch: {
|
parentId: {
|
handler(val) {
|
if (this.parentId) {
|
this.clearSelectList();
|
this.queryParam.parentId = val;
|
this.queryParam.version = this.version;
|
this.loadData(1);
|
this.queryParam = {}
|
}
|
}
|
},
|
version: {
|
handler(val) {
|
this.$emit('changeVersion', val)
|
if (this.parentId == '0') {
|
this.queryParam.parentId = this.parentId;
|
this.queryParam.version = val;
|
this.loadData(1);
|
}
|
this.queryParam = {}
|
}
|
},
|
versionStatus: {
|
handler(val) {
|
this.$emit('changeVersionStatus', val)
|
}
|
}
|
|
}
|
}
|
</script>
|
<style scoped>
|
@import '~@assets/less/common.less';
|
</style>
|