<template>
|
<a-card :bordered="false"
|
title="工作中心"
|
style="height: 100%;"
|
>
|
<!-- 操作按钮区域 -->
|
<div class="table-operator">
|
<a-row :gutter="24">
|
<a-col :md="24">
|
<a-button
|
@click="handleAdd"
|
type="primary"
|
icon="plus"
|
:disabled="(!addDisabled||(versionStatus!=''&&versionStatus!='0'&&versionStatus!='1'))"
|
v-if="updatePermission&&updateVersionPermission&&factoryStatus"
|
>
|
新增
|
</a-button>
|
<a-dropdown v-if="selectedRowKeys.length > 0&&!(versionStatus!='0'&&versionStatus!='1')&&updatePermission&&updateVersionPermission&&factoryStatus">
|
<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"
|
@click="updateVersion"
|
:loading="updataVersionloading"
|
:disabled="versionStatus=='1'||versionStatus=='0'"
|
v-if="updatePermission&&updateVersionPermission&&factoryStatus"
|
style="margin-left:100px"
|
>
|
升版
|
</a-button>
|
<a-button
|
type="primary"
|
icon="arrow-up"
|
style="margin-left:100px"
|
:loading="updataVersionloading"
|
@click="updateVersionForChange"
|
v-if="updatePermission&&!updateVersionPermission&&booleanTag&&factoryStatus"
|
>
|
升版维护
|
</a-button>
|
<a-dropdown
|
:disabled="versionStatus!='1'&&versionStatus!='0'||usablePermission"
|
v-if="updatePermission&&updateVersionPermission&&factoryStatus"
|
>
|
<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"
|
:disabled="versionSelectDisabled"
|
>
|
<a-select-option v-for="item of this.versionList" :value="item" :key="item" >
|
{{version==0?"":"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>
|
<!-- 查询区域 -->
|
|
<!-- 查询区域-END -->
|
|
<!-- table区域-begin -->
|
<div style="margin-top:20px">
|
<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="clearSelectList">清空</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&&factoryStatus"
|
>
|
编辑
|
</a-button>
|
<a-divider type="vertical"/>
|
<a-button
|
type="primary"
|
icon="delete"
|
:disabled="(versionStatus!='0'&&versionStatus!='1')"
|
@click="deleteOnePre(record.id)"
|
v-if="updatePermission&&factoryStatus"
|
>删除
|
</a-button>
|
</span>
|
</a-table>
|
</div>
|
<work-center-modal ref="modalForm"
|
@ok="modalFormOk"
|
@reloadUi="reloadUi"
|
:parentId="parentId"
|
:enterpriseId="factoryInfo.enterpriseId"
|
:version="version"
|
:versionStatus="versionStatus"
|
@continueAdd="handleAdd"
|
>
|
</work-center-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="defaultActiveKey" type="card" :tabBarGutter="15">
|
<a-tab-pane tab="分配人员" key="1" >
|
<work-center-user-list
|
:workCenterId="selectWorkCenterId"
|
:enterpriseId="factoryInfo.enterpriseId"
|
:departId="departId"
|
:versionStatus="versionStatus"
|
/>
|
</a-tab-pane>
|
<a-tab-pane tab="分配设备" key="2" v-if="workCenterCategory!='1'" >
|
<work-center-equipment-list
|
:workCenterId="selectWorkCenterId"
|
:enterpriseId="factoryInfo.enterpriseId"
|
:equipmentCategoryId="equipmentCategoryId"
|
:versionStatus="versionStatus"
|
/>
|
</a-tab-pane>
|
</a-tabs>
|
</a-card>
|
</template>
|
<script>
|
import '@/assets/less/TableExpand.less'
|
import { mixinDevice } from '@/utils/mixin'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import WorkCenterModal from './WorkCenterModal'
|
import { deleteAction, getAction, postAction } from '../../../../api/manage'
|
import JDate from '@/components/jeecg/JDate'
|
import dayjs from 'dayjs'
|
import WorkCenterUserList from './WorkCenterUserList.vue'
|
import WorkCenterEquipmentList from './WorkCenterEquipmentList.vue'
|
export default {
|
name: 'WorkCenterList',
|
mixins:[JeecgListMixin, mixinDevice],
|
components: {
|
WorkCenterModal,
|
JDate,
|
dayjs,
|
WorkCenterUserList,
|
WorkCenterEquipmentList
|
},
|
props: {
|
parentId:{
|
type: String,
|
default: '',
|
required: false
|
},
|
addDisabled:{
|
type: Boolean,
|
default: false,
|
required: false,
|
},
|
updatePermission:{
|
type:Boolean,
|
required:false
|
},
|
factoryInfo:{
|
type:Object,
|
required:false
|
},
|
factoryStatus:{
|
type:Boolean,
|
required:false
|
}
|
},
|
data () {
|
return {
|
description: 'mom_base_work_center管理页面',
|
disableMixinCreated:true,
|
updataVersionloading:false,
|
visible:false,
|
timeLoading:false,
|
usableLoading:false,
|
booleanTag:true,
|
updateVersionPermission:true,
|
usablePermission:false,
|
versionSelectDisabled:false,
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
align:"center",
|
width:50,
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'工作中心编码',
|
align:"center",
|
dataIndex: 'code',
|
width:150
|
},
|
{
|
title:'工作中心名称',
|
align:"center",
|
dataIndex: 'name',
|
width:150,
|
ellipsis:true,
|
},
|
{
|
title:'业务类型',
|
align:"center",
|
dataIndex: 'serviceCategory',
|
customRender:function(text){
|
if(text=='0'){
|
return "加工";
|
}else if(text=='1'){
|
return "检验";
|
}else{
|
return ''
|
}
|
},
|
width:150,
|
},
|
{
|
title:'工作中心类型',
|
align:"center",
|
dataIndex: 'workCenterCategory',
|
customRender:function(text){
|
if(text=='0'){
|
return "机台";
|
}else if(text=='1'){
|
return "人员";
|
}else{
|
return ''
|
}
|
},
|
width:150,
|
},
|
{
|
title:'设备组',
|
align:"center",
|
dataIndex: 'equipmentTeamName',
|
width:150,
|
},
|
{
|
title:'上料区',
|
align:"center",
|
dataIndex: 'feedingArea',
|
width:150,
|
},
|
{
|
title:'下料区',
|
align:"center",
|
dataIndex: 'baitingArea',
|
width:150,
|
},
|
{
|
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",
|
scopedSlots: { customRender: 'action' },
|
width:220,
|
}
|
],
|
url: {
|
getInitVersion:"/base/workCenter/getInitVersion",
|
list: "/base/workCenter/list",
|
delete: "/base/workCenter/delete",
|
deleteBatch: "/base/workCenter/deleteBatch",
|
exportXlsUrl: "/base/workCenter/exportXls",
|
importExcelUrl: "base/workCenter/importExcel",
|
listByParentId:"/base/workCenter/listByPMFIds",
|
getVersionList:"/base/workCenter/versionList",
|
updateVersion:"/base/workCenter/updateVersion",
|
updateVersionStatusToUsable:"/base/workCenter/updateVersionStatusToUsable",
|
updateVersionStatusToUsableBySetTime:"/base/workCenter/updateVersionStatusToUsableBySetTime",
|
getDepartId:"/base/workCenterUser/getDepartId",
|
getNowAndLastUsableVersion:"/base/workCenter/getNowAndLastUsableVersion",
|
checkDel:"/base/workCenter/checkDel",
|
getVersionStatusByVersion:"/base/workCenter/getVersionStatusByVersion",
|
getUpdateVersionPermission: '/base/workCenter/getUpdateVersionPermission',
|
updateVersionForChange:'/base/workCenter/updateVersionForChange',
|
getNewVersionPermission:'/base/workCenter/getNewVersionPermission'
|
},
|
dictOptions:{},
|
superFieldList:[],
|
versionList:[],
|
version:null,
|
versionStatus:'0',
|
versionStatusDetail:'',
|
dateStr:'',
|
quartzJobId:'',
|
selectWorkCenterId:'',
|
departId:'',
|
nowUsableVersion:'',
|
lastUsableVersion:'',
|
equipmentCategoryId:'',
|
delIndexList:[],
|
delMessage:'',
|
delOneMessage:'',
|
workCenterCategory:'',
|
defaultActiveKey:'',
|
originVersionLength:0,
|
|
}
|
},
|
computed: {
|
importExcelUrl: function(){
|
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
|
},
|
},
|
created(){
|
this.getVersionList();
|
this.getInitVersion();
|
this.getInitInfo();
|
this.getNowAndLastUsableVersion();
|
},
|
methods: {
|
getInitVersion(){
|
getAction(this.url.getInitVersion).then(res=>{
|
if(res.success){
|
this.version = res.result;
|
}
|
else{
|
this.$message.warning(res.message)
|
}
|
})
|
},
|
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();
|
})
|
}
|
});
|
|
},
|
setTime(){
|
this.visible = true;
|
},
|
handleCancel(){
|
this.visible = false;
|
},
|
handleOk(){
|
this.timeLoading=true;
|
postAction(this.url.updateVersionStatusToUsableBySetTime,{
|
jobClassName:"org.jeecg.modules.quartz.job.WorkCenterSetUsableJob",
|
cronExpression:this.dateStr,
|
parameter:this.parentId+","+this.version,
|
description: "工作中心数据定时生效",
|
status:"0"
|
}).then(res=>{
|
if(res.success){
|
this.loadData(1);
|
this.$message.success("定时生效触发成功");
|
this.quartzJobId = res.result.id;
|
console.log(this.quartzJobId);
|
}
|
else{
|
this.$message.error("定时生效出现异常")
|
}
|
}).finally(res=>{
|
this.timeLoading=false;
|
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.loadData(1);
|
that.getNowAndLastUsableVersion();
|
}else{
|
that.$message.error(res.message );
|
}
|
}).finally(res=>{
|
that.usableLoading=false;
|
})
|
}
|
});
|
},
|
onSelectChange(selectedRowKeys,selectionRows){
|
this.selectedRowKeys=selectedRowKeys;
|
if(selectedRowKeys.length==1){
|
this.selectWorkCenterId = selectedRowKeys[0];
|
this.equipmentCategoryId = selectionRows[0].equipmentTeamId
|
this.workCenterCategory=selectionRows[0].workCenterCategory
|
this.defaultActiveKey='1'
|
getAction(this.url.getDepartId,{
|
parentFactoryModelId:selectionRows[0].parentFactoryModelId
|
}).then(res=>{
|
if(res.result){
|
this.departId =res.result.departId
|
}
|
});
|
}else{
|
this.selectWorkCenterId = '';
|
}
|
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;
|
},
|
getVersionStatus(){
|
if(this.dataSource[0]){
|
this.versionStatus=this.dataSource[0].versionStatus;
|
}
|
},
|
getVersionStatusByVersion(){
|
getAction(this.url.getVersionStatusByVersion,{version:this.version}).then(res=>{
|
if(res.result[0]){
|
this.versionStatus = res.result[0];
|
this.versionStatusDetail = this.getVersionStatusDetail(this.versionStatus);
|
}
|
else{
|
this.versionStatus='';
|
this.versionStatusDetail='';
|
}
|
})
|
},
|
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 '待生效'
|
}
|
},
|
handleDelete(id){
|
deleteAction(this.url.delete,{id:id}).then(res=>{
|
if(res.success){
|
this.$message.success(res.message);
|
this.myLoadData(this.parentId);
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
|
},
|
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.loadData();
|
that.onClearSelected();
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.loading = false;
|
that.clearSelectList();
|
});
|
}
|
});
|
}
|
|
},
|
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.loadData();
|
} else {
|
that.$message.warning(res.message);
|
}
|
});
|
}
|
});
|
},
|
reloadUi(){
|
this.loadData();
|
this.usablePermission=false;
|
this.versionSelectDisabled=false;
|
this.originVersionLength=this.versionList.length;
|
},
|
clearSelectList(){
|
this.selectedRowKeys = []
|
this.selectedRows = []
|
this.selectWorkCenterId=''
|
},
|
loadData(arg) {
|
if(!this.url.list){
|
this.$message.error("请设置url.list属性!")
|
return
|
}
|
//加载数据 若传入参数1则加载第一页的内容
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
this.queryParam.parentFactoryModelId = this.parentId;
|
this.queryParam.factoryModelVersion=this.factoryInfo.version;
|
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);
|
}
|
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
|
})
|
},
|
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.version}).then(res=>{
|
if(res.result[0]){
|
this.versionStatus = res.result[0];
|
this.versionStatusDetail = this.getVersionStatusDetail(this.versionStatus);
|
}
|
else{
|
this.versionStatus='1';
|
this.versionStatusDetail='编辑';
|
}
|
})
|
},
|
clearVersionInfo(){
|
this.version=null
|
this.versionStatus=''
|
this.lastUsableVersion=''
|
this.nowUsableVersion=''
|
this.versionStatusDetail=''
|
},
|
deleteOnePre(id){
|
postAction(this.url.checkDel,[id]).then(res=>{
|
if(res.success){
|
this.delOneMessage =res.result
|
this.handleDeletePre(id);
|
}else{
|
|
}
|
});
|
},
|
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);
|
}
|
})
|
},
|
updateVersionForChange(){
|
var that = this;
|
this.$confirm({
|
title:"确认升版操作",
|
content:"确认因为生效企业变更而进行的升版维护操作吗?",
|
onOk: function () {
|
that.versionSelectDisabled=true;
|
that.updataVersionloading=true;
|
that.usablePermission=true;
|
postAction(that.url.updateVersionForChange).then(res=>{
|
if(res.success){
|
that.$message.success("升版成功");
|
that.versionList.unshift(res.result);
|
that.version=res.result;
|
that.updateVersionPermission=false;
|
}else{
|
that.$message.error("升版出现异常");
|
}
|
}).finally(res=>{
|
that.updataVersionloading=false;
|
that.clearSelectList();
|
})
|
}
|
});
|
|
},
|
getInitInfo(){
|
getAction(this.url.getNewVersionPermission).then(res=>{
|
if(res.result==true){
|
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={}
|
}
|
}
|
},
|
'factoryInfo.version'(val){
|
this.loadData(1)
|
},
|
version:{
|
handler(val) {
|
if(this.factoryInfo!={}){
|
this.loadData(1);
|
getAction(this.url.getUpdateVersionPermission,{version:val}).then(res=>{
|
if((res.result==null||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';
|
a.disabled {
|
pointer-events: none;
|
filter: alpha(opacity=50); /*IE滤镜,透明度50%*/
|
-moz-opacity: 0.5; /*Firefox私有,透明度50%*/
|
opacity: 0.5; /*其他,透明度50%*/
|
}
|
</style>
|