|
@@ -0,0 +1,263 @@
|
|
|
+<template>
|
|
|
+ <el-card class="box-card">
|
|
|
+ <test v-model="queryParams" :form-config="queryForm"></test>
|
|
|
+
|
|
|
+ <el-table :data="tableList" v-loading="loading">
|
|
|
+ <el-table-column label="所属行业" align="center" prop="applicationName" />
|
|
|
+ <el-table-column label="所属产品" align="center" prop="productName" />
|
|
|
+ <el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
|
+ <el-table-column label="设备标识" align="center" prop="nodeId" width="120" />
|
|
|
+ <el-table-column label="设备状态" align="center" prop="" width="120" />
|
|
|
+ <el-table-column label="设备ID" align="center" prop="deviceId" />
|
|
|
+ <el-table-column label="密钥" align="center" prop="secret" width="120" />
|
|
|
+ <el-table-column label="操作" align="center" width="80">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
|
|
+
|
|
|
+ <el-dialog title="添加设备" v-if="open" :visible.sync="open" width="30%">
|
|
|
+ <test ref="test" v-model="dialogParams" :form-config="dialogForm" :insideRules="dialogRules"></test>
|
|
|
+ </el-dialog>
|
|
|
+ </el-card>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import * as API from '@/api/Internet-of-things/equipment-management.js'
|
|
|
+import * as APISelect from '@/api/Internet-of-things/select.js'
|
|
|
+import test from '@/components/form-test/index.vue'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'equipment-management',
|
|
|
+ components: { test },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ keyword: '',
|
|
|
+ tdaApplicationId: '',
|
|
|
+ tdaProductId: '',
|
|
|
+ },
|
|
|
+ queryForm: {
|
|
|
+ keyword: {
|
|
|
+ label: '关键字',
|
|
|
+ span: 6,
|
|
|
+ },
|
|
|
+ tdaApplicationId: {
|
|
|
+ label: '行业',
|
|
|
+ span: 6,
|
|
|
+ type: 'select',
|
|
|
+ data: [],
|
|
|
+ keyName: 'id',
|
|
|
+ labelName: 'appName',
|
|
|
+ },
|
|
|
+ tdaProductId: {
|
|
|
+ label: '产品',
|
|
|
+ span: 6,
|
|
|
+ type: 'select',
|
|
|
+ data: [],
|
|
|
+ keyName: 'id',
|
|
|
+ labelName: 'name',
|
|
|
+ },
|
|
|
+ operation: {
|
|
|
+ // 搜索按钮操作
|
|
|
+ query: () => {
|
|
|
+ this.queryParams.pageNum = 1
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ // 重置按钮操作
|
|
|
+ reset: () => {
|
|
|
+ this.queryParams = { pageNum: 1, pageSize: 10, keyword: '', tdaApplicationId: '', name: '' }
|
|
|
+ this.queryParams.pageNum = 1
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ otherButton: {
|
|
|
+ list: [
|
|
|
+ {
|
|
|
+ name: '添加设备',
|
|
|
+ methodsText: 'add',
|
|
|
+ type: 'primary',
|
|
|
+ add: () => {
|
|
|
+ this.handleAdd()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ tableList: [],
|
|
|
+ total: 0,
|
|
|
+ loading: false,
|
|
|
+ open: false,
|
|
|
+ title: '',
|
|
|
+ dialogParams: {
|
|
|
+ tdaApplicationId: '',
|
|
|
+ tdaProductId: '',
|
|
|
+ nodeId: '',
|
|
|
+ deviceName: '',
|
|
|
+ secret: 'Fjhx@2012#',
|
|
|
+ },
|
|
|
+ dialogForm: {
|
|
|
+ loadingStatus: false,
|
|
|
+ loadingText: '请稍后',
|
|
|
+ tdaApplicationId: {
|
|
|
+ label: '所属行业',
|
|
|
+ type: 'select',
|
|
|
+ data: [],
|
|
|
+ keyName: 'id',
|
|
|
+ labelName: 'appName',
|
|
|
+ },
|
|
|
+ tdaProductId: {
|
|
|
+ label: '所属产品',
|
|
|
+ type: 'select',
|
|
|
+ data: [],
|
|
|
+ keyName: 'id',
|
|
|
+ labelName: 'name',
|
|
|
+ },
|
|
|
+ deviceName: {
|
|
|
+ label: '设备名称',
|
|
|
+ },
|
|
|
+ nodeId: {
|
|
|
+ label: '设备标识',
|
|
|
+ span: 2,
|
|
|
+ },
|
|
|
+ secret: {
|
|
|
+ label: '密钥',
|
|
|
+ disabled: true,
|
|
|
+ span: 2,
|
|
|
+ },
|
|
|
+ otherButton: {
|
|
|
+ align: 'center',
|
|
|
+ list: [
|
|
|
+ {
|
|
|
+ name: '取消',
|
|
|
+ methodsText: 'cancel',
|
|
|
+ cancel: () => {
|
|
|
+ this.open = false
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '确定',
|
|
|
+ methodsText: 'submit',
|
|
|
+ type: 'primary',
|
|
|
+ submit: () => {
|
|
|
+ this.handleSubmit()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ dialogRules: {
|
|
|
+ tdaApplicationId: [{ required: true, message: '请选择所属行业', trigger: 'change' }],
|
|
|
+ tdaProductId: [{ required: true, message: '请选择所属产品', trigger: 'change' }],
|
|
|
+ deviceName: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
|
|
|
+ nodeId: [{ required: true, message: '请输入设备标识', trigger: 'blur' }],
|
|
|
+ secret: [{ required: true, message: '请输入密钥', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getSelectList()
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ 'dialogParams.tdaApplicationId': {
|
|
|
+ handler(val) {
|
|
|
+ if (val) {
|
|
|
+ APISelect.tdaProductList({ tdaApplicationId: val }).then((res) => {
|
|
|
+ this.dialogForm.tdaProductId.data = res.data.data
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.dialogForm.tdaProductId.data = []
|
|
|
+ }
|
|
|
+ this.dialogParams.tdaProductId = ''
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getSelectList() {
|
|
|
+ APISelect.tdaApplicationList().then((res) => {
|
|
|
+ this.queryForm.tdaApplicationId.data = res.data.data
|
|
|
+ this.dialogForm.tdaApplicationId.data = res.data.data
|
|
|
+ })
|
|
|
+ APISelect.tdaProductList().then((res) => {
|
|
|
+ this.queryForm.tdaProductId.data = res.data.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getList() {
|
|
|
+ this.loading = true
|
|
|
+ API.tdaDevicePage(this.queryParams).then(
|
|
|
+ (res) => {
|
|
|
+ this.total = res.data.data.total
|
|
|
+ this.tableList = res.data.data.records
|
|
|
+ this.loading = false
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log('tdaDevicePage: ' + err)
|
|
|
+ this.loading = false
|
|
|
+ },
|
|
|
+ )
|
|
|
+ },
|
|
|
+ handleAdd() {
|
|
|
+ this.dialogParams = {
|
|
|
+ tdaApplicationId: '',
|
|
|
+ tdaProductId: '',
|
|
|
+ nodeId: '',
|
|
|
+ deviceName: '',
|
|
|
+ secret: 'Fjhx@2012#',
|
|
|
+ }
|
|
|
+ this.open = true
|
|
|
+ },
|
|
|
+ handleSubmit() {
|
|
|
+ this.$refs.test.$refs['form'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.dialogForm.loadingStatus = true
|
|
|
+ API.tdaDeviceAdd(this.dialogParams).then(
|
|
|
+ () => {
|
|
|
+ this.msgSuccess('添加成功')
|
|
|
+ this.open = false
|
|
|
+ this.dialogForm.loadingStatus = false
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log('tdaDeviceAdd: ' + err)
|
|
|
+ this.dialogForm.loadingStatus = false
|
|
|
+ },
|
|
|
+ )
|
|
|
+ // } else {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // const errorDiv = document.getElementsByClassName('is-error')
|
|
|
+ // errorDiv[0].scrollIntoView()
|
|
|
+ // }, 0)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$confirm('请问是否删除设备:' + row.appName, '警告', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '确定',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ API.tdaDeviceDelete({ id: row.id }).then(() => {
|
|
|
+ this.msgSuccess('删除成功')
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.box-card {
|
|
|
+ height: calc(100vh - 110px);
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+</style>
|