//组件
var rsmcomponent = {
template:`
`,
data(){
// 获取当前屏幕的分辨率
let screenW = window.screen.width;
let screenH = window.screen.height;
console.log("screen width:",screenW);
console.log("screen height:",screenH);
return {
tHeight:screenH*0.8,
tableData: [],
input:'',
currentPage: 1,
pagesize:50,
recordTotal:0,
form: {
id:0,
rs: '',
},
dialogVisible:false,
oper_type:0,
rules: {
rs: [
{ required: true, message: '维修状态不可为空', trigger: 'blur' }
],
},
}
},
mounted() {
var _this = this;
var objs;
axios.post('/u_ma/get_rs', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
state: '',
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
})
.catch(function (error) {
console.log(error);
});
},
methods: {
input_change(value) {
console.log(value);
this.get_rs(this.$data.input);
},
postRs(){
this.$refs['userform'].validate((valid) => {
if(valid){
this.$data.dialogVisible = false;
var _this = this;
console.log(_this.$data.form);
var objs;
axios.post('/u_ma/postRs', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: _this.$data.form.id,
rs:_this.$data.form.rs,
oper_type: _this.$data.oper_type,
})
.then(function (response) {
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
errType = "success"
} else{
errType = "error"
}
if (_this.$data.oper_type == 1) {
if (r ==0) {
s = "新增成功!";
} else if(r == 1) {
s = "已存在相同维修状态!";
}else{
s = "新增失败!";
}
} else if (_this.$data.oper_type ==2){
if (r ==0) {
s = "修改成功!";
} else{
s = "修改失败!";
}
}
_this.$message({
message: s,
type: errType,
duration: 1500
});
//更新页面
_this.get_rs(_this.$data.input);
})
.catch(function (error) {
console.log(error);
});
}
});
},
delRs(info){
this.$data.oper_type = 3;
var _this = this;
var objs;
axios.post('/u_ma/postRs', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: info.id,
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.get_rs("");//更新页面
}
})
.catch(function (error) {
console.log(error);
});
},
addRs(){
document.getElementById("bt_add").blur();
this.$data.oper_type = 1;
this.$data.form = {
id: 0,
rs: '',
};
this.$nextTick(() => {
this.$refs['userform'].clearValidate()
});
this.$data.dialogVisible = true;
},
updateRs(info){
this.$data.oper_type = 2;
this.$data.form = {
id: info.id,
rs: info.rs,
};
this.$nextTick(() => {
this.$refs['userform'].clearValidate()
});
this.$data.dialogVisible = true;
},
get_rs(_search_name){
document.getElementById("bt_search").blur();
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/u_ma/get_rs', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
state: _search_name,
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
})
.catch(function (error) {
console.log(error);
});
},
}
}