| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" ref="crud" @row-del="rowDel" |
| | | v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave" |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" ref="crud" |
| | | @row-del="rowDel" v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave" |
| | | :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset" |
| | | @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
| | | @refresh-change="refreshChange" @on-load="onLoad"> |
| | | |
| | | <template #menu="scope"> |
| | | <el-button type="primary" text icon="el-icon-copy-document" @click.stop="copyInfo(scope.row, scope.index)" |
| | | v-if="userInfo.role_name.includes('admin')">复制 |
| | | <el-button type="primary" text icon="el-icon-copy-document" |
| | | @click.stop="copyInfo(scope.row, scope.index)" v-if="userInfo.role_name.includes('admin')">复制 |
| | | </el-button> |
| | | </template> |
| | | </avue-crud> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | |
| | | <script> |
| | | import { |
| | | getList, |
| | |
| | | update, |
| | | add, |
| | | getDetail, |
| | | } from '@/api/device/workspaces'; |
| | | } from '@/api/device/workspaces' |
| | | |
| | | import { getLazyTree } from '@/api/base/region'; |
| | | import { getLazyTree } from '@/api/base/region' |
| | | |
| | | import { mapGetters } from 'vuex'; |
| | | import { getWebsocketUrl } from '@/websocket/util/config'; |
| | | import ConnectWebSocket from '@/websocket'; |
| | | import { $Clipboard } from "@smallwei/avue"; |
| | | import { mapGetters } from 'vuex' |
| | | import { getWebsocketUrl } from '@/websocket/util/config' |
| | | import ConnectWebSocket from '@/websocket' |
| | | import { $Clipboard } from "@smallwei/avue" |
| | | |
| | | |
| | | export default { |
| | | components: { |
| | | }, |
| | | |
| | | data() { |
| | | data () { |
| | | return { |
| | | // 用于记录已经创建的websocket,防止重复创建 |
| | | webSocketIdSet: new Set(), |
| | |
| | | menuWidth: 300, |
| | | lazy: true, |
| | | tree: true, |
| | | // height: '460', |
| | | // calcHeight: 32, |
| | | |
| | | // dialogWidth: 1050, |
| | | tip: false, |
| | | searchShow: true, |
| | |
| | | addBtn: true, |
| | | dialogClickModal: false, |
| | | grid: false, |
| | | |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | column: [ |
| | | { |
| | | label: '工作空间名称', |
| | |
| | | ], |
| | | }, |
| | | { |
| | | label: '设备类型', |
| | | prop: 'type', |
| | | type: 'radio', |
| | | labelWidth: 130, |
| | | value: 0, |
| | | dicData: [ |
| | | { |
| | | label: '机场', |
| | | value: 0 |
| | | }, |
| | | { |
| | | label: '遥控器', |
| | | value: 1 |
| | | } |
| | | ], |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择设备类型', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '创建时间', |
| | | prop: 'create_time', |
| | | addDisplay: false, |
| | |
| | | format: 'YYYY-MM-DD HH:mm:ss', |
| | | |
| | | }, |
| | | { |
| | | label: '行政区划', |
| | | prop: 'area_code', |
| | | type: 'cascader', |
| | | labelWidth: 130, |
| | | hide: true, |
| | | editDisplay: true, |
| | | viewDisplay: false, |
| | | props: { |
| | | label: 'title', |
| | | value: 'value', |
| | | emitPath: false, |
| | | checkStrictly: true, |
| | | multiple: false, |
| | | expandTrigger: 'hover', |
| | | }, |
| | | dataType: 'string', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择行政区划', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | lazy: true, |
| | | lazyLoad (node, resolve) { |
| | | let level = node.level |
| | | let list = [] |
| | | let callback = () => { |
| | | resolve( |
| | | (list || []).map(ele => ({ |
| | | ...ele, |
| | | value: ele.value, |
| | | leaf: level >= 2, |
| | | })) |
| | | ) |
| | | } |
| | | |
| | | if (level === 0) { |
| | | getLazyTree('000000000000').then(res => { |
| | | list = res.data.data |
| | | callback() |
| | | }) |
| | | } else if (level === 1) { |
| | | getLazyTree(node.value).then(res => { |
| | | list = res.data.data |
| | | callback() |
| | | }) |
| | | } else if (level === 2) { |
| | | getLazyTree(node.value).then(res => { |
| | | list = res.data.data |
| | | callback() |
| | | }) |
| | | } else { |
| | | callback() |
| | | } |
| | | }, |
| | | }, |
| | | |
| | | ], |
| | | }, |
| | | data: [], |
| | | |
| | | }; |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['userInfo', 'permission']), |
| | | permissionList() { |
| | | permissionList () { |
| | | return { |
| | | addBtn: this.validData(this.permission.airport_add, false), |
| | | viewBtn: this.validData(this.permission.airport_view, true), |
| | | delBtn: this.validData(this.permission.airport_delete, false), |
| | | editBtn: this.validData(this.permission.airport_edit, false), |
| | | }; |
| | | } |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | ids () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | }, |
| | | destroyed() { |
| | | destroyed () { |
| | | this.websocketMap.forEach((k, v) => { |
| | | if (null != v) { |
| | | v.close() |
| | | this.websocketMap.delete(k) |
| | | this.webSocketIdSet.delete(k) |
| | | } |
| | | }); |
| | | }) |
| | | }, |
| | | methods: { |
| | | |
| | | copyInfo(row, index) { |
| | | let params = ` |
| | | host: tcp://139.196.74.78:1883 |
| | | 账号:drone |
| | | 密码:123456 |
| | | 组织id:${row.bing_id} |
| | | 设备码:${row.bind_code} |
| | | 机场名称:${row.workspace_name} |
| | | aircrattName:${row.workspace_desc}`; |
| | | $Clipboard({ |
| | | text: params, |
| | | }).then(() => { |
| | | this.$message.success("复制成功"); |
| | | }).catch(() => { |
| | | this.$message.error("复制失败"); |
| | | }); |
| | | copyInfo (row, index) { |
| | | const ipAddress = import.meta.env.VITE_APP_DEVICE_IP |
| | | let params = ` |
| | | host: tcp://${ipAddress} |
| | | 账号:drone |
| | | 密码:drone@123 |
| | | 组织id:${row.bing_id} |
| | | 设备码:${row.bind_code} |
| | | 机场名称:${row.workspace_name} |
| | | aircrattName:${row.workspace_desc}` |
| | | $Clipboard({ |
| | | text: params, |
| | | }).then(() => { |
| | | this.$message.success("复制成功") |
| | | }).catch(() => { |
| | | this.$message.error("复制失败") |
| | | }) |
| | | }, |
| | | init() { |
| | | this.onLoad(this.page); |
| | | init () { |
| | | this.onLoad(this.page) |
| | | }, |
| | | |
| | | handleOpenRemoteDebugging(row) { |
| | | this.curDeviceInfo = row; |
| | | this.remoteDebuggingShow = true; |
| | | handleOpenRemoteDebugging (row) { |
| | | this.curDeviceInfo = row |
| | | this.remoteDebuggingShow = true |
| | | }, |
| | | |
| | | rowSave(row, done, loading) { |
| | | rowSave (row, done, loading) { |
| | | let areaCode = row.area_code |
| | | if (Array.isArray(areaCode)) { |
| | | areaCode = areaCode[areaCode.length - 1] |
| | | } else if (typeof areaCode === 'string' && areaCode.includes(',')) { |
| | | const codes = areaCode.split(',') |
| | | areaCode = codes[codes.length - 1] |
| | | } |
| | | row.area_code = areaCode || null |
| | | add(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | update(row).then( |
| | | rowUpdate (row, index, done, loading) { |
| | | const submitData = { |
| | | ...row, |
| | | area_code: row.area_code.split(',').pop(), |
| | | } |
| | | update(submitData).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDel(row) { |
| | | rowDel (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | return remove(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.onLoad(this.page); |
| | | searchReset () { |
| | | this.query = {} |
| | | this.onLoad(this.page) |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | searchChange (params, done) { |
| | | this.query = params |
| | | this.page.currentPage = 1 |
| | | this.onLoad(this.page, params) |
| | | done() |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | selectionChange (list) { |
| | | this.selectionList = list |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | selectionClear () { |
| | | this.selectionList = [] |
| | | this.$refs.crud.toggleSelection() |
| | | }, |
| | | handleDelete() { |
| | | handleDelete () { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | return remove(this.ids) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crud.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getDetail(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }); |
| | | async getFullAreaCode (areaCode) { |
| | | if (!areaCode) return '' |
| | | |
| | | const code = areaCode.toString() |
| | | |
| | | if (code.includes(',')) return code |
| | | |
| | | if (code.endsWith('0000000000')) { |
| | | return code |
| | | } else if (code.endsWith('00000000') && !code.endsWith('0000000000')) { |
| | | const provinceCode = code.substring(0, 2) + '0000000000' |
| | | return `${provinceCode},${code}` |
| | | } else { |
| | | const provinceCode = code.substring(0, 2) + '0000000000' |
| | | const cityCode = code.substring(0, 4) + '00000000' |
| | | return `${provinceCode},${cityCode},${code}` |
| | | } |
| | | done(); |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | beforeOpen (done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getDetail(this.form.id).then(async res => { |
| | | const data = res.data.data |
| | | this.form = { |
| | | ...data, |
| | | area_code: await this.getFullAreaCode(data.area_code), |
| | | } |
| | | }) |
| | | } |
| | | done() |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | currentChange (currentPage) { |
| | | this.page.currentPage = currentPage |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | sizeChange (pageSize) { |
| | | this.page.pageSize = pageSize |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | const { releaseTimeRange } = this.query; |
| | | refreshChange () { |
| | | this.onLoad(this.page, this.query) |
| | | }, |
| | | onLoad (page, params = {}) { |
| | | const { releaseTimeRange } = this.query |
| | | let values = { |
| | | ...params, |
| | | ...this.query, |
| | | }; |
| | | } |
| | | if (releaseTimeRange) { |
| | | values = { |
| | | ...values, |
| | | releaseTime_datege: releaseTimeRange[0], |
| | | releaseTime_datelt: releaseTimeRange[1], |
| | | }; |
| | | values.releaseTimeRange = null; |
| | | } |
| | | values.releaseTimeRange = null |
| | | } |
| | | values['type'] = 1; |
| | | this.loading = true; |
| | | values['type'] = 1 |
| | | this.loading = true |
| | | getList(page.currentPage, page.pageSize, values).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | const data = res.data.data |
| | | this.page.total = data.total |
| | | // data.records.forEach(e => { |
| | | // e['hasChildren'] = e.has_children; |
| | | // if (e.firmware_status == 4) { |
| | | // this.connectWebSocket(e); |
| | | // } |
| | | // }); |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | this.data = data.records |
| | | this.loading = false |
| | | this.selectionClear() |
| | | }) |
| | | }, |
| | | treeLoad(tree, treeNode, resolve) { |
| | | treeLoad (tree, treeNode, resolve) { |
| | | var params = { |
| | | childSn: tree.child_sn, |
| | | }; |
| | | } |
| | | getList(1, 10, params).then(res => { |
| | | const data = res.data.data.records; |
| | | resolve(data); |
| | | }); |
| | | const data = res.data.data.records |
| | | resolve(data) |
| | | }) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | | |
| | | |
| | | <style lang="scss" scoped> |
| | | .firmware_status { |
| | | background-color: aqua; |
| | |
| | | } |
| | | } |
| | | </style> |
| | | |