Browse Source

病历必填内容富文本框展示

yanqiliang 2 months ago
parent
commit
2d49a4c41f
1 changed files with 185 additions and 4 deletions
  1. 185 4
      src/pages/entryWrite/page/Entry/medicalRecord/medicalRecord.vue

+ 185 - 4
src/pages/entryWrite/page/Entry/medicalRecord/medicalRecord.vue

@@ -268,8 +268,11 @@
                 </mp-cells>
                 <!-- 信息采集表单 -->
                 <view class="info-collection" v-if="formData.length > 0">
-                    <view class="info-item" v-for="(item, index) in formData" :key="index">
-                        <view class="info-label" :class="{'required': item.state && item.state.includes('required')}">{{ item.label }}</view>
+                    <view class="info-item" :class="{'info-item--required-input': isRequiredInput(item)}" v-for="(item, index) in formData" :key="index">
+                        <view class="info-label" :class="{'required': item.state && item.state.includes('required')}">
+                            {{ item.label }}
+                            <button v-if="isRequiredInput(item) && !isReadonlyField(item)" class="info-expand-button" @tap="openInputEditor(item)">展开编辑</button>
+                        </view>
                         <view class="info-control" :class="{'info-readonly': isReadonlyField(item)}">
                             <!-- 下拉选择 -->
                             <picker
@@ -346,6 +349,19 @@
                                 </block>
                                 <view v-else class="info-image-empty">暂无图片</view>
                             </view>
+                            <!-- 仅必填 input 使用自适应多行录入,保留模板原始类型 -->
+                            <view v-else-if="isRequiredInput(item)" class="info-required-input-box">
+                                <textarea
+                                    class="info-required-input"
+                                    :class="{'info-required-input--empty': !dataKeyObj[item.key]}"
+                                    :value="dataKeyObj[item.key] || ''"
+                                    :data-key="item.key"
+                                    :disabled="isReadonlyField(item)"
+                                    auto-height
+                                    @input="inputChange"
+                                    placeholder="请输入"
+                                />
+                            </view>
                             <!-- 单行文本 -->
                             <input
                                 v-else
@@ -361,6 +377,24 @@
                 </view>
             </view>
         </view>
+        <view v-if="inputEditor" class="medical-input-editor-mask">
+            <view class="medical-input-editor">
+                <view class="medical-input-editor__header">
+                    <button class="medical-input-editor__action" @tap="closeInputEditor">取消</button>
+                    <text class="medical-input-editor__title">{{ inputEditor.label }}</text>
+                    <button class="medical-input-editor__action" @tap="confirmInputEditor">完成</button>
+                </view>
+                <view class="medical-input-editor__body">
+                    <textarea
+                        class="medical-input-editor__textarea"
+                        :value="inputEditor.value"
+                        :fixed="true"
+                        @input="inputEditor.value = $event.detail.value"
+                        placeholder="请输入"
+                    />
+                </view>
+            </view>
+        </view>
         <!-- 保存按钮固定底部 -->
         <view class="fixed-save-bar">
             <button
@@ -461,6 +495,7 @@ export default {
             formDataSource: [], //病历解析后的表单内容(原始)
             formData: [], //病历解析后的表单内容(下拉菜单数组调整为一维数组)
             dataKeyObj: {}, //存值对象
+            inputEditor: null, // 必填输入框展开编辑的临时内容
             birthDate: '', //出生日期
             admID: '', //就诊ID
             isInfoSubmitting: false, //信息采集提交中
@@ -1112,6 +1147,29 @@ export default {
     return item && item.state && item.state.includes && item.state.includes('readonly');
   },
 
+  isRequiredInput(item) {
+    return item.type === 'input' && item.state && item.state.includes('required');
+  },
+
+  openInputEditor(item) {
+    if (!this.isRequiredInput(item) || this.isReadonlyField(item)) return;
+    this.inputEditor = { key: item.key, label: item.label, value: this.dataKeyObj[item.key] || '' };
+  },
+
+  closeInputEditor() {
+    this.inputEditor = null;
+  },
+
+  confirmInputEditor() {
+    if (!this.inputEditor) return;
+    const { key, value } = this.inputEditor;
+    const item = this.formData.find((field) => field.key === key);
+    if (item && this.isRequiredInput(item) && !this.isReadonlyField(item)) {
+      this.updateInputValue(key, value);
+    }
+    this.closeInputEditor();
+  },
+
   //picker选择器选择事件监听
   pickerChange(e) {
     let key = e.currentTarget.dataset.key;
@@ -1146,8 +1204,10 @@ export default {
 
   //input/textarea输入事件监听
   inputChange(e) {
-    let key = e.currentTarget.dataset.key;
-    let value = e.detail.value;
+    this.updateInputValue(e.currentTarget.dataset.key, e.detail.value);
+  },
+
+  updateInputValue(key, value) {
     let newDataKeyObj = Object.assign({}, this.dataKeyObj);
     newDataKeyObj[key] = value;
     newDataKeyObj[key + 'code'] = '';
@@ -2115,6 +2175,127 @@ export default {
     box-sizing: border-box;
 }
 
+.info-item--required-input {
+    flex-direction: column;
+}
+
+.info-item--required-input .info-label,
+.info-item--required-input .info-control {
+    flex: none;
+    width: 100%;
+    max-width: 100%;
+}
+
+.info-item--required-input .info-label {
+    position: relative;
+    padding-right: 160rpx;
+    margin-bottom: 12rpx;
+}
+
+.info-expand-button {
+    position: absolute;
+    top: 0;
+    right: 0;
+    margin: 0;
+    padding: 0 8rpx;
+    color: #1890ff;
+    background: transparent;
+    font-size: 26rpx;
+    line-height: 56rpx;
+}
+
+.info-expand-button::after,
+.medical-input-editor__action::after {
+    border: none;
+}
+
+.info-required-input-box {
+    width: 100%;
+    padding: 16rpx 20rpx;
+    border: 1rpx solid #e5e7eb;
+    border-radius: 8rpx;
+    box-sizing: border-box;
+}
+
+.info-required-input {
+    width: 100%;
+    min-height: 44rpx;
+    font-size: 30rpx;
+    line-height: 44rpx;
+    text-align: left;
+}
+
+.info-required-input--empty {
+    min-height: 88rpx;
+}
+
+.info-readonly .info-required-input {
+    color: #999;
+}
+
+.medical-input-editor-mask {
+    position: fixed;
+    z-index: 1100;
+    top: 0;
+    right: 0;
+    bottom: 0;
+    left: 0;
+    display: flex;
+    align-items: flex-end;
+    background: rgba(0, 0, 0, 0.45);
+}
+
+.medical-input-editor {
+    display: flex;
+    flex-direction: column;
+    width: 100%;
+    height: 80vh;
+    max-height: 100%;
+    padding-bottom: env(safe-area-inset-bottom);
+    border-radius: 24rpx 24rpx 0 0;
+    background: #fff;
+    box-sizing: border-box;
+}
+
+.medical-input-editor__header {
+    display: flex;
+    align-items: center;
+    padding: 12rpx 20rpx;
+    border-bottom: 1rpx solid #edf1f5;
+}
+
+.medical-input-editor__action {
+    flex: none;
+    margin: 0;
+    padding: 0 16rpx;
+    color: #1890ff;
+    background: transparent;
+    font-size: 30rpx;
+    line-height: 64rpx;
+}
+
+.medical-input-editor__title {
+    flex: 1;
+    min-width: 0;
+    padding: 0 16rpx;
+    font-size: 32rpx;
+    text-align: center;
+}
+
+.medical-input-editor__body {
+    flex: 1;
+    min-height: 0;
+    padding: 24rpx 30rpx;
+}
+
+.medical-input-editor__textarea {
+    width: 100%;
+    height: 100%;
+    font-size: 30rpx;
+    line-height: 44rpx;
+    text-align: left;
+}
+
 .history-record-card {
     overflow: hidden;
     padding: 3rpx;