瀏覽代碼

人脸登录

yaorongkeji 1 月之前
父節點
當前提交
d274c42999
共有 2 個文件被更改,包括 135 次插入5 次删除
  1. 30 0
      src/api/patient/face.js
  2. 105 5
      src/views/patient/list/lookDetail.vue

+ 30 - 0
src/api/patient/face.js

@@ -0,0 +1,30 @@
+import request from "@/utils/request"
+
+/**
+ * 根据用户id查询人脸照片列表
+ * @param {*} UserId 
+ * @returns 
+ */
+export function selectByUserId(UserId) {
+    return request({
+        url: "/face/selectByUserId?UserId="+UserId,
+        method: "post"
+    })
+}
+
+
+export function saveFace(query) {
+    return request ({
+        url: "/face/save",
+        method: "post",
+        data: query
+    })
+}
+
+export function deleteById(query) {
+    return request({
+        url: "/face/delete",
+        method: "post",
+        data: query
+    })
+}

+ 105 - 5
src/views/patient/list/lookDetail.vue

@@ -152,8 +152,30 @@
           </el-descriptions-item>
 
         </el-descriptions>
-        <h4 style="font-size: 16px;font-weight: bold; display: inline-block;">套餐记录</h4>
 
+        <h4 style="font-size: 16px;font-weight: bold; display: inline-block;">人脸照片</h4>
+        <el-button type="primary"  style="margin-left: 20px;"  plain icon="el-icon-plus" size="mini"
+                  @click="dialogVisibleFace = true">新增</el-button>
+        <el-table :data="faceList" stripe height="300" style="width: 100%">
+          <el-table-column prop="fid" label="编号"/>
+          <el-table-column prop="faceBase" label="人脸照片">
+            <template slot-scope="scope">
+              <el-image
+              :src="scope.row.faceBase"
+              fit="cover"
+            ></el-image>
+            </template>
+          </el-table-column>
+          <el-table-column prop="createTime" label="创建时间"/>
+          <el-table-column prop="remark" label="备注"/>
+          <el-table-column prop="packageName" label="操作">
+            <template slot-scope="scope">
+                <el-button size="mini" type="text" icon="el-icon-edit" @click="deleteface(scope.row.fid)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        
+        <h4 style="font-size: 16px;font-weight: bold; display: inline-block;">套餐记录</h4>
         <el-table :data="defaultVal.packageHis" stripe height="300" style="width: 100%">
           <el-table-column prop="packageName" label="套餐名称" />
           <el-table-column prop="packagePriceYUAN" label="套餐价格(元)" />
@@ -430,18 +452,29 @@
       </span>
     </el-dialog>
 
+    <el-dialog title="添加人脸照片" :visible.sync="dialogVisibleFace" width="30%" destroy-on-close>
+      <ImageUpload v-if="dialogVisibleFace" :imgList="imgUrl" :paramsData="{ dirName: 'humanFace' }" :limit="1"  @input="handleImageUpload" />
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisibleFace = false">取 消</el-button>
+        <el-button type="primary" @click="addFace">确 定</el-button>
+      </span>
+    </el-dialog>
+
   </div>
 </template>
 
 <script>
-import { updatePatientGame, gamehisGame, addUserGame, delUserGame, patientDetail, patientGames } from '@/api/patient/index'
+import { updatePatientGame, gamehisGame, addUserGame, delUserGame, patientDetail, patientGames } from '@/api/patient/index';
+import { selectByUserId, saveFace, deleteById} from '@/api/patient/face';
 import { listData as gameListData } from "@/api/game/index";
 import { departmentList } from "@/api/doctor/physician";
+import { getToken } from "@/utils/auth";
 import store from '@/store';
 export default {
   dicts: ['career', 'package_type', 'department', 'medical_current_type', 'diagnose_result_type', 'medical_his_type', 'patient_source', 'genetic_disease', 'game_type', 'game_difficulty', 'education_type'],
   data() {
     return {
+      imgUrl: [],
       drawer: false,
       defaultVal: {},
       dialogVisible: false,
@@ -484,12 +517,76 @@ export default {
       homeLodaing: true,
       freeLodaing: true,
       taskLodaing: true,
-      department: []
+      department: [],
+      faceList: [],
+      face: {
+        
+      },
+      dialogVisibleFace: false,
     }
   },
   methods: {
+    // 监听图片上传事件
+    handleImageUpload(value) {
+      // value 是组件传出的字符串,如 "humanFace/xxx.jpg"
+      if (value) {
+        // 将字符串转换为数组
+        const images = value.split(',');
+        // 如果需要完整 URL,可以拼接 baseUrl
+        // const baseUrl = process.env.VUE_APP_BASE_API;
+        // this.imgUrl = images.map(img => baseUrl + img);
+        this.imgUrl = images;
+        
+        // 保存到 face 对象中
+        if (images.length > 0) {
+          this.face.faceBase = images[0];
+        }
+      } else {
+        this.imgUrl = [];
+        this.face.faceBase = "";
+      }
+    },
+    getFace() {
+      selectByUserId(this.defaultVal.id).then(resp =>{
+        this.faceList = resp.data
+      })
+    },
+    addFace(){
+      if(this.face.faceBase == '' && this.face.faceBase == undefined) {
+        this.$modal.msgError('请上传人脸!');
+      }
+      this.face.userId = this.defaultVal.id
+      this.face.faceName = this.defaultVal.name
+      saveFace(this.face).then(resp =>{
+        if(resp.code == "200" && resp.data) {
+          this.$modal.msgSuccess('添加成功');
+          this.dialogVisibleFace = false
+          this.face = {}
+          this.imgUrl = []
+          this.getFace()
+        }
+      })
+    },
+    deleteface(fid) {
+      this.$confirm('此操作将永久删除人脸照片, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+         this.face.userId = this.defaultVal.id
+         this.face.fid = fid
+        deleteById(this.face).then(resp => {
+          if(resp.code == "200" && resp.data) {
+          this.$modal.msgSuccess('删除成功');
+          this.dialogVisibleFace = false
+          this.imgUrl = []
+          this.getFace()
+        }
+        })
+      }).catch(() => {
+      });
+    },
     handleDetali(id) {
-      console.log('111111111');
       this.loadingTable = true
       patientDetail(id).then(res => {
         res.data.medicalCurrentTypes = res.data.medicalCurrentTypes.split ? res.data.medicalCurrentTypes.split(',') : undefined
@@ -613,7 +710,7 @@ export default {
       this.searchGames('hometext', 'B', 'newhomeGames')
       this.searchGames('freetext', 'C', 'newfreeGames')
       this.searchGames('tasktext', 'A', 'newtaskGames')
-      console.log(this.defaultVal);
+      this.getFace()
       this.drawer = true
       this.homeData = e.homeGames || []
       this.freeData = e.freeGames || []
@@ -781,4 +878,7 @@ export default {
 .margin-top {
   margin-top: 20px;
 }
+
+
+
 </style>