Commit 203bdf7b authored by 冯超鹏's avatar 冯超鹏

提交装维人员

parent 4df1e763
Pipeline #48 failed with stages
......@@ -17,31 +17,65 @@ use Validator;
class InstallerController extends Controller
{
//装维人员列表
public function installerlist (){
return $this->jsonSuccessData(Installer::where('delete','=','1')
->get());
public function installerlist (Request $request){
$pagenNum= (int)$request->input('page')-1;//页数
$limit = (int)$request->input('limit');
$instllerdata = Installer::offset($pagenNum)->limit($limit)->get();
$count = Installer::count();
return $this->jsonSuccessData(['instllerdata'=>$instllerdata,'count'=>$count]);
}
//用户添加
public function addinstaller(Request $request){
$keys = $request->all();
$validator = Validator::make($request->all(), $this->getValidationRulesinstaller(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
}
$type = new Installer();
return $this->jsonSuccessData($type->addinstall($request->all()));
foreach ($keys as $key => $val) {
if ($key == 'ispassword') {
unset($keys[$key]);
}
}
return $this->jsonSuccessData($type->addinstall($keys));
}
// 用户搜索
public function seekInstaller(Request $request){
$keys = $request->all();
$handle = DB::table('installer');
foreach ($keys as $key => $val) {
if ($key == 'page') {
unset($keys[$key]);
} elseif ($key == 'limit'){
unset($keys[$key]);
}
}
foreach ($keys as $k => $v) {
if ($v == '正常'){
$v = 1;
}else if ($v == '禁用'){
$v = 2;
}
$keys[$key] && $handle->where($k, 'like', '%' . $v . '%');
}
return $this->jsonSuccessData(['instllerdata'=>$handle->get(),'count'=>$handle->count()]);
}
//更新用户操作
public function updateinstaller(Request $request){
$uid = $request->input('uid');//用户id
$uid = $request->input('id');//用户id
$data = $request->all();
if (is_null($uid)){
return $this->jsonErrorData(105,'用户id不能为空');
}
if ($_POST){
if ($request->isMethod('post')){
foreach ($data as $k => $v) {
if ($k == 'uid') {
if ($k == 'id') {
unset($data[$k]);
}else if ($k == 'ispassword'){
unset($data[$k]);
}else if ($k == 'password') {
$data['password'] = md5(md5($v) . $data['salt']);
}
}
$upin = Installer::where('id','=',(int)$uid)->update($data);
......@@ -72,10 +106,14 @@ class InstallerController extends Controller
if ($type == 1){//物理删除
return $this->jsonSuccessData(Installer::where('id','=',$uid)->delete());
}elseif($type == 2){//逻辑删除
return $this->jsonSuccessData(Installer::where('id','=',$uid)->update(['delete'=>2]));
return $this->jsonSuccessData(Installer::where('id','=',$uid)->update(['delete'=>2,'status'=>2]));
}
}
//用户回复正常
public function normalinstaller($id){
return $this->jsonSuccessData(Installer::where('id','=',$id)->update(['delete'=>1,'status'=>1]));
}
//验证用户提交表单
private function getValidationRulesinstaller($isNew = true){
......
import request from '@/utils/request';
export function installerlist(limit, page) { // 设备类型
return request({
url: 'installer/installerlist?page=' + page + '&limit=' + limit,
method: 'get',
});
}
export function seekInstaller(data) { // 设备类型
return request({
url: 'installer/seekInstaller',
method: 'post',
data,
});
}
export function deleteInsrall(id, type) { // 删除设备
return request({
url: 'installer/deleteinstaller?uid=' + id + '&type=' + type,
method: 'get',
});
}
export function addinstaller(data) { // 添加
return request({
url: 'installer/addinstaller',
method: 'post',
data,
});
}
export function updateinstaller(id) { // 添加
return request({
url: 'installer/updateinstaller?id=' + id,
method: 'get',
});
}
export function postupdateinstaller(data) { // 添加
return request({
url: 'installer/updateinstaller',
method: 'post',
data,
});
}
export function normalinstaller(id) { // 添加
return request({
url: 'installer/normalinstaller/' + id,
method: 'get',
});
}
......@@ -2,7 +2,7 @@
<div class="app-container">
<div class="filter-container">
<el-form ref="query" :model="userdata" style="display: inline-block;">
<el-input v-model="userdata.nickname" placeholder="用户名称" style="width: 200px;" class="filter-item" name="userskk" />
<el-input v-model="userdata.nickname" placeholder="用户名称" clearable style="width: 200px;" class="filter-item" name="userskk" @input="changeValue" />
<el-select v-model="userdata.state" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOne">
<el-option v-for="item in calendarTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
......@@ -236,6 +236,11 @@ export default {
this.userdata.state = undefined;
}
},
changeValue(event, item) {
if (event === '') {
this.userdata.nickname = undefined;
}
},
// 重置
resetForm() {
for (const key in this.upUserData) {
......
<template>
<div>装维人员</div>
<div class="app-container">
<div class="filter-container">
<el-form ref="query" :model="installerdata" style="display: inline-block;">
<el-input v-model="installerdata.phone" placeholder="手机号" clearable style="width: 200px;" class="filter-item" @input="changeValue" />
<el-select v-model="installerdata.status" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOne">
<el-option v-for="item in calendarTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
{{ $t('table.search') }}
</el-button>
</el-form>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="addinstaller">添加</el-button>
<el-button v-if="total > 0 " v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
{{ $t('table.export') }}
</el-button>
</div>
<el-table :key="tableKey" v-loading="loading" :data="instller" border fit highlight-current-rows>
<el-table-column prop="username" label="用户名" width="150">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column prop="name" label="姓名" width="150">
<template slot-scope="scope">
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column prop="phone" label="手机号" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.phone,$event)">{{ scope.row.phone }}</span>
</template>
</el-table-column>
<el-table-column prop="email" label="邮箱" width="160">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.email,$event)">{{ scope.row.email }}</span>
</template>
</el-table-column>
<el-table-column prop="addtime" label="创建时间" width="150">
<template slot-scope="scope">
<span>{{ scope.row.addtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column prop="zip" label="状态" width="140">
<template slot-scope="scope">
<span :style="{color:( scope.row.status==1 ? '#67C23A' : '#909399' )}">{{ scope.row.status==1 ? '正常' : '禁用' }}</span>
</template>
</el-table-column>
<el-table-column prop="zip" label="是否被删除" width="150">
<template slot-scope="scope">
<el-tag v-if="scope.row.delete==1" type="success" effect="dark">正常</el-tag>
<el-popover v-if="scope.row.delete==2" width="160" trigger="hover" placement="top">
<p>将禁用以及删除用户人员恢复</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="normalinstaller(scope.row.id)">恢复人员</el-button>
</div>
<el-button slot="reference" size="mini" type="danger">已删除</el-button>
</el-popover>
</template>
</el-table-column>
<el-table-column label="操作" width="150">
<template slot-scope="scope">
<el-popover width="160" trigger="click" placement="top">
<p>此删除,分丢弃废纸篓,和删除</p>
<div style="text-align: right; margin: 0">
<el-button v-if="scope.row.delete==1" size="mini" type="text" @click="deleteInsrall(scope.row.id, 2)">丢弃废纸篓</el-button>
<el-button type="text" size="mini" @click="deleteInsrall(scope.row.id, 1)">删除</el-button>
</div>
<el-button slot="reference" size="mini" type="danger">删除</el-button>
</el-popover>
<el-button slot="reference" size="mini" type="primary" @click="getUpInsrall(scope.row.id)">编辑</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="installerdata.page" :limit.sync="installerdata.limit" @pagination="installerlist" />
<el-dialog title="添加装维人员" :visible.sync="dialogFormVisible">
<el-form ref="addinstallerfrom" :model="addinstallerfrom" :rules="rules">
<el-form-item label="用户名" :label-width="formLabelWidth" prop="username">
<el-input v-model="addinstallerfrom.username" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="姓名" :label-width="formLabelWidth" prop="username">
<el-input v-model="addinstallerfrom.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="手机号" :label-width="formLabelWidth" prop="phone">
<el-input v-model="addinstallerfrom.phone" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="邮箱" :label-width="formLabelWidth" prop="email">
<el-input v-model="addinstallerfrom.email" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="密码" :label-width="formLabelWidth" prop="password">
<el-input v-model="addinstallerfrom.password" type="password" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="确认密码" :label-width="formLabelWidth" prop="ispassword">
<el-input v-model="addinstallerfrom.ispassword" type="password" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="okdialogFormVisible('addinstallerfrom')"> </el-button>
</div>
</el-dialog>
<!-- 编辑 -->
<el-dialog title="编辑装维人员" :visible.sync="updialogFormVisible">
<el-form ref="addinstallerfrom" :model="upDatainstaller" :rules="rules">
<el-form-item label="用户名" :label-width="formLabelWidth" prop="username">
<el-input v-model="upDatainstaller.username" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="姓名" :label-width="formLabelWidth" prop="username">
<el-input v-model="upDatainstaller.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="手机号" :label-width="formLabelWidth" prop="phone">
<el-input v-model="upDatainstaller.phone" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="邮箱" :label-width="formLabelWidth" prop="email">
<el-input v-model="upDatainstaller.email" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="密码" :label-width="formLabelWidth" prop="password">
<el-input v-model="upDatainstaller.password" type="password" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="updialogFormVisible = false"> </el-button>
<el-button type="primary" @click="okUpdialogFormVisible('addinstallerfrom')"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { parseTime } from '@/utils';
import Pagination from '@/components/Pagination'; // 分页
import { installerlist, seekInstaller, deleteInsrall, addinstaller, updateinstaller, postupdateinstaller, normalinstaller } from '@/api/installer';
import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard';
export default {
components: { Pagination },
directives: { waves },
data() {
return {
instller: [], // 列表
tableKey: 0,
downloadLoading: false,
dialogFormVisible: false,
updialogFormVisible: false,
formLabelWidth: '120px',
total: 0,
installerdata: {
limit: 10,
page: 1,
phone: undefined,
status: undefined,
},
calendarTypeOptions: ['正常', '禁用'],
addinstallerfrom: {
username: undefined,
name: undefined,
phone: undefined,
email: undefined,
password: undefined,
ispassword: undefined,
},
upDatainstaller: [],
rules: {
name: [
{ required: true, message: '请输入姓名', trigger: 'blur' },
{ min: 2, max: 5, message: '长度在 2 到 5 个字符', trigger: 'blur' },
],
username: [
{ required: true, message: '请输入用户名', trigger: 'change' },
{ min: 2, max: 5, message: '长度在 2 到 5 个字符', trigger: 'blur' },
],
phone: [
{ type: 'string', required: true, message: '请输入手机号', trigger: 'change' },
{ min: 11, max: 11, message: '长度在11字符', trigger: 'blur' },
],
email: [
{ type: 'email', required: true, message: '请输入邮箱', trigger: 'change' },
],
password: [
{ type: 'string', required: true, message: '请输入密码', trigger: 'change' },
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' },
],
ispassword: [
{ type: 'string', required: true, message: '请输入密码', trigger: 'change' },
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' },
],
},
};
},
created() {
this.installerlist(); // 用户列表
},
methods: {
installerlist() {
this.loading = true;
installerlist(this.installerdata.limit, this.installerdata.page)
.then(response => {
this.instller = response.data.instllerdata;
this.instller.forEach((element, index) => {
element['index'] = (this.installerdata.page - 1) * this.installerdata.limit + index + 1;
});
this.total = response.data.count;
this.loading = false;
})
.catch(err => {
console.log(err);
});
},
handleCopy(text, event) {
clip(text, event);
},
selectOne(event, item) {
console.log(event);
if (event === '') {
this.installerdata.status = undefined;
}
},
changeValue(event, item) {
if (event === '') {
this.installerdata.phone = undefined;
}
},
handleSubmit() {
seekInstaller(this.installerdata)
.then(response => {
this.instller = response.data.instllerdata;
this.instller.forEach((element, index) => {
element['index'] = (this.installerdata.page - 1) * this.installerdata.limit + index + 1;
});
this.total = response.data.count;
})
.catch(err => {
console.log(err);
});
},
handleDownload() {
this.downloadLoading = true;
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id', '用户名', '姓名', '用户邮箱', '创建时间', '状态'];
const filterVal = ['id', 'username', 'name', 'email', 'addtime', 'status'];
const data = this.formatJson(filterVal, this.instller);
excel.export_json_to_excel({
header: tHeader,
data,
filename: '装维人员',
});
this.downloadLoading = false;
});
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
if (j === 'addtime') {
return parseTime(v[j]);
} else if (j === 'status') {
return v[j] === 1 ? '正常' : '禁用';
} else {
return v[j];
}
}));
},
// 删除
deleteInsrall(id, type) {
deleteInsrall(id, type)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else {
this.installerlist();
}
})
.catch(err => {
console.log(err);
});
},
addinstaller() {
this.dialogFormVisible = true;
},
okdialogFormVisible(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
if (this.addinstallerfrom.password !== this.addinstallerfrom.ispassword) {
this.$message.error('两次密码不一致');
} else {
addinstaller(this.addinstallerfrom)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else if (response.code === 200) {
this.installerlist();
this.dialogFormVisible = false;
this.$refs[formName].resetFields();
}
})
.catch(err => {
console.log(err);
});
}
} else {
console.log('error submit!!');
return false;
}
});
},
getUpInsrall(id) {
updateinstaller(id)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else {
this.upDatainstaller = response.data;
this.updialogFormVisible = true;
}
})
.catch(err => {
console.log(err);
});
},
okUpdialogFormVisible(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
postupdateinstaller(this.upDatainstaller)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else if (response.code === 200) {
this.installerlist();
this.updialogFormVisible = false;
}
})
.catch(err => {
console.log(err);
});
} else {
console.log('error submit!!');
return false;
}
});
},
normalinstaller(id) {
normalinstaller(id)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else {
this.installerlist();
}
})
.catch(err => {
console.log(err);
});
},
},
};
</script>
<style>
......
......@@ -88,6 +88,8 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::post('installer/addinstaller','InstallerController@addinstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//添加新的装维人员
Route::match(['get','post'],'installer/updateinstaller','InstallerController@updateinstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//返回设备列表和更改设备
Route::get('installer/deleteinstaller','InstallerController@deleteinstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除用户
Route::post('installer/seekInstaller','InstallerController@seekInstaller')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//用户搜索
Route::get('installer/normalinstaller/{id}','InstallerController@normalinstaller');//回复状态
});
// Fake APIs
Route::get('/table/list', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment