East il y a 3 ans
Parent
commit
d6b4bd741d

+ 31 - 1
src/utils/chenApi.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-18 13:40:39
- * @LastEditTime: 2021-12-24 14:29:19
+ * @LastEditTime: 2021-12-25 19:20:05
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \hyyfClient\src\utils\chenApi.js
@@ -9,6 +9,36 @@
 import axios from './http';
 
 /** 生物安全 */
+/* 人员档案 */
+// 新增人员
+export function addPerson(data) {
+  return axios({
+    url: 'http://192.168.1.171:8096/person/addPerson',
+    method: 'post',
+    data: 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',
+    method: 'post',
+    data,
+    headers: {
+      "Authorization": `bearer ${token}`
+    }
+  })
+}
+
+// 删除人员
+export function delPerson(data) {
+  return axios({
+    url: 'http://192.168.1.171:8096/person/deletePercon',
+    method: 'post',
+    data: data
+  })
+}
+
 /** 车辆档案列表 **/
 export function getCarList(data) {
   return axios({

+ 73 - 19
src/views/BioSafety/PersonAdmin.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-09-16 11:27:35
- * @LastEditTime: 2021-12-22 17:42:08
+ * @LastEditTime: 2021-12-25 19:32:36
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: \hyyfClient\src\views\BioSafety\PersonAdmin.vue
@@ -46,12 +46,15 @@
       :tableItems="tableItems"
       :shows="tableShows"
       :height="475"
+      @selectionChange="handleSelectionChange"
     >
       <template v-slot:right>
         <template v-if="btnSelected === 1">
           <div>
-            <el-button size="mini">新增人员</el-button>
-            <el-button size="mini" type="danger">批量删除</el-button>
+            <el-button size="mini" @click="handleAddOrEdit">新增人员</el-button>
+            <el-button size="mini" type="danger" @click="handleDelete"
+              >批量删除</el-button
+            >
           </div>
         </template>
         <!-- <template v-else-if="btnSelected === 2">
@@ -80,8 +83,12 @@
       <!-- 档案管理 -->
       <template v-slot:personBiosignatures="slotProps">
         <img
-          :src="slotProps.row.personBiosignatures[0].path"
-          alt="人员门禁"
+          :src="
+            slotProps.row.personBiosignatures
+              ? slotProps.row.personBiosignatures[0].path
+              : ''
+          "
+          alt="没有图片"
           width="100"
           @click="clickImg(slotProps.row.personBiosignatures[0].path)"
         />
@@ -95,10 +102,18 @@
       <template #handler="slotProps">
         <el-button
           size="mini"
+          type="primary"
+          @click="handleAddOrEdit(slotProps.row)"
+        >
+          编 辑
+        </el-button>
+        <el-button
+          size="mini"
           type="danger"
           @click="handleDelete(slotProps.row)"
-          >删 除</el-button
         >
+          删 除
+        </el-button>
       </template>
     </new-table>
     <table-footer
@@ -117,6 +132,7 @@
         </el-button>
       </span>
     </el-dialog>
+    <add-or-edit ref="addOrEdit" @reflash="reflash"></add-or-edit>
   </div>
 </template>
 
@@ -129,6 +145,7 @@ import Board from "components/bioSafety/Board";
 import ChartElectro from "./chart/ChartElectro.vue";
 import CostHistogram from "./chart/CostHistogram.vue";
 import { timeDate } from "../../utils/index";
+import AddOrEdit from "./personAdmin/AddOrEdit.vue";
 
 import { formItems, propFormData } from "./personAdmin/queryCondition.config";
 import { titles, tableItems, tableShows } from "./personAdmin/table.config";
@@ -137,6 +154,7 @@ import {
   getFaceGuardTotal,
   getPersonFiles,
   getRecord,
+  delPerson,
 } from "../../utils/chenApi";
 import { mapState } from "vuex";
 
@@ -150,6 +168,7 @@ export default {
     Board,
     ChartElectro,
     CostHistogram,
+    AddOrEdit,
   },
   computed: {
     ...mapState(["ip"]),
@@ -183,6 +202,7 @@ export default {
       imgUrl: "", // 点击图片后放大的图片路径
       recordData: {}, // 进出统计
       loading: true,
+      rows: [], // 人员列表 selection
     };
   },
   mounted() {
@@ -191,6 +211,7 @@ export default {
     this.title = titles[this.btnSelected - 1];
     this.tableItems = tableItems[this.btnSelected - 1];
     this.tableShows = tableShows;
+    this.tableShows.showSelect = true;
     this.initPersonFiles();
   },
   methods: {
@@ -201,6 +222,9 @@ export default {
       this.propFormData = propFormData[id - 1];
       this.title = titles[id - 1];
       this.tableItems = tableItems[id - 1];
+      if (this.btnSelected === 1) {
+        this.tableShows.showSelect = true;
+      }
       this.chooseApi();
     },
     // 按钮选中情况 --> 对应的 api
@@ -233,14 +257,6 @@ export default {
       this.pageNum = val;
       this.chooseApi(false);
     },
-    init() {
-      let params = {
-        pageNum: this.pageNum,
-        pageSize: this.size,
-        searchStr: this.keyword,
-      };
-      // 获取后端数据
-    },
     // 人脸门禁的查询 + 近 7 小时进出统计
     faceGuard() {
       if (!this.params.time) {
@@ -296,9 +312,8 @@ export default {
         openType: 61, // 进门,刷脸
       };
       getFaceGuardTotal(queryParams).then((res) => {
-        console.log("total:", JSON.parse(res.result));
         this.total = JSON.parse(res.result).data;
-        if(this.isTotal === false) {
+        if (this.isTotal === false) {
           this.total1 = JSON.parse(res.result).data;
           this.isTotal = true;
         }
@@ -317,10 +332,11 @@ export default {
         if (success) {
           const listData = JSON.parse(result);
           this.listData = listData.data.pageData;
-          console.log(this.listData);
           this.total = listData.data.totalRows;
           this.listData.forEach((item) => {
-            item.personBiosignatures[0].path = `${this.ip}/video/picture/get?path=${item.personBiosignatures[0].path}`;
+            if (item.personBiosignatures) {
+              item.personBiosignatures[0].path = `${this.ip}/video/picture/get?path=${item.personBiosignatures[0].path}`;
+            }
           });
         }
       });
@@ -330,9 +346,47 @@ export default {
       this.dialogVisible = true;
       this.imgUrl = url;
     },
+    // 人员列表选中 selection
+    handleSelectionChange(rows) {
+      this.rows = [];
+      rows.forEach((row) => {
+        this.rows.push(row.id);
+      });
+    },
     // 档案管理 - 删除
     handleDelete(row) {
-      console.log(row);
+      let ids = [];
+      if (row.id) {
+        ids.push(row.id);
+      } else {
+        ids = this.rows;
+      }
+      this.$confirm("确定删除该人员?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+      }).then(async () => {
+        const loading = this.$loading({
+          lock: true,
+          text: "加载中...",
+          spinner: "el-icon-loading",
+          background: "rgba(0, 0, 0, 0.7)",
+        });
+        const res = await delPerson({ ids });
+        loading.close();
+        this.reflash();
+        if (res.code === 10000) {
+          this.$message.success("删除成功");
+        }
+      });
+    },
+    // 新增 or 编辑
+    handleAddOrEdit(row) {
+      this.$refs["addOrEdit"].init(row);
+    },
+    // 刷新
+    reflash() {
+      this.pageNum = 1;
+      this.initPersonFiles();
     },
   },
 };

+ 2 - 1
src/views/BioSafety/SaleAdmin.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-12-17 15:50:33
- * @LastEditTime: 2021-12-24 14:32:04
+ * @LastEditTime: 2021-12-25 14:32:26
  * @LastEditors: Please set LastEditors
  * @Description: 大门事件
  * @FilePath: \hyyfClient\src\views\BioSafety\DoorAdmin.vue
@@ -181,6 +181,7 @@ export default {
         if (res && res.code === 0) {
           const result = JSON.parse(res.data.result);
           this.listData = result.data.pageData;
+          console.log(this.listData);
           this.listData.forEach((item) => {
             item.alarmPicture = `${this.ip}/video/picture/get?alarmPicture=${item.alarmPicture}`;
           });

+ 179 - 0
src/views/BioSafety/personAdmin/AddOrEdit.vue

@@ -0,0 +1,179 @@
+<!--
+ * @Author: your name
+ * @Date: 2021-12-25 17:22:27
+ * @LastEditTime: 2021-12-25 18:52:27
+ * @LastEditors: Please set LastEditors
+ * @Description: 人员档案 - 增加人员 or 编辑人员
+ * @FilePath: \hyyfClient\src\views\BioSafety\personAdmin\AddOrEdit.vue
+-->
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="dialogVisible"
+    width="30%"
+    @close="handleCancel"
+  >
+    <div class="reset-form">
+      <el-form
+        label-width="120px"
+        size="small"
+        :rules="rules"
+        :model="form"
+        ref="form"
+      >
+        <el-form-item label="姓名:" prop="name">
+          <el-input v-model="form.name"></el-input>
+        </el-form-item>
+        <el-form-item label="部门:" prop="departmentId">
+          <el-select v-model="form.departmentId" style="width: 100%">
+            <el-option
+              v-for="item in departmentList"
+              :key="item.label"
+              :value="item.value"
+              :label="item.label"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="图片:">
+          <el-upload
+            class="upload-demo"
+            action="''"
+            :auto-upload="false"
+            :on-change="handleSuccess"
+            :on-remove="handleRemove"
+            :before-remove="beforeRemove"
+            :limit="1"
+            :on-exceed="handleExceed"
+            :file-list="file"
+          >
+            <el-button size="small" type="primary">Click to upload</el-button>
+            <!-- <template #tip>
+              <div class="el-upload__tip">
+                jpg/png files with a size less than 500kb
+              </div>
+            </template> -->
+          </el-upload>
+        </el-form-item>
+      </el-form>
+    </div>
+    <span slot="footer" class="dialog-footer">
+      <el-button size="small" @click="handleCancel">取 消</el-button>
+      <el-button size="small" type="primary" @click="handleSubmit">
+        确 定
+      </el-button>
+    </span>
+  </el-dialog>
+</template>
+<script>
+import { addPerson, addPersonPicture } from "@/utils/chenApi.js";
+import { getFaceToken } from "@/utils/api.js";
+export default {
+  data() {
+    return {
+      title: "",
+      dialogVisible: false,
+      form: {
+        id: undefined,
+        name: "",
+        departmentId: "",
+      },
+      rules: {
+        name: [{ required: true, message: "姓名不可以为空", trigger: "blur" }],
+        departmentId: [
+          { required: true, message: "部门需要选择", trigger: "blur" },
+        ],
+      },
+      departmentList: [
+        {
+          value: 4,
+          label: "维修部门",
+        },
+        {
+          value: 2,
+          label: "技术部门",
+        },
+        {
+          value: 5,
+          label: "基层部门",
+        },
+      ],
+      file: [],
+    };
+  },
+  methods: {
+    init(row) {
+      if (row) {
+        this.title = "编辑人员";
+        this.$nextTick(() => {
+          this.form = { ...row };
+        });
+      } else {
+        this.title = "新增人员";
+      }
+      this.dialogVisible = true;
+    },
+    handleSubmit() {
+      const loading = this.$loading({
+        lock: true,
+        text: "加载中...",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+      let request = addPerson;
+      if (this.form.id) {
+        // request = postDeviceEdit;
+      }
+      request({ ...this.form }).then(async (res) => {
+        loading.close();
+        if (res.code === 0) {
+          try {
+            const formData = new FormData();
+            formData.append("file", this.file[0]);
+            const { token } = await getFaceToken({});
+            const pictureRes = await addPersonPicture(formData, token);
+            console.log(pictureRes);
+          } catch (err) {
+            this.$message.error(`照片${this.form.id ? "修改" : "添加"}成功`);
+          }
+          this.$message.success(`${this.form.id ? "修改" : "添加"}成功`);
+          this.handleCancel();
+          this.$emit("reflash");
+        } else {
+          this.$message.error(`${this.form.id ? "修改" : "添加"}失败`);
+        }
+      });
+    },
+    // 取消
+    handleCancel() {
+      this.dialogVisible = false;
+      if (this.form.id) {
+        this.$nextTick(() => {
+          this.$refs["form"].resetFields();
+        });
+      }
+    },
+    // 图片接口
+    handleRemove() {
+      this.file = [];
+    },
+    handleExceed() {
+      this.$message.warning("请注意,只能选择一张图片");
+    },
+    beforeRemove(file) {
+      return this.$confirm(`取消上传${file.name} ?`);
+    },
+    handleSuccess(file) {
+      this.file.push(file);
+    },
+  },
+};
+</script>
+<style scoped>
+.reset-form {
+  margin-right: 20px;
+}
+.dialog-footer {
+  margin-right: 20px;
+}
+</style>

+ 1 - 1
src/views/DeviceMana/Device.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-12-07 14:27:28
- * @LastEditTime: 2021-12-23 09:25:40
+ * @LastEditTime: 2021-12-25 17:24:39
  * @LastEditors: Please set LastEditors
  * @Description: 设备管理页面
  * @FilePath: \hyyfClient\src\views\DeviceMana\Device.vue

+ 6 - 1
src/views/Env/SalePig.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-12-07 10:07:56
- * @LastEditTime: 2021-12-23 15:15:21
+ * @LastEditTime: 2021-12-25 16:56:34
  * @LastEditors: Please set LastEditors
  * @Description: 电子秤 - TODO: 卖猪计量的视频回放按钮
  * @FilePath: \hyyfClient\src\views\Env\SalePig.vue
@@ -12,6 +12,7 @@
       <div class="reset-title">
         <span>卖猪重量计量</span>
         <div class="reset-btns">
+          <span>视频监控:</span>
           <el-button size="small" @click="handlePlay(1)">卖猪台点猪</el-button>
           <el-button size="small" @click="handlePlay(2)">卖猪台猪舍</el-button>
         </div>
@@ -385,6 +386,10 @@ export default {
   display: flex;
   align-items: center;
 }
+.reset-btns > span {
+  color: #000;
+  margin-right: 3px;
+}
 .echarts {
   width: 100%;
   height: 401px;