Files
scrq-hd/.svn/pristine/5d/5dc7bb6fd955b1e05d9411bb70568934c554c99c.svn-base
2025-07-03 10:34:04 +08:00

833 lines
23 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<div class="main">
<query-params
ref="query"
:form="queryFormConfig"
@handleQuery="handleQuery"
@getTableData="getTableData"
@resetQuery="resetQuery"
>
</query-params>
<el-divider></el-divider>
</div>
<div>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="openDetailAdd"
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-plus"
size="mini"
:disabled="updateButton"
@click="updatedThis"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="deletedButton"
@click="deleteAll"
>删除
</el-button>
</el-col>
<el-popover
style="float: right"
placement="bottom-end"
title="自定义显示列"
width="250"
@show="initPopover"
trigger="hover"
>
<headConfig
ref="test"
@fathers="fathers"
:propThis="propThis"
></headConfig>
<el-button
size="mini"
type="primary"
class="el-icon-caret-bottom"
slot="reference"
>自定义列</el-button
>
</el-popover>
</el-row>
<el-row :gutter="10" style="margin: 10px 0px" class="mb8" v-show="isSortShow">
<el-col>
<el-select
class="sortSeq"
ref="select"
@click.native="notSelect"
style="width: 800px"
v-model="seqence"
:multiple="true"
placeholder=""
>
<el-option
v-for="(item,index) in seqenceOptions"
:key="index"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-col>
</el-row>
</div>
<el-table
@sort-change="sortChange"
@header-dragend="headerDragend"
@selection-change="handleSelectionChangeMainTable"
v-if="indexShow"
v-loading="loading"
:data="tableData"
border
ref="list"
:height="tableHeight"
:cell-style="cellStyle"
highlight-current-row
>
<el-table-column
type="index"
width="50"
align="center"
label="序号"
/>
<el-table-column align="center" type="selection" width="55"> </el-table-column>
<el-table-column
v-for="(item, index) in realList"
:sortable="item.notSort == true ? false : `custom`"
:prop="item.tableProp"
:key="index"
:align="item.align"
header-align="center"
:min-width="item.width"
:label="item.tableTitle"
:show-overflow-tooltip="item.show_overflow_tooltip"
></el-table-column>
</el-table>
<el-pagination
style="margin-top: 10px"
@size-change="handleSizeChange"
@current-change="handleCurrentChange2"
:current-page="currentPage"
:page-sizes="[10, 20, 50, 100, 200, 500, 1000]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
>
</el-pagination>
</div>
</template>
<script >
import Edit from "./edit";
export default {
components: {
Edit,
},
computed:{
queryFormConfig()
{
return{
controlList:[
{
key:'deviceCode',
label:'设备编号',
type:'input',
placeholder:'请输入',
prop:'deviceCode',
class:'width_0180'
},
{
key:'deviceName',
label:'设备名称',
type:'input',
placeholder:'请输入',
prop:'deviceName',
class:'width_0180'
},
{
key:'specificationModel',
label:'规格型号',
type:'input',
placeholder:'请输入',
prop:'specificationModel',
class:'width_0180'
},
{
key:'status',
label: '状态',
type: 'select',
placeholder: '请选择',
prop: 'status',
options: this.statusArr,
optionLabel:'name',
optionValue:'id'
},
{
key:'deptName',
label:'使用部门',
type:'input',
placeholder:'请输入',
prop:'deptName',
class:'width_0180'
},
{
key:'serviceLife',
label:'使用年限',
type:'input',
placeholder:'请输入',
prop:'serviceLife',
class:'width_0180'
},
{
key: "workCenterId",
label: "工作中心",
type: "treeSelect",
prop: "workCenterId",
treeOptions: this.treeOptions,
},
{
key:"datetime",label: '购入日期', type: 'datetimerange', startPlaceholder:"开始日期",endPlaceholder:"结束日期", prop: 'datetime',
},
{
key:"datetime1",label: '保养日期', type: 'datetimerange', startPlaceholder:"开始日期",endPlaceholder:"结束日期", prop: 'datetime1',
},
{
key: "dictEquipmentType",
label: "设备类型",
type: "select",
placeholder: "请选择",
prop: "dictEquipmentType",
options: this.$dictType.getDict('apm_equipment_type'),
optionLabel: "text",
optionValue: "key",
},
],
config:{
//零散的配置参数
hasAdvQuery:false,//有无高级查询
storageMode:true,//记忆模式开启后每次查询会存储到localstorage中存储名为下面的storageKey
storageKey:"equipmentAccount",
propThis:this,//this
preFixWidthClass:'width_0100', //前置框的宽度calss不写则为默认100
marginWidthClass:'width_0180' //空白选择框的宽度calss不写则为默认180
},
defaultList: [
//默认展示的属性,跟controList里面的key相对应
'deviceCode','name','specificationModel',//'planStartDtArray',
],
}
}
},
data() {
return {
dictEquipmentTypeArr:[],
realList: [],
isSortShow:false,
propThis: this,
isAdd: null,
datetime:[],
datetime1:[],
treeOptions:[],
queryParams: {
deviceCode: null,
deviceName: null,
specificationModel: null,
status: null,
deptName: null,
buyStart: null,
buyEnd: null,
maintenanceStart: null,
maintenanceEnd: null,
manufacturer: null,
serviceLife: null,
},
indexShow: false,
showMore: false,
tableHeight: 0,
tableData: [],
seqenceOptions: [],
seqence: [],
total: null,
loading: false,
pageSize: 50,
currentPage: 1,
statusArr: [
{ id: 0, name: "在库" },
{ id: 1, name: "在用" },
],
deletedButton: true,
updateButton: true,
selectRow: {},
selectAllRow: [],
};
},
mounted() {
this.$nextTick(() => {
this.tableHeight =
window.innerHeight - this.$refs.query.offsetHeight - 230;
// 监听窗口大小变化
let self = this;
window.onresize = function () {
self.tableHeight =
window.innerHeight - self.$refs.query.offsetHeight - 230;
};
});
this.dictEquipmentTypeArr=this.$dictType.getDict("apm_equipment_type")
this.initSeqenceOptions();
this.initData();
this.getWorkCenterTree();
this.$refs.query.init()
},
watch: {
seqence: function () {
this.getList();
var oldIsSortShow = this.isSortShow
//判断是否显示排序条件
if(this.seqence.length > 0 ){
this.isSortShow = true
}else{
this.isSortShow = false
}
//判断table高度
if(oldIsSortShow != this.isSortShow){
if (this.isSortShow) {
this.tableHeight = this.tableHeight - 47;
} else {
this.tableHeight = this.tableHeight + 47;
}
}
},
},
methods: {
notSelect() {
this.$refs.select.blur();
},
cellStyle ({ row, column, rowIndex, columnIndex }) {
if (row.status == 0 && column.property=='dictStatusShow') {
//在库
return 'color:lightgreen;font-weight:bold;'
}
else if (row.status == 1 && column.property=='dictStatusShow') {
//在用
return 'color:green;font-weight:bold;'
}
},
handleRowClick(selection, column, event) {
if (this.rows.length == 0 || this.rowClickFlag) {
this.rowClickFlag = true;
this.rows = [];
this.rows.push(selection);
this.single = this.rows.length != 1;
this.multiple = !this.rows.length;
if (this.rows.length > 0) {
let flag = false;
this.rows.forEach((element) => {
if (element.pickNumber) {
flag = true;
}
});
if (flag) {
this.ispickshow = true;
} else {
this.ispickshow = false;
}
} else {
this.ispickshow = true;
}
if (this.rows.length === 1 && this.ispickshow) {
this.isReturnShow = false;
} else {
this.isReturnShow = true;
}
this.isReShow = !this.rows.length;
} else {
this.single = this.rows.length != 1;
this.multiple = !this.rows.length;
this.isReShow = !this.rows.length;
}
},
headerDragend(newWidth, oldWidth, column, event) {
// realList
this.realList.forEach((value) => {
if (column.property == value.tableProp) {
value.width = newWidth;
}
});
this.$refs.test.init();
setTimeout(() => {
this.$refs.test.show();
}, 1000);
},
sortChange({ column, prop, order }) {
console.log(prop);
let sTemp = {
value: null,
label: null,
};
let value = prop.replace("Show", "") + " " + order;
let judgeValue = value.split(" ");
// this.seqence.push(value)
if (this.seqence.length === 0) {
this.seqence.push(value);
console.log(this.seqence);
} else {
for (let i = 0; i < this.seqence.length; i++) {
let judgeSeqence = this.seqence[i].split(" ");
if (judgeValue[0] === judgeSeqence[0]) {
if (judgeValue[1] === "null") {
return;
}
this.seqence.splice(i, 1, value);
console.log(this.seqence);
return;
}
if (i + 1 === this.seqence.length) {
this.seqence.push(value);
console.log(this.seqence);
}
}
}
},
getWorkCenterTree() {
this.$plan.getWorkCenterTree().then((resp) => {
console.log(resp,'work-index getWorkCenterTree resp')
this.treeOptions = [];
this.treeOptions.push(resp.data.data);
this.removeBlackChildren(this.treeOptions);
});
},
removeBlackChildren(list) {
list.forEach((value) => {
if (value.children.length == 0) {
value.children = undefined;
} else {
this.removeBlackChildren(value.children);
}
});
},
initSeqenceOptions() {
let tempList = this.$headerConfig.getList("equipmentAccount");
tempList.forEach((data, index) => {
if (data.notSort) return;
let temp = {
value: null,
label: null,
};
temp.value = data.tableProp.replace("Show", "") + " ascending";
temp.label = data.tableTitle + " 升序";
this.seqenceOptions.push(temp);
let tempD = {
value: null,
label: null,
};
tempD.value = data.tableProp.replace("Show", "") + " descending";
tempD.label = data.tableTitle + " 降序";
this.seqenceOptions.push(tempD);
});
},
//初始化表格
initData() {
this.workStatus = [];
this.workStatus.push({});
this.workType = [];
this.workType.push({});
this.$dictType
.getOrderWorkStatusArray()
.forEach((value) => this.workStatus.push(value));
const params = {
tableName: "equipmentAccount",
};
this.getList();
this.$headerConfig.getRealList(params).then((data) => {
console.log("开始输出真正表格",data);
if (data.data && data.data.data && data.data.data !== null) {
let temp = JSON.parse(data.data.data);
this.realList = temp.headerList;
this.List = temp.List;
} else {
this.List = this.$headerConfig.getList("equipmentAccount");
this.realList = this.List;
let temp = {
headerList: this.realList,
List: this.List,
};
const params = {
tableName: "equipmentAccount",
configure: JSON.stringify(temp),
};
this.$headerConfig.updateRealList(params).then((value) => {
console.log(value);
});
}
this.tableData=JSON.parse(JSON.stringify(this.tableData))
this.indexShow = true;
});
},
initPopover() {
const params = {
tableName: "equipmentAccount",
};
this.$headerConfig.getRealList(params).then((_data) => {
console.log(_data,'_data')
let data=_data.config?_data.data:_data
console.log("开始输出真正表格1548",data);
let temp = JSON.parse(data.data);
console.log(temp,'temp');
this.realList = temp.headerList;
console.log(this.realList);
this.$refs.test.init();
});
},
fathers(data) {
this.List = data.configure.List;
data.configure.List.forEach((value) => {
this.realList.forEach((real) => {
if (value.tableProp == real.tableProp) {
value.width = real.width;
}
});
});
data.configure.headerList.forEach((value) => {
this.realList.forEach((real) => {
if (value.tableProp == real.tableProp) {
value.width = real.width;
}
});
});
if (data.configure.headerList.length <= 0) {
return;
}
const params = {
tableName: "equipmentAccount",
configure: JSON.stringify(data.configure),
};
this.realList = data.configure.headerList;
this.$headerConfig.updateRealList(params).then((value) => {
if(value.status=='200'){
this.$message({
message: '自定义列宽保存成功',
type: 'success'
});
}else{
this.$message({
message: '自定义列宽保存失败',
type: 'error'
});
}
});
},
showMoreChange() {
if (!this.showMore) {
this.tableHeight = this.tableHeight - 70;
} else {
this.tableHeight = this.tableHeight + 70;
}
this.$nextTick(() => {
this.showMore = !this.showMore;
});
},
handleCurrentChange2(val) {
console.log(val);
this.currentPage = val;
this.getList();
},
handleSizeChange(val) {
this.pageSize = val;
this.getList();
},
stateFormat(row, column) {
if (row.status === 0) {
return "在库";
} else if (row.status === 1) {
return "在用";
}
},
handleQuery() {
this.getQueryParams()
this.getList();
this.queryParams.pageNo = 1;
},
getQueryParams()
{
let pageSize=this.queryParams.pageSize
let pageNo=this.queryParams.pageNo
this.queryParams=this.$refs.query.getQueryParams()//返回子组件的queryParams
this.queryParams.pageSize=pageSize
this.queryParams.pageNo=pageNo
//取得子组件的queryParams并且与原来的pagesize pageNo合并
},
getTableData(val) {
//高级查询
this.queryData = val
this.tableData=this.queryData.data
this.tableData.forEach((value) => {
value.materialNumber=value.materialCode
value.dictStatusShow = this.$dictType.getOrderWorkStatus(
value.dictStatus
);
value.dictFlowtypeShow = this.$dictType.getMaterialFlowType(
value.dictFlowtype
);
value.dictPtypeShow = this.$dictType.getOrderPtypeType(
value.dictPtype
);
value.dictPstatusShow = this.$dictType.getWorkPStatus(value.dictPstatus);//领料状态
});
this.total=this.queryData.recordsTotal
// this.getBomlList()
},
getList() {
this.loading = true;
const orders = [];
this.seqence.map((val) => {
orders.push(
val.replace("ascending", "asc").replace("descending", "desc")
);
});
let params = {
pageSize: this.pageSize,
pageNo: this.currentPage,
deviceCode: this.queryParams.deviceCode,
deviceName: this.queryParams.deviceName,
specificationModel: this.queryParams.specificationModel,
status: this.queryParams.status,
deptName: this.queryParams.deptName,
buyStart: this.queryParams.buyStart,
buyEnd: this.queryParams.buyEnd,
maintenanceStart: this.queryParams.maintenanceStart,
maintenanceEnd: this.queryParams.maintenanceEnd,
manufacturer: this.queryParams.manufacturer,
serviceLife: this.queryParams.serviceLife,
workCenterId: this.queryParams.workCenterId,
dictEquipmentType:this.queryParams.dictEquipmentType,
orders:orders
};
if(this.queryParams.datetime!=undefined && this.queryParams.datetime!=null)
{
params.buyStart=this.g_method.dateFtt("yyyy-MM-dd hh:mm:ss", this.queryParams.datetime[0]),
params.buyEnd=this.g_method.dateFtt("yyyy-MM-dd hh:mm:ss", this.queryParams.datetime[1])
}
if(this.queryParams.datetime1!=undefined && this.queryParams.datetime1!=null)
{
params.maintenanceStart=this.g_method.dateFtt("yyyy-MM-dd hh:mm:ss", this.queryParams.datetime1[0]),
params.maintenanceEnd=this.g_method.dateFtt("yyyy-MM-dd hh:mm:ss", this.queryParams.datetime1[1])
}
this.$EquipmentAccount.getEquipmentList(params).then((resp) => {
if (resp.data.code === 200) {
console.log("拿到整体得数据", resp.data.data);
this.tableData = resp.data.data.data;
this.tableData.forEach((value)=>{
value.dictStatusShow=this.$dictType.getApmEquipmentAccountStatus(
value.status
)
value.dictEquipmentTypeShow=this.$dictType.getequipmentType(value.dictEquipmentType)
})
this.total = resp.data.data.recordsTotal;
this.loading = false;
}
});
},
Query() {
this.currentPage = 1;
this.getList();
},
resetQuery() {
this.queryParams = {
deviceCode: null,
name: null,
specificationModel: null,
status: null,
deptName: null,
buyStart: null,
buyEnd: null,
maintenanceStart: null,
maintenanceEnd: null,
manufacturer: null,
serviceLife: null,
};
this.getList();
},
handleSelectionChangeMainTable(val) {
console.log(val, "shibu是");
if (val.length == 1) {
this.updateButton = false;
this.selectRow = val[0];
console.log("选中的当前行", this.selectRow);
} else {
this.updateButton = true;
this.selectRow = {};
}
if (val.length) {
let ids = [];
val.forEach((e) => {
ids.push(e.id);
});
this.selectAllRow = ids;
this.deletedButton = false;
} else {
this.deletedButton = true;
}
},
openDetailAdd() {
this.isAdd = true;
this.$layer.iframe({
shadeClose: false,
content: {
content: Edit, //传递的组件对象
parent: this, //当前的vue对象
shadeClose: false,
data: this.currentRow,
},
title: "新增",
});
},
updatedThis() {
this.isAdd = false;
this.$layer.iframe({
shadeClose: false,
content: {
content: Edit, //传递的组件对象
parent: this, //当前的vue对象
shadeClose: false,
data: this.selectRow,
},
title: "修改",
});
},
deleteAll() {
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
console.log(this.selectAllRow ,'1811s');
let params = { ids: this.selectAllRow.join(",") };
this.$EquipmentAccount.DeleteEquipment(params).then((resp) => {
if (resp.data.code == 200) {
this.$message.success("删除成功");
this.getList();
} else {
console.log(resp,"4544444");
this.$message.error(resp.data.msg);
}
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
},
};
</script>
<style lang="scss" scoped>
>>> .el-form-item {
padding: 0px;
margin: 0px;
}
>>> .vue-treeselect__control {
height: 20px;
line-height: 28px;
}
>>> .el-divider {
margin: 1px;
}
>>> .el-table__body tr.current-row > td {
background-color: #8ac1ff !important;
cursor: pointer;
}
.el-table >>> tbody tr:hover > td {
background-color: #8ac1ff !important;
}
.mb8 >>> .el-select .el-input__inner {
border: 0px;
}
.mb8 >>> .el-select .el-input__inner {
border: 0px;
padding-right: 35px;
}
.sortSeq >>> .el-input__suffix-inner {
display: none;
}
>>> .el-form-item {
margin-bottom: 10px;
}
.el-divider {
margin-top: 0px;
margin-bottom: 5px;
}
>>> .el-table .el-table__header-wrapper th {
padding: 5px 0;
}
>>> .vue-treeselect__control {
height: 30px !important;
line-height: 30px !important;
}
>>> .vue-treeselect--single .vue-treeselect__input-container {
height: 30px !important;
line-height: 30px !important;
}
// >>> .el-input-group__append{
// padding: 5px;
// }
>>> .el-input-group__append .el-select,
.el-input-group__append .el-button,
.el-input-group__prepend .el-select,
.el-input-group__prepend .el-button {
margin-left: -28px !important;
margin-right: -33px !important;
}
</style>