yubo
2026-03-12 74612d64c6bd2d28dcf80450f2cb94ffbee9970d
src/views/user/Informationinput.vue
@@ -442,8 +442,8 @@
          <el-table-column show-overflow-tooltip prop="injuredPart" label="受伤部位" width="80" />
          <el-table-column show-overflow-tooltip prop="injuredDescribe" label="受伤经过描述" width="120" />
          <el-table-column show-overflow-tooltip prop="injuredDiacrisis" label="意外险诊断" width="120" />
          <el-table-column show-overflow-tooltip prop="hospitalName" label="就诊医院" width="80" />
          <el-table-column show-overflow-tooltip prop="treatmentName" label="就诊科室" width="80" />
          <!--          <el-table-column show-overflow-tooltip prop="hospitalName" label="就诊医院" width="80" />-->
          <!--          <el-table-column show-overflow-tooltip prop="treatmentName" label="就诊科室" width="80" />-->
          <el-table-column
            show-overflow-tooltip
            prop="hospitalizatioFlag"
@@ -451,10 +451,10 @@
            width="80"
            :formatter="hospitalizatioFlagFormat"
          />
          <el-table-column show-overflow-tooltip prop="bedNumb" label="床号" width="60" />
          <!--          <el-table-column show-overflow-tooltip prop="bedNumb" label="床号" width="60" />-->
          <el-table-column show-overflow-tooltip prop="reprotTime" label="报案时间" width="80" />
          <el-table-column show-overflow-tooltip prop="submitTime" label="递交资料时间" width="120" />
          <el-table-column show-overflow-tooltip prop="sbumitBy" label="递交人" width="80" />
          <!--          <el-table-column show-overflow-tooltip prop="submitTime" label="递交资料时间" width="120" />-->
          <!--          <el-table-column show-overflow-tooltip prop="sbumitBy" label="递交人" width="80" />-->
          <el-table-column show-overflow-tooltip prop="expensesFee" label="医疗总费用" width="100" />
          <el-table-column show-overflow-tooltip prop="innsureFee" label="保险赔付费用" width="120" />
        </el-table>
@@ -666,17 +666,19 @@
    <el-dialog title="基本信息" top="8vh" :visible.sync="dialogshowArr[0].show" width="60%" class="baseinfo">
      <el-container style="height: 70vh;">
        <el-aside width="200px">
          <el-upload
            class="avatar-uploader"
            action="#"
            :show-file-list="false"
            :on-change="handlePictureCardPreview"
            :auto-upload="false"
          >
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过4MB</div>
            <img v-if="empBaseInfoImageUrl" :src="empBaseInfoImageUrl" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon" />
          </el-upload>
          <!-- 头像显示区域 -->
          <div class="avatar-wrapper">
            <img
              v-if="empBaseInfoImageUrl"
              :src="empBaseInfoImageUrl"
              class="avatar"
              @click="openCamera"
            >
            <div v-else class="avatar-uploader-placeholder" @click="openCamera">
              <i class="el-icon-plus avatar-uploader-icon" />
              <div class="upload-tip">点击拍照上传</div>
            </div>
          </div>
        </el-aside>
        <el-main>
          <el-form
@@ -1742,6 +1744,9 @@
                />
              </el-select>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="accidentCasesForm.remark" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
@@ -2170,6 +2175,33 @@
    <el-dialog title="选择员工" :visible.sync="dialogShowXzyg" width="60%">
      <Selectuser @selectedUser="selectedUser" @cancleChooseUser="cancleChooseUser" />
    </el-dialog>
    <!-- 摄像头拍照弹窗 -->
    <el-dialog
      title="拍照上传"
      :visible.sync="cameraDialogVisible"
      width="640px"
      :close-on-click-modal="false"
      @close="closeCamera"
    >
      <div class="camera-container">
        <video
          v-show="!capturedImage"
          ref="video"
          class="camera-video"
          autoplay
          playsinline
        />
        <canvas ref="canvas" style="display: none;" />
        <img v-if="capturedImage" :src="capturedImage" class="captured-image">
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeCamera">取消</el-button>
        <el-button v-if="!capturedImage" type="primary" @click="takePhoto">拍照</el-button>
        <el-button v-if="capturedImage" @click="retakePhoto">重拍</el-button>
        <el-button v-if="capturedImage" type="primary" @click="confirmPhoto">确认使用</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
@@ -2190,6 +2222,10 @@
      baseicInformationForm: {},
      dialogShowDryg: false,
      empBaseInfoImageUrl: '',
      // 摄像头相关
      cameraDialogVisible: false,
      capturedImage: '',
      stream: null,
      total: 0, // 总数量
      queryParams: {}, // 查询参数
      sort: {}, // 排序
@@ -3252,6 +3288,97 @@
        }
      } else {
        this.$message.error('图片大小超过4M,请重新上传')
      }
    },
    // 打开摄像头
    openCamera() {
      this.cameraDialogVisible = true
      this.$nextTick(() => {
        this.initCamera()
      })
    },
    // 初始化摄像头
    async initCamera() {
      try {
        // 请求摄像头权限
        this.stream = await navigator.mediaDevices.getUserMedia({
          video: {
            width: { ideal: 640 },
            height: { ideal: 480 },
            facingMode: 'user' // 前置摄像头
          },
          audio: false
        })
        // 将视频流绑定到 video 元素
        const video = this.$refs.video
        if (video) {
          video.srcObject = this.stream
        }
      } catch (error) {
        this.$message.error('无法访问摄像头,请检查摄像头权限设置')
        console.error('摄像头初始化失败:', error)
      }
    },
    // 拍照
    takePhoto() {
      const video = this.$refs.video
      const canvas = this.$refs.canvas
      if (!video || !canvas) return
      // 设置画布尺寸
      canvas.width = video.videoWidth || 640
      canvas.height = video.videoHeight || 480
      // 绘制视频帧到画布
      const ctx = canvas.getContext('2d')
      ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
      // 转换为图片数据
      this.capturedImage = canvas.toDataURL('image/jpeg', 0.9)
      // 停止摄像头
      this.stopCamera()
    },
    // 重拍
    retakePhoto() {
      this.capturedImage = ''
      this.initCamera()
    },
    // 确认使用照片
    confirmPhoto() {
      if (this.capturedImage) {
        // 设置图片预览
        this.empBaseInfoImageUrl = this.capturedImage
        // 设置表单数据(Base64格式)
        this.empBaseInfoForm.imagePath = this.capturedImage
        // 关闭弹窗
        this.closeCamera()
        this.$message.success('照片已保存')
      }
    },
    // 关闭摄像头
    closeCamera() {
      this.stopCamera()
      this.cameraDialogVisible = false
      this.capturedImage = ''
    },
    // 停止摄像头流
    stopCamera() {
      if (this.stream) {
        this.stream.getTracks().forEach(track => {
          track.stop()
        })
        this.stream = null
      }
      const video = this.$refs.video
      if (video) {
        video.srcObject = null
      }
    },
    // 翻页插件翻页方法
@@ -6084,6 +6211,72 @@
.el-date-editor.el-input__inner {
  width: 100%;
}
/* 头像上传相关样式 */
.avatar-wrapper {
  width: 178px;
  height: 178px;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-wrapper:hover {
  border-color: #409EFF;
}
.avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.avatar-uploader-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8c939d;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  margin-bottom: 8px;
}
.upload-tip {
  font-size: 12px;
  color: #8c939d;
}
/* 摄像头弹窗样式 */
.camera-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000;
  min-height: 360px;
}
.camera-video {
  width: 100%;
  max-width: 640px;
  height: auto;
}
.captured-image {
  max-width: 100%;
  max-height: 480px;
}
</style>
<style lang="scss">