//组件
var devcomponent = {
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,
tHeight1:screenH*0.5,
tableData: Array(0),
input:'',
currentPage: 1,
pagesize:50,
recordTotal:0,
pdf_visible:false,
dev_tableData:[],
wellnames:[],
add_visible:false,
update_visible:false,
form: {
id:0,
wellname:'',
sid:'',
iid:'',
ver: '',
p_date:'',
cal_date:'',
total_wt:'',
cur_wt:'',
repair_cnt:'',
region:'',
location:'',
responsible:''
},
rules: {
wellname: [
{ required: true, message: '系列号不可为空', trigger: 'blur' }
],
sid: [
{ required: true, message: '系列号不可为空', trigger: 'blur' }
],
iid: [
{ required: true, message: '编码不可为空', trigger: 'blur' }
],
},
if_show_bt:true,
if_show_et:false,
ps_info:'',
}
},
mounted() {
var _this = this;
axios.post('/deescloud/get_page_setting', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
})
.then(function (response) {
if(response.data.r3=="1"){
_this.$data.ps_info = response.data;
_this.$data.if_show_bt=true;
_this.$data.if_show_et=false;
}else{
_this.$data.if_show_et=true;
_this.$data.if_show_bt=false;
}
})
.catch(function (error) {
console.log(error);
});
var objs;
axios.post('/deescloud/get_well_dev', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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);
});
},
methods: {
remove_dev_m(row){
var _this = this;
var r;
axios.post('/deescloud/remove_dev_manage', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
data:{
id: row.id
}
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
axios.post('/deescloud/get_dev_manage', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: row.wellname,
})
.then(function (response) {
console.log(response.data);
_this.$data.dev_tableData = response.data.data;
})
.catch(function (error) {
console.log(error);
});
_this.$message({
message: "删除成功",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "删除失败",
type: "error",
duration: 1500
});
}
})
.catch(function (error) {
console.log(error);
});
},
update_dev_manage(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/update_dev_manage', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
data:{
id:_this.$data.form.id,
wellname:_this.$data.form.wellname,
sid:_this.$data.form.sid,
iid:_this.$data.form.iid,
ver: _this.$data.form.ver,
p_date:_this.$data.form.p_date,
cal_date:_this.$data.form.cal_date,
total_wt:_this.$data.form.total_wt,
cur_wt:_this.$data.form.cur_wt,
repair_cnt:_this.$data.form.repair_cnt,
region:_this.$data.form.region,
location:_this.$data.form.location,
responsible:_this.$data.form.responsible
}
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
axios.post('/deescloud/get_dev_manage', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: _this.$data.form.wellname,
})
.then(function (response) {
console.log(response.data);
_this.$data.dev_tableData = response.data.data;
})
.catch(function (error) {
console.log(error);
});
_this.$message({
message: "修改成功",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "修改失败",
type: "error",
duration: 1500
});
}
_this.$data.update_visible=false;
})
.catch(function (error) {
console.log(error);
});
}})
},
update_dev_m_dialog(row){
this.$data.form.id=row.id;
console.log("wellname",row.wellname);
this.$data.form.wellname=row.wellname;
this.$data.form.sid=row.sid;
this.$data.form.iid=row.iid;
this.$data.form.ver= row.ver;
if(this.$data.ps_info.r3=="1"){
this.$data.form.p_date=row.p_date;
this.$data.form.cal_date=row.cal_date;
}else{
if (row.p_date.length>=10){
var arr = row.p_date.split("-")
var t = arr[2]+"-"+arr[0]+"-"+arr[1];
console.log(t);
this.$data.form.p_date=t;
}
if (row.cal_date.length>=10){
var arr = row.p_date.split("-")
var t = arr[2]+"-"+arr[0]+"-"+arr[1];
console.log(t);
this.$data.form.cal_date=t;
}
}
//this.$data.form.p_date=row.p_date;
//this.$data.form.cal_date=row.cal_date;
this.$data.form.total_wt=row.total_wt;
this.$data.form.cur_wt=row.cur_wt;
this.$data.form.repair_cnt=row.repair_cnt;
this.$data.form.region=row.region;
this.$data.form.location=row.location;
this.$data.form.responsible=row.responsible;
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.update_visible=true;
},
add_dev_manage(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/add_dev_manage', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
data:{
wellname:_this.$data.form.wellname,
sid:_this.$data.form.sid,
iid:_this.$data.form.iid,
ver: _this.$data.form.ver,
p_date:_this.$data.form.p_date,
cal_date:_this.$data.form.cal_date,
total_wt:_this.$data.form.total_wt,
cur_wt:_this.$data.form.cur_wt,
repair_cnt:_this.$data.form.repair_cnt,
region:_this.$data.form.region,
location:_this.$data.form.location,
responsible:_this.$data.form.responsible
}
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "添加成功",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "添加失败",
type: "error",
duration: 1500
});
}
_this.$data.add_visible=false;
})
.catch(function (error) {
console.log(error);
});
}})
},
add_dev_manage_dialog(){
document.getElementById("bt_add").blur();
this.$data.form.wellname='';
this.$data.form.sid='';
this.$data.form.iid='';
this.$data.form.ver= '';
this.$data.form.p_date='';
this.$data.form.cal_date='';
this.$data.form.total_wt='';
this.$data.form.cur_wt='';
this.$data.form.repair_cnt='';
this.$data.form.region='';
this.$data.form.location='';
this.$data.form.responsible='';
var _this = this;
axios.post('/deescloud/getWellNames',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
})
.then(function (response) {
console.log(response.data);
_this.$data.wellnames = response.data;
})
.catch(function (error) {
console.log(error);
});
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.add_visible=true;
},
export_pdf(row){
var _this = this;
axios.post('deescloud/get_dev_manage_pdf',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: row.wellNameSource
},
).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
downloadUrl(row.wellNameSource+"-设备资产管理报告.pdf",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
show_pdf(row){
let _this= this;
axios.post('/deescloud/get_dev_manage', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: row.wellNameSource,
})
.then(function (response) {
console.log(response.data);
_this.$data.dev_tableData = response.data.data;
_this.$data.pdf_visible = true;
})
.catch(function (error) {
console.log(error);
});
},
getWell(_search_name){
document.getElementById("bt_serach").blur();
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/deescloud/get_well_dev', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
Wellname: _search_name,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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) {
//console.log(`每页 ${val} 条`);
this.$data.pagesize = val;
var _this = this;
var objs;
axios.post('/deescloud/get_well_dev', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
Wellname: this.$data.input,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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) {
//console.log(`当前页: ${val}`);
this.$data.currentPage = val;
var _this = this;
var objs;
axios.post('/deescloud/get_well_dev', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
Wellname: this.$data.input,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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);
});
},
}
}