|
@@ -1,349 +1,351 @@
|
|
|
-<template>
|
|
|
- <div class="app-container">
|
|
|
-
|
|
|
- <!-- 功能按钮 -->
|
|
|
- <el-row class="filter-container">
|
|
|
- <el-col>
|
|
|
- <el-button type="primary" icon="el-icon-plus" size="medium" @click="add">{{ $t("common.add") }}</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
-
|
|
|
- <!-- 列表数据 -->
|
|
|
- <el-table
|
|
|
- :key="tableKey"
|
|
|
- ref="table"
|
|
|
- v-loading="loading"
|
|
|
- :data="tableData"
|
|
|
- border
|
|
|
- fit
|
|
|
- row-key="id"
|
|
|
- style="width: 100%;"
|
|
|
- @selection-change="onSelectChange"
|
|
|
- @cell-click="cellClick"
|
|
|
- >
|
|
|
- <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <div>
|
|
|
- {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
|
|
|
- <el-table-column prop="pic" :label='$t("resource.table.selectQm.pic")' align="center" width="150px">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <div v-if="row.pic" class="demo-image__preview">
|
|
|
- <el-image
|
|
|
- style="width: 100px; height: 60px"
|
|
|
- :src="row.pic"
|
|
|
- :preview-src-list="row.srcList">
|
|
|
- </el-image>
|
|
|
- </div>
|
|
|
- <span v-else>{{$t("common.noData")}}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="name" :label='$t("resource.table.equipment.name")' :show-overflow-tooltip="true" width="180px"></el-table-column>
|
|
|
- <el-table-column prop="code" :label='$t("resource.table.equipment.no")' :show-overflow-tooltip="true" width="100px"></el-table-column>
|
|
|
- <el-table-column prop="brand" :label='$t("resource.table.equipment.brand")' width="100px"></el-table-column>
|
|
|
- <el-table-column prop="specification" :label='$t("resource.table.equipment.specification")' width="180px"></el-table-column>
|
|
|
- <el-table-column prop="model" :label='$t("resource.table.equipment.model")'></el-table-column>
|
|
|
- <el-table-column
|
|
|
- :label="$t('table.operation')"
|
|
|
- fixed="right"
|
|
|
- align="center"
|
|
|
- column-key="operation"
|
|
|
- width="60px"
|
|
|
- >
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
|
|
|
- <i
|
|
|
- class="el-icon-delete table-operation"
|
|
|
- style="color: #f50;"
|
|
|
- @click="rowDel(row)"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
-
|
|
|
- <div slot="footer" class="dialog-footer" align="right" style="margin-top: 30px;">
|
|
|
- <el-button plain type="warning" @click="colse()">{{ $t('common.cancel') }}</el-button>
|
|
|
- <el-button plain type="primary" @click="submitForm">{{ $t('common.confirm') }}</el-button>
|
|
|
- </div>
|
|
|
- <tenant-edit
|
|
|
- ref="edit"
|
|
|
- :dialog-visible="dialog.isVisible"
|
|
|
- :title="dialog.title"
|
|
|
- @close="editClose"
|
|
|
- @success="editSuccess"
|
|
|
- />
|
|
|
- <tenant-view
|
|
|
- ref="view"
|
|
|
- :dialog-visible="tenantViewVisible"
|
|
|
- @close="viewClose"
|
|
|
- />
|
|
|
- <el-dialog
|
|
|
- v-el-drag-dialog
|
|
|
- :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="true"
|
|
|
- :title='$t("common.preview")'
|
|
|
- width="80%"
|
|
|
- top="50px"
|
|
|
- :visible.sync="preview.isVisible"
|
|
|
- >
|
|
|
- <el-scrollbar>
|
|
|
- <div v-html="preview.context" />
|
|
|
- </el-scrollbar>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
- import TenantEdit from "./components/Edit"
|
|
|
- import TenantView from "./components/View"
|
|
|
- // 【区域管理】-API
|
|
|
- import areaMgrApi from "@/api/resourceProductMgr/areaMgr"
|
|
|
- // 【设备管理】-API
|
|
|
- import equipmentMgrApi from "@/api/resourceProductMgr/equipmentMgr"
|
|
|
- import elDragDialog from '@/directive/el-drag-dialog'
|
|
|
- import { downloadFile, initEnums, initDicts, initQueryParams } from '@/utils/commons'
|
|
|
- import axios from 'axios'
|
|
|
- export default {
|
|
|
- name: "EquipmentMgr",
|
|
|
- directives: { elDragDialog },
|
|
|
- components: { TenantEdit, TenantView },
|
|
|
- props: {
|
|
|
- rowData: Object
|
|
|
- },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- audioStatus: [],
|
|
|
- dialog: {
|
|
|
- isVisible: false,
|
|
|
- title: ""
|
|
|
- },
|
|
|
- preview: {
|
|
|
- isVisible: false,
|
|
|
- context: ''
|
|
|
- },
|
|
|
- tenantViewVisible: false,
|
|
|
- tableKey: 0,
|
|
|
- queryParams: initQueryParams({}),
|
|
|
- selection: [],
|
|
|
- loading: false,
|
|
|
- tableData: [],
|
|
|
- dicts: {
|
|
|
- NATION: {}
|
|
|
- },
|
|
|
- enums: {
|
|
|
- TenantTypeEnum: {},
|
|
|
- TenantStatusEnum: {}
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- // 如果rowData.id的值改变了
|
|
|
- 'rowData.id': {
|
|
|
- handler(val, oldVal) {
|
|
|
- // 加载列表数据
|
|
|
- this.fetch()
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
- created() {
|
|
|
- // 调用常量-审核状态
|
|
|
- this.audioStatus = this.$constWKS.SHOWHIDE
|
|
|
- // 加载【字典】
|
|
|
- initDicts(['NATION'], this.dicts);
|
|
|
- // 加载列表数据
|
|
|
- this.fetch()
|
|
|
- },
|
|
|
- computed: {
|
|
|
- currentUser () {
|
|
|
- return this.$store.state.account.user
|
|
|
- },
|
|
|
- nationList() {
|
|
|
- return convertEnum(this.dicts.NATION)
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- },
|
|
|
- methods: {
|
|
|
- rowDel(row){
|
|
|
- // 过滤数据
|
|
|
- let targetList = this.tableData.filter(item => item.id != row.id)
|
|
|
- // 重新赋值
|
|
|
- this.tableData = targetList
|
|
|
- },
|
|
|
- // 【取消】按钮-事件
|
|
|
- colse(){
|
|
|
- this.$emit("close")
|
|
|
- },
|
|
|
- // 【确定】按钮-事件
|
|
|
- submitForm(){
|
|
|
- let obj = {
|
|
|
- id: this.rowData.id,
|
|
|
- resourceList: []
|
|
|
- }
|
|
|
- this.tableData.map(item => {
|
|
|
- obj.resourceList.push(item.id)
|
|
|
- })
|
|
|
- equipmentMgrApi.setResource(obj).then(res => {
|
|
|
- res = res.data
|
|
|
- })
|
|
|
- this.$emit("close")
|
|
|
- },
|
|
|
- viewClose () {
|
|
|
- this.tenantViewVisible = false
|
|
|
- },
|
|
|
- editClose () {
|
|
|
- this.dialog.isVisible = false
|
|
|
- },
|
|
|
- // 【选择 】
|
|
|
- editSuccess (arr) {
|
|
|
- // 子组件传的数据
|
|
|
- // console.log("选择的数据:", arr)
|
|
|
- this.tableData = [...this.tableData, ...arr]
|
|
|
- // 过滤重复的数据
|
|
|
- let obj = {};
|
|
|
- this.tableData = this.tableData.reduce((cur,next) => {
|
|
|
- obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
|
|
|
- return cur;
|
|
|
- },[]) //设置cur默认类型为数组,并且初始值为空的数组
|
|
|
- },
|
|
|
- onSelectChange (selection) {
|
|
|
- this.selection = selection
|
|
|
- },
|
|
|
- search () {
|
|
|
- this.fetch({
|
|
|
- ...this.queryParams
|
|
|
- })
|
|
|
- },
|
|
|
- reset () {
|
|
|
- this.queryParams = initQueryParams({})
|
|
|
- this.$refs.table.clearSort()
|
|
|
- this.$refs.table.clearFilter()
|
|
|
- this.search()
|
|
|
- },
|
|
|
- add () {
|
|
|
- this.$refs.edit.type = "add"
|
|
|
- this.$refs.edit.setTenant(false, this.dicts)
|
|
|
- this.dialog.title = this.$t("resource.common.selectAdd")
|
|
|
- this.dialog.isVisible = true
|
|
|
- },
|
|
|
- singleDelete (row) {
|
|
|
- this.$refs.table.clearSelection()
|
|
|
- this.$refs.table.toggleRowSelection(row, true)
|
|
|
- this.batchDelete()
|
|
|
- },
|
|
|
- batchDelete () {
|
|
|
- if (!this.selection.length) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.noDataSelected"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- this.$confirm(this.$t("resource.tips.areaTips"), this.$t("common.tips"), {
|
|
|
- distinguishCancelAndClose: true,
|
|
|
- confirmButtonText: this.$t("common.confirm"),
|
|
|
- cancelButtonText: this.$t("common.cancel"),
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- const ids = []
|
|
|
- this.selection.forEach(item => {
|
|
|
- ids.push(item.id)
|
|
|
- })
|
|
|
- this.delete(ids)
|
|
|
- }).catch(() => {})
|
|
|
- },
|
|
|
- clearSelections () {
|
|
|
- this.$refs.table.clearSelection()
|
|
|
- },
|
|
|
- delete (ids) {
|
|
|
- areaMgrApi.remove({ ids: ids }).then(response => {
|
|
|
- const res = response.data
|
|
|
- if (res.isSuccess) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.deleteSuccess"),
|
|
|
- type: "success"
|
|
|
- })
|
|
|
- this.search()
|
|
|
- // 清理已经删除的数据
|
|
|
- this.$refs.table.clearSelection()
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- view (row) {
|
|
|
- this.$refs.view.setTenant(row)
|
|
|
- this.tenantViewVisible = true
|
|
|
- },
|
|
|
- // 【修改】表头上Btn-事件
|
|
|
- editOne() {
|
|
|
- if (!this.selection.length) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.noDataSelected"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.selection.length > 1) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.mustOne"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- this.edit(this.selection[0]);
|
|
|
- },
|
|
|
- edit (row) {
|
|
|
- if (row.readonly) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.systemData"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- this.$refs.edit.setTenant(row, this.dicts)
|
|
|
- this.$refs.edit.type = "edit"
|
|
|
- this.dialog.title = this.$t("common.edit")
|
|
|
- this.dialog.isVisible = true
|
|
|
- },
|
|
|
- fetch (params = {}) {
|
|
|
- this.loading = true
|
|
|
-
|
|
|
- equipmentMgrApi.getList({ zoneId: this.rowData.id }).then(response => {
|
|
|
- const res = response.data
|
|
|
- if (res.isSuccess) {
|
|
|
- // 赋值
|
|
|
- this.tableData = res.data
|
|
|
- this.tableData.forEach((item, index) => {
|
|
|
- // item.url = 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg';
|
|
|
- item.srcList = [item.pic];
|
|
|
- })
|
|
|
- }
|
|
|
- // eslint-disable-next-line no-return-assign
|
|
|
- }).finally(() => this.loading = false)
|
|
|
-
|
|
|
- },
|
|
|
- cellClick (row, column) {
|
|
|
- if (column['columnKey'] === "operation") {
|
|
|
- return
|
|
|
- }
|
|
|
- let flag = false
|
|
|
- this.selection.forEach((item) => {
|
|
|
- if (item.id === row.id) {
|
|
|
- flag = true
|
|
|
- this.$refs.table.toggleRowSelection(row)
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- if (!flag) {
|
|
|
- this.$refs.table.toggleRowSelection(row, true)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-</script>
|
|
|
-<style lang="scss" scoped></style>
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+
|
|
|
+ <!-- 功能按钮 -->
|
|
|
+ <el-row class="filter-container">
|
|
|
+ <el-col>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" size="medium" @click="add">{{ $t("common.add") }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 列表数据 -->
|
|
|
+ <el-table
|
|
|
+ :key="tableKey"
|
|
|
+ ref="table"
|
|
|
+ v-loading="loading"
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ row-key="id"
|
|
|
+ style="width: 100%;"
|
|
|
+ @selection-change="onSelectChange"
|
|
|
+ @cell-click="cellClick"
|
|
|
+ >
|
|
|
+ <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div>
|
|
|
+ {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
|
|
|
+ <el-table-column prop="pic" :label='$t("resource.table.selectQm.pic")' align="center" width="150px">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <div v-if="row.pic" class="demo-image__preview">
|
|
|
+ <el-image
|
|
|
+ style="width: 100px; height: 60px"
|
|
|
+ :src="row.pic"
|
|
|
+ :preview-src-list="row.srcList">
|
|
|
+ </el-image>
|
|
|
+ </div>
|
|
|
+ <span v-else>{{$t("common.noData")}}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="name" :label='$t("resource.table.equipment.name")' :show-overflow-tooltip="true" width="180px"></el-table-column>
|
|
|
+ <el-table-column prop="code" :label='$t("resource.table.equipment.no")' :show-overflow-tooltip="true" width="100px"></el-table-column>
|
|
|
+ <el-table-column prop="brand" :label='$t("resource.table.equipment.brand")' width="100px"></el-table-column>
|
|
|
+ <el-table-column prop="specification" :label='$t("resource.table.equipment.specification")' width="180px"></el-table-column>
|
|
|
+ <el-table-column prop="model" :label='$t("resource.table.equipment.model")'></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('table.operation')"
|
|
|
+ fixed="right"
|
|
|
+ align="center"
|
|
|
+ column-key="operation"
|
|
|
+ width="60px"
|
|
|
+ >
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
|
|
|
+ <i
|
|
|
+ class="el-icon-delete table-operation"
|
|
|
+ style="color: #f50;"
|
|
|
+ @click="rowDel(row)"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <div slot="footer" class="dialog-footer" align="right" style="margin-top: 30px;">
|
|
|
+ <el-button plain type="warning" @click="colse()">{{ $t('common.cancel') }}</el-button>
|
|
|
+ <el-button plain type="primary" @click="submitForm">{{ $t('common.confirm') }}</el-button>
|
|
|
+ </div>
|
|
|
+ <tenant-edit
|
|
|
+ ref="edit"
|
|
|
+ :dialog-visible="dialog.isVisible"
|
|
|
+ :title="dialog.title"
|
|
|
+ @close="editClose"
|
|
|
+ @success="editSuccess"
|
|
|
+ />
|
|
|
+ <tenant-view
|
|
|
+ ref="view"
|
|
|
+ :dialog-visible="tenantViewVisible"
|
|
|
+ @close="viewClose"
|
|
|
+ />
|
|
|
+ <el-dialog
|
|
|
+ v-el-drag-dialog
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="true"
|
|
|
+ :title='$t("common.preview")'
|
|
|
+ width="80%"
|
|
|
+ top="50px"
|
|
|
+ :visible.sync="preview.isVisible"
|
|
|
+ >
|
|
|
+ <el-scrollbar>
|
|
|
+ <div v-html="preview.context" />
|
|
|
+ </el-scrollbar>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import TenantEdit from "./components/Edit"
|
|
|
+ import TenantView from "./components/View"
|
|
|
+ // 【区域管理】-API
|
|
|
+ import areaMgrApi from "@/api/resourceProductMgr/areaMgr"
|
|
|
+ // 【设备管理】-API
|
|
|
+ import equipmentMgrApi from "@/api/resourceProductMgr/equipmentMgr"
|
|
|
+ import elDragDialog from '@/directive/el-drag-dialog'
|
|
|
+ import { downloadFile, initEnums, initDicts, initQueryParams } from '@/utils/commons'
|
|
|
+ import axios from 'axios'
|
|
|
+ export default {
|
|
|
+ name: "EquipmentMgr",
|
|
|
+ directives: { elDragDialog },
|
|
|
+ components: { TenantEdit, TenantView },
|
|
|
+ props: {
|
|
|
+ rowData: Object
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ audioStatus: [],
|
|
|
+ dialog: {
|
|
|
+ isVisible: false,
|
|
|
+ title: ""
|
|
|
+ },
|
|
|
+ preview: {
|
|
|
+ isVisible: false,
|
|
|
+ context: ''
|
|
|
+ },
|
|
|
+ tenantViewVisible: false,
|
|
|
+ tableKey: 0,
|
|
|
+ queryParams: initQueryParams({}),
|
|
|
+ selection: [],
|
|
|
+ loading: false,
|
|
|
+ tableData: [],
|
|
|
+ dicts: {
|
|
|
+ NATION: {}
|
|
|
+ },
|
|
|
+ enums: {
|
|
|
+ TenantTypeEnum: {},
|
|
|
+ TenantStatusEnum: {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // 如果rowData.id的值改变了
|
|
|
+ 'rowData.id': {
|
|
|
+ handler(val, oldVal) {
|
|
|
+ // 加载列表数据
|
|
|
+ this.fetch()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
+ created() {
|
|
|
+ // 调用常量-审核状态
|
|
|
+ this.audioStatus = this.$constWKS.SHOWHIDE
|
|
|
+ // 加载【字典】
|
|
|
+ initDicts(['NATION'], this.dicts);
|
|
|
+ // 加载列表数据
|
|
|
+ this.fetch()
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ currentUser () {
|
|
|
+ return this.$store.state.account.user
|
|
|
+ },
|
|
|
+ nationList() {
|
|
|
+ return convertEnum(this.dicts.NATION)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ rowDel(row){
|
|
|
+ // 过滤数据
|
|
|
+ let targetList = this.tableData.filter(item => item.id != row.id)
|
|
|
+ // 重新赋值
|
|
|
+ this.tableData = targetList
|
|
|
+ },
|
|
|
+ // 【取消】按钮-事件
|
|
|
+ colse(){
|
|
|
+ this.$emit("close")
|
|
|
+ },
|
|
|
+ // 【确定】按钮-事件
|
|
|
+ submitForm(){
|
|
|
+ let obj = {
|
|
|
+ id: this.rowData.id,
|
|
|
+ resourceList: []
|
|
|
+ }
|
|
|
+ this.tableData.map(item => {
|
|
|
+ obj.resourceList.push(item.id)
|
|
|
+ })
|
|
|
+ equipmentMgrApi.setResource(obj).then(res => {
|
|
|
+ res = res.data;
|
|
|
+ // 通知,父组件
|
|
|
+ this.$emit("success");
|
|
|
+ })
|
|
|
+ this.$emit("close")
|
|
|
+ },
|
|
|
+ viewClose () {
|
|
|
+ this.tenantViewVisible = false
|
|
|
+ },
|
|
|
+ editClose () {
|
|
|
+ this.dialog.isVisible = false
|
|
|
+ },
|
|
|
+ // 【选择 】
|
|
|
+ editSuccess (arr) {
|
|
|
+ // 子组件传的数据
|
|
|
+ // console.log("选择的数据:", arr)
|
|
|
+ this.tableData = [...this.tableData, ...arr]
|
|
|
+ // 过滤重复的数据
|
|
|
+ let obj = {};
|
|
|
+ this.tableData = this.tableData.reduce((cur,next) => {
|
|
|
+ obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
|
|
|
+ return cur;
|
|
|
+ },[]) //设置cur默认类型为数组,并且初始值为空的数组
|
|
|
+ },
|
|
|
+ onSelectChange (selection) {
|
|
|
+ this.selection = selection
|
|
|
+ },
|
|
|
+ search () {
|
|
|
+ this.fetch({
|
|
|
+ ...this.queryParams
|
|
|
+ })
|
|
|
+ },
|
|
|
+ reset () {
|
|
|
+ this.queryParams = initQueryParams({})
|
|
|
+ this.$refs.table.clearSort()
|
|
|
+ this.$refs.table.clearFilter()
|
|
|
+ this.search()
|
|
|
+ },
|
|
|
+ add () {
|
|
|
+ this.$refs.edit.type = "add"
|
|
|
+ this.$refs.edit.setTenant(false, this.dicts)
|
|
|
+ this.dialog.title = this.$t("resource.common.selectAdd")
|
|
|
+ this.dialog.isVisible = true
|
|
|
+ },
|
|
|
+ singleDelete (row) {
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
+ this.$refs.table.toggleRowSelection(row, true)
|
|
|
+ this.batchDelete()
|
|
|
+ },
|
|
|
+ batchDelete () {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$confirm(this.$t("resource.tips.areaTips"), this.$t("common.tips"), {
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ confirmButtonText: this.$t("common.confirm"),
|
|
|
+ cancelButtonText: this.$t("common.cancel"),
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ const ids = []
|
|
|
+ this.selection.forEach(item => {
|
|
|
+ ids.push(item.id)
|
|
|
+ })
|
|
|
+ this.delete(ids)
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+ clearSelections () {
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
+ },
|
|
|
+ delete (ids) {
|
|
|
+ areaMgrApi.remove({ ids: ids }).then(response => {
|
|
|
+ const res = response.data
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.deleteSuccess"),
|
|
|
+ type: "success"
|
|
|
+ })
|
|
|
+ this.search()
|
|
|
+ // 清理已经删除的数据
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ view (row) {
|
|
|
+ this.$refs.view.setTenant(row)
|
|
|
+ this.tenantViewVisible = true
|
|
|
+ },
|
|
|
+ // 【修改】表头上Btn-事件
|
|
|
+ editOne() {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.selection.length > 1) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.mustOne"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.edit(this.selection[0]);
|
|
|
+ },
|
|
|
+ edit (row) {
|
|
|
+ if (row.readonly) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.systemData"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$refs.edit.setTenant(row, this.dicts)
|
|
|
+ this.$refs.edit.type = "edit"
|
|
|
+ this.dialog.title = this.$t("common.edit")
|
|
|
+ this.dialog.isVisible = true
|
|
|
+ },
|
|
|
+ fetch (params = {}) {
|
|
|
+ this.loading = true
|
|
|
+
|
|
|
+ equipmentMgrApi.getList({ zoneId: this.rowData.id }).then(response => {
|
|
|
+ const res = response.data
|
|
|
+ if (res.isSuccess) {
|
|
|
+ // 赋值
|
|
|
+ this.tableData = res.data
|
|
|
+ this.tableData.forEach((item, index) => {
|
|
|
+ // item.url = 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg';
|
|
|
+ item.srcList = [item.pic];
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // eslint-disable-next-line no-return-assign
|
|
|
+ }).finally(() => this.loading = false)
|
|
|
+
|
|
|
+ },
|
|
|
+ cellClick (row, column) {
|
|
|
+ if (column['columnKey'] === "operation") {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let flag = false
|
|
|
+ this.selection.forEach((item) => {
|
|
|
+ if (item.id === row.id) {
|
|
|
+ flag = true
|
|
|
+ this.$refs.table.toggleRowSelection(row)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (!flag) {
|
|
|
+ this.$refs.table.toggleRowSelection(row, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped></style>
|