Commit 5dc9a2ef authored by chenfm's avatar chenfm

Merge remote-tracking branch 'origin/master'

parents 311744ec eb9e253c
......@@ -2,10 +2,46 @@ import request from '@/utils/request'
// const baseURL = process.env.VUE_APP_BASE_API
const baseURL = ''
// 获取数据集列表-分页
export function getTableData(data) {
// 获取所有设备类型
export function getAllDeviceModel(data) {
return request({
url: `${baseURL}/cc/linque/getDatasetList`,
url: `${baseURL}/iot/deviceModel/all`,
method: 'post',
data
})
}
// 获取设备类型列表-分页
export function getDeviceInstance(data) {
return request({
url: `${baseURL}/iot/deviceModel/instance/list`,
method: 'post',
data
})
}
// 新建设备实例
export function addDeviceInstance(data) {
return request({
url: `${baseURL}/iot/deviceModel/instance/add`,
method: 'post',
data
})
}
// 编辑设备实例
export function updateDeviceInstance(data) {
return request({
url: `${baseURL}/iot/deviceModel/instance/edit`,
method: 'post',
data
})
}
// 编辑设备实例
export function deleteDeviceInstance(data) {
return request({
url: `${baseURL}/iot/deviceModel/instance/delete`,
method: 'post',
data
})
......
......@@ -26,7 +26,7 @@
>
<el-form-item label="">
<el-input v-model="searchForm.instanceName" clearable placeholder="设备名称">
<el-button slot="append" icon="el-icon-search"></el-button>
<el-button slot="append" icon="el-icon-search" @click="getInstanceList(1)"></el-button>
</el-input>
</el-form-item>
</el-form>
......@@ -49,6 +49,7 @@
<el-table-column
prop="businessId"
label="设备业务ID"
min-width="120"
/>
<el-table-column
prop="deviceModel"
......@@ -58,15 +59,17 @@
prop="createTime"
label="创建时间"
:formatter="$moment"
min-width="155"
/>
<el-table-column
prop="updateTime"
label="修改时间"
:formatter="$moment"
min-width="155"
/>
<el-table-column
label="操作"
min-width="80"
min-width="120"
>
<template slot-scope="scope">
<el-button type="text" @click="editItem(scope.row)">编辑</el-button>
......@@ -143,6 +146,14 @@
</template>
<script>
import {
getAllDeviceModel,
getDeviceInstance,
addDeviceInstance,
updateDeviceInstance,
deleteDeviceInstance
} from '@/api/equipment-management/equipment-instance'
export default {
name: 'EquipmentInstance',
props: {},
......@@ -179,25 +190,10 @@ export default {
dataTable: [],
dataHeader: [],
defaultActive: null,
typeList: [
{
id: 1,
name: '类型一'
},
{
id: 2,
name: '类型二'
},
{
id: 3,
name: '类型三'
},
{
id: 4,
name: '类型四'
}
],
searchForm: {},
typeList: [],
searchForm: {
instanceName: null
},
pageForm: {
pageSize: 10,
pageNum: 1,
......@@ -219,22 +215,30 @@ export default {
description: [
{ required: true, message: '请输入设备描述', trigger: 'blur' }
]
}
},
currentId: null,
currentDeviceTypeId: null
}
},
created() {},
mounted() {
if (this.typeList.length > 0) {
const type = this.typeList[0]
const indexPath = type.id.toString()
this.defaultActive = indexPath
this.getInstanceList(indexPath)
}
created() {
getAllDeviceModel()
.then(res => {
this.typeList = res.data
if (this.typeList.length > 0) {
const type = this.typeList[0]
this.currentDeviceTypeId = type.id
const indexPath = type.id.toString()
this.defaultActive = indexPath
this.getInstanceList(1)
}
})
.catch(_ => {})
},
mounted() {},
methods: {
showAddItem() {
this.instanceForm = {
deviceTypeId: null,
deviceTypeId: this.currentDeviceTypeId,
name: null,
description: null,
businessId: null,
......@@ -244,22 +248,25 @@ export default {
this.add = true
},
onSelect(index, indexPath) {
const activeType = this.typeList[parseInt(index) - 1]
this.instanceForm.deviceTypeId = activeType.id
this.getInstanceList(indexPath[0])
const id = parseInt(index)
const activeType = this.typeList.find(v => v.id === id)
this.currentDeviceTypeId = activeType.id
this.getInstanceList(1)
},
getInstanceList(indexPath) {
const data = [...this.fakeData[indexPath]]
this.dataHeader = []
for (const key in data[0]) {
if (Object.prototype.hasOwnProperty.call(data[0], key)) {
this.dataHeader.push({
label: key,
prop: key
})
}
getInstanceList(pageNum) {
const params = {
deviceTypeId: this.currentDeviceTypeId,
name: this.searchForm.instanceName,
pageNum: pageNum,
pageSize: this.pageForm.pageSize
}
this.dataTable = data
getDeviceInstance(params)
.then(res => {
const { records, total } = res.data
this.dataTable = records
this.pageForm.total = total
})
.catch(_ => {})
},
handleSizeChange(val) {
this.pageForm.pageSize = val
......@@ -270,20 +277,35 @@ export default {
editItem(row) {
const { id, deviceTypeId, name, description, businessId, deviceModel } = row
this.instanceForm = {
id,
deviceTypeId,
name,
description,
businessId,
deviceModel
}
this.currentId = id
this.dialogVisible = true
this.add = false
},
deleteItem(id) {},
deleteItem(id) {
deleteDeviceInstance({ id })
.then(_ => this.getInstanceList(1))
.catch(_ => {})
},
addItem() {
this.$refs.instanceForm.validate()
.then(_ => {})
.then(_ => {
return { ...this.instanceForm }
})
.then(params => {
if (!this.add) { params.id = this.currentId }
return this.add ? addDeviceInstance(params) : updateDeviceInstance(params)
})
.then(_ => this.$message.success('操作成功'))
.then(_ => this.getInstanceList(1))
.then(_ => {
this.dialogVisible = false
})
.catch(_ => {})
}
}
......
......@@ -160,7 +160,7 @@ export default {
rules: {
api: [
{ required: true, message: '请输入API接口', trigger: 'blur' },
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
{ min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' }
],
authType: [
{ required: true, message: '请选择权限类型', trigger: 'blur' }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment