From de41e845dcaf44b535de787db3eb6a23ee45e920 Mon Sep 17 00:00:00 2001
From: zrj <646384940@qq.com>
Date: Fri, 30 Aug 2024 11:18:26 +0800
Subject: [PATCH] 新增机场授权管理
---
src/page/login/index.vue | 2
src/api/device/devicePerMenu.js | 10
src/views/device/components/devicePerShare.vue | 320 +++++++++++----------------------------
src/views/device/airport.vue | 29 ++-
src/views/device/devicePerMenu.vue | 2
src/api/device/devicePerShare.js | 49 ++++++
src/api/system/dept.js | 11 +
7 files changed, 181 insertions(+), 242 deletions(-)
diff --git a/src/api/device/devicePerMenu.js b/src/api/device/devicePerMenu.js
index ba027d6..f56bf2c 100644
--- a/src/api/device/devicePerMenu.js
+++ b/src/api/device/devicePerMenu.js
@@ -2,7 +2,7 @@
export const getList = (current, size, params) => {
return request({
- url: '/drone-yw/manage/api/v1/devicePerMenuPerMenu/page',
+ url: '/drone-yw/manage/api/v1/devicePerMenu/page',
method: 'get',
params: {
...params,
@@ -14,7 +14,7 @@
export const remove = ids => {
return request({
- url: '/drone-yw/manage/api/v1/devicePerMenuPerMenu/delete',
+ url: '/drone-yw/manage/api/v1/devicePerMenu/delete',
method: 'post',
params: {
ids,
@@ -24,7 +24,7 @@
export const add = row => {
return request({
- url: '/drone-yw/manage/api/v1/devicePerMenuPerMenu/add',
+ url: '/drone-yw/manage/api/v1/devicePerMenu/add',
method: 'post',
data: row,
});
@@ -32,7 +32,7 @@
export const update = row => {
return request({
- url: '/drone-yw/manage/api/v1/devicePerMenuPerMenu/update',
+ url: '/drone-yw/manage/api/v1/devicePerMenu/update',
method: 'post',
data: row,
});
@@ -40,7 +40,7 @@
// export const getDetail = id => {
// return request({
-// url: '/drone-yw/manage/api/v1/devicePerMenuPerMenu/getDetail',
+// url: '/drone-yw/manage/api/v1/devicePerMenu/getDetail',
// method: 'get',
// params: {
// id,
diff --git a/src/api/device/devicePerShare.js b/src/api/device/devicePerShare.js
new file mode 100644
index 0000000..e82cfa7
--- /dev/null
+++ b/src/api/device/devicePerShare.js
@@ -0,0 +1,49 @@
+import request from '@/axios';
+
+export const getList = (current, size, params) => {
+ return request({
+ url: '/drone-yw/manage/api/v1/devicePerShare/page',
+ method: 'get',
+ params: {
+ ...params,
+ current,
+ size,
+ },
+ });
+};
+
+export const remove = ids => {
+ return request({
+ url: '/drone-yw/manage/api/v1/devicePerShare/delete',
+ method: 'post',
+ params: {
+ ids,
+ },
+ });
+};
+
+export const add = row => {
+ return request({
+ url: '/drone-yw/manage/api/v1/devicePerShare/add',
+ method: 'post',
+ data: row,
+ });
+};
+
+export const update = row => {
+ return request({
+ url: '/drone-yw/manage/api/v1/devicePerShare/update',
+ method: 'post',
+ data: row,
+ });
+};
+
+// export const getDetail = id => {
+// return request({
+// url: '/drone-yw/manage/api/v1/devicePerShare/getDetail',
+// method: 'get',
+// params: {
+// id,
+// },
+// });
+// };
\ No newline at end of file
diff --git a/src/api/system/dept.js b/src/api/system/dept.js
index c3d378a..730ca86 100644
--- a/src/api/system/dept.js
+++ b/src/api/system/dept.js
@@ -78,3 +78,14 @@
},
});
};
+
+export const getDeptTreeByNotItself = (deptId,deviceSn) => {
+ return request({
+ url: '/blade-system/dept/getDeptTreeByNotItself',
+ method: 'get',
+ params: {
+ deptId,
+ deviceSn
+ },
+ });
+};
diff --git a/src/page/login/index.vue b/src/page/login/index.vue
index 2f3b650..839ea1d 100644
--- a/src/page/login/index.vue
+++ b/src/page/login/index.vue
@@ -82,7 +82,7 @@
methods: {
// 动态获取系统名称
getSysConfigInfo(){
- let sysConfigId = this.$route.query?.id || 2;
+ let sysConfigId = this.$route.query?.id || 1;
getDetail(sysConfigId).then(res=>{
this.login.info = res.data.data.name
})
diff --git a/src/views/device/airport.vue b/src/views/device/airport.vue
index 9d36f6e..14e6b2a 100644
--- a/src/views/device/airport.vue
+++ b/src/views/device/airport.vue
@@ -102,14 +102,14 @@
@click.stop="handleOpenFirmwarm(scope.row, scope.index)"
>固件管理
</el-button>
- <!-- <el-button
+ <el-button
type="primary"
text
icon="el-icon-share"
- v-if="permission.per_share"
- @click.stop="handleOpenFirmwarm(scope.row, scope.index)"
- >权限分享
- </el-button> -->
+ v-if="permission.per_share && scope.row.domain==3"
+ @click.stop="handleOpenDevicePerShare(scope.row, scope.index)"
+ >机场授权
+ </el-button>
</template>
</avue-crud>
<el-dialog title="固件升级" append-to-body v-model="firmwareBox" width="455px">
@@ -122,13 +122,13 @@
</template>
</el-dialog>
<el-drawer
- title="固件管理"
+ title="机场授权管理"
size="60%"
append-to-body
- v-model="firmwareManageVisible"
+ v-model="devicePerShareVisible"
:direction="'rtl'"
>
- <FirmwareManage ref="firmwareManage" />
+ <DevicePerShare ref="devicePerShare" />
</el-drawer>
</basic-container>
</template>
@@ -148,13 +148,16 @@
import { mapGetters } from 'vuex';
import FirmwareManage from './components/firmwareManage.vue';
+import DevicePerShare from './components/devicePerShare.vue';
export default {
components: {
FirmwareManage,
+ DevicePerShare
},
data() {
return {
- firmwareManageVisible: false,
+ devicePerShareVisible: false,
+ firmwareManageVisible:false,
percentageNum: 0,
firmwareBox: false,
firmwareInfo: {},
@@ -522,6 +525,14 @@
init() {
this.onLoad(this.page);
},
+ // 打开权限分享页面
+ handleOpenDevicePerShare(row) {
+ var that = this;
+ this.devicePerShareVisible = true;
+ this.$nextTick(() => {
+ that.$refs.devicePerShare.init(row);
+ });
+ },
// 打开固件管理页面
handleOpenFirmwarm(row) {
var that = this;
diff --git a/src/views/device/components/devicePerShare.vue b/src/views/device/components/devicePerShare.vue
index 0fe4c63..0151ddd 100644
--- a/src/views/device/components/devicePerShare.vue
+++ b/src/views/device/components/devicePerShare.vue
@@ -9,6 +9,7 @@
@row-del="rowDel"
v-model="form"
:permission="permissionList"
+ @row-save="rowSave"
@row-update="rowUpdate"
:before-open="beforeOpen"
@search-change="searchChange"
@@ -19,78 +20,22 @@
@refresh-change="refreshChange"
@on-load="onLoad"
>
- <template #menu-left>
- <el-button type="primary" icon="el-icon-plus" plain @click="openFirmwareUpload"
- >固件上传
- </el-button>
- </template>
</avue-crud>
- <el-dialog title="固件上传" append-to-body v-model="firmwareUploadBox" width="40%" height="60%">
- <el-form
- ref="form"
- :model="importForm"
- v-loading="loadingForm"
- label-width="80px"
- style="width: 80%; margin-left: 10%"
- :rules="rules"
- >
- <el-form-item label="设备名称" prop="device_name">
- <el-input v-model="importForm.device_name" clearable></el-input>
- </el-form-item>
-
- <!-- 上传 -->
- <el-form-item label="固件文件" label-width="80px" prop="file">
- <el-upload
- class="upload-demo"
- action="#"
- ref="uploadFirmware"
- :limit="1"
- :auto-upload="false"
- :multiple="false"
- :before-upload="beforeUploadFile"
- >
- <i class="el-icon-upload"></i>
- <div class="el-upload__text" style="height: 50px"><em>点击上传</em></div>
- </el-upload>
- </el-form-item>
- <el-form-item label="是否可用" prop="status">
- <el-select v-model="importForm.status" placeholder="请选择" clearable>
- <el-option label="是" value="1"></el-option>
- <el-option label="否" value="0"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="说明" label-width="80px" prop="release_note">
- <el-input type="textarea" v-model="importForm.release_note" clearable></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="onConfirm">确定</el-button>
- <el-button @click="onCancel">取消</el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
</basic-container>
</template>
<script>
-import { getDeviceFirmwareList, deleteFirmware, updateFirmware, upload } from '@/api/device/device';
+import { getList, remove, add, update } from '@/api/device/devicePerShare';
+import { getDeptTreeByNotItself } from '@/api/system/dept';
import { mapGetters } from 'vuex';
export default {
data() {
return {
- loadingForm:false,
- file: '',
- rules: {
- device_name: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
- status: [{ required: true, message: '请选择', trigger: 'change' }],
- release_note:[{ required: true, message: '请输入版本说明', trigger: 'blur' }],
- },
- importForm: {},
- firmwareUploadBox: false,
+ deptId:'',
+ deviceSn:'',
form: {},
query: {},
- workspaceId: '',
- deviceName: '',
loading: true,
page: {
pageSize: 10,
@@ -103,150 +48,93 @@
tree: true,
height: 'atuo',
calcHeight: 32,
- dialogWidth: 950,
+ dialogWidth: 750,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
- addBtn: false,
+ addBtn: true,
selection: true,
excelBtn: false,
dialogClickModal: false,
grid: false,
column: [
{
- label: '设备名称',
- prop: 'device_name',
- editDisabled: true,
- // search: true,
- // searchSpan: 5,
+ label: '授权单位',
+ prop: 'dept_id',
labelWidth: 130,
- addDisplay: false,
- editDisabled: true,
- rules: [
- {
- required: true,
- message: '请输入设备型号',
- trigger: 'blur',
- },
- ],
- },
- {
- label: '固件文件名称',
- prop: 'file_name',
- labelWidth: 130,
- search: true,
- searchSpan: 8,
- searchLabelWidth: 120,
- editDisabled: true,
- rules: [
- {
- required: true,
- message: '请输入固件文件名称',
- trigger: 'blur',
- },
- ],
- },
- {
- label: '文件大小',
- prop: 'file_size',
- addDisplay: false,
- editDisabled: true,
+ type: 'tree',
+ dicData:[],
+ props: {
+ label: 'name',
+ value: 'id',
+ },
+ span:24,
+ row:true,
hide:true,
- labelWidth: 130,
- rules: [
- {
- required: false,
- message: '请输入文件大小',
- trigger: 'blur',
- },
- ],
- },
- {
- label: '固件版本',
- prop: 'firmware_version',
- labelWidth: 130,
- width: 100,
- editDisabled: true,
+ editDisplay:false,
+ viewDisplay:false,
rules: [
{
required: true,
- message: '请输入固件版本',
+ message: '请输入授权单位',
trigger: 'blur',
},
],
},
{
- label: '上传时间',
+ label: '授权单位',
+ prop: 'dept_name',
+ labelWidth: 130,
+ addDisplay:false,
+ editDisabled: true,
+ search: true,
+ searchSpan: 6,
+ span:24,
+ row:true,
+ rules: [
+ {
+ required: true,
+ message: '请输入授权单位',
+ trigger: 'blur',
+ },
+ ],
+ },
+ {
+ label: '授权功能',
+ prop: 'device_per_menu_id',
+ labelWidth: 130,
+ type: 'tree',
+ dicUrl: '/drone-yw/manage/api/v1/devicePerMenu/selectDeviceList',
+ props: {
+ label: 'name',
+ value: 'id',
+ },
+ multiple: true,
+ dataType: 'string',
+ span:24,
+ row:true,
+ rules: [
+ {
+ required: true,
+ message: '请输入授权功能',
+ trigger: 'blur',
+ },
+ ],
+ },
+ {
+ label: '授权时间',
prop: 'create_time',
type: 'date',
addDisplay: false,
editDisplay: false,
- labelWidth: 130,
+ span: 24,
+ row: true,
width: 160,
format: 'YYYY-MM-DD HH:mm:ss',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
- startPlaceholder: '任务开始时间',
- rules: [
- {
- required: true,
- message: '请输入在线时间',
- trigger: 'blur',
- },
- ],
- },
- {
- label: '是否可用',
- prop: 'status',
- addDisplay: false,
- labelWidth: 130,
- type: 'select',
- width: 100,
- dicData: [
- {
- label: '可用',
- value: true,
- },
- {
- label: '不可用',
- value: false,
- },
- ],
- rules: [
- {
- required: true,
- message: '请输入在线状态',
- trigger: 'blur',
- },
- ],
- },
- {
- label: '上传状态',
- prop: 'upload_status',
- addDisplay: false,
- editDisplay: false,
- labelWidth: 130,
- type: 'select',
- width: 100,
- dicData: [
- {
- label: '上传中或者上传失败',
- value: 1,
- },
- {
- label: '上传成功',
- value: 2,
- },
- ],
- rules: [
- {
- required: true,
- message: '请输入在线状态',
- trigger: 'blur',
- },
- ],
},
],
},
@@ -272,58 +160,40 @@
},
},
methods: {
- //自定义上传方法,使用上传组件的submit()后才会触发以获取文件实体
- beforeUploadFile(param) {
- this.file = param;
- return false;
- },
- // 确定按钮
- onConfirm() {
- var that = this;
- this.$refs.form.validate(valid => {
- if (valid) {
- this.$refs.uploadFirmware.submit();
- const formDatas = new FormData();
- formDatas.append('file', that.file);
- formDatas.append('deviceName', that.importForm.device_name);
- formDatas.append('releaseNote', that.importForm.release_note);
- formDatas.append('status', that.importForm.status);
- this.loadingForm = true;
- // 提交
- upload(this.workspaceId, formDatas).then(res => {
- this.loadingForm = false;
- this.firmwareUploadBox = false;
- that.importForm = {}
- this.onLoad(this.page);
- this.$message({
- type: 'success',
- message: '操作成功!',
- });
- });
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- onCancel(){
- this.firmwareUploadBox = false;
- this.file = ''
- },
- //打卡固件上传页面
- openFirmwareUpload() {
- this.firmwareUploadBox = true;
- this.importForm['device_name'] = this.deviceName;
- },
// 初始化数据
init(data) {
- this.workspaceId = data.workspace_id;
- // this.workspaceId = '4a574d68-4ad3-48f7-9f16-3edbcd8056e1';
- this.deviceName = data.device_name;
+ this.deptId = data.dept_id;
+ this.deviceSn = data.device_sn;
+ this.getDeptTreeInfo();
this.onLoad(this.page);
},
+ getDeptTreeInfo(){
+ getDeptTreeByNotItself(this.deptId,this.deviceSn).then(res => {
+ const column = this.findObject(this.option.column, 'dept_id');
+ column.dicData = res.data.data;
+ });
+ },
+ rowSave(row, done, loading) {
+ row['device_sn'] = this.deviceSn;
+ add(row).then(
+ () => {
+ this.initFlag = false;
+ this.onLoad(this.page);
+ this.$message({
+ type: 'success',
+ message: '操作成功!',
+ });
+ done();
+ },
+ error => {
+ window.console.log(error);
+ loading();
+ }
+ );
+ },
rowUpdate(row, index, done, loading) {
- updateFirmware(row).then(
+ row['device_sn'] = this.deviceSn;
+ update(row).then(
() => {
this.onLoad(this.page);
this.$message({
@@ -345,7 +215,7 @@
type: 'warning',
})
.then(() => {
- return deleteFirmware(row.id);
+ return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
@@ -407,9 +277,9 @@
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
- params['device_name'] = this.deviceName;
+ params['device_sn'] = this.deviceSn;
this.loading = true;
- getDeviceFirmwareList(page.currentPage, page.pageSize, params).then(res => {
+ getList(page.currentPage, page.pageSize, params).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
diff --git a/src/views/device/devicePerMenu.vue b/src/views/device/devicePerMenu.vue
index 025bf51..0af498c 100644
--- a/src/views/device/devicePerMenu.vue
+++ b/src/views/device/devicePerMenu.vue
@@ -26,7 +26,6 @@
<script>
import { getList, remove, add, update } from '@/api/device/devicePerMenu';
-import { getLazyList } from '@/api/system/menu';
import { mapGetters } from 'vuex';
export default {
@@ -190,7 +189,6 @@
},
methods: {
rowSave(row, done, loading) {
- console.log(row, 8888);
add(row).then(
() => {
this.initFlag = false;
--
Gitblit v1.9.3