271 lines
5.9 KiB
JavaScript
271 lines
5.9 KiB
JavaScript
//组件
|
|
var rsmcomponent = {
|
|
template:`
|
|
<div>
|
|
<div id="" style="display: inline-block;width: 100%;">
|
|
|
|
<div style="float: left; width: 20%;">
|
|
<el-input v-model="input" placeholder="请输入维修状态" clearable @change="input_change"></el-input>
|
|
</div>
|
|
<div style="float: left;">
|
|
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="get_rs(input)">搜索</el-button>
|
|
<el-button id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="addRs()">新增</el-button>
|
|
</div>
|
|
</div>
|
|
<div class="span">
|
|
<el-table
|
|
:data="tableData"
|
|
style="width: 100%"
|
|
:height="tHeight"
|
|
:cell-style="{background:'#fff'}"
|
|
border
|
|
>
|
|
<el-table-column
|
|
prop="rs"
|
|
label="维修状态"
|
|
width="160">
|
|
</el-table-column>
|
|
<el-table-column
|
|
label="操作"
|
|
width="100">
|
|
<template slot-scope="scope">
|
|
<el-button @click="updateRs(scope.row)" type="text" size="medium" >修改</el-button>
|
|
<el-button @click="delRs(scope.row)" type="text" size="medium" >删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
|
|
<el-dialog
|
|
title="用户信息"
|
|
:visible.sync="dialogVisible"
|
|
:lock-scroll ="false"
|
|
width="30%">
|
|
<el-form ref="userform" :model="form" label-width="80px" :rules="rules">
|
|
<el-form-item label="维修状态" prop="rs">
|
|
<el-input v-model="form.rs"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
<el-button id ="bt_ok" plain type="primary" @click="postRs()">确 定</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</div>
|
|
`,
|
|
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);
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
}
|
|
|