Просмотр исходного кода

设备管理, 行业和产品的代码改进

l1069030731 2 лет назад
Родитель
Сommit
eecbfee49f

+ 4 - 4
src/api/Internet-of-things/Industry-management.js

@@ -1,7 +1,7 @@
 import request from '@/router/axios'
 
 // 行业管理-分页
-export function tdaApplicationPage(data) {
+export function tdaApplicationPage(data = {}) {
   return request({
     url: '/api/syringe-production/tdaApplication/page',
     method: 'post',
@@ -10,7 +10,7 @@ export function tdaApplicationPage(data) {
 }
 
 // 行业管理-详情
-export function tdaApplicationDetails(data) {
+export function tdaApplicationDetails(data = {}) {
   return request({
     url: '/api/syringe-production/tdaApplication/details',
     method: 'post',
@@ -19,7 +19,7 @@ export function tdaApplicationDetails(data) {
 }
 
 // 行业管理-添加
-export function tdaApplicationAdd(data) {
+export function tdaApplicationAdd(data = {}) {
   return request({
     url: '/api/syringe-production/tdaApplication/add',
     method: 'post',
@@ -28,7 +28,7 @@ export function tdaApplicationAdd(data) {
 }
 
 // 行业管理-删除
-export function tdaApplicationDelete(data) {
+export function tdaApplicationDelete(data = {}) {
   return request({
     url: '/api/syringe-production/tdaApplication/delete',
     method: 'post',

+ 28 - 0
src/api/Internet-of-things/equipment-management.js

@@ -0,0 +1,28 @@
+import request from '@/router/axios'
+
+// 设备管理-分页
+export function tdaDevicePage(data = {}) {
+  return request({
+    url: '/api/syringe-production/tdaDevice/page',
+    method: 'post',
+    data: data,
+  })
+}
+
+// 设备管理-添加
+export function tdaDeviceAdd(data = {}) {
+  return request({
+    url: '/api/syringe-production/tdaDevice/add',
+    method: 'post',
+    data: data,
+  })
+}
+
+// 设备管理-删除
+export function tdaDeviceDelete(data = {}) {
+  return request({
+    url: '/api/syringe-production/tdaDevice/delete',
+    method: 'post',
+    data: data,
+  })
+}

+ 3 - 3
src/api/Internet-of-things/product-management.js

@@ -1,7 +1,7 @@
 import request from '@/router/axios'
 
 // 产品管理-分页
-export function tdaProductPage(data) {
+export function tdaProductPage(data = {}) {
   return request({
     url: '/api/syringe-production/tdaProduct/page',
     method: 'post',
@@ -10,7 +10,7 @@ export function tdaProductPage(data) {
 }
 
 // 产品管理-添加
-export function tdaProductAdd(data) {
+export function tdaProductAdd(data = {}) {
   return request({
     url: '/api/syringe-production/tdaProduct/add',
     method: 'post',
@@ -19,7 +19,7 @@ export function tdaProductAdd(data) {
 }
 
 // 产品管理-删除
-export function tdaProductDelete(data) {
+export function tdaProductDelete(data = {}) {
   return request({
     url: '/api/syringe-production/tdaProduct/delete',
     method: 'post',

+ 5 - 5
src/api/Internet-of-things/select.js

@@ -1,7 +1,7 @@
 import request from '@/router/axios'
 
 // 行业列表
-export function tdaApplicationList(data) {
+export function tdaApplicationList(data = {}) {
   return request({
     url: '/api/syringe-production/tdaApplication/list',
     method: 'post',
@@ -10,7 +10,7 @@ export function tdaApplicationList(data) {
 }
 
 // 产品列表
-export function tdaProductList(data) {
+export function tdaProductList(data = {}) {
   return request({
     url: '/api/syringe-production/tdaProduct/list',
     method: 'post',
@@ -19,7 +19,7 @@ export function tdaProductList(data) {
 }
 
 // 产品-厂商名称列表
-export function tdaProductManufacturerNameList(data) {
+export function tdaProductManufacturerNameList(data = {}) {
   return request({
     url: '/api/syringe-production/tdaProduct/manufacturerNameList',
     method: 'post',
@@ -28,7 +28,7 @@ export function tdaProductManufacturerNameList(data) {
 }
 
 // 产品-设备类型列表
-export function tdaProductDeviceTypeList(data) {
+export function tdaProductDeviceTypeList(data = {}) {
   return request({
     url: '/api/syringe-production/tdaProduct/deviceTypeList',
     method: 'post',
@@ -37,7 +37,7 @@ export function tdaProductDeviceTypeList(data) {
 }
 
 // 设备列表
-export function tdaDeviceList(data) {
+export function tdaDeviceList(data = {}) {
   return request({
     url: '/api/syringe-production/tdaDevice/list',
     method: 'post',

+ 13 - 0
src/router/page/index.js

@@ -122,4 +122,17 @@ export default [
       },
     ],
   },
+  {
+    path: '/Internet-of-things/equipment-management',
+    component: Layout,
+    redirect: '/Internet-of-things/equipment-management/index',
+    children: [
+      {
+        path: 'index',
+        name: '设备管理',
+        component: () => import(/* webpackChunkName: "page" */ '@/views/Internet-of-things/equipment-management/index'),
+        props: true,
+      },
+    ],
+  },
 ]

+ 1 - 1
src/views/Internet-of-things/Industry-management/index.vue

@@ -78,7 +78,7 @@ export default {
       },
       dialogForm: {
         loadingStatus: false,
-        loadingText: '数据提交中,请稍后',
+        loadingText: '请稍后',
         appName: {
           label: '行业名称',
         },

+ 263 - 0
src/views/Internet-of-things/equipment-management/index.vue

@@ -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>

+ 2 - 2
src/views/Internet-of-things/product-management/index.vue

@@ -113,7 +113,7 @@ export default {
       },
       dialogForm: {
         loadingStatus: false,
-        loadingText: '数据提交中,请稍后',
+        loadingText: '请稍后',
         tdaApplicationId: {
           label: '所属行业',
           type: 'select',
@@ -274,7 +274,7 @@ export default {
       })
     },
     handleDelete(row) {
-      this.$confirm('请问是否删除行业:' + row.appName, '警告', {
+      this.$confirm('请问是否删除产品:' + row.name, '警告', {
         confirmButtonText: '确定',
         cancelButtonText: '确定',
         type: 'warning',