Procházet zdrojové kódy

优化换班及增加下班功能

wenningning před 4 roky
rodič
revize
9573c9dde5

+ 3 - 7
src/views/hospitalFrame/nurse_watch_frame.vue

@@ -35,7 +35,6 @@
      */
      */
 import * as API_hospitalFrame from '@/api/ncs_hospitalFrame'
 import * as API_hospitalFrame from '@/api/ncs_hospitalFrame'
 import * as API_device from '@/api/ncs_device'
 import * as API_device from '@/api/ncs_device'
-import {qingkong} from "@/api/ncs_hospitalFrame";
 
 
 export default {
 export default {
   name: 'FrameGroupEdit',
   name: 'FrameGroupEdit',
@@ -61,11 +60,8 @@ export default {
     }
     }
   },
   },
   watch: {
   watch: {
-    deviceId: function(newval) {
-      console.log('deviceId===', newval)
-    },
-    roleId: function(newval) {
-      console.log('roleId===', newval)
+    roleId: function(old, newval) {
+      this.getFrameByType()
     }
     }
   },
   },
   mounted() {
   mounted() {
@@ -78,7 +74,6 @@ export default {
     this.getGroup()
     this.getGroup()
   },
   },
   methods: {
   methods: {
-
     getGroup() {
     getGroup() {
       const _this = this
       const _this = this
       API_device.getFrameByDeviceId(this.deviceId).then(res => {
       API_device.getFrameByDeviceId(this.deviceId).then(res => {
@@ -198,6 +193,7 @@ export default {
     },
     },
     back() {
     back() {
       this.$router.push({ name: 'nurse_watch' })
       this.$router.push({ name: 'nurse_watch' })
+      this.$emit('fanhui')
     }
     }
   }
   }
 
 

+ 81 - 39
src/views/ncs-device/nurse_watch.vue

@@ -33,28 +33,30 @@
       />
       />
     </ag-grid-layout>
     </ag-grid-layout>
     <!--编辑表单-->
     <!--编辑表单-->
-    <el-dialog v-if="formshow" 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;">
-          <el-form-item label="设备标识码">
-            {{ deviceInfo.eth_mac }}
-          </el-form-item>
-          <el-form-item v-for="(item, index) in nurses" :key="index" :label="item[0]" v-if="item[0] !== '管理员'">
-            <el-radio-group v-model="deviceInfo.member_id">
-              <el-radio v-for="(t, i) in item[1]" :key="i" :label="t.member_id" :disabled="deviceInfo.member_id !== t.member_id && t.device_id !== null">
-                <i class="el-icon-user-solid" style="color: #b59abf;margin-top: 5px" />{{ t.clerk_name }}
-              </el-radio>
-            </el-radio-group>
-          </el-form-item>
-        </el-form>
-      </div>
-      <div v-if="deviceInfo.role_id">
-        <nurse-watch-frame :device-id="deviceInfo.id" :role-id="deviceInfo.role_id" />
-      </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 v-if="formshow" title="编辑" :visible.sync="formshow" width="70%">
+      <el-tabs v-model="activeName">
+        <el-tab-pane label="换   班" name="huan-ban">
+          <el-form label-width="120px" style="min-width: 100%;float:left;">
+            <el-form-item label="设备标识码">
+              {{ deviceInfo.eth_mac }}
+            </el-form-item>
+            <el-form-item v-for="(item, index) in nurses" :key="index" :label="item[0]" v-if="item[0] !== '管理员'">
+              <el-radio-group v-model="deviceInfo.member_id" @change="changeClerk">
+                <el-radio v-for="(t, i) in item[1]" :key="i" :label="t.member_id" :disabled="deviceInfo.member_id !== t.member_id && t.device_id !== null">
+                  <i class="el-icon-user-solid" style="color: #b59abf;margin-top: 5px" />{{ t.clerk_name }}
+                </el-radio>
+              </el-radio-group>
+            </el-form-item>
+            <el-form-item style="margin-top:15px;">
+              <el-button type="primary" @click="handlerFormSubmit('editform')">保存修改</el-button>
+              <el-button v-if="member_id" type="primar" @click="xiaban('editform')">下班</el-button>
+            </el-form-item>
+          </el-form>
+        </el-tab-pane>
+        <el-tab-pane v-if="role_id" label="管理空间" name="watch-frame">
+          <nurse-watch-frame :device-id="deviceInfo.id" :role-id="role_id" @fanhui="fanhui" />
+        </el-tab-pane>
+      </el-tabs>
     </el-dialog>
     </el-dialog>
   </div>
   </div>
 </template>
 </template>
@@ -68,6 +70,7 @@ import * as clerk_API from '@/api/ncs_clerk'
 import ButtonCellRender from '@/components/AgGridCellRender/ButtonCellRender'
 import ButtonCellRender from '@/components/AgGridCellRender/ButtonCellRender'
 import RadioFilter from '@/components/AgGridCustomFilter/RadioFilter'
 import RadioFilter from '@/components/AgGridCustomFilter/RadioFilter'
 import nurseWatchFrame from '@/views/hospitalFrame/nurse_watch_frame'
 import nurseWatchFrame from '@/views/hospitalFrame/nurse_watch_frame'
+import * as API_UserInfo from "@/api/calling-userInfo";
 
 
 export default {
 export default {
   name: 'Index',
   name: 'Index',
@@ -112,7 +115,10 @@ export default {
         { key: '启用', value: 1, color: 'green' },
         { key: '启用', value: 1, color: 'green' },
         { key: '未启用', value: 0, color: 'red' }
         { key: '未启用', value: 0, color: 'red' }
       ],
       ],
-      clerks: []
+      clerks: [],
+      role_id: null,
+      activeName: 'huan-ban',
+      member_id: null
     }
     }
   },
   },
   computed: {
   computed: {
@@ -243,7 +249,8 @@ export default {
         this.formshow = true
         this.formshow = true
         this.deviceInfo = JSON.parse(e.data)
         this.deviceInfo = JSON.parse(e.data)
         this.role_id = this.deviceInfo.role_id
         this.role_id = this.deviceInfo.role_id
-        this.getEmployees()
+        this.member_id = this.deviceInfo.member_id
+        this.getEmployees(this.deviceInfo.role_name)
       }
       }
     },
     },
     websocketclose: function(e) {
     websocketclose: function(e) {
@@ -301,21 +308,41 @@ export default {
         this.$message.info('请选择护士')
         this.$message.info('请选择护士')
         return
         return
       }
       }
+      if (this.deviceInfo.member_id === this.member_id) {
+        this.$message.info('未做任何改变')
+        return
+      }
       const params = this.MixinClone(this.deviceInfo)
       const params = this.MixinClone(this.deviceInfo)
-      const clerk = this.clerks.find(res => res.member_id === params.member_id)
       const sendData = {
       const sendData = {
         id: params.id,
         id: params.id,
         member_id: params.member_id,
         member_id: params.member_id,
         status: 1,
         status: 1,
-        eth_ip: params.eth_ip,
-        eth_ip_port: params.eth_ip_port,
-        role_id: clerk.role_id
+        role_id: this.role_id
       }
       }
+      this.sendMsg(sendData)
+    },
+    xiaban() {
+      this.$confirm('您确定要下班吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        const params = this.MixinClone(this.deviceInfo)
+        const sendData = {
+          id: params.id,
+          member_id: null,
+          status: 1,
+          role_id: this.role_id
+        }
+        this.sendMsg(sendData)
+      })
+    },
+    sendMsg(sendData) {
       this.websock.send(JSON.stringify(sendData))
       this.websock.send(JSON.stringify(sendData))
       this.formshow = false
       this.formshow = false
       const _this = this
       const _this = this
       setTimeout(function() {
       setTimeout(function() {
-        _this.$message.success('分配成功')
+        _this.$message.success('操作成功')
         _this.getList()
         _this.getList()
       }, 1000)
       }, 1000)
     },
     },
@@ -340,12 +367,12 @@ export default {
     },
     },
     formatterName(params) {
     formatterName(params) {
       if (params.value && params.data.role_name) {
       if (params.value && params.data.role_name) {
-        return params.value + params.data.role_name
+        return params.value + ' ' + params.data.role_name
       } else {
       } else {
         if (params.value) {
         if (params.value) {
           return params.value
           return params.value
         } else if (params.data.role_name) {
         } else if (params.data.role_name) {
-          return '未绑定' + params.data.role_name
+          return '未绑定 ' + params.data.role_name
         }
         }
       }
       }
     },
     },
@@ -393,8 +420,9 @@ export default {
         return '<span style="color:red">未启用</span>'
         return '<span style="color:red">未启用</span>'
       }
       }
     },
     },
-    getEmployees() {
+    getEmployees(role_name) {
       const _this = this
       const _this = this
+      _this.nurses = []
       clerk_API.listByPartRoleId({ partId: this.$store.getters.partId }).then(res => {
       clerk_API.listByPartRoleId({ partId: this.$store.getters.partId }).then(res => {
         _this.clerks = res
         _this.clerks = res
         const groupBy = (arr, func) =>
         const groupBy = (arr, func) =>
@@ -404,12 +432,16 @@ export default {
           }, {})
           }, {})
         const groupData = groupBy(res, item => item.role_name)
         const groupData = groupBy(res, item => item.role_name)
         if (Object.entries(groupData).length > 0) {
         if (Object.entries(groupData).length > 0) {
-          _this.nurses = Object.entries(groupData)
-          // Object.entries(groupData).forEach(item => {
-          //   if (item[0] === '护士') {
-          //     _this.nurses = item[1]
-          //   }
-          // })
+          console.log('_this.deviceInfo.member_id===', _this.deviceInfo.member_id)
+          if (_this.deviceInfo.member_id) {
+            Object.entries(groupData).forEach(item => {
+              if (item[0] === role_name) {
+                _this.nurses.push(item)
+              }
+            })
+          } else {
+            _this.nurses = Object.entries(groupData)
+          }
         }
         }
       })
       })
     },
     },
@@ -424,7 +456,17 @@ export default {
       this.formshow = true
       this.formshow = true
       this.deviceInfo = row
       this.deviceInfo = row
       this.role_id = this.deviceInfo.role_id
       this.role_id = this.deviceInfo.role_id
-      this.getEmployees()
+      this.member_id = this.deviceInfo.member_id
+      this.getEmployees(this.deviceInfo.role_name)
+    },
+    changeClerk(e) {
+      const clerk = this.clerks.find(res => res.member_id === e)
+      if (clerk) {
+        this.role_id = clerk.role_id
+      }
+    },
+    fanhui() {
+      this.formshow = false
     }
     }
   }
   }
 }
 }