var msComponent = {
template:`
`,
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);
});
}
}
}