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