Browse Source

1、腕表功能开发;2、其他功能优化

WenNingning 4 years ago
parent
commit
7ba95d372a
4 changed files with 414 additions and 13 deletions
  1. 13 0
      src/router/index.js
  2. 1 1
      src/utils/domain.js
  3. 400 0
      src/views/ncs-device/nurse_watch.vue
  4. 0 12
      src/views/ncs-event/index.vue

+ 13 - 0
src/router/index.js

@@ -139,6 +139,19 @@ export const partRoutes = [
     ]
   },
   {
+    path: '/ncs-nurse-watch',
+    component: Layout,
+    redirect: '/ncs-device/nurse_watch',
+    children: [
+      {
+        path: 'index',
+        component: () => import('@/views/ncs-device/nurse_watch'),
+        name: 'nurse_watch',
+        meta: { title: '腕表管理', icon: 'component', noCache: true }
+      }
+    ]
+  },
+  {
     path: '/remark',
     component: Layout,
     redirect: '/remark/index',

+ 1 - 1
src/utils/domain.js

@@ -1,6 +1,6 @@
 module.exports = {
   serverUrl: 'http://localhost:8005',
-  runtimeUrl: 'http://localhost:8003',
+  DeviceUrl: 'http://localhost:8006',
   apiMode: 'dev'
 }
 

+ 400 - 0
src/views/ncs-device/nurse_watch.vue

@@ -0,0 +1,400 @@
+<template>
+  <div class="formwrap">
+    <ag-grid-layout
+      :table-height="tableHeight"
+      theme="ag-theme-alpine"
+      :column-defs="columnDefs"
+      :row-data="tableData"
+      :locale-text="localeText"
+      :grid-options="gridOptions"
+      :default-col-def="defaultColDef"
+      :animate-rows="true"
+      :row-selection="rowSelection"
+      row-height="50"
+      @filterChanged="filterModifed"
+      @sortChanged="gridSortChange"
+    >
+      <!--工具栏-->
+      <div slot="toolbar" class="inner-toolbar">
+        <div class="toolbar-search">
+          <en-table-search placeholder="请输入搜索关键字" @search="handlerSearch" />
+        </div>
+      </div>
+      <el-pagination
+        v-if="pageData"
+        slot="pagination"
+        :current-page="pageData.page_no"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="pageData.page_size"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="pageData.data_total"
+        @size-change="handlePageSizeChange"
+        @current-change="handlePageCurrentChange"
+      />
+    </ag-grid-layout>
+    <!--编辑表单-->
+    <el-dialog title="改绑" :visible.sync="formshow" width="70%">
+      <div style="width:100%;margin:0 auto;height: 400px;">
+        <el-form label-width="120px" style="min-width: 100%;float:left;">
+          <table border="1" class="tablewen">
+            <tr>
+              <td class="td1">设备别名:</td>
+              <td class="td2"><span>{{ deviceInfo.name }}</span></td>
+              <td class="td1">设备状态:</td>
+              <td class="td2">
+                <span v-if="deviceInfo.status===1">已启用</span>
+                <span v-else>未启用</span>
+              </td>
+            </tr>
+            <tr>
+              <td class="td1">绑定人:</td>
+              <td class="td2"><span>{{ deviceInfo.member_name }}</span></td>
+              <td class="td1">设备型号:</td>
+              <td class="td2"><span>{{ deviceInfo.model }}</span></td>
+            </tr>
+            <tr>
+              <td class="td1">有线物理地址:</td>
+              <td class="td2"><span>{{ deviceInfo.eth_mac }}</span></td>
+              <td class="td1">有线IP地址:</td>
+              <td class="td2"><span>{{ deviceInfo.eth_ip }}</span></td>
+            </tr>
+            <tr>
+              <td class="td1">出厂编号:</td>
+              <td class="td2"><span>{{ deviceInfo.code }}</span></td>
+              <td class="td1">SIP账号:</td>
+              <td class="td2"><span>{{ deviceInfo.sip_id }}</span></td>
+            </tr>
+            <tr>
+              <td class="td1">软件版本:</td>
+              <td class="td2"><span>{{ deviceInfo.soft_ver }}</span></td>
+              <td class="td1">硬件版本:</td>
+              <td class="td2"><span>{{ deviceInfo.hard_ver }}</span></td>
+            </tr>
+            <tr>
+              <td class="td1">WIFI物理地址:</td>
+              <td class="td2"><span>{{ deviceInfo.wifi_mac }}</span></td>
+              <td class="td1">WIFIIP地址:</td>
+              <td class="td2"><span>{{ deviceInfo.wifi_ip }}</span></td>
+            </tr>
+          </table>
+          <el-form-item label="可选护士:">
+            <el-radio-group v-model="deviceInfo.member_id">
+              <el-radio v-for="(item, index) in nurses" :key="index" :label="item.member_id">
+                <i class="el-icon-user-solid" style="color: #b59abf;margin-top: 5px" />{{ item.clerk_name }}
+              </el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-form>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="formshow = false">取 消</el-button>
+        <el-button type="primary" @click="handlerFormSubmit('editform')">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import * as API_Device from '@/api/ncs_device'
+import { unixToDate } from '@/utils/Foundation'
+import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
+import { DeviceUrl } from '@/utils/domain'
+import * as clerk_API from '@/api/ncs_clerk'
+
+export default {
+  name: 'Index',
+  data: function() {
+    return {
+      /** 表格数据 */
+      tableData: [],
+      /** 表单数据 */
+      formmodel: {},
+      formshow: false, // 编辑表单显示开关
+      /** 表单校验 */
+      rules: {
+        name: [
+          { required: true, message: '请输入名称', trigger: 'blur' }
+        ]
+      },
+      pageData: [],
+      loading: false,
+      multipleSelection: [],
+      /** 列表参数 */
+      params: {
+        page_size: 20,
+        page_no: 1,
+        fixedCondition: ' part_id=' + this.$store.getters.partId + ' and device_type = 7',
+        sort: 'id',
+        dir: 'desc'
+      },
+      editflag: 0,
+      deviceInfo: {},
+      nurses: [],
+      columnDefs: null, // 新表格
+      defaultColDef: null,
+      gridOptions: null,
+      gridApi: null,
+      columnApi: null,
+      localeText: AG_GRID_LOCALE_CN,
+      rowSelection: null,
+      showViewer: false
+    }
+  },
+  computed: {
+    tableHeight() {
+      return this.mainAreaHeight - 130
+    }
+  },
+  beforeMount() {
+    this.gridOptions = {
+    }
+    this.columnDefs = [
+      {
+        headerName: '#',
+        headerCheckboxSelection: true,
+        headerCheckboxSelectionFilteredOnly: true,
+        checkboxSelection: true,
+        sortable: false,
+        width: 50,
+        resizable: false,
+        valueGetter: this.hashValueGetter
+      },
+      { headerName: '设备别名', field: 'name', sortable: true, minWidth: 150 },
+      { headerName: '设备状态', field: 'status', sortable: true, cellRenderer: this.formatterSatus, minWidth: 100 },
+      { headerName: '绑定人', field: 'member_name', sortable: true, minWidth: 140 },
+      { headerName: '所属位置', field: 'full_name', sortable: true, minWidth: 140 },
+      { headerName: '有线物理地址', field: 'eth_mac', sortable: true, minWidth: 150 },
+      { headerName: '有线IP地址', field: 'eth_ip', sortable: true, minWidth: 150 },
+      { headerName: '设备型号', field: 'model', sortable: true, minWidth: 150 },
+      { headerName: '出厂编号', field: 'code', sortable: true, minWidth: 150 },
+      { headerName: '软件版本', field: 'soft_ver', sortable: true, minWidth: 150 },
+      { headerName: '硬件版本', field: 'hard_ver', sortable: true, minWidth: 150 },
+      { headerName: 'WIFI物理地址', field: 'wifi_mac', sortable: true, minWidth: 150 },
+      { headerName: 'WIFIIP地址', field: 'wifi_ip', sortable: true, minWidth: 150 },
+      { headerName: 'SIP账号', field: 'sip_id', sortable: true, minWidth: 150 },
+      { headerName: '最后修改时间', field: 'update_time', sortable: true, valueFormatter: this.formatterDate, minWidth: 170 }
+    ]
+    this.defaultColDef = {
+      filter: false,
+      sortable: true,
+      resizable: true,
+      comparator: this.testComparator,
+      filterParams: {
+        debounceMs: 200,
+        newRowsAction: 'keep',
+        textCustomComparator: this.textCustomComparator,
+        comparator: this.testComparator
+      }
+    }
+    this.rowSelection = 'multiple'
+  },
+  mounted() {
+    this.gridApi = this.gridOptions.api
+    this.getList()
+    this.initWebSocket()
+  },
+  methods: {
+    initWebSocket: function() {
+      const stockbase = DeviceUrl.replace('http', 'ws')
+      this.websock = new WebSocket(stockbase + '/web-socket/nurseDevice/' + this.$store.getters.partId)
+      this.websock.onopen = this.websocketonopen
+      this.websock.onerror = this.websocketonerror
+      this.websock.onmessage = this.websocketonmessage
+      this.websock.onclose = this.websocketclose
+    },
+    websocketonopen: function() {
+      console.log('WebSocket连接成功')
+      this.$message.success('连接成功')
+    },
+    websocketonerror: function(e) {
+      console.log('WebSocket连接发生错误')
+    },
+    websocketonmessage: function(e) {
+      console.log('收到消息:', e.data)
+      if (e.data) {
+        this.formshow = true
+        this.deviceInfo = JSON.parse(e.data)
+        this.getEmployees()
+      }
+    },
+    websocketclose: function(e) {
+      const _this = this
+      console.log('socket连接关闭connection closed (' + e.code + ')')
+      this.$alert('连接已断开,需重新连接', '连接确定', {
+        confirmButtonText: '确定',
+        callback: action => {
+          _this.initWebSocket()
+        }
+      })
+    },
+    /** 选择行变化时,记录选中的行数据 */
+    selectFun(val) {
+      this.multipleSelection = val
+    },
+    /** 分页大小发生改变 */
+    handlePageSizeChange(size) {
+      this.params.page_size = size
+      this.getList()
+    },
+    /** 分页页数发生改变 */
+    handlePageCurrentChange(page) {
+      this.params.page_no = page
+      this.getList()
+    },
+    /** 加载通知列表 */
+    getList() {
+      this.loading = true
+      this.gridApi.showLoadingOverlay()
+      this.gridApi.sizeColumnsToFit()
+      API_Device.getList(this.params).then(response => {
+        this.loading = false
+        this.tableData = response.data
+        this.pageData = {
+          page_no: response.page_no,
+          page_size: response.page_size,
+          data_total: response.data_total
+        }
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    /** 新增 提交表单 */
+    handlerFormSubmit(formName) {
+      if (this.deviceInfo.member_id === null || this.deviceInfo.member_id === '') {
+        this.$message.info('请选择护士')
+        return
+      }
+      const params = this.MixinClone(this.deviceInfo)
+      const sendData = {
+        id: params.id,
+        member_id: params.member_id,
+        status: 1,
+        eth_ip: params.eth_ip,
+        eth_ip_port: params.eth_ip_port
+      }
+      this.websock.send(JSON.stringify(sendData))
+      this.formshow = false
+      const _this = this
+      setTimeout(function() {
+        _this.$message.success('分配成功')
+        _this.getList()
+      }, 1000)
+    },
+    /** 处理搜索 */
+    handlerSearch(keywords) {
+      this.params.query = keywords
+      this.getList()
+    },
+    /** 处理排序 */
+    tableSort(column) {
+      if (column.order !== null) {
+        this.params.sort = column.prop
+        this.params.dir = column.order === 'ascending' ? 'asc' : 'desc'
+      } else {
+        this.params.sort = null
+        this.params.dir = null
+      }
+      this.getList()
+    },
+    formatterDate(params) {
+      return unixToDate(params.value)
+    },
+    filterModifed(param) {
+      const model = param.api.getFilterModel()
+      this.params.filter = JSON.stringify(model)
+      this.GET_List()
+    },
+    gridSortChange(param) {
+      const columnState = param.columnApi.getColumnState()
+      // 排序状态
+      const sortState = columnState.filter(function(s) {
+        return s.sort != null
+      }).map(function(s) {
+        return {
+          colId: s.colId,
+          sort: s.sort,
+          sortIndex: s.sortIndex
+        }
+      }).sort(function(a, b) {
+        return a.sortIndex - b.sortIndex
+      })
+      if (sortState.length > 0) {
+        if (sortState.length === 1) {
+          this.params.sort = sortState[0].colId
+          this.params.dir = sortState[0].sort
+        } else {
+          let sortstring = ''
+          sortState.forEach(function(item) {
+            sortstring += item.colId + ' ' + item.sort + ','
+          })
+          this.params.sort = sortstring.substring(0, sortstring.length - 1)
+          this.params.dir = ' '
+        }
+      } else {
+        delete this.params.sort
+        delete this.params.dir
+      }
+      this.GET_List()
+    },
+    formatterSatus(param) {
+      if (param.value === 1) {
+        return '<span style="color:green">已启用</span>'
+      } else {
+        return '<span style="color:red">未启用</span>'
+      }
+    },
+    getEmployees() {
+      const _this = this
+      clerk_API.listByPartRoleId({ partId: this.$store.getters.partId }).then(res => {
+        const groupBy = (arr, func) =>
+          arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => {
+            acc[val] = (acc[val] || []).concat(arr[i])
+            return acc
+          }, {})
+        const groupData = groupBy(res, item => item.role_name)
+        if (Object.entries(groupData).length > 0) {
+          Object.entries(groupData).forEach(item => {
+            if (item[0] === '护士') {
+              _this.nurses = item[1]
+            }
+          })
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style type="text/scss" scoped>
+  .tablewen{
+    width:100%;
+    border-collapse:collapse;
+    border: 1px solid #a5b6c8;
+    margin-bottom: 30px;
+    line-height: 40px;
+  }
+  .tablewen td{
+    font-size: 14px;
+    -webkit-margin-before: 0.83em;
+    -webkit-margin-after: 0.83em;
+    -webkit-margin-start: 0px;
+    -webkit-margin-end: 0px;
+    font-weight: bold;
+  }
+  .tablewen td span{
+    font-size: 0.8em;
+    -webkit-margin-before: 0.83em;
+    -webkit-margin-after: 0.83em;
+    -webkit-margin-start: 0px;
+    -webkit-margin-end: 0px;
+    font-weight: bold;
+    color: #8c939d;
+    margin-left: 5px;
+  }
+  .tablewen .td1{
+    width:15%;
+  }
+  .tablewen .td2{
+    width:20%;
+  }
+</style>

+ 0 - 12
src/views/ncs-event/index.vue

@@ -324,18 +324,6 @@
                     })
                 })
             },
-            /** 批量数据删除处理(删除选中的行) */
-            batchDelete: function () {
-                if (rows.length === 0) {
-                    this.$message({ type: 'info', message: '请先勾选需要删除的数据' })
-                    return
-                }
-                const ids = []
-                rows.forEach(function (item) {
-                    ids.push(item.id)
-                })
-                this.handlerDelete(ids.join(','))
-            },
             /** 分页大小发生改变 */
             handlePageSizeChange(size) {
                 this.params.page_size = size