<template>
|
<a-card :bordered="false" title="工厂列表">
|
<!-- 查询区域 -->
|
<div class="table-operator">
|
<a-row :gutter="24">
|
<a-col :md="24">
|
<a-button @click="selectFactoryType"
|
type="primary"
|
icon="plus"
|
:disabled="(versionStatus!=''&&versionStatus!='0'&&versionStatus!='1')"
|
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="factoryInfo.version"
|
: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="handleEditPre(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>
|
<factory-model-modal
|
:parentId="parentId"
|
:enterpriseId="factoryInfo.enterpriseId"
|
:version="factoryInfo.version"
|
:factoryElementCategoryId="model.factoryElementCategoryId"
|
:preLabel="preLabel"
|
ref="modalForm"
|
@ok="modalFormOk"
|
@reloadUi="reloadUi"
|
@clearFactoryElementCategoryInfo="clearFactoryElementCategoryInfo"
|
></factory-model-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>
|
<j-modal
|
:width="width"
|
switchFullscreen
|
:visible="categoryVisible"
|
@ok="categoryHandleOk"
|
@cancel="categoryHandleCancel"
|
:confirmLoading="categoryLoading"
|
cancelText="关闭"
|
title="请选择工厂要素类型"
|
>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
<a-row>
|
<a-col :span="24">
|
<a-form-model-item label="工厂要素类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryElementCategoryId">
|
<a-radio-group button-style="solid" v-model="model.factoryElementCategoryId">
|
<a-radio-button
|
v-for="item in factoryElementCategoryList"
|
:value="item.id"
|
:key="item.id"
|
style="width:100px;text-align: center;">
|
{{item.name}}
|
</a-radio-button>
|
</a-radio-group>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
</j-modal>
|
</a-card>
|
</template>
|
<script>
|
import { validateDuplicateValue } from '@/utils/util'
|
import JDate from '@/components/jeecg/JDate'
|
import '@/assets/less/TableExpand.less'
|
import { mixinDevice } from '@/utils/mixin'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import { deleteAction, getAction, postAction } from '../../../../api/manage'
|
import dayjs from 'dayjs'
|
import FactoryModelModal from './FactoryModelModal.vue'
|
import JModal from '../../../../components/jeecg/JModal/JModal.vue'
|
export default {
|
name: 'FactoryModelList',
|
mixins:[JeecgListMixin, mixinDevice],
|
components: {
|
FactoryModelModal,
|
JDate,
|
dayjs,
|
JModal
|
},
|
props:{
|
parentId:{
|
type:String,
|
default:'',
|
required:false
|
},
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
},
|
updatePermission:{
|
type:Boolean,
|
required:false
|
},
|
},
|
data () {
|
return {
|
description: '工厂建模管理页面',
|
disableMixinCreated:true,
|
versionStatus:'',
|
preLabel:'',
|
factoryInfo:{},
|
versionStatusDetail:'',
|
versionSelectDisabled:false,
|
|
updataVersionloading:false,
|
usableLoading:false,
|
visible:false,
|
loading:false,
|
timeLoading:false,
|
newVerssionPermission:false,
|
usablePermission:false,
|
updateVersionPermission:true,
|
booleanTag:true,
|
categoryVisible:false,
|
categoryLoading:false,
|
versionList:[],
|
dateStr:'',
|
nowUsableVersion:'',
|
lastUsableVersion:'',
|
factoryElementCategoryId:'',
|
originVersionLength:0,
|
factoryElementCategoryList:[],
|
//表单
|
width:800,
|
model:{
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
factoryElementCategoryId: [
|
{ required: true, message: '请选择工厂要素类型!'},
|
],
|
},
|
// 表头
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'工厂要素编码',
|
align:"center",
|
dataIndex: 'code',
|
width:100,
|
},
|
{
|
title:'工厂要素名称',
|
align:"center",
|
dataIndex: 'name',
|
width:100,
|
ellipsis:true,
|
},
|
{
|
title:'责任组织',
|
align:"center",
|
dataIndex: 'departName',
|
width:100,
|
},
|
{
|
title:'上级要素',
|
align:"center",
|
dataIndex: 'parentName',
|
width:100,
|
},
|
{
|
title:'工厂要素类型',
|
align:"center",
|
dataIndex: 'factoryElementCategoryName',
|
width:100,
|
},
|
{
|
title:'是否虚拟',
|
align:"center",
|
dataIndex: 'virtualFlag',
|
width:100,
|
customRender:function(text){
|
if(text==1){
|
return "是";
|
}else{
|
return "否";
|
}
|
},
|
},
|
{
|
title:'创建人',
|
align:"center",
|
dataIndex: 'createBy',
|
width:100,
|
},
|
{
|
title:'创建时间',
|
align:"center",
|
dataIndex: 'createTime',
|
customRender:function (text) {
|
return !text?"":(text.length>10?text.substr(0,10):text)
|
},
|
width:100,
|
},
|
{
|
title:'更新人',
|
align:"center",
|
dataIndex: 'updateBy',
|
width:100,
|
},
|
{
|
title:'更新时间',
|
align:"center",
|
dataIndex: 'updateTime',
|
customRender:function (text) {
|
return !text?"":(text.length>10?text.substr(0,10):text)
|
},
|
width:100,
|
},
|
{
|
title:'备注',
|
align:"center",
|
dataIndex: 'remark',
|
customRender:function(text){
|
if(text=='null'){
|
return '';
|
}else {
|
return text
|
}
|
|
},
|
width:150,
|
ellipsis:true,
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align:"center",
|
fixed:"right",
|
width:220,
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
url: {
|
getFactoryInfo:"/base/factoryModel/getFactoryInfo",
|
list: "/base/factoryModel/list",
|
delete: "/base/factoryModel/delete",
|
deleteBatch: "/base/factoryModel/deleteBatch",
|
exportXlsUrl: "/base/factoryModel/exportXls",
|
importExcelUrl: "/base/factoryModel/importExcel",
|
getVersionList: "/base/factoryModel/getVersionList",
|
getInitVersion: "/base/factoryModel/getInitVersion",
|
updateVersion: "base/factoryModel/updateVersion",
|
updateVersionStatusToUsable:"/base/factoryModel/updateVersionStatusToUsable",
|
updateVersionStatusToUsableBySetTime:"/base/factoryModel/updateVersionStatusToUsableBySetTime",
|
getNowAndLastUsableVersion:"/base/factoryModel/getNowAndLastUsableVersion",
|
factoryElementCategoryList:"/base/factoryElementCategory/list",
|
getVersionStatusByVersion:"/base/factoryModel/getVersionStatusByVersion",
|
getNewVersionPermission: '/base/factoryModel/getNewVersionPermission',
|
getUpdateVersionPermission:'/base/factoryModel/getUpdateVersionPermission'
|
},
|
dictOptions:{},
|
superFieldList:[],
|
}
|
},
|
created() {
|
this.getFactoryInfo();
|
this.getVersionList();
|
this.getNowAndLastUsableVersion();
|
this.getFactoryElementCategoryList();
|
this.getInitInfo();
|
},
|
computed: {
|
importExcelUrl: function(){
|
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
|
},
|
formDisabled(){
|
return this.disabled
|
},
|
},
|
methods: {
|
getFactoryInfo(){
|
getAction(this.url.getFactoryInfo).then(res=>{
|
if(res.success){
|
this.factoryInfo = 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.FactoryModelSetUsableJob",
|
cronExpression:this.dateStr,
|
parameter:this.factoryInfo.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;
|
})
|
}
|
},
|
categoryHandleOk(){
|
const that = this;
|
this.$refs.form.validate(valid => {
|
if(valid){
|
that.categoryVisible=false;
|
that.handleAdd();
|
}
|
})
|
},
|
handleCancel(){
|
this.visible = false;
|
},
|
categoryHandleCancel(){
|
this.categoryVisible=false;
|
this.clearFactoryElementCategoryInfo();
|
},
|
setTime(){
|
this.visible = true;
|
},
|
selectFactoryType(){
|
this.categoryVisible=true;
|
},
|
updateVersionStatusToUsable(){
|
var that = this;
|
this.$confirm({
|
title:"确认立即生效",
|
content:"数据量较大时,会导致生效时间过长(建议断点生效),确认立即生效吗?",
|
onOk:function(){
|
that.usableLoading=true;
|
postAction(that.url.updateVersionStatusToUsable,{version:that.factoryInfo.version}).then(res=>{
|
if(res.success){
|
that.$message.success("生效成功");
|
that.loadData(1);
|
that.getNowAndLastUsableVersion();
|
}else{
|
that.$message.error(res.message );
|
}
|
}).finally(res=>{
|
that.usableLoading=false;
|
})
|
}
|
});
|
|
},
|
updateVersion(){
|
var that = this;
|
this.$confirm({
|
title:"确认升版操作",
|
content:"数据量较大时,会导致升版时间过长,确认升版吗?",
|
onOk: function () {
|
that.updataVersionloading=true;
|
postAction(that.url.updateVersion,{version:that.factoryInfo.version}).then(res=>{
|
if(res.success){
|
that.$message.success("升版成功");
|
that.factoryInfo.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.factoryInfo.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"
|
}
|
})
|
},
|
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.factoryInfo.version){
|
this.$emit('reloadUi');
|
this.loadData(1);
|
}else{
|
this.factoryInfo.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 '待生效'
|
}
|
},
|
getFactoryElementCategoryList(){
|
getAction(this.url.factoryElementCategoryList).then(res=>{
|
if(res.success){
|
this.factoryElementCategoryList = res.result.records;
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
},
|
getVersionStatusByVersion(){
|
getAction(this.url.getVersionStatusByVersion,{version:this.factoryInfo.version}).then(res=>{
|
if(res.result[0]){
|
this.versionStatus = res.result[0];
|
this.versionStatusDetail = this.getVersionStatusDetail(this.versionStatus);
|
}
|
else{
|
this.versionStatus='1';
|
this.versionStatusDetail='编辑';
|
}
|
})
|
},
|
handleEditPre(record){
|
if(record.factoryElementCategoryName){
|
this.preLabel = record.factoryElementCategoryName;
|
}else{
|
this.preLabel='';
|
}
|
|
this.handleEdit(record);
|
},
|
clearFactoryElementCategoryInfo(){
|
this.model={};
|
this.preLabel='';
|
},
|
updateVersionForChange(){
|
var that = this;
|
this.$confirm({
|
title:"确认升版操作",
|
content:"确认因为生效企业变更而进行的升版维护操作码?",
|
onOk: function () {
|
that.usablePermission=true;
|
that.versionSelectDisabled=true;
|
that.updataVersionloading=true;
|
postAction(that.url.updateVersion,{version:that.factoryInfo.version}).then(res=>{
|
if(res.success){
|
that.$message.success("升版成功");
|
that.versionList.unshift(res.result);
|
that.factoryInfo.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.booleanTag=false;
|
this.usablePermission=false;
|
}
|
})
|
}
|
},
|
watch:{
|
parentId:{
|
handler(val) {
|
if(this.parentId){
|
this.clearSelectList();
|
this.loadData(1);
|
this.queryParam={}
|
}
|
}
|
},
|
version:{
|
immediate:true,
|
handler(val) {
|
this.$emit('changeVersion',val)
|
}
|
},
|
versionStatus:{
|
handler(val) {
|
this.$emit('changeVersionStatus',val)
|
}
|
},
|
factoryInfo:{
|
deep:true,
|
handler(val) {
|
this.$emit('getFactoryInfo',val)
|
}
|
},
|
model:{
|
immediate:true,
|
deep:true,
|
handler(val) {
|
for(var i=0;i<this.factoryElementCategoryList.length;i++){
|
if(this.factoryElementCategoryList[i].id==val.factoryElementCategoryId){
|
this.preLabel=this.factoryElementCategoryList[i].name;
|
}
|
}
|
}
|
},
|
'factoryInfo.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>
|