You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
569 lines
15 KiB
569 lines
15 KiB
<template> |
|
<basic-container> |
|
<avue-crud |
|
:option="option" |
|
:table-loading="loading" |
|
:data="data" |
|
v-model="form" |
|
v-model:page="page" |
|
ref="crud" |
|
@row-del="rowDel" |
|
@row-update="rowUpdate" |
|
@row-save="rowSave" |
|
@search-change="searchChange" |
|
@search-reset="searchReset" |
|
@selection-change="selectionChange" |
|
@current-change="currentChange" |
|
@size-change="sizeChange" |
|
@refresh-change="refreshChange" |
|
@on-load="onLoad" |
|
:before-open="beforeOpen" |
|
:span-method="spanMethod" |
|
@sort-change="sortChange" |
|
> |
|
<template #menu-left> |
|
<el-button type="primary" @click="handleAdd" v-if="permission.equipmentCapacity_add">新增</el-button> |
|
</template> |
|
<template #menu-right> </template> |
|
<template #menu="{ row }"> |
|
<el-button type="text" @click="handleEdit(row)" v-if="permission.equipmentCapacity_edit">修改</el-button> |
|
</template> |
|
|
|
<template #standardProcessAbility="scope"> |
|
<span v-if="scope.row.partType == 0"> |
|
{{ scope.row.standardProcessAbility }} |
|
</span> |
|
<span v-else> |
|
<p v-for="(item, index) in scope.row.abilityList" :key="index"> |
|
{{ `${item.startNum}≤φ<${item.endNum}` |
|
}}{{ item.standardProcessAbility ? `,${item.standardProcessAbility}` : '' }} |
|
</p> |
|
</span> |
|
</template> |
|
</avue-crud> |
|
|
|
<!-- 新增 --> |
|
<addEquipment |
|
v-if="addShow" |
|
:showDialog="addShow" |
|
:moldAddMore="moldAddMore" |
|
:title="title" |
|
:rowData="rowData" |
|
ref="addEquipment" |
|
@closeDialog="closeDialog" |
|
@refresh="refreshChange" |
|
@success="success" |
|
></addEquipment> |
|
</basic-container> |
|
</template> |
|
|
|
<script> |
|
import { |
|
getListEquipAbility, |
|
removeEquipAbility, |
|
addEquipAbility, |
|
updateEquipAbility, |
|
} from '@/api/productionSchedulingPlan/basic'; |
|
import addEquipment from './components/addEquipment.vue'; |
|
import { mapGetters } from 'vuex'; |
|
import { ElButton } from 'element-plus'; |
|
export default { |
|
components: { |
|
addEquipment, |
|
}, |
|
data() { |
|
return { |
|
form: {}, |
|
selectionList: [], |
|
query: {}, |
|
loading: false, |
|
page: { |
|
pageSize: 10, |
|
currentPage: 1, |
|
total: 0, |
|
}, |
|
option: { |
|
columnSort: true, |
|
tip: false, |
|
height: 'auto', |
|
calcHeight: 32, |
|
simplePage: false, |
|
searchShow: true, |
|
searchMenuSpan: 6, |
|
searchIcon: true, |
|
searchIndex: 3, |
|
tree: false, |
|
border: true, |
|
index: true, |
|
selection: false, |
|
addBtn: false, |
|
editBtn: false, |
|
viewBtn: false, |
|
delBtn: false, |
|
editBtnText: '修改', |
|
labelWidth: 120, |
|
menuWidth: 120, |
|
dialogWidth: 900, |
|
dialogClickModal: false, |
|
searchEnter: true, |
|
excelBtn: false, |
|
filterBtn: true, |
|
searchShowBtn: false, |
|
excelBtn: true, |
|
showOverflowTooltip: true, |
|
addBtnIcon: ' ', |
|
viewBtnIcon: ' ', |
|
delBtnIcon: ' ', |
|
editBtnIcon: ' ', |
|
gridBtn: false, |
|
searchLabelPosition: 'left', |
|
searchGutter: 24, |
|
searchSpan: 6, |
|
menuAlign: 'left', |
|
gridBtn: false, |
|
searchMenuPosition: 'right', |
|
align: 'center', |
|
searchLabelWidth:'auto', |
|
column: [ |
|
{ |
|
label: '作业中心', |
|
prop: 'workCenterName', |
|
search: true, |
|
sortable: 'custom', |
|
span: 12, |
|
display: false, |
|
width: 120, |
|
}, |
|
{ |
|
label: '设备名称', |
|
prop: 'equipName', |
|
search: true, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 120, |
|
disabled: true, |
|
}, |
|
{ |
|
label: '设备编码', |
|
prop: 'equipCode', |
|
search: true, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 120, |
|
disabled: true, |
|
}, |
|
|
|
// { |
|
// label: '设备型号', |
|
// prop: 'equipNameType', |
|
// search: false, |
|
// sortable: 'custom', |
|
// span: 12, |
|
// width: 120, |
|
// disabled: true, |
|
// }, |
|
|
|
{ |
|
label: '设备分类', |
|
prop: 'equipType', |
|
search: false, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 120, |
|
type: 'select', |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请选择', |
|
trigger: 'blur', |
|
}, |
|
], |
|
dicData: [ |
|
{ |
|
label: '产线设备', |
|
value: '0', |
|
}, |
|
{ |
|
label: '普通设备', |
|
value: '1', |
|
}, |
|
], |
|
}, |
|
{ |
|
label: '设备排序', |
|
prop: 'equipOrder', |
|
search: true, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 120, |
|
disabled: true, |
|
}, |
|
{ |
|
label: '工序', |
|
prop: 'processName', |
|
search: false, |
|
sortable: 'custom', |
|
span: 12, |
|
display: false, |
|
width: 120, |
|
}, |
|
{ |
|
label: '工艺能力', |
|
prop: 'craftName', |
|
search: false, |
|
sortable: 'custom', |
|
span: 12, |
|
display: false, |
|
width: 120, |
|
}, |
|
{ |
|
label: '额定加工能力(烧结-件/热表-dm²)', |
|
prop: 'standardProcessAbility', |
|
search: false, |
|
sortable: 'custom', |
|
span: 14, |
|
width: 270, |
|
labelWidth: 270, |
|
type: 'number', |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请输入', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
{ |
|
label: '额定工时(分钟)', |
|
prop: 'standardTime', |
|
search: false, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 180, |
|
labelWidth: 180, |
|
type: 'number', |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请输入', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
{ |
|
label: '准备工时(分钟)', |
|
prop: 'prepareTime', |
|
search: false, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 180, |
|
labelWidth: 180, |
|
type: 'number', |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请输入', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
{ |
|
label: '轮次间隔(分钟)', |
|
prop: 'interval', |
|
search: false, |
|
sortable: 'custom', |
|
span: 12, |
|
width: 180, |
|
labelWidth: 180, |
|
type: 'number', |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请输入', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
|
|
// { |
|
// label: '指定使用', |
|
// prop: 'assignUse', |
|
// search: false, |
|
// sortable: 'custom', |
|
// span: 12, |
|
// width: 120, |
|
// }, |
|
// { |
|
// label: '备注', |
|
// prop: 'remarks', |
|
// search: false, |
|
// sortable: 'custom', |
|
// span: 12, |
|
// width: 180, |
|
// }, |
|
], |
|
}, |
|
|
|
data: [], |
|
addShow: false, |
|
moldAddMore: false, |
|
title: '新增', |
|
rowData: [], //行数据 |
|
spanArr: [ |
|
{ prop: 'workCenterName', span: [] }, |
|
{ prop: 'equipName', span: [] }, |
|
{ prop: 'equipCode', span: [] }, |
|
{ prop: 'equipType', span: [] }, |
|
], // 存储合并行数的容器,格式:{workCenterName: [], equipName: [], equipCode: []} |
|
}; |
|
}, |
|
computed: { |
|
...mapGetters(['permission']), |
|
}, |
|
created(){ |
|
this.option.delBtn = this.permission.equipmentCapacity_delete ? true : false; |
|
}, |
|
methods: { |
|
// 表格排序 |
|
sortChange({ prop, order }) { |
|
console.log('prop----------',prop) |
|
console.log('order----------',order) |
|
if (!prop) { |
|
// 如果取消排序,清空排序参数 |
|
this.query.orderByField = undefined; |
|
// this.query.isAsc = undefined; |
|
this.query.ascs = undefined; |
|
this.query.descs = undefined; |
|
} else { |
|
const orderByField = prop.replace(/([a-z])([A-Z0-9])/g, '$1_$2').toUpperCase(); |
|
if(order === 'ascending'){ |
|
this.query.ascs = orderByField; |
|
this.query.descs = undefined; |
|
}else{ |
|
this.query.descs = orderByField; |
|
this.query.ascs = undefined; |
|
} |
|
// this.query.orderByField = orderByField; |
|
// this.query.isAsc = order === 'ascending' ? true : false; |
|
// this.query.asc = order === 'ascending' ? true : false; |
|
} |
|
// // 重新加载数据 |
|
this.onLoad(this.page, this.query); |
|
}, |
|
// 计算合并单元格的核心方法 |
|
calculateSpan(arr) { |
|
if (!arr || arr.length === 0) { |
|
this.spanArr = [ |
|
{ prop: 'workCenterName', span: [] }, |
|
{ prop: 'equipName', span: [] }, |
|
{ prop: 'equipCode', span: [] }, |
|
{ prop: 'equipType', span: [] }, |
|
]; |
|
return; |
|
} |
|
|
|
const workCenterSpan = []; |
|
const equipNameSpan = []; |
|
const equipCodeSpan = []; |
|
const equipType = []; |
|
let currentIndex = 0; |
|
|
|
while (currentIndex < arr.length) { |
|
const currentItem = arr[currentIndex]; |
|
// 匹配条件:作业中心 + 设备名称 + 设备编码完全相同 |
|
const matchCondition = item => |
|
item.workCenterName === currentItem.workCenterName && |
|
item.equipName === currentItem.equipName && |
|
item.equipCode === currentItem.equipCode&& |
|
item.equipType === currentItem.equipType; |
|
|
|
// 统计连续匹配的行数 |
|
let span = 1; |
|
for (let i = currentIndex + 1; i < arr.length; i++) { |
|
if (matchCondition(arr[i])) { |
|
span++; |
|
} else { |
|
break; |
|
} |
|
} |
|
|
|
// 为当前行设置合并数,后续行设置为 0(不显示) |
|
workCenterSpan[currentIndex] = span; |
|
equipNameSpan[currentIndex] = span; |
|
equipCodeSpan[currentIndex] = span; |
|
equipType[currentIndex] = span; |
|
for (let i = currentIndex + 1; i < currentIndex + span; i++) { |
|
workCenterSpan[i] = 0; |
|
equipNameSpan[i] = 0; |
|
equipCodeSpan[i] = 0; |
|
equipType[i] = 0; |
|
} |
|
|
|
currentIndex += span; |
|
} |
|
|
|
this.spanArr = [ |
|
{ prop: 'workCenterName', span: workCenterSpan }, |
|
{ prop: 'equipName', span: equipNameSpan }, |
|
{ prop: 'equipCode', span: equipCodeSpan }, |
|
{prop: 'equipType', span: equipType} |
|
]; |
|
}, |
|
// AVUE-CRUD 合并单元格方法 |
|
spanMethod({ row, column, rowIndex, columnIndex }) { |
|
// 默认不合并 |
|
const defaultReturn = { rowspan: 1, colspan: 1 }; |
|
|
|
for (let i = 0; i < this.spanArr.length; i++) { |
|
const ele = this.spanArr[i]; |
|
if (column.property == ele.prop) { |
|
const _row = ele.span[rowIndex]; |
|
// 如果 span 数据不存在或为 0,返回默认值 |
|
if (_row === undefined || _row === 0) { |
|
return { rowspan: 0, colspan: 0 }; |
|
} |
|
return { |
|
rowspan: _row, |
|
colspan: 1, |
|
}; |
|
} |
|
} |
|
// 其他列不合并 |
|
return defaultReturn; |
|
}, |
|
handleAdd() { |
|
this.addShow = true; |
|
this.moldAddMore = true; |
|
this.title = '新增'; |
|
}, |
|
// 修改 |
|
handleEdit(row) { |
|
this.addShow = true; |
|
this.moldAddMore = true; |
|
this.rowData = [row]; |
|
this.title = '修改'; |
|
}, |
|
closeDialog() { |
|
this.addShow = false; |
|
this.onLoad(this.page, this.query); |
|
}, |
|
beforeOpen(done, type) { |
|
if (['edit', 'view'].includes(type)) { |
|
// this.form.processId = this.form.processId+'' |
|
// this.form.craftId = this.form.craftId+'' |
|
this.form.workCenterId = this.form.workCenterId + ''; |
|
} |
|
done(); |
|
}, |
|
onChangeData(val, type) { |
|
if (val && type == 'workCenterId') { |
|
this.form.workCenterName = val.wcCode; |
|
} |
|
if (val && type == 'equipName') { |
|
this.form.equipName = val.deviceName; |
|
} |
|
if (val && type == 'craftId') { |
|
this.form.craftName = val.caName; |
|
} |
|
}, |
|
rowSave(row, done, loading) { |
|
addEquipAbility(row).then( |
|
() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
done(); |
|
}, |
|
error => { |
|
window.console.log(error); |
|
loading(); |
|
} |
|
); |
|
}, |
|
rowUpdate(row, index, done, loading) { |
|
updateEquipAbility(row).then( |
|
() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
done(); |
|
}, |
|
error => { |
|
window.console.log(error); |
|
loading(); |
|
} |
|
); |
|
}, |
|
rowDel(row) { |
|
this.$confirm('确定将选择数据删除?', { |
|
confirmButtonText: '确定', |
|
cancelButtonText: '取消', |
|
type: 'warning', |
|
}) |
|
.then(() => { |
|
return removeEquipAbility(row.id); |
|
}) |
|
.then(() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
}); |
|
}, |
|
|
|
searchReset() { |
|
this.query = {}; |
|
this.onLoad(this.page); |
|
}, |
|
searchChange(params, done) { |
|
this.query = params; |
|
this.page.currentPage = 1; |
|
this.onLoad(this.page, params); |
|
done(); |
|
}, |
|
selectionChange(list) { |
|
this.selectionList = list; |
|
}, |
|
selectionClear() { |
|
this.selectionList = []; |
|
this.$refs.crud.toggleSelection(); |
|
}, |
|
|
|
currentChange(currentPage) { |
|
this.page.currentPage = currentPage; |
|
}, |
|
sizeChange(pageSize) { |
|
this.page.pageSize = pageSize; |
|
}, |
|
refreshChange() { |
|
this.onLoad(this.page, this.query); |
|
}, |
|
onLoad(page, params = {}) { |
|
this.loading = true; |
|
getListEquipAbility(page.currentPage, page.pageSize, Object.assign(params, this.query)).then( |
|
res => { |
|
this.data = res.data.data.records; |
|
this.loading = false; |
|
this.page.total = res.data.data.total; |
|
this.data.forEach(item => { |
|
if (item.partType != 0) { |
|
item.abilityList = JSON.parse(item.standardProcessAbility); |
|
} |
|
if (item.craftId !== undefined && item.craftId !== null) { |
|
item.craftId = item.craftId + ''; |
|
} |
|
}); |
|
// 关键:数据处理完成后计算合并行数 |
|
this.calculateSpan(this.data); |
|
} |
|
); |
|
}, |
|
}, |
|
mounted() {}, |
|
}; |
|
</script>
|
|
|