deesCloud-web/scripts/ms-en.js

628 lines
16 KiB
JavaScript
Raw Permalink Normal View History

2025-08-01 16:50:32 +08:00
var msComponent_en = {
template:`
<div>
<div v-show="if_show0">
<div id="" style="display: inline-block;width: 100%;margin-top: 10px;">
<!--
<div style="float: left; width: 20%;">
<el-select v-model="searchType" filterable placeholder="请选择查询类型" style="width: 100%;">
<el-option
v-for="item in searchTypes"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
-->
<div style="float: left; width: 30%;">
<el-input v-model="input" :placeholder="holder" clearable></el-input>
</div>
<div style="float: left;margin-left: 5px;">
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="getMs(input)">Search</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportMs()">Export</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_export_source" plain type="primary" icon="el-icon-document" @click="exportAnalysis()">Export Original Data</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_export_cfg" plain type="primary" icon="el-icon-setting" @click="setting()">Display settings</el-button>
</div>
</div>
<div class="span">
<el-table
:data="tableData"
style="width: 100%"
:height="tHeight"
:cell-style="{background:'#304156'}"
border
>
<el-table-column
v-if="if_series"
prop="series"
label="Instrument Series No."
width="160">
</el-table-column>
<el-table-column
v-if="if_instrument_id"
prop="instrument_id"
label="Instrument Code"
width="80">
</el-table-column>
<el-table-column
prop="repairCnt"
label="Maintenance Times"
width="150">
<template slot="header" >
<el-tooltip
effect="dark"
content="number of maintenance events"
placement="top"
>
<span>Maintenance Times</span>
</el-tooltip>
</template>
</el-table-column>
<el-table-column
prop="totalTime"
label="Total Working Time(h)"
width="180">
</el-table-column>
<el-table-column
prop="mtbfTime"
label="MTBF"
width="100">
</el-table-column>
</el-table>
</div>
<div class="block">
<span class="demonstration" style="background-color: #ECF5FF;"></span>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[50,100, 200, 300]"
:page-size="pagesize"
layout="total, sizes, prev, pager, next, jumper"
:total="recordTotal" style="background-color: #ECF5FF;">
</el-pagination>
</div>
<el-dialog
title="Series number merge display settings"
:visible.sync="adddialogVisible"
:lock-scroll ="false"
width="35%">
<el-form ref="msform" :model="form" label-width="170px" :rules="rules">
<el-form-item label="Instrument Series No." prop="series_num">
<el-input v-model="form.series_num" placeholder="format: LHE6118,LHE6118A"></el-input>
</el-form-item>
<el-form-item label="Merged name" prop="series_num_new">
<el-input v-model="form.series_num_new" placeholder="format: LHE6118/A"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button id ="bt_cancel" plain @click="adddialogVisible = false">Cancel</el-button>
<el-button id ="bt_ok" plain type="primary" @click="postMsSetting()">Ok</el-button>
</span>
</el-dialog>
<el-dialog
title="Display settings"
:visible.sync="dialogVisible"
:lock-scroll ="false"
width="50%">
<div id="" style="display: block;">
<div style="float: right; ">
<el-button id ="bt_add" plain size="medium" type="primary" icon="el-icon-circle-plus-outline" @click="addMsSetting()">Add</el-button>
</div>
</div>
<el-table
:data="tableData1"
style="width: 100%"
:cell-style="{background:'#fff'}"
height="300"
>
<el-table-column
prop="series_num"
label="Instrument Series No."
width="300">
</el-table-column>
<el-table-column
prop="series_num_new"
label="Merged name"
width="150">
</el-table-column>
<el-table-column
label="Operation"
width="120">
<template slot-scope="scope">
<!--style="height:23px;padding:0px" -->
<el-button id ="bt_update" plain @click="updateMsSetting(scope.row)" type="text" size="medium" >Update</el-button>
<el-button id ="bt_del" plain @click="delMsSetting(scope.row)" type="text" size="medium" >Delete</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
<div v-show="if_show" style="text-align: center; width: 100%;;font-size: 14px;">
<el-tag type="warning" style="width: 100%;height: 50px;font-size: 14px;">The user does not have permission for this menu!</el-tag>
</div>
</div>
`,
data(){
// 获取当前屏幕的分辨率
let screenW = window.screen.width;
let screenH = window.innerHeight;
console.log("screen width:",screenW);
console.log("screen height:",screenH);
return {
tHeight:screenH-192,
searchType: '系列号',
holder:"Please Input Series No.",
input:'',
tableData: [],
currentPage: 1,
pagesize:50,
recordTotal:0,
if_instrument_id:false,
if_series:true,
form: {
id:"",
series_num: '',
series_num_new:'',
},
adddialogVisible:false,
rules: {
series_num: [
{ required: true, message: 'The series no. cannot be empty!', trigger: 'blur' }
],
series_num_new: [
{ required: true, message: 'Consolidated Name cannot be empty!', trigger: 'blur' }
],
},
dialogVisible:false,
oper_type:0,
tableData1: [],
if_show0:false,
if_show:false,
}
},
watch: {
searchType: function() { //searchType是select绑定的字段在这里监听searchType
if(this.searchType == '系列号') {
this.holder = '请输入查询系列号';
this.$data.input = '';
} else if(this.searchType == '编码') {
this.holder = '请输入查询编码';
this.$data.input = '';
}
}
},
mounted() {
if (localStorage.getItem("level")==4) {
this.$data.if_show = true;
return;
}
this.$data.if_show0= true;
var _this = this;
var objs;
axios.post('/deescloud/getMs', {
type:this.$data.searchType,
index: this.$data.currentPage,
count: this.$data.pagesize,
op_user:localStorage.getItem("online_user"),
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
var _this = this;
var objs;
axios.post('/deescloud/getMsSetting', {
op_user:localStorage.getItem("online_user"),
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
_this.$data.tableData1 = objs;
})
.catch(function (error) {
console.log(error);
});
/*
axios.post('/deescloud/GetMhSetting', {
op_user:localStorage.getItem("online_user")
})
.then(function (response) {
console.log(response.data);
_this.$data.form.series_num = response.data.series_num;
_this.$data.form.series_num_new = response.data.series_num_new;
})
.catch(function (error) {
console.log(error);
});*/
},
methods: {
getMsSetting(){
var _this = this;
var objs;
axios.post('/deescloud/getMsSetting', {
op_user:localStorage.getItem("online_user"),
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
_this.$data.tableData1 = objs;
})
.catch(function (error) {
console.log(error);
});
},
postMsSetting(){
var check_num = 0;
if (this.$data.form.series_num == '') {
check_num = check_num+1;
}
if ( this.$data.form.series_num_new == '') {
check_num = check_num+1;
}
if (check_num==1) {
this.$message({
message: "Series No. and Consolidated Name cannot be empty!",
type: "warning",
duration: 1500
});
return;
}
this.$data.adddialogVisible = false;
var _this = this;
console.log(_this.$data.form);
var objs;
axios.post('/deescloud/postMsSetting', {
op_user:localStorage.getItem("online_user"),
series_num: _this.$data.form.series_num,
series_num_new:_this.$data.form.series_num_new,
id:_this.$data.form.id,
oper_type: _this.$data.oper_type
})
.then(function (response) {
let r = response.data.r;
if (r == 0) {
_this.$message({
message: "Set successfully!",
type: "success",
duration: 1500
});
_this.getMsSetting();//更新页面
} else{
if (r ==1) {
_this.$message({
message: "The number of new and old series no. groups does not match!",
type: "error",
duration: 1500
});
} else{
_this.$message({
message: "Setting failed!",
type: "error",
duration: 1500
});
}
}
})
.catch(function (error) {
console.log(error);
});
},
delMsSetting(info){
this.$data.oper_type = 3;
var _this = this;
var objs;
axios.post('/deescloud/postMsSetting', {
op_user:localStorage.getItem("online_user"),
id:info.id,
series_num: info.series_num,
series_num_new:info.series_num_new,
oper_type: _this.$data.oper_type
})
.then(function (response) {
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
s = "Delete succeeded!";
errType = "success"
} else{
s = "Delete failed!";
errType = "error"
}
_this.$message({
message: s,
type: errType,
duration: 1500
});
if (r ==0) {
_this.getMsSetting("");//更新页面
}
})
.catch(function (error) {
console.log(error);
});
},
updateMsSetting(info){
this.$data.oper_type = 2;
this.$data.form = {
op_user:localStorage.getItem("online_user"),
id:info.id,
series_num: info.series_num,
series_num_new:info.series_num_new
};
this.$nextTick(() => {
this.$refs['msform'].clearValidate()
});
this.$data.adddialogVisible = true;
},
addMsSetting(){
this.$data.oper_type = 1;
this.$data.form = {
id:"",
series_num: '',
series_num_new:'',
};
this.$data.adddialogVisible = true;
this.$nextTick(() => {
this.$refs['msform'].clearValidate();
});
},
updateMhSetting(){
var check_num = 0;
if (this.$data.form.series_num == '') {
check_num = check_num+1;
}
if ( this.$data.form.series_num_new == '') {
check_num = check_num+1;
}
if (check_num==1) {
this.$message({
message: "Series No. and Consolidated Name cannot be empty!",
type: "warning",
duration: 1500
});
return;
}
this.$data.adddialogVisible = false;
var _this = this;
console.log(_this.$data.form);
var objs;
axios.post('/deescloud/updateMhSetting', {
op_user:localStorage.getItem("online_user"),
series_num: _this.$data.form.series_num,
series_num_new:_this.$data.form.series_num_new,
})
.then(function (response) {
let r = response.data.r;
if (r == 0) {
_this.$message({
message: "Set successfully!",
type: "success",
duration: 1500
});
} else{
if (r ==1) {
_this.$message({
message: "The number of new and old series no. groups does not match!",
type: "error",
duration: 1500
});
} else{
_this.$message({
message: "Setting failed!",
type: "error",
duration: 1500
});
}
}
})
.catch(function (error) {
console.log(error);
});
//update table data
},
setting(){
document.getElementById("bt_export_cfg").blur();
this.$data.dialogVisible = true;
/*this.$nextTick(() => {
this.$refs['msform'].clearValidate();
});*/
},
exportMs(){
document.getElementById("bt_export").blur();
var _this = this;
axios.post('deescloud/getMsCsv_en',{seriesNum:_this.$data.input,op_user:localStorage.getItem("online_user"),}
).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
//var filename = "维保"+_this.$data.searchType+"全部统计.csv";
var filename = "MTBF.csv";
downloadUrl(filename,downUrl);
})
.catch(function (error) {
console.log(error);
});
},
exportAnalysis(){
document.getElementById("bt_export_source").blur();
var _this = this;
axios.post('deescloud/get_mt_analysis_en',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
}).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
var filename = "MTBF-raw-data.xlsx";
downloadUrl(filename,downUrl);
})
.catch(function (error) {
console.log(error);
});
},
getMs(_search_name){
document.getElementById("bt_search").blur();
if (this.$data.searchType == "系列号") {
this.$data.if_series = true;
this.$data.if_instrument_id = false;
}else{
this.$data.if_instrument_id = true;
this.$data.if_series = false;
}
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/deescloud/getMs', {
type:this.$data.searchType,
value:this.$data.input,
index: this.$data.currentPage,
count: this.$data.pagesize,
op_user:localStorage.getItem("online_user"),
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
handleSizeChange(val) {
this.$data.pagesize = val;
var _this = this;
var objs;
axios.post('/deescloud/getMs', {
type:this.$data.searchType,
value:this.$data.input,
index: this.$data.currentPage,
count: this.$data.pagesize,
op_user:localStorage.getItem("online_user"),
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
handleCurrentChange(val) {
this.$data.currentPage = val;
var _this = this;
var objs;
axios.post('/deescloud/getMs', {
type:this.$data.searchType,
value:this.$data.input,
index: this.$data.currentPage,
count: this.$data.pagesize,
op_user:localStorage.getItem("online_user"),
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
}
}
}