| | |
| | | <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-save="rowSave" |
| | | @row-update="rowUpdate" |
| | | :before-open="beforeOpen" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | > |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" ref="crud" @row-del="rowDel" |
| | | v-model="form" :permission="permissionList" @row-save="rowSave" @row-update="rowUpdate" :before-open="beforeOpen" |
| | | @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" |
| | | @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"> |
| | | </avue-crud> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getList, remove, add, update } from '@/api/device/devicePerShare'; |
| | | import { getDeptTreeByNotItself } from '@/api/system/dept'; |
| | | import { mapGetters } from 'vuex'; |
| | | import { getList, remove, add, update } from '@/api/device/devicePerShare' |
| | | import { getDeptTreeByNotItself } from '@/api/system/dept' |
| | | import { mapGetters } from 'vuex' |
| | | |
| | | export default { |
| | | data() { |
| | | data () { |
| | | return { |
| | | deptId: '', |
| | | deviceSn: '', |
| | |
| | | excelBtn: false, |
| | | dialogClickModal: false, |
| | | grid: false, |
| | | |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | |
| | | column: [ |
| | | { |
| | | label: '授权单位', |
| | |
| | | ], |
| | | }, |
| | | data: [], |
| | | }; |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permission']), |
| | | permissionList() { |
| | | permissionList () { |
| | | return { |
| | | addBtn: this.validData(this.permission.airport_add, true), |
| | | viewBtn: this.validData(this.permission.airport_view, true), |
| | | delBtn: this.validData(this.permission.airport_delete, true), |
| | | editBtn: this.validData(this.permission.airport_edit, true), |
| | | }; |
| | | } |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | ids () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | }, |
| | | methods: { |
| | | init(data) { |
| | | this.deptId = data.dept_id; |
| | | this.deviceSn = data.device_sn; |
| | | this.getDeptTreeInfo(); |
| | | this.getLoadPage(this.page); |
| | | init (data) { |
| | | this.deptId = data.dept_id |
| | | this.deviceSn = data.device_sn |
| | | this.getDeptTreeInfo() |
| | | this.getLoadPage(this.page) |
| | | }, |
| | | getDeptTreeInfo() { |
| | | getDeptTreeInfo () { |
| | | getDeptTreeByNotItself(this.deptId, this.deviceSn).then(res => { |
| | | const column = this.findObject(this.option.column, 'deptId'); |
| | | this.deptTreeData = res.data.data; |
| | | column.dicData = res.data.data; |
| | | }); |
| | | const column = this.findObject(this.option.column, 'deptId') |
| | | this.deptTreeData = res.data.data |
| | | column.dicData = res.data.data |
| | | }) |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | rowSave (row, done, loading) { |
| | | // 添加毫秒级时间戳 |
| | | row['createTime'] = Date.now(); |
| | | row['deviceSn'] = this.deviceSn; |
| | | row['createTime'] = Date.now() |
| | | row['deviceSn'] = this.deviceSn |
| | | |
| | | add(row).then( |
| | | () => { |
| | | this.initFlag = false; |
| | | this.getLoadPage(this.page); |
| | | this.getDeptTreeInfo(); |
| | | this.initFlag = false |
| | | this.getLoadPage(this.page) |
| | | this.getDeptTreeInfo() |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | row['device_sn'] = this.deviceSn; |
| | | rowUpdate (row, index, done, loading) { |
| | | row['device_sn'] = this.deviceSn |
| | | update(row).then( |
| | | () => { |
| | | this.getLoadPage(this.page); |
| | | this.getLoadPage(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.getDeptTreeInfo(); |
| | | this.getLoadPage(this.page); |
| | | this.getDeptTreeInfo() |
| | | this.getLoadPage(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.getLoadPage(this.page); |
| | | searchReset () { |
| | | this.query = {} |
| | | this.getLoadPage(this.page) |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.getLoadPage(this.page, params); |
| | | done(); |
| | | searchChange (params, done) { |
| | | this.query = params |
| | | this.page.currentPage = 1 |
| | | this.getLoadPage(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.getLoadPage(this.page); |
| | | this.getLoadPage(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crud.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpen(done, type) { |
| | | done(); |
| | | beforeOpen (done, type) { |
| | | done() |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | this.getLoadPage(this.page, this.query); // 添加数据刷新 |
| | | currentChange (currentPage) { |
| | | this.page.currentPage = currentPage |
| | | this.getLoadPage(this.page, this.query) // 添加数据刷新 |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | this.page.currentPage = 1; // 每页条数改变时,重置到第一页 |
| | | this.getLoadPage(this.page, this.query); // 添加数据刷新 |
| | | sizeChange (pageSize) { |
| | | this.page.pageSize = pageSize |
| | | this.page.currentPage = 1 // 每页条数改变时,重置到第一页 |
| | | this.getLoadPage(this.page, this.query) // 添加数据刷新 |
| | | }, |
| | | refreshChange() { |
| | | this.getLoadPage(this.page, this.query); |
| | | refreshChange () { |
| | | this.getLoadPage(this.page, this.query) |
| | | }, |
| | | getLoadPage(page, params = {}) { |
| | | params['deviceSn'] = this.deviceSn; |
| | | this.loading = true; |
| | | getLoadPage (page, params = {}) { |
| | | params['deviceSn'] = this.deviceSn |
| | | this.loading = true |
| | | getList(page.currentPage, page.pageSize, params).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | const data = res.data.data |
| | | this.page.total = data.total |
| | | this.data = data.records |
| | | this.loading = false |
| | | this.selectionClear() |
| | | }).catch(err => { |
| | | console.error('加载数据失败:', err); |
| | | this.loading = false; |
| | | }); |
| | | console.error('加载数据失败:', err) |
| | | this.loading = false |
| | | }) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | |
| | | background-color: aqua; |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .firmware_status:hover { |
| | | cursor: pointer; |
| | | } |