فهرست منبع

1、空间设备开发;
2、首页优化;
3、其他优化

wennn 3 سال پیش
والد
کامیت
4a45273373

+ 5 - 2
languages/zh-CN.js

@@ -127,7 +127,8 @@ module.exports = {
     uploadVersionCode: '版本信息',
     inputUploadVersionCode: '请输入版本信息',
     uploadVersionCodeMsg: '版本信息不能为空',
-    initialing: '正在初始化,请稍后...'
+    initialing: '正在初始化,请稍后...',
+    deviceFrame: '设备空间'
   },
   member: {
     face: '头像',
@@ -777,7 +778,8 @@ module.exports = {
     menuManage: '菜单管理',
     organization: '组织机构',
     roleManage: '角色管理',
-    debugging485: '485调试'
+    debugging485: '485调试',
+    deviceFrame: '设备空间'
   },
   deviceType: {
     NURSE_HOST: '护士主机',
@@ -841,6 +843,7 @@ module.exports = {
     ENTRACEGUARD: '门禁',
     CHANNELIM: '频道留言',
     LOCATION: '定位',
+    PHONE: '电话',
     UNKNOWN: '未知'
   },
   relativeNameType: {

+ 25 - 0
src/api/ncs_device.js

@@ -194,3 +194,28 @@ export function get485DeviceAndFrame(partId, tid) {
   })
 }
 
+export function getDeviceByHasNoFrameId(partId) {
+  return request({
+    url: `/ncs/device/get_device_by_has_no_frame_id/${partId}`,
+    method: 'GET',
+    loading: false
+  })
+}
+export function updateDevicesFrame(data) {
+  return request({
+    url: `/ncs/device/update_devices_frame`,
+    method: 'POST',
+    data: data,
+    headers: { 'Content-Type': 'application/json' },
+    loading: true
+  })
+}
+
+export function delAllDeviceFrame(id, parentId) {
+  return request({
+    url: `/ncs/device/del_all_device_frame/${id}/${parentId}`,
+    method: 'GET',
+    loading: true
+  })
+}
+

+ 8 - 0
src/api/ncs_hospitalFrame.js

@@ -167,3 +167,11 @@ export function getListByDeviceId(id) {
     loading: false
   })
 }
+// 获取空间及其设备
+export function getFrameAndDevice(id) {
+  return request({
+    url: `/ncs/frame/get_frame_and_device/${id}`,
+    method: 'GET',
+    loading: false
+  })
+}

+ 7 - 1
src/api/ncs_interaction.js

@@ -46,4 +46,10 @@ export function getLogTable(params) {
     params
   })
 }
-
+export function getListByHonePage(partId) {
+  return request({
+    url: `/ncs/interaction/getListByHonePage/${partId}`,
+    method: 'get',
+    loading: true
+  })
+}

+ 13 - 0
src/router/index.js

@@ -640,6 +640,19 @@ export const adminRoutes = [
       }
     ]
   },
+  {
+    path: '/device-frame',
+    component: Layout,
+    children: [
+      {
+        path: 'device-frame',
+        component: () => import('@/views/ncs-orginazition/device-frame'),
+        name: 'device-frame',
+        meta: { title: i18n.t('tab.deviceFrame'), icon: 'nested', noCache: true },
+        hidden: true
+      }
+    ]
+  },
 
   { path: '*', redirect: '/404', hidden: true }
 ]

+ 10 - 7
src/views/dashboard/calling/index.vue

@@ -134,6 +134,7 @@ import * as API_task from '@/api/ncs_task'
 import * as API_Remark from '@/api/ncs_remark'
 import { unixToDate } from '@/utils/Foundation'
 import * as API_CallingList from '@/api/ncs_interaction'
+import {getListByHonePage} from "@/api/ncs_interaction";
 const uiVersion = domain.uiVersion
 
 export default {
@@ -226,13 +227,13 @@ export default {
       })
     },
     getCallingHistoryList() {
-      const param = this.MixinClone(this.params)
-      param.page_size = 10
-      param.fixedCondition = ' part_id=' + this.$store.getters.partId
-      param.sort = 'id'
+      // const param = this.MixinClone(this.params)
+      // param.page_size = 10
+      // param.fixedCondition = ' part_id=' + this.$store.getters.partId
+      // param.sort = 'id'
       const _this = this
-      API_CallingList.getList(param).then(response => {
-        _this.callingHistoryList = response.data
+      API_CallingList.getListByHonePage(this.$store.getters.partId).then(response => {
+        _this.callingHistoryList = response
       })
     },
     forDate(date) {
@@ -249,7 +250,9 @@ export default {
       this.$router.push({ name: path })
     },
     formatterFromName(row, column, cellValue) {
-      if (!row.outerior_action && row.relative_id === null) {
+      console.log(!row.outerior_action, row.relative_name, !row.outerior_action && row.relative_name === null)
+      if (!row.outerior_action && row.relative_name === null) {
+        console.log('row===', row.id)
         let named = ''
         if (row.from_frame_full_name && row.from_member_name) {
           named = row.from_frame_full_name + row.from_member_name

+ 8 - 5
src/views/ncs-chars/index.vue

@@ -63,11 +63,11 @@
             </el-row>
           </div>
           <div class="table-wrapper">
-            <el-table :data="tableData" stripe border style="width: 100%">
+            <el-table :data="tableData" :default-sort = "{prop: 'count', order: 'descending'}" stripe border style="width: 100%">
               <el-table-column type="index" width="100" :label="this.$t('action.index')" align="center" />
               <el-table-column prop="name" :label="this.$t('interaction.actionType')" min-width="130" align="center" />
-              <el-table-column prop="count" :label="this.$t('interaction.actionTime')" min-width="130" align="center" />
-              <el-table-column prop="noCount" :label="this.$t('interaction.unSuccessTime')" min-width="130" align="center" />
+              <el-table-column prop="count" :label="this.$t('interaction.actionTime')" min-width="130" align="center" sortable />
+              <el-table-column prop="noCount" :label="this.$t('interaction.unSuccessTime')" min-width="130" align="center" sortable />
             </el-table>
           </div>
           <el-card shadow="always" style="margin-top: 15px;">
@@ -99,6 +99,9 @@
       <el-tab-pane name="SOS">
         <span slot="label"><i class="el-icon-sunrise-1" /> {{ this.$t('tcpType.SOS') }}</span>
       </el-tab-pane>
+      <el-tab-pane name="PHONE">
+        <span slot="label"><i class="el-icon-mobile-phone" /> {{ this.$t('tcpType.PHONE') }}</span>
+      </el-tab-pane>
     </el-tabs>
     <div v-if="sssparams.type">
       <el-card shadow="always" style="margin-top: 15px;">
@@ -166,12 +169,12 @@ export default {
       shopId: -1,
       shopInfo: {},
       partTotal: {
-        lx: 6,
+        lx: 7,
         count: 0,
         noCount: 0
       },
       tableData: [],
-      dataList: [this.$t('tcpType.VOICE'), this.$t('tcpType.VIDEO'), this.$t('tcpType.IM'), this.$t('tcpType.EVENT'), this.$t('tcpType.ENTRACEGUARD'), this.$t('tcpType.SOS')],
+      dataList: [this.$t('tcpType.VOICE'), this.$t('tcpType.VIDEO'), this.$t('tcpType.IM'), this.$t('tcpType.EVENT'), this.$t('tcpType.ENTRACEGUARD'), this.$t('tcpType.SOS'), this.$t('tcpType.PHONE')],
       activeName: 'ALL',
       userActionList: [],
       activeName2: 'user'

+ 525 - 0
src/views/ncs-orginazition/device-frame.vue

@@ -0,0 +1,525 @@
+<template>
+  <el-container style="height:850px; border: 1px solid #eee">
+    <el-aside width="25%" style="background-color: rgb(255,255,255);border: 1px solid #eee">
+      <div>
+        <el-input v-model="searchDeviceStr" placeholder="输入搜索" clearable @change="clickSearch">
+          <el-select v-model="frameType" slot="prepend" placeholder="请选择设备位置级别" @change="changeFrameType">
+            <el-option label="全部" value="all"></el-option>
+            <el-option label="科室" value="part"></el-option>
+            <el-option label="房间" value="room"></el-option>
+            <el-option label="床位" value="bed"></el-option>
+          </el-select>
+          <el-button slot="append" size="mini" icon="el-icon-search" @click="clickSearch"></el-button>
+        </el-input>
+      </div>
+      <draggable class="selected-list2" tag="ul" v-model="changeDeviceList" :options="dragOptions" @start="allMove" @end="onEnd" @remove="allRemove" style="min-height: 700px;font-size: 14px;">
+        <div v-for="(item, index) in changeDeviceList" :key="index" class="item">
+          {{item.code}}    <span style="font-size: 12px;color: rgba(174,128,158,0.23)">{{ formotType(item.device_type) }}</span>
+        </div>
+      </draggable>
+    </el-aside>
+
+    <el-container>
+      <el-header style="font-size: 12px; margin-top: 10px;">
+        <div style="text-align: left; float: left">
+          <el-button type="success" @click="onekeySave" :loading="isSave">一键分配</el-button>
+          <el-button type="danger" plain @click="onekeyDel">一键重置</el-button>
+        </div>
+        <div style="text-align: right">
+          <el-switch v-model="openType" active-text="折叠显示" inactive-text="卡片显示" style="margin-right: 20px;"></el-switch>
+          <el-button type="success" icon="el-icon-check" :loading="isSave" :disabled="needUpdateList.length === 0" @click="saveUpdate">保存</el-button>
+          <el-button icon="el-icon-close" :disabled="needUpdateList.length === 0" @click="canle">取消</el-button>
+        </div>
+      </el-header>
+
+      <el-main>
+        <!--        科室start-->
+        <el-row>
+          <el-col :span="24">
+            <el-card class="box-card" shadow="hover" :body-style="{ padding: '0px', margin: '0px' }">
+              <div slot="header" class="clearfix">
+                <span>{{ framesAndDevices.full_name }}-{{ framesAndDevices.device_size }}台设备</span>
+                <!--                <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>-->
+              </div>
+              <div :class="boolPart ? 'mybg' : ''" style="width: 100%; height: 100%; padding: 15px 0px 10px 0px; min-height: 80px;">
+                <draggable style="margin: 0;"  class="selected-list-part" tag="ul" v-model="framesAndDevices.device_dos" :options="dragOptions" :disabled="boolPart"
+                           @start="partMove" @end="onEnd" @remove="otherRemove" @change="changeAllList">
+                  <el-tag v-for="(item, index) in framesAndDevices.device_dos" :key="index" :type="getColor(index)" style="margin-bottom: 5px;"> {{ item.code }}</el-tag>
+                </draggable>
+              </div>
+
+            </el-card>
+          </el-col>
+        </el-row>
+        <!--        科室end-->
+
+
+        <el-collapse v-if="openType">
+          <el-collapse-item v-for="(item, index) in framesAndDevices.children" :key="index" style="margin-bottom: 10px;">
+<!--            <draggable :class="boolRoom ? 'mybg' : ''" slot="title" style="margin: 0;width: 100%;min-height: 50px;" class="selected-list" tag="span" v-model="item.device_dos" :options="dragOptions" :disabled="boolRoom">-->
+<!--              <div>-->
+<!--                <span style="font-size: 15px;margin-right: 15px">{{ item.full_name }}w</span>-->
+<!--                <el-tag v-for="(t, i) in item.device_dos" :key="i" :type="getColor(i)" style="margin-bottom: 5px;"> {{ t.name }}</el-tag>-->
+<!--              </div>-->
+<!--            </draggable>-->
+
+
+              <div slot="title" style="width: 100%;min-height: 50px;">
+                <div style="font-size: 15px;float: left;width: 10%;" :class="boolRoom ? 'mybg' : ''">{{ item.full_name }}</div>
+                <div :class="boolRoom ? 'mybg' : ''"  style="margin: 0;float: left;width: 85%;">
+                  <div v-if="item.device_dos.length === 0" style="float: left;height: 100%"><el-tag effect="plain" type="info">房间无设备</el-tag></div>
+                  <draggable class="selected-list" v-model="item.device_dos" tag="div" :options="dragOptions" :disabled="boolRoom" @start="roomMove" @end="onEnd" @remove="otherRemove">
+                    <el-tag v-for="(t, i) in item.device_dos" :key="i" :type="getColor(i)" style="margin-bottom: 5px;"> {{ t.name }}</el-tag>
+                  </draggable>
+                </div>
+              </div>
+            <div>
+              <el-card v-for="(t, i) in item.children" :key="i" class="box-card" shadow="hover" :body-style="{ padding: '0px', margin: '0px' }">
+                  <div class="clearfix" :class="boolBed ? 'mybg' : ''" style="margin: 0;padding: 15px 0px 10px 0px">
+                    <div style="font-size: 15px;float: left;width: 10%;margin-left: 5px;">{{ t.full_name }}</div>
+                    <div style="margin: 0;float: left;width: 85%;">
+                      <div v-if="t.device_dos.length === 0" style="float: left;height: 100%"><el-tag effect="plain" type="info">床位无设备</el-tag></div>
+                      <draggable class="selected-list" tag="div" v-model="t.device_dos" :options="dragOptions" :disabled="boolBed" style="height: 100%" @start="bedMove" @end="onEnd" @remove="otherRemove">
+                        <el-tag v-for="(tt, ii) in t.device_dos" :key="ii" :type="getColor(ii)"> {{ tt.name }}</el-tag>
+                      </draggable>
+                    </div>
+                  </div>
+              </el-card>
+            </div>
+          </el-collapse-item>
+        </el-collapse>
+
+        <el-row v-if="!openType" v-for="(item, index) in framesAndDevices.children" :key="index">
+          <el-col :span="24">
+            <el-card class="box-card" shadow="hover">
+              <!--              房间start-->
+              <div slot="header" :class="boolRoom ? 'mybg' : ''" class="clearfix" style="width: 100%;min-height: 40px;">
+                <div style="font-size: 15px;float: left;width: 10%;margin-top: 5px;">{{ item.full_name }}</div>
+                <div style="margin: 0;float: left;width: 85%;">
+                  <div v-if="item.device_dos.length === 0" style="float: left;height: 100%"><el-tag effect="plain" type="info">房间无设备</el-tag></div>
+                  <draggable class="selected-list" v-model="item.device_dos" tag="div" :options="dragOptions" :disabled="boolRoom" @start="roomMove" @end="onEnd" @remove="otherRemove">
+                    <el-tag v-for="(t, i) in item.device_dos" :key="i" :type="getColor(i)" style="margin-bottom: 5px;"> {{ t.name }}</el-tag>
+                  </draggable>
+                </div>
+              </div>
+              <!--              房间end-->
+              <!--              床位start-->
+              <div>
+                <el-card v-for="(t, i) in item.children" :key="i" class="box-card" shadow="hover" :body-style="{ padding: '0px', margin: '0px' }">
+                  <div class="clearfix" :class="boolBed ? 'mybg' : ''" style="margin: 0;padding: 15px 0 10px 0;min-height: 40px">
+                    <div style="font-size: 15px;float: left;width: 10%;margin: 5px">{{ t.full_name }}</div>
+                    <div style="margin: 0;float: left;width: 85%;">
+                      <div v-if="t.device_dos.length === 0" style="float: left;height: 100%"><el-tag effect="plain" type="info">床位无设备</el-tag></div>
+                      <draggable class="selected-list" tag="div" v-model="t.device_dos" :options="dragOptions" :disabled="boolBed" style="height: 100%" @start="bedMove" @end="onEnd" @remove="otherRemove">
+                        <el-tag v-for="(tt, ii) in t.device_dos" :key="ii" :type="getColor(ii)"> {{ tt.name }}</el-tag>
+                      </draggable>
+                    </div>
+                  </div>
+                </el-card>
+<!--                <el-card v-for="(t, i) in item.children" :key="i" class="box-card" shadow="hover">-->
+<!--                  <div class="clearfix">-->
+<!--                    <span>{{ t.full_name }}</span>-->
+<!--                    <el-tag v-for="(tt, ii) in t.device_dos" :key="ii" :type="getColor(ii)"> {{ tt.name }}</el-tag>-->
+<!--                  </div>-->
+<!--                </el-card>-->
+              </div>
+              <!--              床位end-->
+            </el-card>
+          </el-col>
+        </el-row>
+      </el-main>
+    </el-container>
+  </el-container>
+</template>
+
+<script>
+import draggable from 'vuedraggable'
+import { DEVICE_TYPE } from '@/utils/enum/DeviceTypeEnum'
+import { delAllDeviceFrame, getDeviceByHasNoFrameId, updateDevicesFrame } from '@/api/ncs_device'
+import { getFrameAndDevice } from '@/api/ncs_hospitalFrame'
+
+export default {
+  name: 'device-frame',
+  components: { draggable },
+  data() {
+    return {
+      changeDeviceList: [],
+      deviceList: [],
+      framesAndDevices: {
+        full_name: null
+      },
+      tagColors: ['', 'success', 'info', 'warning', 'danger'],
+      openType: true,
+      frameType: 'all',
+      boolPart: false,
+      boolRoom: false,
+      boolBed: false,
+      needUpdateList: [],
+      searchDeviceStr: '',
+      isSave: false,
+      originalDevices: [],
+      originalFrames: []
+    }
+  },
+  computed: {
+    dragOptions() {
+      return {
+        animation: 0,
+        group: "description",
+        ghostClass: "ghost"
+      };
+    }
+  },
+  mounted() {
+    console.log(this.$route.params.id, this.$route.params.parent_id)
+    if (this.$route.params.id) {
+      this.API_getDeviceList()
+      this.API_getFrameAndDevice()
+    }
+  },
+  methods: {
+    API_getDeviceList() {
+      const _this = this
+      getDeviceByHasNoFrameId(this.$route.params.parent_id).then(res => {
+        _this.deviceList = res
+        _this.changeDeviceList = res
+        _this.originalDevices = this.MixinClone(res)
+      })
+    },
+    API_getFrameAndDevice() {
+      const _this = this
+      getFrameAndDevice(this.$route.params.id).then(res => {
+        _this.framesAndDevices = res
+        _this.originalFrames = this.MixinClone(res)
+        console.log(res)
+      })
+    },
+    getColor(index) {
+      return this.tagColors[index % this.tagColors.length]
+    },
+    changeFrameType(e) {
+      if (e === 'part') {
+        this.changeDeviceList = this.returnPartList()
+        let list = this.returnCurrencyList()
+        this.changeDeviceList.push.apply(this.changeDeviceList, list)
+      } else if (e === 'room') {
+        this.changeDeviceList = this.returnRoomList()
+        let list = this.returnCurrencyList()
+        this.changeDeviceList.push.apply(this.changeDeviceList, list)
+      } else if (e === 'bed') {
+        this.changeDeviceList = this.returnBedList()
+        let list = this.returnCurrencyList()
+        this.changeDeviceList.push.apply(this.changeDeviceList, list)
+      } else {
+        this.changeDeviceList = this.deviceList
+      }
+    },
+    // 返回科室级设备
+    returnPartList() {
+      return this.deviceList.filter(item => item.device_type === 1 || item.device_type === 2 || item.device_type === 5 || item.device_type === 6 || item.device_type === 7
+          || item.device_type === 8 || item.device_type === 9 || item.device_type === 11 || item.device_type === 16 || item.device_type === 17 || item.device_type === 18
+          || item.device_type === 19 || item.device_type === 20 || item.device_type === 31)
+    },
+    // 返回房间级设备
+    returnRoomList() {
+      return this.deviceList.filter(item => item.device_type === 3 || item.device_type === 13 || item.device_type === 14 || item.device_type === 22)
+    },
+    // 返回床位级设备
+    returnBedList() {
+      return this.deviceList.filter(item => item.device_type === 4 || item.device_type === 10 || item.device_type === 12 || item.device_type === 15 || item.device_type === 21
+          || item.device_type === 28 || item.device_type === 29 || item.device_type === 32)
+    },
+    // 返回通用设备
+    returnCurrencyList() {
+      return this.deviceList.filter(item => item.device_type === 23 || item.device_type === 24 || item.device_type === 25 || item.device_type === 26 || item.device_type === 27 || item.device_type === 30)
+    },
+    clickSearch() {
+      this.changeDeviceList = this.deviceList.filter(item => item.code.indexOf(this.searchDeviceStr) !== -1)
+    },
+    allMove(e) {
+      let dragInEl = e.to['className']
+      console.log(dragInEl, e.oldIndex)
+      const type = this.changeDeviceList[e.oldIndex].device_type
+      if (type === 1 || type === 2 || type === 5 || type === 6 || type === 7
+          || type === 8 || type === 9 || type === 11 || type === 16 || type === 17 || type === 18
+          || type === 19 || type === 20 || type === 31) { // 是科室级设备
+        this.boolRoom = true
+        this.boolBed = true
+      } else if (type === 3 || type === 13 || type === 14 || type === 22) { // 是房间级设备
+        this.boolPart = true
+        this.boolBed = true
+      } else if (type === 4 || type === 10 || type === 12 || type === 15 || type === 21 || type === 28 || type === 29 || type === 32) {
+        this.boolPart = true
+        this.boolRoom = true
+      }
+      // const relatedElement = relatedContext.element
+      // const draggedElement = draggedContext.element
+      // console.log(relatedElement, draggedElement)
+
+      // return (
+      //     (!relatedElement || !relatedElement.fixed) && !draggedElement.fixed
+      // );
+    },
+    partMove(e) {
+      this.boolRoom = true
+      this.boolBed = true
+    },
+    roomMove(e) {
+      this.boolPart = true
+      this.boolBed = true
+    },
+    bedMove(e) {
+      this.boolPart = true
+      this.boolRoom = true
+    },
+    onEnd(e) {
+      this.boolPart = false
+      this.boolRoom = false
+      this.boolBed = false
+    },
+    // 全部设备的移动
+    allRemove(e) {
+      console.log('onRemove===', e)
+      console.log('e.oldIndex===', e.oldIndex, e.newIndex)
+      const data = e.item['_underlying_vm_']
+      const index = this.deviceList.findIndex(item => item.id === data.id)
+      const i = this.needUpdateList.findIndex(item => item.id === data.id)
+      if (i === -1) {
+        this.needUpdateList.push(this.deviceList[index])
+      } else {
+        this.needUpdateList.splice(i, 1)
+        this.needUpdateList.push(this.deviceList[index])
+      }
+      this.deviceList.splice(index, 1)
+    },
+    // 除全部设备外的移动
+    otherRemove(e) {
+      const data = e.item['_underlying_vm_']
+      const myclass = e.to['className']
+      if (myclass === 'selected-list2') {
+        this.deviceList.push(data)
+      }
+      const i = this.needUpdateList.findIndex(item => item.id === data.id)
+      if (i === -1) {
+        this.needUpdateList.push(data)
+      } else {
+        this.needUpdateList.splice(i, 1)
+        this.needUpdateList.push(data)
+      }
+    },
+    changeAllList(e) {
+      console.log('11111=', e)
+    },
+    // deviceType转化
+    formotType(value) {
+      return DEVICE_TYPE.getDescFromValue(value)
+    },
+    // 保存修改
+    saveUpdate() {
+      this.isSave = true
+      console.log(this.needUpdateList)
+      let saveData = []
+      this.framesAndDevices.device_dos.forEach(item => { // 科室需要修改的设备
+        this.needUpdateList.forEach((t, i) => {
+          if (item.id === t.id) {
+            const data = {
+              id: t.id,
+              frame_id: this.framesAndDevices.id,
+              part_id: this.framesAndDevices.part_id,
+              // frame_name: this.framesAndDevices.full_name,
+              // code: t.code
+            }
+            saveData.push(data)
+            this.needUpdateList.splice(i, 1)
+          }
+        })
+      })
+      console.log(this.needUpdateList.length)
+      console.log(saveData)
+      this.framesAndDevices.children.forEach(tt => { // 房间需要修改的设备
+        tt.device_dos.forEach(item => {
+          this.needUpdateList.forEach((t, i) => {
+            if (item.id === t.id) {
+              const data = {
+                id: t.id,
+                frame_id: tt.id,
+                part_id: this.framesAndDevices.part_id,
+                // frame_name: tt.full_name,
+                // code: t.code
+              }
+              saveData.push(data)
+              this.needUpdateList.splice(i, 1)
+            }
+          })
+        })
+        tt.children.forEach(ttt => { // 床位需要修改的设备
+          ttt.device_dos.forEach(item => {
+            this.needUpdateList.forEach((t, i) => {
+              if (item.id === t.id) {
+                const data = {
+                  id: t.id,
+                  frame_id: ttt.id,
+                  part_id: this.framesAndDevices.part_id,
+                  // frame_name: ttt.full_name,
+                  // code: t.code
+                }
+                saveData.push(data)
+                this.needUpdateList.splice(i, 1)
+              }
+            })
+          })
+        })
+      })
+      this.needUpdateList.forEach(item => { // 从科室、房间、床位移动到需分配的设备
+        this.deviceList.forEach(t => {
+          if (item.id === t.id) {
+            const data = {
+              id: t.id,
+              frame_id: null,
+              part_id: this.$route.params.parent_id,
+              // frame_name: ttt.full_name,
+              // code: t.code
+            }
+            saveData.push(data)
+          }
+        })
+      })
+      console.log(this.needUpdateList.length)
+      this.needUpdateList = []
+      updateDevicesFrame(saveData).then(res => {
+        this.isSave = false
+        this.API_getDeviceList()
+        this.API_getFrameAndDevice()
+        this.$message.success('保存成功!')
+      })
+    },
+    // 取消
+    canle() {
+      this.needUpdateList = []
+      this.frameType = 'all'
+      this.searchDeviceStr = ''
+      this.deviceList = this.changeDeviceList = this.MixinClone(this.originalDevices)
+      this.framesAndDevices = this.MixinClone(this.originalFrames)
+    },
+    // 一键分配
+    onekeySave() {
+      this.isSave = true
+      if (this.deviceList.length === 0) {
+        this.isSave = false
+        this.$message.info('没有空余分配的设备!')
+        return
+      }
+      this.canle()
+      console.log(this.framesAndDevices.device_size, this.framesAndDevices.device_dos.length)
+      const partList = this.returnPartList()
+      partList.forEach(item => {
+        const index = this.deviceList.findIndex(t => t.id === item.id)
+        this.deviceList.splice(index, 1)
+        this.framesAndDevices.device_dos.push(item)
+        this.needUpdateList.push(item)
+      })
+      // let item
+      // for (let i = 0; i < this.deviceList.length; i++) {
+      //   item = this.deviceList[i]
+      //   if (item.device_type === 1 || item.device_type === 2 || item.device_type === 5 || item.device_type === 6 || item.device_type === 7
+      //       || item.device_type === 8 || item.device_type === 9 || item.device_type === 11 || item.device_type === 16 || item.device_type === 17 || item.device_type === 18
+      //       || item.device_type === 19 || item.device_type === 20 || item.device_type === 31) {
+      //     this.framesAndDevices.device_dos.push(item)
+      //     this.deviceList.splice(i--, 1)
+      //   }
+      // }
+      if (this.framesAndDevices.device_size > this.framesAndDevices.device_dos.length) {
+        this.isSave = false
+        this.$message.info('房间及床位有设备,只能自动分配科室级设备!')
+          // let item
+          // while(i--){
+          //   item = this.deviceList[i]
+          //   if (item.device_type === 1 || item.device_type === 2 || item.device_type === 5 || item.device_type === 6 || item.device_type === 7
+          //       || item.device_type === 8 || item.device_type === 9 || item.device_type === 11 || item.device_type === 16 || item.device_type === 17 || item.device_type === 18
+          //       || item.device_type === 19 || item.device_type === 20  || item.device_type === 31) {
+          //     this.framesAndDevices.device_dos.push(item)
+          //     this.deviceList.splice(i,1)
+          //   }
+          // }
+          return
+      }
+      this.$message.info('开始自动分配!')
+      const roomList = this.returnRoomList()
+      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 roomGroupData = groupBy(roomList, item => item.device_type)
+      Object.entries(roomGroupData).forEach(item => {
+        this.framesAndDevices.children.forEach((tt, ii) => {
+          if (item[1][ii]) {
+            tt.device_dos.push(item[1][ii])
+            this.needUpdateList.push(item[1][ii])
+            const index = this.deviceList.findIndex(ttt => ttt.id === item[1][ii].id)
+            this.deviceList.splice(index, 1)
+          }
+        })
+      })
+      const bedList = this.returnBedList()
+      const bedGroupData = groupBy(bedList, item => item.device_type)
+      let a = 0
+      Object.entries(bedGroupData).forEach(item => {
+        this.framesAndDevices.children.forEach((t, i) => {
+          t.children.forEach((tt, ii) => {
+            if (item[1][a]) {
+              tt.device_dos.push(item[1][a])
+              this.needUpdateList.push(item[1][a])
+              const index = this.deviceList.findIndex(ttt => ttt.id === item[1][a].id)
+              this.deviceList.splice(index, 1)
+            }
+            a++
+          })
+        })
+      })
+      this.isSave = false
+      this.changeDeviceList = this.deviceList
+      this.$alert('自动分配已完成,全级别设备需手动分配,分配完成后请点击【保存】!', '提示', {
+        confirmButtonText: '确定',
+        callback: action => {
+          console.log('确定')
+        }
+      })
+    },
+    // 一键重置
+    onekeyDel() {
+      const _this = this
+      this.$confirm('确定要重置所有设备吗?', this.$t('action.tips'), {
+        confirmButtonText: this.$t('action.yes'),
+        cancelButtonText: this.$t('action.cancel'),
+        type: 'warning'
+      }).then(() => {
+        delAllDeviceFrame(_this.$route.params.id, _this.$route.params.parent_id).then(res => {
+          _this.$message.success('已成功重置!')
+          _this.canle()
+          _this.API_getDeviceList()
+          _this.API_getFrameAndDevice()
+        })
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.mybg {
+  background-color: rgba(70, 72, 73, 0.39)
+}
+.selected-list2 :hover{
+  cursor: pointer;
+}
+.el-input .el-select  {
+  width: 75px;
+}
+.el-input .el-button {
+  width: 40px;
+}
+.input-with-select .el-input-group__prepend {
+  background-color: #fff;
+}
+</style>

+ 65 - 26
src/views/ncs-orginazition/index.vue

@@ -104,10 +104,11 @@ import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
 import * as API_PartInfo from '@/api/ncs_partInfo'
 import { unix2Date } from '@/utils/Foundation'
 import ButtonCellRender from '../../components/AgGridCellRender/ButtonCellRender'
+import ButtonCellRenderList from '@/components/AgGridCellRender/ButtonCellRenderList'
 import { initData } from '@/api/initialize'
 export default {
   name: 'Index',
-  components: { ButtonCellRender },
+  components: { ButtonCellRender, ButtonCellRenderList },
   data() {
     return {
       tableData: [],
@@ -209,37 +210,71 @@ export default {
         newRowsAction: 'keep',
         flex: 1
       }},
-      { headerName: this.$t('action.edit'), field: 'shop_id',
-        cellRendererFramework: 'ButtonCellRender',
-        cellRendererParams: {
-          onClick: this.handEdit,
-          label: this.$t('action.edit'),
-          buttonType: 'primary',
-          buttonSize: 'mini'
-        },
-        filter: false,
-        pinned: 'right',
-        lockPinned: true,
-        width: 100,
-        resizable: false,
-        sortable: false },
-      { headerName: this.$t('action.delete'), field: 'shop_id',
-        cellRendererFramework: 'ButtonCellRender',
+      { headerName: this.$t('action.handle'), field: 'id',
+        cellRendererFramework: 'ButtonCellRenderList',
         cellRendererParams: param => {
           return {
-            onClick: this.deleteSingle,
-            label: this.$t('action.delete'),
-            buttonType: 'danger',
-            buttonSize: 'mini',
-            disabled: param.data['member_name'] === 'superadmin' ? true:false
-          }
+            list: [
+              {
+                onClick: this.handEdit,
+                label: this.$t('action.edit'),
+                buttonType: 'primary',
+                buttonSize: 'mini'
+              },
+              {
+                onClick: this.deviceBind,
+                label: this.$t('action.deviceFrame'),
+                buttonType: 'success',
+                buttonSize: 'mini',
+                disabled: param.data['shop_type'] !== '5'
+              },{
+                onClick: this.deleteSingle,
+                label: this.$t('action.delete'),
+                buttonType: 'danger',
+                buttonSize: 'mini',
+                disabled: param.data['member_name'] === 'superadmin'
+              }
+            ]}
         },
+        filter: false,
         pinned: 'right',
         lockPinned: true,
-        width: 100,
+        minWidth: 230,
         resizable: false,
-        filter: false,
-        sortable: false }
+        sortable: false },
+
+
+      // { headerName: this.$t('action.edit'), field: 'shop_id',
+      //   cellRendererFramework: 'ButtonCellRender',
+      //   cellRendererParams: {
+      //     onClick: this.handEdit,
+      //     label: this.$t('action.edit'),
+      //     buttonType: 'primary',
+      //     buttonSize: 'mini'
+      //   },
+      //   filter: false,
+      //   pinned: 'right',
+      //   lockPinned: true,
+      //   width: 100,
+      //   resizable: false,
+      //   sortable: false },
+      // { headerName: this.$t('action.delete'), field: 'shop_id',
+      //   cellRendererFramework: 'ButtonCellRender',
+      //   cellRendererParams: param => {
+      //     return {
+      //       onClick: this.deleteSingle,
+      //       label: this.$t('action.delete'),
+      //       buttonType: 'danger',
+      //       buttonSize: 'mini',
+      //       disabled: param.data['member_name'] === 'superadmin' ? true:false
+      //     }
+      //   },
+      //   pinned: 'right',
+      //   lockPinned: true,
+      //   width: 100,
+      //   resizable: false,
+      //   filter: false,
+      //   sortable: false }
     ]
     this.defaultColDef = {
       filter: 'agTextColumnFilter',
@@ -470,6 +505,10 @@ export default {
       }, 60000)
       _this.$message.info(this.$t('action.initialing'))
       initData()
+    },
+    deviceBind(row) {
+      console.log('--------------------', row.shop_id, row.parent_id)
+      this.$router.push({ name: 'device-frame', params: { id: row.shop_id, parent_id: row.parent_id }})
     }
   }
 }