var pUsercomponent = { 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:'', group_name_v:'', currentPage: 1, pagesize:50, recordTotal:0, form: { id:'', pusername: '', group_name:'', produce_plan:'', }, dialogVisible:false, oper_type:0, rules: { pusername: [ { required: true, message: '生产人员不可为空', trigger: 'blur' } ], group_name: [ { required: true, message: '生产分组不可为空', trigger: 'blur' } ], produce_plan:[ { required: true, message: '生产工序不可为空', trigger: 'blur' } ], }, } }, mounted() { var _this = this; var objs; axios.post('/pkpi/getpUsers', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), puser: '', 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: { postUser(){ this.$refs['userform'].validate((valid) => { if(valid){ this.$data.dialogVisible = false; var _this = this; console.log(_this.$data.form); var objs; axios.post('/pkpi/postpUser', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), id: _this.$data.form.id, pusername:_this.$data.form.pusername, group_name: _this.$data.form.group_name, oper_type: _this.$data.oper_type, produce_plan:_this.$data.form.produce_plan, }) .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.getUser(); /*if (_this.$data.oper_type == 1) { _this.getUser(""); }else{ _this.getUser(_this.$data.input); }*/ }) .catch(function (error) { console.log(error); }); } }); }, delUser(userinfo){ this.$data.oper_type = 3; var _this = this; var objs; axios.post('/pkpi/postpUser', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), id: userinfo.userid, pusername:userinfo.pusername, group_name: userinfo.group_name, 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.getUser();//更新页面 } }) .catch(function (error) { console.log(error); }); }, addUser(){ document.getElementById("bt_add").blur(); this.$data.oper_type = 1; this.$data.form = { id:'', pusername: '', group_name:'', produce_plan:'', }; this.$nextTick(() => { this.$refs['userform'].clearValidate() }); this.$data.dialogVisible = true; }, updateUser(userinfo){ this.$data.oper_type = 2; this.$data.form = { id:userinfo.userid, pusername: userinfo.pusername, group_name:userinfo.group_name, produce_plan:userinfo.produce_plan, }; this.$nextTick(() => { this.$refs['userform'].clearValidate() }); this.$data.dialogVisible = true; }, getUser(){ document.getElementById("bt_search").blur(); this.$data.currentPage=1; var _this = this; var objs; axios.post('/pkpi/getpUsers', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), puser: this.$data.input, index: this.$data.currentPage, count: this.$data.pagesize, group_name_v:this.$data.group_name_v, }) .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('/pkpi/getpUsers', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), puser: this.$data.input, index: this.$data.currentPage, count: this.$data.pagesize, group_name_v:this.$data.group_name_v, }) .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('/pkpi/getpUsers', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), puser: this.$data.input, index: this.$data.currentPage, count: this.$data.pagesize, group_name_v:this.$data.group_name_v, }) .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); }); } } }