xsh 3 år sedan
förälder
incheckning
c043526e9c

+ 11 - 3
src/utils/chenApi.js

@@ -13,7 +13,7 @@ import axios from './http';
 // 新增人员
 export function addPerson(data) {
   return axios({
-    url: 'http://192.168.1.171:8096/person/addPerson',
+    url: 'video/person/addPerson',
     method: 'post',
     data: data
   })
@@ -21,7 +21,7 @@ export function addPerson(data) {
 // 新增人员 - 图片
 export function addPersonPicture(data, token) {
   return axios({
-    url: 'https://36.26.62.70:447/evo-apigw/evo-brm/1.0.0/person/upload/img',
+    url: 'video/person/addPersonPicture',
     method: 'post',
     data,
     headers: {
@@ -30,10 +30,18 @@ export function addPersonPicture(data, token) {
   })
 }
 
+export function addPictureToPerson(data) {
+  return axios({
+    url: 'video/person/addPictureToPerson',
+    method: 'post',
+    data: data
+  })
+}
+
 // 删除人员
 export function delPerson(data) {
   return axios({
-    url: 'http://192.168.1.171:8096/person/deletePercon',
+    url: 'video/person/deletePercon',
     method: 'post',
     data: data
   })

+ 7 - 7
src/views/BioSafety/PersonAdmin.vue

@@ -100,13 +100,13 @@
         <span>{{ personStatus[slotProps.row.status] }}</span>
       </template>
       <template #handler="slotProps">
-        <el-button
-          size="mini"
-          type="primary"
-          @click="handleAddOrEdit(slotProps.row)"
-        >
-          编 辑
-        </el-button>
+<!--        <el-button-->
+<!--          size="mini"-->
+<!--          type="primary"-->
+<!--          @click="handleAddOrEdit(slotProps.row)"-->
+<!--        >-->
+<!--          编 辑-->
+<!--        </el-button>-->
         <el-button
           size="mini"
           type="danger"

+ 32 - 8
src/views/BioSafety/personAdmin/AddOrEdit.vue

@@ -47,7 +47,7 @@
             :on-exceed="handleExceed"
             :file-list="file"
           >
-            <el-button size="small" type="primary">Click to upload</el-button>
+            <el-button size="small" type="primary">选择图片</el-button>
             <!-- <template #tip>
               <div class="el-upload__tip">
                 jpg/png files with a size less than 500kb
@@ -66,7 +66,7 @@
   </el-dialog>
 </template>
 <script>
-import { addPerson, addPersonPicture } from "@/utils/chenApi.js";
+import { addPerson, addPersonPicture, addPictureToPerson } from "@/utils/chenApi.js";
 import { getFaceToken } from "@/utils/api.js";
 export default {
   data() {
@@ -131,14 +131,27 @@ export default {
             const formData = new FormData();
             formData.append("file", this.file[0]);
             const { token } = await getFaceToken({});
-            const pictureRes = await addPersonPicture(formData, token);
-            console.log(pictureRes);
+            const { data } = await addPersonPicture(formData, token);
+            console.log(data);
+            if(data) {
+              let params = {
+                personId: res.data.data.id,
+                path: data
+              }
+              addPictureToPerson(params).then(res => {
+                if(res.code == 0) {
+                 this.$message.success('新增档案成功!');
+                 this.handleCancel();
+                  this.$emit("reflash");
+                }
+              })
+            }
           } catch (err) {
             this.$message.error(`照片${this.form.id ? "修改" : "添加"}成功`);
           }
-          this.$message.success(`${this.form.id ? "修改" : "添加"}成功`);
-          this.handleCancel();
-          this.$emit("reflash");
+          // this.$message.success(`${this.form.id ? "修改" : "添加"}成功`);
+          // this.handleCancel();
+          // this.$emit("reflash");
         } else {
           this.$message.error(`${this.form.id ? "修改" : "添加"}失败`);
         }
@@ -164,7 +177,18 @@ export default {
       return this.$confirm(`取消上传${file.name} ?`);
     },
     handleSuccess(file) {
-      this.file.push(file);
+      const isImg = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png';
+      const isLt2M = file.size / 1024 / 1024 < 2;
+      if(!isLt2M) {
+        this.$message.error('上传头像图片大小不能超过 2MB!');
+        this.file = [];
+      }
+      if(!isImg) {
+        this.$message.error('上传头像图片只能是JPG或者png格式的图片!');
+        this.file = [];
+      } else {
+        this.file.push(file.raw);
+      }
     },
   },
 };