You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.9 KiB

2 years ago
<template>
<el-dialog
title="请选择设备"
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
width="1000px"
@close="close"
@open="open"
>
2 years ago
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="80px"
label-suffix=":"
>
<el-form-item label="编码名称">
<el-input
v-model="query.search"
clearable
size="mini"
placeholder="编码名称"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<rrOperation />
</el-form>
2 years ago
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
style="width: 100%;"
size="mini"
border
2 years ago
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
2 years ago
@select="handleSelectionChange"
@select-all="onSelectAll"
@current-change="clickChange"
>
2 years ago
<el-table-column v-if="!isSingle" type="selection" width="55" />
2 years ago
<el-table-column v-if="isSingle" label="选择" width="55">
<template slot-scope="scope">
2 years ago
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
2 years ago
</template>
</el-table-column>
2 years ago
<el-table-column prop="device_code" label="设备编码" show-overflow-tooltip />
<el-table-column prop="device_name" label="设备名称" show-overflow-tooltip />
<el-table-column prop="device_model" label="设备型号" show-overflow-tooltip>
<template slot-scope="scope">
{{ dict.label.pdm_device_type[scope.row.device_model] }}
</template>
</el-table-column>
2 years ago
<el-table-column prop="region_name" label="所属区域" show-overflow-tooltip />
2 years ago
<el-table-column prop="extend_code" label="外部编码" show-overflow-tooltip />
2 years ago
</el-table>
<!--分页组件-->
2 years ago
<pagination />
2 years ago
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</el-dialog>
</template>
<script>
import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
2 years ago
import crudDevice from '@/api/wms/pdm/device'
import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import crudClassstandard from '@/api/wms/basedata/classstandard'
2 years ago
export default {
name: 'EndPointDialog',
2 years ago
dicts: ['pdm_device_type'],
2 years ago
components: { rrOperation, pagination },
cruds() {
2 years ago
return CRUD({ title: '设备', url: 'api/device', crudMethod: { ...crudDevice }, optShow: {}})
2 years ago
},
mixins: [presenter(), header()],
props: {
dialogShow: {
type: Boolean,
default: false
},
isSingle: {
type: Boolean,
default: true
},
openParam: {
type: Object,
default: null
}
},
data() {
return {
dialogVisible: false,
2 years ago
classes: [],
tableRadio: null,
class_idStr: null,
checkrow: null,
rows: []
2 years ago
}
},
watch: {
dialogShow: {
2 years ago
handler(newValue) {
2 years ago
this.dialogVisible = newValue
}
}
},
methods: {
2 years ago
clickChange(item) {
this.tableRadio = item
2 years ago
},
open() {
this.crud.toQuery()
},
close() {
this.crud.resetQuery(false)
this.$emit('update:dialogShow', false)
},
submit() {
// 处理单选
if (this.isSingle && this.tableRadio) {
this.$emit('update:dialogShow', false)
this.$emit('tableChanged', this.tableRadio)
return
}
this.rows = this.$refs.table.selection
if (this.rows.length <= 0) {
this.$message('请选择设备')
return
}
this.crud.resetQuery(false)
this.$emit('update:dialogShow', false)
this.$emit('tableChanged', this.rows)
},
handleSelectionChange(val, row) {
if (val.length > 1) {
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(val.pop())
} else {
this.checkrow = row
}
},
onSelectAll() {
this.$refs.table.clearSelection()
},
hand(value) {
this.crud.toQuery()
2 years ago
},
loadClass({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
}
2 years ago
}
}
}
</script>
<style scoped>
.crud-opts2 {
padding: 4px 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .crud-opts-right2 {
margin-left: auto;
}
2 years ago
.el-table_body tr.current-row>td {
2 years ago
background-color: #e9e500;
}
</style>