358 lines
8.7 KiB
JavaScript
358 lines
8.7 KiB
JavaScript
|
|
var bUsercomponent = {
|
||
|
|
template:`
|
||
|
|
<div>
|
||
|
|
<div id="" style="display: inline-block;width: 100%;">
|
||
|
|
|
||
|
|
<div style="float: left; width: 30%;">
|
||
|
|
<el-input v-model="input" placeholder="请输入采购人员" clearable></el-input>
|
||
|
|
</div>
|
||
|
|
<div style="float: left;">
|
||
|
|
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="getUser()">搜索</el-button>
|
||
|
|
<el-button id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="addUser()">新增</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="busername"
|
||
|
|
label="采购人员"
|
||
|
|
width="100">
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column
|
||
|
|
label="操作"
|
||
|
|
width="100">
|
||
|
|
<template slot-scope="scope">
|
||
|
|
<!--style="height:23px;padding:0px" -->
|
||
|
|
<!--<el-button @click="updateUser(scope.row)" type="text" size="medium" >修改</el-button>-->
|
||
|
|
<el-button @click="delUser(scope.row)" type="text" size="medium" >删除</el-button>
|
||
|
|
</template>
|
||
|
|
</el-table-column>
|
||
|
|
</el-table>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="block">
|
||
|
|
<span class="demonstration"></span>
|
||
|
|
<el-pagination
|
||
|
|
@size-change="handleSizeChange"
|
||
|
|
@current-change="handleCurrentChange"
|
||
|
|
:current-page="currentPage"
|
||
|
|
:page-sizes="[50,100, 200, 300]"
|
||
|
|
:page-size="pagesize"
|
||
|
|
layout="total, sizes, prev, pager, next, jumper"
|
||
|
|
:total="recordTotal">
|
||
|
|
</el-pagination>
|
||
|
|
</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="busername">
|
||
|
|
<el-input v-model="form.busername"></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
<!--<el-form-item label="生产分组" prop="group_name">
|
||
|
|
<el-select v-model="form.group_name" placeholder="请选择分组">
|
||
|
|
<el-option-group
|
||
|
|
key="1"
|
||
|
|
label="">
|
||
|
|
<el-option label="研发组" value="研发组"></el-option>
|
||
|
|
<el-option label="常规组" value="常规组"></el-option>
|
||
|
|
<el-option label="装配组" value="装配组"></el-option>
|
||
|
|
<el-option label="电装组" value="电装组"></el-option>
|
||
|
|
<el-option label="保障组" value="保障组"></el-option>
|
||
|
|
</el-option-group>
|
||
|
|
</el-select>
|
||
|
|
</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="postUser()">确 定</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:'',
|
||
|
|
busername: '',
|
||
|
|
group_name:'',
|
||
|
|
},
|
||
|
|
dialogVisible:false,
|
||
|
|
oper_type:0,
|
||
|
|
rules: {
|
||
|
|
pusername: [
|
||
|
|
{ required: true, message: '采购人员不可为空', trigger: 'blur' }
|
||
|
|
],
|
||
|
|
group_name: [
|
||
|
|
{ required: true, message: '生产分组不可为空', trigger: 'blur' }
|
||
|
|
]
|
||
|
|
},
|
||
|
|
|
||
|
|
}
|
||
|
|
},
|
||
|
|
mounted() {
|
||
|
|
|
||
|
|
var _this = this;
|
||
|
|
|
||
|
|
var objs;
|
||
|
|
axios.post('/pkpi/getbUsers', {
|
||
|
|
opuser:localStorage.getItem("online_user"),
|
||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
||
|
|
buser: '',
|
||
|
|
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/postbUser', {
|
||
|
|
opuser:localStorage.getItem("online_user"),
|
||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
||
|
|
id: _this.$data.form.id,
|
||
|
|
busername:_this.$data.form.busername,
|
||
|
|
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.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/postbUser', {
|
||
|
|
opuser:localStorage.getItem("online_user"),
|
||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
||
|
|
id: userinfo.userid,
|
||
|
|
busername:userinfo.busername,
|
||
|
|
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:'',
|
||
|
|
busername: '',
|
||
|
|
group_name:'',
|
||
|
|
};
|
||
|
|
|
||
|
|
this.$nextTick(() => {
|
||
|
|
this.$refs['userform'].clearValidate()
|
||
|
|
});
|
||
|
|
|
||
|
|
this.$data.dialogVisible = true;
|
||
|
|
},
|
||
|
|
|
||
|
|
updateUser(userinfo){
|
||
|
|
this.$data.oper_type = 2;
|
||
|
|
this.$data.form = {
|
||
|
|
id:userinfo.userid,
|
||
|
|
busername: userinfo.busername,
|
||
|
|
group_name:userinfo.group_name,
|
||
|
|
};
|
||
|
|
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/getbUsers', {
|
||
|
|
opuser:localStorage.getItem("online_user"),
|
||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
||
|
|
buser: 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);
|
||
|
|
});
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
handleSizeChange(val) {
|
||
|
|
this.$data.pagesize = val;
|
||
|
|
|
||
|
|
var _this = this;
|
||
|
|
|
||
|
|
var objs;
|
||
|
|
axios.post('/pkpi/getbUsers', {
|
||
|
|
opuser:localStorage.getItem("online_user"),
|
||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
||
|
|
buser: 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) {
|
||
|
|
this.$data.currentPage = val;
|
||
|
|
|
||
|
|
var _this = this;
|
||
|
|
|
||
|
|
var objs;
|
||
|
|
axios.post('/pkpi/getbUsers', {
|
||
|
|
opuser:localStorage.getItem("online_user"),
|
||
|
|
opuser_uuid:localStorage.getItem("uuid"),
|
||
|
|
buser: 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);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|