626 lines
15 KiB
JavaScript
626 lines
15 KiB
JavaScript
var msComponent = {
|
||
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)">搜索</el-button>
|
||
</div>
|
||
|
||
<div style="float: left; margin-left: 5px;">
|
||
<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportMs()">导出</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()">导出原始数据</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()">显示设置</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="仪器系列号"
|
||
width="100">
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="if_instrument_id"
|
||
prop="instrument_id"
|
||
label="仪器编码"
|
||
width="80">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="repairCnt"
|
||
label="维修次数"
|
||
width="80">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="totalTime"
|
||
label="总工作时间(h)"
|
||
width="100">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="mtbfTime"
|
||
label="MTBF时间(h)"
|
||
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="系列号合并显示设置"
|
||
:visible.sync="adddialogVisible"
|
||
:lock-scroll ="false"
|
||
width="30%">
|
||
<el-form ref="msform" :model="form" label-width="100px" :rules="rules">
|
||
<el-form-item label="系列号" prop="series_num">
|
||
<el-input v-model="form.series_num" placeholder="格式: LHE6118,LHE6118A"></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="合并后名称" prop="series_num_new">
|
||
<el-input v-model="form.series_num_new" placeholder="格式: LHE6118/A"></el-input>
|
||
</el-form-item>
|
||
</el-form>
|
||
<span slot="footer" class="dialog-footer">
|
||
<el-button id ="bt_cancel" plain @click="adddialogVisible = false">取 消</el-button>
|
||
<el-button id ="bt_ok" plain type="primary" @click="postMsSetting()">确 定</el-button>
|
||
</span>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
title="显示设置"
|
||
: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()">新增</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<el-table
|
||
:data="tableData1"
|
||
style="width: 100%"
|
||
:cell-style="{background:'#fff'}"
|
||
height="300"
|
||
>
|
||
<el-table-column
|
||
prop="series_num"
|
||
label="系列号"
|
||
width="300">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="series_num_new"
|
||
label="合并后名称"
|
||
width="150">
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="操作"
|
||
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" >修改</el-button>
|
||
<el-button id ="bt_del" plain @click="delMsSetting(scope.row)" type="text" size="medium" >删除</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;">用户没有本菜单权限!</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,
|
||
searchTypes: [{
|
||
value: '系列号',
|
||
label: '系列号'
|
||
}, {
|
||
value: '编码',
|
||
label: '编码'
|
||
}],
|
||
searchType: '系列号',
|
||
holder:"请输入查询系列号",
|
||
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: '系列号不可为空', trigger: 'blur' }
|
||
],
|
||
series_num_new: [
|
||
{ required: true, message: '重命名不可为空', 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: "系列号和修改后的序列号名称不可单一为空!",
|
||
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: "设置成功!",
|
||
type: "success",
|
||
duration: 1500
|
||
});
|
||
|
||
_this.getMsSetting();//更新页面
|
||
} else{
|
||
if (r ==1) {
|
||
_this.$message({
|
||
message: "新旧系列号分组个数不匹配!",
|
||
type: "error",
|
||
duration: 1500
|
||
});
|
||
} else{
|
||
_this.$message({
|
||
message: "设置失败!",
|
||
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 = "删除成功!";
|
||
errType = "success"
|
||
} else{
|
||
s = "删除失败!";
|
||
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: "系列号和修改后的序列号名称不可单一为空!",
|
||
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: "设置成功!",
|
||
type: "success",
|
||
duration: 1500
|
||
});
|
||
} else{
|
||
if (r ==1) {
|
||
_this.$message({
|
||
message: "新旧系列号分组个数不匹配!",
|
||
type: "error",
|
||
duration: 1500
|
||
});
|
||
} else{
|
||
_this.$message({
|
||
message: "设置失败!",
|
||
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',{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',{
|
||
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原始数据.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);
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|