//组件 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' } ], }, beganChange:'',//记录修改前内容 } }, 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 = "新增成功!"; // 操作日志 _this.add_operation_log("新增维修状态:" + _this.$data.form.rs); } else if (r == 1) { s = "已存在相同维修状态!"; } else { s = "新增失败!"; } } else if (_this.$data.oper_type == 2) { if (r == 0) { s = "修改成功!"; // 操作日志 _this.add_operation_log("修改维修状态:" + _this.$data.beganChange + " -> " + _this.$data.form.rs); } 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; // 操作日志 this.$data.beganChange = info.rs; }, 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); }); }, // 操作日志 add_operation_log(operation) { axios.post('/u_ma/add_operation_log', { opuser: localStorage.getItem("online_user"), opuser_uuid: localStorage.getItem("uuid"), operation: operation, }).then(function (response) { console.log(response); }).catch(function (error) { console.log(error); }) } } }