|
|
@ -1,7 +1,7 @@ |
|
|
|
<template> |
|
|
|
<!--表单组件--> |
|
|
|
<!-- :before-close="crud.cancelCU" --> |
|
|
|
<el-dialog class="binding-params-dialog" :close-on-click-modal="false" :visible.sync="bingParamsVisible" title="绑定参数"> |
|
|
|
<el-dialog class="binding-params-dialog" :close-on-click-modal="false" :visible.sync="bingParamsVisible" title="绑定参数" @closed="handleClose"> |
|
|
|
<span class="dialog-right-top" /> |
|
|
|
<span class="dialog-left-bottom" /> |
|
|
|
<div class="setting-dialog"> |
|
|
@ -19,19 +19,14 @@ |
|
|
|
<el-button type="primary" @click="add">添加</el-button> |
|
|
|
</el-form> |
|
|
|
</div> |
|
|
|
<!-- <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
|
|
|
<el-form-item label="区域名称" prop="name"> |
|
|
|
<el-input v-model="form.name" style="width: 370px;" /> |
|
|
|
</el-form-item> |
|
|
|
</el-form> --> |
|
|
|
<el-table ref="table" v-loading="crud.loading" :data="params"> |
|
|
|
<el-table ref="table" :loading="loading" :data="params"> |
|
|
|
<el-table-column type="index" label="序号" width="55" align="center" /> |
|
|
|
<el-table-column prop="paramId" label="参数ID" align="center" /> |
|
|
|
<el-table-column prop="paramName" label="参数名称" align="center" /> |
|
|
|
<el-table-column prop="unit" label="单位值" align="center" /> |
|
|
|
<el-table-column label="操作" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-button size="mini" icon="el-icon-delete" class="delete-btn" @click="handleDelete(scope.$index)">删除</el-button> |
|
|
|
<el-button size="mini" icon="el-icon-delete" class="delete-btn" @click="handleDelete(scope.$index, scope.row)">删除</el-button> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
@ -41,106 +36,60 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import crudMethod from '@/api/storeManage/deviceManage/param' |
|
|
|
import CRUD, { presenter, form } from '@crud/crud' |
|
|
|
// import Vue from 'vue' |
|
|
|
|
|
|
|
const defaultForm = { id: null, name: null, sort: null } |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'BingParams', |
|
|
|
cruds() { |
|
|
|
return [ |
|
|
|
CRUD({ |
|
|
|
title: '区域', url: 'api/storeroom/tree', |
|
|
|
crudMethod: { ...crudMethod }, |
|
|
|
sort: ['sort,asc'] |
|
|
|
}) |
|
|
|
] |
|
|
|
}, |
|
|
|
mixins: [presenter(), form(defaultForm)], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
rules: { |
|
|
|
name: [ |
|
|
|
{ required: true, message: '请输入区域名称', trigger: 'blur' } |
|
|
|
paramId: [ |
|
|
|
{ required: true, message: '请输入参数ID', trigger: 'blur' } |
|
|
|
], |
|
|
|
paramName: [ |
|
|
|
{ required: true, message: '请输入参数名称', trigger: 'blur' } |
|
|
|
], |
|
|
|
unit: [ |
|
|
|
{ required: true, message: '请输入单位值', trigger: 'blur' } |
|
|
|
] |
|
|
|
}, |
|
|
|
params: [], |
|
|
|
form: {}, |
|
|
|
// permission: { |
|
|
|
// add: ['admin', 'storeroom:add'], |
|
|
|
// edit: ['admin', 'storeroom:edit'], |
|
|
|
// del: ['admin', 'storeroom:del'] |
|
|
|
// }, |
|
|
|
// defaultProps: { |
|
|
|
// children: 'children', |
|
|
|
// label: 'name' |
|
|
|
// }, |
|
|
|
// activeRightBtn: false, |
|
|
|
deviceInfoId: null, |
|
|
|
loading: false, |
|
|
|
bingParamsVisible: false |
|
|
|
// , |
|
|
|
// deleteData: {}, |
|
|
|
// allowDelete: false, // 是否允许删除当前区域 |
|
|
|
// defaultExpandedKeys: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// // 获取数据前设置好接口地址 |
|
|
|
// [CRUD.HOOK.beforeRefresh]() { |
|
|
|
// if (this.$refs.deviceDetail) { |
|
|
|
// this.$refs.deviceDetail.query.id = '' |
|
|
|
// } |
|
|
|
// return true |
|
|
|
// }, |
|
|
|
// [CRUD.HOOK.afterRefresh]() { |
|
|
|
// Vue.set(this.defaultExpandedKeys, 0, this.crud.data[0].id) |
|
|
|
// this.$refs.tree.setCurrentKey(this.crud.data[0].id) |
|
|
|
// this.$refs.deviceDetail.storeroomId = this.crud.data[0].id |
|
|
|
// this.crud.selections = [this.crud.data[0]] |
|
|
|
// }, |
|
|
|
// // 选中区域后,显示设备详情数据 |
|
|
|
// handleNodeClick(val) { |
|
|
|
// if (val) { |
|
|
|
// this.crud.selectionChangeHandler([val]) |
|
|
|
// this.$refs.deviceDetail.query.id = val.id |
|
|
|
// this.$refs.deviceDetail.storeroomId = val |
|
|
|
// // this.$refs.deviceDetail.crud.toQuery() |
|
|
|
// this.activeRightBtn = true |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// // 编辑前将区域临时清空,避免日志入库数据过长 |
|
|
|
// [CRUD.HOOK.beforeToEdit](crud, form) { |
|
|
|
// form.deviceDetails = null |
|
|
|
// }, |
|
|
|
// [CRUD.HOOK.beforeSubmit]() { |
|
|
|
// this.crud.form.pid = this.defaultExpandedKeys[0] |
|
|
|
// this.crud.form.remark = this.crud.form.name |
|
|
|
// if (!this.crud.form.sort) { |
|
|
|
// this.crud.form.sort = this.crud.data[0].children.reduce((prev, cur) => { return { sort: Math.max(prev.sort, cur.sort) } }).sort + 1 |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// toDelete(data) { |
|
|
|
// this.deleteData = data |
|
|
|
// this.deleteVisible = true |
|
|
|
// this.allowDelete = this.$refs.deviceDetail.crud.data && this.$refs.deviceDetail.crud.data.length === 0 |
|
|
|
// }, |
|
|
|
// handleConfirm() { |
|
|
|
// this.deleteVisible = false |
|
|
|
// this.crud.delAllLoading = true |
|
|
|
// this.crud.doDelete(this.deleteData) |
|
|
|
// }, |
|
|
|
// handleClose(done) { |
|
|
|
// this.deleteData = {} |
|
|
|
// done() |
|
|
|
// } |
|
|
|
handleDelete(index) { |
|
|
|
// this.params.splice(index, 1) |
|
|
|
handleDelete(index, row) { |
|
|
|
crudMethod.del(row.id).then((res) => { |
|
|
|
this.params.splice(index, 1) |
|
|
|
}) |
|
|
|
}, |
|
|
|
add() { |
|
|
|
// this.params.push(JSON.parse(JSON.stringify(this.form))) |
|
|
|
// this.form.paramId = '' |
|
|
|
// this.form.paramName = '' |
|
|
|
// this.form.unit = '' |
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
this.form.deviceInfoId = { id: this.deviceInfoId } |
|
|
|
this.form.sequence = this.params.reduce((prev, cur) => { return { sequence: Math.max(prev.sequence, cur.sequence) } }, { sequence: 0 }).sequence + 1 |
|
|
|
crudMethod.add(this.form).then((res) => { |
|
|
|
this.loading = true |
|
|
|
crudMethod.getParams({ deviceInfoId: this.deviceInfoId }).then((data) => { |
|
|
|
this.params.splice(0, this.params.length, ...data) |
|
|
|
this.resetForm() |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleClose() { |
|
|
|
this.resetForm() |
|
|
|
}, |
|
|
|
resetForm() { |
|
|
|
this.form.paramId = '' |
|
|
|
this.form.paramName = '' |
|
|
|
this.form.unit = '' |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|