Explorar o código

1、用户地图足迹;
2、其他优化

wennn %!s(int64=3) %!d(string=hai) anos
pai
achega
412578225f

+ 4 - 1
languages/zh-CN.js

@@ -343,6 +343,7 @@ module.exports = {
     choiceNurse: '请选择护士',
     worker: '责任护工',
     choiceWorker: '请选择护工',
+    choiceUser: '请选择用户',
     customerRelative: '用户亲属',
     sureDeleteRelative: '你确定要删除此病人亲属信息?',
     customerRelativeTrueName: '亲属姓名',
@@ -372,7 +373,8 @@ module.exports = {
     message: '的信息',
     customerStatus: '当前状态',
     customerStatusTrue: '入住中',
-    customerStatusFalse: '已离开'
+    customerStatusFalse: '已离开',
+    footprint: '足迹'
   },
   vital: {
     customerVital: '用户体征日志',
@@ -734,6 +736,7 @@ module.exports = {
     customerManage: '用户管理',
     customerQrCode: '用户二维码',
     mobileDeviceManage: '移动设备',
+    userLocationManage: '用户位置',
     sosDeviceSettingManage: '报警设备',
     channelManage: '对讲频道',
     remarkManage: '便签管理',

+ 7 - 2
public/domain.js

@@ -1,6 +1,11 @@
 const domain = {
-  serverUrl: 'http://172.28.100.100:8005',
-  DeviceUrl: 'http://172.28.100.100:8006',
+  // serverUrl: 'http://172.28.100.100:8005',
+  // DeviceUrl: 'http://172.28.100.100:8006',
+  serverUrl: 'http://localhost:8005',
+  DeviceUrl: 'http://localhost:8006',
+  // serverUrl: 'http://8.129.220.143:8005',
+  // DeviceUrl: 'http://8.129.220.143:8006',
+  OnlineSystemUrl: 'http://api.base.wdklian.com',
   apiMode: 'dev',
   uiVersion: 3 // 1 医院版,2 月子中心版,3养老院版
 }

+ 8 - 0
src/api/initialize.js

@@ -1,4 +1,5 @@
 import request from '@/utils/request'
+const OnlineSystemUrl = domain.OnlineSystemUrl
 
 export function initData() {
   return request({
@@ -17,4 +18,11 @@ export function initDeviceList(partId) {
     url: `/initialize/init_device_list/${partId}`,
     method: 'GET'
   })
+}
+
+export function getDevicesByUuid(id) {
+  return request({
+    url: OnlineSystemUrl + `/ncs_sync/get_device_by_uuid/${id}`,
+    method: 'GET'
+  })
 }

+ 14 - 0
src/router/index.js

@@ -208,6 +208,20 @@ export const partRoutes = [
     hidden: uiVersion === 1
   },
   {
+    path: '/ncs-user-watch',
+    component: Layout,
+    redirect: '/ncs-device/user_watch',
+    children: [
+      {
+        path: 'index',
+        component: () => import('@/views/ncs-device/user_watch'),
+        name: 'user_watch',
+        meta: { title: i18n.t('tab.userLocationManage'), icon: 'el-icon-watch', noCache: true }
+      }
+    ],
+    hidden: uiVersion === 1
+  },
+  {
     path: '/ncs-sos-device',
     component: Layout,
     redirect: '/ncs-device/sos_device',

+ 43 - 12
src/views/customer/components/elderlyCareManager.vue

@@ -395,6 +395,10 @@
                     </div>
                 </el-tab-pane>
 
+              <el-tab-pane v-if="formmodel.id && boolDevice" :label="this.$t('customerManage.footprint')" name="footprint">
+                <my-map-html :map-url="mapUrl" style="width: 100%; height: 670px;"></my-map-html>
+              </el-tab-pane>
+
             </el-tabs>
         </el-dialog>
         <!-- 用户信息 -->
@@ -489,11 +493,14 @@
     import * as API_Clerk from '@/api/ncs_clerk'
     import * as API_NurseConfig from '@/api/ncs_nurse_config'
     import vitalSignLog from '@/views/vital-sign/log'
+    import myMapHtml from '@/views/customer/myMapHtml'
     import myMap from '@/views/customer/myMap'
+    import * as API_SystemConfig from '@/api/ncs_systemconfig'
+    import { getDevicesByUuid } from '@/api/initialize'
     const serverUrl = domain.serverUrl
     export default {
         name: 'ElderlyCareManager',
-        components: {ButtonCellRender, ListFilter, RadioFilter, vitalSignLog, myMap},
+        components: {ButtonCellRender, ListFilter, RadioFilter, vitalSignLog, myMap, myMapHtml},
         filters: {
             unixDateFilter(val) {
                 return unixToDate(val)
@@ -575,18 +582,21 @@
                     true_name: [{required: true, message: this.$t('customerManage.inputRemarks'), trigger: 'blur'}],
                     relative_name: [{required: true, message: this.$t('customerManage.inputRelativeName'), trigger: 'blur'}],
                     mobile: [
-                        {
-                            validator: (rule, value, callback) => {
-                                if (value === null || value === '') { // 手机号可为空
-                                    callback()
-                                }
-                                if (!RegExp.mobile.test(value)) {
-                                    callback(new Error(this.$t('member.mobileInputMsg')))
-                                } else {
-                                    callback()
-                                }
+                      { required: false, message: this.$t('member.inputMobile'), trigger: 'blur',
+                        validator: (rule, value, callback) => {
+                          // this.isCloud = false
+                          if (this.isCloud === false) {
+                            if (value === null || value === '') { // 手机号可为空
+                              callback()
                             }
+                          }
+                          if (!RegExp.mobile.test(value)) {
+                            callback(new Error(this.$t('member.mobileInputMsg')))
+                          } else {
+                            callback()
+                          }
                         }
+                      }
                     ]
                 },
                 /** 换床 */
@@ -639,7 +649,10 @@
                 customerRemarkTime: this.$t('customerManage.remarkTime'),
                 customerRemarkName: this.$t('customerManage.remarkName'),
                 deleted: this.$t('action.delete'),
-              locationShow: false
+              locationShow: false,
+              isCloud: false,
+              boolDevice: false,
+              mapUrl: null
             }
         },
         computed: {
@@ -849,6 +862,7 @@
             this.getEmployees()
             // 加载护理参数设置项
             this.getNurseConfigs()
+            this.getCloud() // 是否开启同步线上
             // var column = this.gridColumnApi.getColumn('id')
             // const _this = this
             // column.addEventListener('sortChanged', function(event) {
@@ -1164,6 +1178,9 @@
             },
 
             handleEdit(row) {
+                this.activeName = 'customerBaseInfo'
+                this.boolDevice = false
+                this.relativeRules.mobile[0].required = this.isCloud
                 this.formmodel = {
                     ...row
                 }
@@ -1194,6 +1211,15 @@
                 this.handNusreColor()
                 this.getRemarks()
                 this.getRelatives()
+                if (this.isCloud) {
+                  const _this = this
+                  getDevicesByUuid(row.uuid).then(res => {
+                    if (res) {
+                      _this.boolDevice = true
+                      _this.mapUrl = res
+                    }
+                  })
+                }
             },
             /** 出院 退床 **/
             handleOut(row) {
@@ -1478,6 +1504,11 @@
           },
           goPage() {
             this.$router.push({path:'/allMap'})
+          },
+          getCloud() {
+            API_SystemConfig.cloud().then(r => {
+              this.isCloud = r
+            })
           }
         }
     }

+ 15 - 11
src/views/customer/myMap.vue

@@ -48,17 +48,21 @@ name: "wyMap",
   },
   methods: {
     handler ({BMap, map}) {
-      if (this.lngLat) {
-        this.center.lng = this.lngLat.split(',')[0]
-        this.center.lat = this.lngLat.split(',')[1]
-        this.myCenter = this.center
-        this.isShow = true
-      } else {
-        this.center.lng = 116.404
-        this.center.lat = 39.915
-      }
-      console.log(this.center.lng, this.center.lat)
-      this.zoom = 15
+      const _this = this
+      setTimeout(()=>{
+        if (_this.lngLat) {
+          _this.center.lng = _this.lngLat.split(',')[0]
+          _this.center.lat = _this.lngLat.split(',')[1]
+          _this.myCenter = _this.center
+          _this.isShow = true
+        } else {
+          _this.center.lng = 116.404
+          _this.center.lat = 39.915
+        }
+        console.log(_this.center.lng, _this.center.lat)
+        _this.zoom = 15
+      },500)
+
     },
     clickMap(e) {
       console.log('点击的经纬度:' + e.Bg.lng + ', ' + e.Bg.lat)

+ 29 - 0
src/views/customer/myMapHtml.vue

@@ -0,0 +1,29 @@
+<template>
+  <div style="width: 100%; height: 100%">
+    <iframe :src="mapUrl" frameborder="0" style="width: 100%; height: 100%"></iframe>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "myMapHtml",
+  props: {
+    mapUrl: {
+      type: String,
+      default: ''
+    }
+  },
+  data() {
+    return {
+
+    }
+  },
+  mounted() {
+    console.log('1111111111111111')
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 1 - 1
src/views/ncs-chars/index.vue

@@ -514,7 +514,7 @@ export default {
           return min +this.$t('action.minute2') + secondTime + this.$t('action.second')
         }
       } else {
-        return secondTime + this.$t('action.second')``
+        return secondTime + this.$t('action.second')
       }
     }
   }

+ 19 - 19
src/views/ncs-device/nurse_watch.vue

@@ -223,25 +223,25 @@ export default {
         resizable: false,
         sortable: false
       }
-      // ,
-      // {
-      //   headerName: this.$t('watch.place'), field: 'shop_id',
-      //   cellRendererFramework: 'ButtonCellRender',
-      //   cellRendererParams: param => {
-      //     return {
-      //       onClick: this.getLocation,
-      //       label: this.$t('watch.place'),
-      //       buttonType: 'warning',
-      //       buttonSize: 'mini'
-      //     }
-      //   },
-      //   filter: false,
-      //   pinned: 'right',
-      //   lockPinned: true,
-      //   minWidth: 100,
-      //   resizable: false,
-      //   sortable: false
-      // }
+      ,
+      {
+        headerName: this.$t('watch.place'), field: 'shop_id',
+        cellRendererFramework: 'ButtonCellRender',
+        cellRendererParams: param => {
+          return {
+            onClick: this.getLocation,
+            label: this.$t('watch.place'),
+            buttonType: 'warning',
+            buttonSize: 'mini'
+          }
+        },
+        filter: false,
+        pinned: 'right',
+        lockPinned: true,
+        minWidth: 100,
+        resizable: false,
+        sortable: false
+      }
       // {
       //   headerName: '管理', field: 'shop_id',
       //   cellRendererFramework: 'ButtonCellRender',

+ 518 - 0
src/views/ncs-device/user_watch.vue

@@ -0,0 +1,518 @@
+<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="this.$t('watch.deviceKeywords')" @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 v-if="formshow" :title="this.$t('action.edit')+(member_id===null?'':'('+member_name+')')" :visible.sync="formshow" width="70%">
+      <el-form label-width="120px" ref="addMemberForm">
+        <el-form-item :label="this.$t('watch.ethMac')">
+          {{ deviceInfo.eth_mac }}
+        </el-form-item>
+        <el-form-item :label="this.$t('customerManage.named')">
+          <el-radio-group v-model="deviceInfo.member_id">
+            <el-radio v-for="(t, i) in users" :key="i" :label="t.member_id" :disabled="member_id === t.member_id && t.device_id !== null">
+              <i class="el-icon-user-solid" style="color: #b59abf;margin-top: 5px" />{{ t.named }}
+            </el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item style="margin-top:15px;">
+          <el-button type="success" @click="handlerFormSubmit('editform')">{{ this.$t('action.saveEdit') }}</el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+
+<!--    位置信息-->
+    <el-dialog :title="this.$t('watch.placeInfo')" :visible.sync="locationShow" width="70%">
+      <watch-location :device-id="deviceId" :is-show="locationShow"></watch-location>
+    </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 ButtonCellRender from '@/components/AgGridCellRender/ButtonCellRender'
+import RadioFilter from '@/components/AgGridCustomFilter/RadioFilter'
+import watchLocation from '@/views/ncs-device/watch_location'
+import { getListByPartId } from '@/api/ncs_customer'
+const DeviceUrl = domain.DeviceUrl
+export default {
+  name: 'Index',
+  components: { ButtonCellRender, RadioFilter, watchLocation },
+  data: function() {
+    return {
+      /** 表格数据 */
+      tableData: [],
+      /** 表单数据 */
+      formmodel: {},
+      formshow: false, // 编辑表单显示开关
+      /** 表单校验 */
+      rules: {
+        name: [
+          { required: true, message: this.$t('watch.inputName'), trigger: 'blur' }
+        ]
+      },
+      pageData: [],
+      loading: false,
+      multipleSelection: [],
+      /** 列表参数 */
+      params: {
+        page_size: 100,
+        page_no: 1,
+        fixedCondition: ' part_id=' + this.$store.getters.partId + ' and device_type = 9',
+        sort: 'id',
+        dir: 'desc'
+      },
+      editflag: 0,
+      deviceInfo: {},
+      users: [],
+      columnDefs: null, // 新表格
+      defaultColDef: null,
+      gridOptions: null,
+      gridApi: null,
+      columnApi: null,
+      localeText: AG_GRID_LOCALE_CN,
+      rowSelection: null,
+      showViewer: false,
+      deviceStatusTransfer: [
+        { key: this.$t('deviceManage.statusTure'), value: 1, color: 'green' },
+        { key: this.$t('deviceManage.statusFalse'), value: 0, color: 'red' }
+      ],
+      clerks: [],
+      role_id: null,
+      role_name: '',
+      member_id: null,
+      member_name:'',
+      onlineDevice: [],
+      locationShow: false,
+      deviceId: null
+    }
+  },
+  computed: {
+    tableHeight() {
+      return this.mainAreaHeight - 130
+    }
+  },
+  beforeMount() {
+    this.gridOptions = {
+    }
+    this.columnDefs = [
+      {
+        headerName: '#',
+        headerCheckboxSelection: true,
+        headerCheckboxSelectionFilteredOnly: true,
+        checkboxSelection: true,
+        sortable: false,
+        width: 80,
+        resizable: false,
+        valueGetter: this.hashValueGetter
+      },
+      { headerName: 'ID', field: 'id', sortable: true, filter: 'agNumberColumnFilter', minWidth: 100 },
+      { headerName: this.$t('deviceManage.deviceName'), field: 'name', sortable: true, filter: 'agTextColumnFilter', minWidth: 150 },
+      { headerName: this.$t('watch.deviceMember'), field: 'member_name', sortable: true, filter: 'agTextColumnFilter', minWidth: 220, valueFormatter: this.formatterName },
+      { headerName: this.$t('watch.ethMac'), field: 'eth_mac', sortable: true, filter: 'agTextColumnFilter', minWidth: 150 },
+      { headerName: this.$t('deviceManage.connect'), field: 'online_state', sortable: false, filter: 'agTextColumnFilter', minWidth: 120,
+        filterParams: {
+          textCustomComparator: (filter, value, filterText) => {
+            const filterTextLowerCase = filterText.toLowerCase()
+            const valueLowerCase = value.toString().toLowerCase()
+            switch (filter) {
+              case 'contains':
+                return valueLowerCase.indexOf(filterTextLowerCase) >= 0
+              case 'notContains':
+                return valueLowerCase.indexOf(filterTextLowerCase) === -1
+              case 'equals':
+                return valueLowerCase === filterTextLowerCase
+              case 'notEqual':
+                return valueLowerCase !== filterTextLowerCase
+              case 'startsWith':
+                return valueLowerCase.indexOf(filterTextLowerCase) === 0
+              case 'endsWith':
+                var index = valueLowerCase.lastIndexOf(filterTextLowerCase)
+                return index >= 0 && index === (valueLowerCase.length - filterTextLowerCase.length)
+              default:
+                // should never happen
+                console.warn('invalid filter type ' + filter)
+                return false
+            }
+          }
+        },
+        cellRenderer: this.onlineStateFormatter
+      },
+      { headerName: this.$t('deviceManage.ethIp'), field: 'eth_ip', sortable: true, filter: 'agTextColumnFilter', minWidth: 150 },
+      { headerName: this.$t('deviceManage.model'), field: 'model', sortable: true, filter: 'agTextColumnFilter', minWidth: 150 },
+      { headerName: this.$t('deviceManage.code'), field: 'code', sortable: true, filter: 'agTextColumnFilter', minWidth: 150 },
+      { headerName: this.$t('deviceManage.sipId'), field: 'sip_id', sortable: true, filter: 'agTextColumnFilter', minWidth: 150 },
+      { headerName: this.$t('deviceManage.updateTime'), field: 'update_time', sortable: true, filter: 'agDateColumnFilter', minWidth: 170, valueFormatter: this.formatterDate,
+        filterParams: {
+          comparator: (filterLocalDateAtMidnight, cellValue) => { // 所有数据都由服务器端过滤,此处只需返回0 即可
+            const celldate = unixToDate(cellValue, 'yyyy-MM-dd 00:00:00')
+            return (new Date(celldate).getTime() / 1000) - (filterLocalDateAtMidnight.getTime() / 1000)
+          }
+        }
+      },
+      {
+        headerName: this.$t('watch.binding'), field: 'shop_id',
+        cellRendererFramework: 'ButtonCellRender',
+        cellRendererParams: param => {
+          return {
+            onClick: this.huanban,
+            label: this.$t('watch.binding'),
+            buttonType: param.data['member_id'] === null ? 'primary' : 'success',
+            buttonSize: 'mini'
+          }
+        },
+        filter: false,
+        pinned: 'right',
+        lockPinned: true,
+        minWidth: 100,
+        resizable: false,
+        sortable: false
+      }
+      ,
+      {
+        headerName: this.$t('watch.place'), field: 'shop_id',
+        cellRendererFramework: 'ButtonCellRender',
+        cellRendererParams: param => {
+          return {
+            onClick: this.getLocation,
+            label: this.$t('watch.place'),
+            buttonType: 'warning',
+            buttonSize: 'mini'
+          }
+        },
+        filter: false,
+        pinned: 'right',
+        lockPinned: true,
+        minWidth: 100,
+        resizable: false,
+        sortable: false
+      }
+    ]
+    this.defaultColDef = {
+      sortable: true,
+      resizable: true,
+      comparator: this.testComparator,
+      filterParams: {
+        debounceMs: 200,
+        newRowsAction: 'keep',
+        textCustomComparator: this.textCustomComparator,
+        comparator: this.testComparator
+      }
+    }
+    this.rowSelection = 'multiple'
+  },
+  mounted() {
+    window.onresize = this.windowResize()
+    this.gridApi = this.gridOptions.api
+    this.getList()
+    this.deviceOnlineWebSocket()
+  },
+  methods: {
+    windowResize() {
+      this.$set(this, 'mainAreaHeight', Number(document.documentElement.clientHeight) - 84)
+    },
+    deviceOnlineWebSocket: function() {
+      var stockbase = DeviceUrl.replace('http', 'ws')
+      this.websock1 = new WebSocket(stockbase + '/deviceonline/' + this.$store.getters.uuid)
+      this.websock1.onopen = this.deviceOnlineWebsocketonopen
+      this.websock1.onerror = this.deviceOnlineWebsocketonerror
+      this.websock1.onmessage = this.deviceOnlineWebsocketonmessage
+      this.websock1.onclose = this.deviceOnlineWebsocketclose
+    },
+    deviceOnlineWebsocketonopen: function() {
+      console.log(this.$t('deviceManage.webSocketSuccess'))
+    },
+    deviceOnlineWebsocketonerror: function(e) {
+      console.log(this.$t('deviceManage.webSocketError'))
+    },
+    deviceOnlineWebsocketonmessage: function(e) {
+      this.onlineDevice = JSON.parse(e.data)
+      if (this.tableData !== null) {
+        this.tableData.forEach(item => {
+          const mac = this.onlineDevice.filter(p => p.toLowerCase() === item.eth_mac.toLowerCase())[0]
+          item.online_state = (mac !== undefined && mac !== null) ? '在线' : '离线'
+        })
+        const tableData = [...this.tableData]
+        this.$set(this, 'tableData', tableData)
+      }
+    },
+    deviceOnlineWebsocketclose: function(e) {
+      console.log('connection closed (' + e.code + ')')
+    },
+    /** 选择行变化时,记录选中的行数据 */
+    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
+        response.data.forEach(item => {
+          if (this.onlineDevice.length > 0) {
+            const mac = this.onlineDevice.filter(p => p.toLowerCase() === item.eth_mac.toLowerCase())[0]
+            // console.log('在线设备1', mac)
+            if (mac !== undefined && mac !== null) {
+              item['online_state'] = this.$t('deviceManage.connectTrue')
+            } else {
+              item['online_state'] = this.$t('deviceManage.connectFalse')
+            }
+          } else {
+            item['online_state'] = this.$t('deviceManage.connectFalse')
+          }
+        })
+        this.tableData = response.data
+        this.pageData = {
+          page_no: response.page_no,
+          page_size: response.page_size,
+          data_total: response.data_total
+        }
+        this.$nextTick(() => {
+          const node = this.gridApi.getDisplayedRowAtIndex(0)
+          if (node !== null && node !== undefined) {
+            node.setSelected(true)
+          }
+        })
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    /** 新增 提交表单 */
+    handlerFormSubmit(formName) {
+      if (this.deviceInfo.member_id === null || this.deviceInfo.member_id === '') {
+        this.$message.info(this.$t('watch.choiceUser'))
+        return
+      }
+      if (this.deviceInfo.member_id === this.member_id) {
+        this.$message.info(this.$t('watch.doNothing'))
+        return
+      }
+      const params = this.MixinClone(this.deviceInfo)
+      const sendData = {
+        member_id: params.member_id,
+        device_type: params.device_type,
+        status: 1
+      }
+      this.formshow = false
+      const _this = this
+      API_Device.update(params.id, sendData).then(res => {
+        _this.$message.success(_this.$t('action.editSuccess'))
+        _this.member_id = _this.deviceInfo.member_id
+        _this.getList()
+      })
+    },
+    /** 处理搜索 */
+    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)
+    },
+    formatterName(params) {
+      if (params.value && params.data.role_name) {
+        return params.value + ' ' + params.data.role_name
+      } else {
+        if (params.value) {
+          return params.value
+        } else if (params.data.role_name) {
+          return this.$t('watch.binding') + params.data.role_name
+        }
+      }
+    },
+    filterModifed(param) {
+      const model = param.api.getFilterModel()
+      // 连接状态不经过服务器过滤
+      delete model.online_state
+      this.params.filter = JSON.stringify(model)
+      this.getList()
+    },
+    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.getList()
+    },
+    formatterSatus(param) {
+      if (param.value === 1) {
+        return '<span style="color:green">' + this.$t('deviceManage.statusTure') + '</span>'
+      } else {
+        return '<span style="color:red">' + this.$t('deviceManage.statusFalse') + '</span>'
+      }
+    },
+    getEmployees() {
+      const _this = this
+      _this.users = []
+      getListByPartId(this.$store.getters.partId).then(res =>{
+        _this.users = res
+      })
+      // clerk_API.listByPartRoleId({ partId: this.$store.getters.partId }).then(res => {
+      //   _this.clerks = res
+      //   console.log('res',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) {
+      //     if (_this.deviceInfo.member_id) {
+      //       res.forEach(item=>{
+      //         if(item.member_id===_this.deviceInfo.member_id){
+      //           _this.member_name = item.clerk_name
+      //         }
+      //       })
+      //       Object.entries(groupData).forEach(item => {
+      //
+      //         if (item[0] === _this.role_name) {
+      //           _this.users.push(item)
+      //         }
+      //       })
+      //     } else {
+      //       _this.users = Object.entries(groupData)
+      //     }
+      //   }
+      // })
+    },
+    huanban(row) {
+      this.formshow = true
+      this.deviceInfo = Object.assign({}, row)
+      this.role_id = this.deviceInfo.role_id
+      this.member_id = this.deviceInfo.member_id
+      this.member_name = this.deviceInfo.member_name
+      this.role_name = this.deviceInfo.role_name
+      this.getEmployees()
+    },
+    fanhui() {
+      this.formshow = false
+    },
+    /** 设备连接状态格式化 **/
+    onlineStateFormatter(params) {
+      if (params.value === '在线') {
+        return '<span style="color:green;">' + this.$t('deviceManage.connectTrue') + '</span>'
+      } else {
+        return '<span style="color:gray;">' + this.$t('deviceManage.connectFalse') + '</span>'
+      }
+    },
+    getLocation(row) {
+      this.deviceId = row.id
+      this.locationShow = true
+    }
+  }
+}
+</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>

+ 3 - 3
src/views/ncs-device/watch_location.vue

@@ -30,9 +30,9 @@
     <div v-if="locationList.length > 0" style="margin-top: 20px;">
       <el-card>
         <div v-for="(item, index) in locationList" :key="index" class="text item">
-          <i class="el-icon-user-solid"></i> {{ this.$t('watch.you') }} <el-tag><i class="el-icon-time"></i>{{ formatterCreateTime(item.create_time )}}</el-tag> 在
+          <i class="el-icon-user-solid"></i> {{ $t('watch.you') }} <el-tag><i class="el-icon-time"></i>{{ formatterCreateTime(item.create_time )}}</el-tag> 在
           <el-tag type="success"><i class="el-icon-location-outline"></i>{{ item.full_name }}</el-tag>
-          {{ this.$t('watch.nearby') }}
+          {{ $t('watch.nearby') }}
         </div>
       </el-card>
     </div>
@@ -156,7 +156,7 @@ export default {
             document.getElementById('myIcon'+data.beacon_device_id).style.display='inline'
             _this.$notify({
               title: data.full_name,
-              message: unixToDate(data.create_time) + this.$t('watch.in') + data.full_name + this.$t('watch.nearby'),
+              message: unixToDate(data.create_time) + _this.$t('watch.in') + data.full_name + _this.$t('watch.nearby'),
               position: 'bottom-right',
               showClose: false,
               duration: 2500