ソースを参照

优化发送通知

xiaochan 1 年間 前
コミット
419cb22fc8

+ 2 - 2
src/components/cy/message-box/src/cy-message-box.ts

@@ -1,4 +1,4 @@
-//@ts-ignore
+//@ts-nocheck
 import MessageBoxConstructor from './index.vue';
 import {createVNode, render} from "vue";
 import {
@@ -9,7 +9,7 @@ import {
     DeleteFilled
 } from '@element-plus/icons-vue'
 import {IElMessageBox, MessageBoxType} from "./message-box.type";
-import {uuid} from '../../../../utils/getUuid'
+import {uuid} from '@/utils/getUuid'
 
 const iconData = {
     success: {

+ 13 - 2
src/components/cy/message-box/src/index.vue

@@ -15,6 +15,7 @@ import sleep from "@/utils/sleep";
 import {Close} from '@element-plus/icons-vue';
 import {useCompRef} from "@/utils/useCompRef";
 import {uuid} from '@/utils/getUuid';
+import XEUtils from "xe-utils";
 
 const props = defineProps({
   title: {
@@ -26,7 +27,7 @@ const props = defineProps({
     default: true
   },
   message: {
-    type: String,
+    type: [String, Object],
     default: ''
   },
   showInput: {
@@ -105,6 +106,10 @@ const props = defineProps({
   beforeClose: {
     type: Function,
     default: () => true
+  },
+  placeholder: {
+    type: String,
+    default: ''
   }
 })
 
@@ -275,7 +280,12 @@ onMounted(async () => {
                     <component :is="props.showInput ? 'label' : 'p'"
                                v-else
                                :for="inputId">
-                      {{ props.message }}
+                      <template v-if="XEUtils.isString(props.message)">
+                        {{ props.message }}
+                      </template>
+                      <template v-else>
+                        <component :is="props.message"/>
+                      </template>
                     </component>
                   </div>
                   <div v-if="props.showInput" style="padding-top: 15px">
@@ -295,6 +305,7 @@ onMounted(async () => {
                                  :key="item.code"/>
                     </el-select>
                     <el-input v-model="inputValue"
+                              :placeholder
                               size="small"
                               v-else
                               @keydown.prevent.enter="handelClose('confirm')"

+ 2 - 1
src/components/cy/message-box/src/message-box.type.ts

@@ -1,5 +1,5 @@
 export interface MessageBoxType {
-    message?: string;
+    message: string | any;
     title?: string;
     showInput?: boolean;
     type?: 'success' | 'warning' | 'info' | 'error' | 'delete';
@@ -19,6 +19,7 @@ export interface MessageBoxType {
     confirmButtonText?: string,
     showIcon?: boolean,
     beforeClose?: (inputValue: string) => boolean,
+    placeholder?: string
 }
 
 declare type CyMessageClose = { action: 'cancel' | 'confirm' | 'close', value: string }

+ 0 - 1
src/views/hospitalization/zhu-yuan-yi-sheng/shou-shu-shen-qing/src/components/AddShouShuEditor.vue

@@ -139,7 +139,6 @@ const delClick = () => {
   emits('clear')
 }
 
-
 onMounted(() => {
   if (anestheticMode.value.length === 0) {
     maZuiFangShi().then(res => {

+ 72 - 62
src/views/settings/SendNotification.vue

@@ -14,13 +14,18 @@
             </span>
               </div>
             </template>
-            <el-input type="textarea" :rows="3" v-model="param.message" placeholder="在此输入要发送的消息。"></el-input>
-            <div style="height: 10px"></div>
-            <el-input type="number" size="small" v-model="param.refreshDelay" style="width: 150px"
-                      placeholder="不刷新请勿填写"></el-input>&nbsp;秒后刷新全体连接
-            <div style="margin-top: 12px">
-              <el-button type="primary" icon="Upload" @click="beforeSend">发送消息</el-button>
-            </div>
+            <el-input type="textarea"
+                      :rows
+                      @keydown.ctrl.enter="beforeSend"
+                      v-model="param.message"
+                      placeholder="在此输入要发送的消息。(发送快捷键 Ctrl + Enter)"></el-input>
+            <template #footer>
+              <el-button type="primary"
+                         icon="Upload"
+                         @click="beforeSend">
+                发送消息
+              </el-button>
+            </template>
           </el-card>
         </el-col>
         <el-col :span="12">
@@ -28,11 +33,14 @@
             <template #header>
               发送系统更新消息
             </template>
-            <el-input type="textarea" :rows="3" v-model="systemUpdatesMessage"
-                      placeholder="在此输入要发送的消息,如果不填写就是清空消息。"/>
-            <div style="margin-top: 12px">
+            <el-input type="textarea"
+                      @keydown.ctrl.enter="clickSendUpdateMessage"
+                      :rows
+                      v-model="systemUpdatesMessage"
+                      placeholder="在此输入要发送的消息,如果不填写就是清空消息。(发送快捷键 Ctrl + Enter)"/>
+            <template #footer>
               <el-button type="primary" icon="Upload" @click="clickSendUpdateMessage">发送消息</el-button>
-            </div>
+            </template>
           </el-card>
         </el-col>
         <el-col :span="12" style="margin-top: 10px">
@@ -40,11 +48,14 @@
             <template #header>
               发送滚动通知
             </template>
-            <el-input type="textarea" :rows="3" v-model="scrollingMessage"
-                      placeholder="在此输入要发送的消息,如果不填写就是清空消息。"/>
-            <div style="margin-top: 12px">
+            <el-input type="textarea"
+                      :rows
+                      v-model="scrollingMessage"
+                      @keydown.ctrl.enter="clickSendScrollingMessages"
+                      placeholder="在此输入要发送的消息,如果不填写就是清空消息。(发送快捷键 Ctrl + Enter)"/>
+            <template #footer>
               <el-button type="primary" icon="Upload" @click="clickSendScrollingMessages">发送消息</el-button>
-            </div>
+            </template>
           </el-card>
         </el-col>
       </el-row>
@@ -52,57 +63,62 @@
   </el-container>
 </template>
 
-<script setup>
-import {onMounted, ref, computed, reactive} from 'vue'
+<script setup lang="tsx">
+import {onMounted, ref, reactive} from 'vue'
 import {
   getOnlineCount,
   sendMessageToAll,
   sendScrollingMessages,
   sendSystemUpdatesMessage
 } from '@/api/settings/send-notification'
-import {ElMessage, ElMessageBox} from 'element-plus'
+import {ElMessage} from 'element-plus'
 import {getSystemAnnouncement} from "@/api/public-api";
-import {useSystemStore} from "@/pinia/system-store";
+import {CyMessageBox} from "@/components/cy/message-box";
+import XEUtils from "xe-utils";
+import {stringIsBlank} from "@/utils/blank-utils";
+import {xcMessage} from "@/utils/xiaochan-element-plus";
+
 
-const isCollapse = useSystemStore().getCollapse
-const left = computed(() => {
-  return isCollapse.value ? '65px' : '220px'
-})
 const onlineCount = ref(10)
-const param = reactive({
+const param = reactive<{
+  message: null | string,
+  refreshDelay: null | number,
+}>({
   message: null,
   refreshDelay: null,
 })
 
+const rows = 7
+
 const beforeSend = () => {
-  if (!param.message) {
-    ElMessage({
-      message: '消息体不能为空!',
-      type: 'warning',
-      duration: 2500,
-      showClose: true,
-    })
+  if (stringIsBlank(param.message)) {
+    xcMessage.warning('消息体不能为空!')
   } else {
-    ElMessageBox.confirm('确定要发送以下消息吗:' + param.message, '提示', {
-      type: 'info',
-      confirmButtonText: '发送',
-      cancelButtonText: '取消',
-    })
-        .then(() => {
-          sendMessageToAll(param).then(() => {
-            ElMessage({
-              message: '发送成功。',
-              type: 'success',
-              duration: 2500,
-              showClose: true,
-            })
-          })
-        })
-        .catch(() => {
+    CyMessageBox.prompt({
+      title: '是否发送以下消息',
+      message: (
+          <pre class={'pre-css'}>{param.message}</pre>
+      ),
+      inputAllowEmpty: true,
+      placeholder: '刷新页面秒数(不刷新请勿填写)'
+    }).then(({value}) => {
+      if (stringIsBlank(value)) {
+        param.refreshDelay = null;
+      } else {
+        param.refreshDelay = XEUtils.toNumber(value)
+      }
+      sendMessageToAll(param).then(() => {
+        ElMessage({
+          message: '发送成功。',
+          type: 'success',
+          duration: 2500,
+          showClose: true,
         })
+      })
+    }).catch(() => {
+    })
   }
 }
-const dialogVisible = true
 
 const systemUpdatesMessage = ref('')
 const clickSendUpdateMessage = () => {
@@ -119,8 +135,8 @@ onMounted(() => {
     onlineCount.value = res
   })
   getSystemAnnouncement().then((res) => {
-    systemUpdatesMessage.value = res.systemUpdatesMessage
-    scrollingMessage.value = res.scrollingMessages
+    systemUpdatesMessage.value = res['systemUpdatesMessage']
+    scrollingMessage.value = res['scrollingMessages']
   })
 })
 
@@ -133,17 +149,11 @@ onMounted(() => {
   align-items: center;
 }
 
-
-/* 去掉input number的上下箭头 */
-:deep(input::-webkit-outer-spin-button) {
-  -webkit-appearance: none !important;
-}
-
-:deep(input::-webkit-inner-spin-button) {
-  -webkit-appearance: none !important;
-}
-
-:deep(input[type='number']) {
-  -moz-appearance: textfield !important;
+.pre-css {
+  margin-top: 16px;
+  font-size: 16px;
+  font-weight: bold;
+  color: #303133;
+  white-space: pre-wrap;
 }
 </style>