Commit 6290bd5b authored by Administrator's avatar Administrator

修改分类

parent 84620446
Pipeline #110 failed with stages
......@@ -445,6 +445,20 @@ class DevicesController extends Controller
$this->timeline('添加了分类[分类名称' . $data . ']');
return $this->jsonSuccessData(DB::table('device_type')->insertGetId(['tname' => $data]));
}
/**
* 更新设备分类
* @param $id 分类ID
*/
public function updateClassify(Request $request)
{
$data = $request->all();
$status = DB::table('device_type')->where('tid', '=', $data['tid'])->update([
'tname' => $data['tname']
]);
return $status ? $this->jsonSuccessData($status) : $this->jsonErrorData(202, 'error');
}
public function delteClassify($id)
{
//删除分类
......
......@@ -63,6 +63,14 @@ export function addClassify(data) {
method: 'get',
});
}
// 更新设备分类
export function updateClassify(data) {
return request({
url: '/devices/updateClassify',
method: 'post',
data: data,
});
}
export function delteClassify(id) {
return request({
......
......@@ -21,7 +21,7 @@
</el-table-column>
<el-table-column label="操作" width="150">
<template slot-scope="scope">
<el-button type="info" size="small" @click="handleClick()">修改</el-button>
<el-button type="info" size="small" @click="handleEdit(scope.row.tid, scope.row.tname)">修改</el-button>
<el-button type="danger" size="small" @click="delteClassify(scope.row.tid)">删除</el-button>
</template>
</el-table-column>
......@@ -30,7 +30,7 @@
</template>
<script>
import { deviceTypeList, addClassify, delteClassify } from '@/api/device';
import { deviceTypeList, addClassify, updateClassify, delteClassify } from '@/api/device';
export default {
data() {
return {
......@@ -78,6 +78,35 @@ export default {
});
this.categoryName = '';
},
// 修改分类
handleEdit(tid, tname) {
this.$prompt('请输入分类名称', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /\S/,
inputErrorMessage: '分类名称格式不正确',
inputValue: tname,
}).then(({ value }) => {
updateClassify({ 'tid': tid, 'tname': value })
.then(response => {
if (response.code === 200) {
this.$message({
type: 'success',
message: '修改成功!',
});
this.getList();
}
})
.catch(err => {
console.log(err);
});
}).catch(() => {
this.$message({
type: 'info',
message: '取消输入',
});
});
},
delteClassify(id){
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
......
......@@ -94,7 +94,8 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/UpPaperBasket/{id}','DevicesController@UpPaperBasket');//更新废纸篓和禁用用户
Route::get('devices/deviceBasketList','DevicesController@deviceBasketList');//返回禁用设备和废纸篓设备
Route::get('devices/addClassify/{data}','DevicesController@addClassify');//添加分类
Route::get('devices/delteClassify/{id}','DevicesController@delteClassify');//删除分类
Route::post('devices/updateClassify','DevicesController@updateClassify');//删除分类
Route::post('devices/delteClassify/{id}','DevicesController@delteClassify');//删除分类
Route::post('devices/detedevice','DevicesController@detedevice');//查看历史数据
Route::get('devices/addUserDevice','DevicesController@addUserDevice');//返回正常用户
Route::get('devices/control','DevicesController@control');//返回消防监测
......
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