liujt 3 недель назад
Родитель
Сommit
f99971ce91

+ 1 - 1
src/api/‌doorSecurity‌/index.js

@@ -57,7 +57,7 @@ export async function editBind(params) {
 export async function syncDevice(id) {
   const res = await request.post(`/mms/acs/bind/sync-pull/${id}`);
   if (res.data.code == 0) {
-    return res.data.data;
+    return res.data;
   }
   return Promise.reject(new Error(res.data.message));
 }

+ 0 - 3
src/views/‌doorSecurity‌/doorLedger/components/addOrEditDialog.vue

@@ -78,7 +78,6 @@ import { getDeviceDetail, saveDevice } from '@/api/‌doorSecurity‌';
           password: '',
           doorCount: 0,
           stream: '',
-          enable: 'true'
         },
         formRules: {
           deviceName: [
@@ -139,7 +138,6 @@ import { getDeviceDetail, saveDevice } from '@/api/‌doorSecurity‌';
           //   password: row.password || '',
           //   doorCount: row.doorCount ?? 0,
           //   stream: row.stream || '',
-          //   enable: row.enable || 'true'
           // };
           const res = await getDeviceDetail(row.id);
           console.log(res, 'res');
@@ -155,7 +153,6 @@ import { getDeviceDetail, saveDevice } from '@/api/‌doorSecurity‌';
             password: '',
             doorCount: 0,
             stream: '',
-            enable: 'true'
           };
         }
         this.$nextTick(() => {

+ 20 - 5
src/views/‌doorSecurity‌/doorLedger/index.vue

@@ -48,6 +48,8 @@
         <template v-slot:enable="{ row }">
           <el-switch
             :value="row.enable"
+            :active-value="false"
+            :inactive-value="true"
             @change="(val) => handleEnableChange(row, val)"
           />
         </template>
@@ -131,7 +133,10 @@
         currentRow: null,
         selection: [],
         cacheKeyUrl: 'eos-doorLedger-list',
-        columnsVersion: 1
+        columnsVersion: 1,
+        statusMap: {
+          0: '在线', 1: '离线', 2: '异常'
+        }
       };
     },
     computed: {
@@ -209,6 +214,16 @@
             align: 'center',
             showOverflowTooltip: true
           },
+          {
+            minWidth: 100,
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            formatter: (_row, _column, cellValue) => {
+              return this.statusMap[cellValue] || cellValue;
+            }
+          },
           {
             minWidth: 100,
             prop: 'enable',
@@ -216,9 +231,9 @@
             slot: 'enable',
             align: 'center',
             showOverflowTooltip: true,
-            formatter: (_row, _column, cellValue) => {
-              return cellValue == 0 ? '启用' : '禁用';
-            }
+            // formatter: (_row, _column, cellValue) => {
+            //   return cellValue == 0 ? '启用' : '禁用';
+            // }
           },
           {
             columnKey: 'action',
@@ -297,7 +312,7 @@
         // TODO: 替换为实际的启用/禁用接口
         enableDoorLedger(_row.id, {enable: val})
           .then(() => {
-            this.$message.success(val ? '已启用' : '已禁用');
+            this.$message.success(!val ? '已启用' : '已禁用');
             this.reload();
           })
           .catch(() => {

+ 1 - 1
src/views/‌doorSecurity‌/entryExitRecords/index.vue

@@ -206,7 +206,7 @@
           size: limit,
           ...where
         });
-
+        res.count = res.total || 0;
         res.list = res.records || [];
  
         return res

+ 10 - 43
src/views/‌doorSecurity‌/personnelAuthorization/components/door-authorize.vue

@@ -20,7 +20,7 @@
       <el-row>
         <el-col :span="24">
           <el-form-item label="授权类型:" prop="isPermanent">
-            <el-radio-group v-model="form.isPermanent">
+            <el-radio-group v-model="form.isPermanent" @change="handleChange">
               <el-radio :label="0">临时授权</el-radio>
               <el-radio :label="1">长期授权</el-radio>
             </el-radio-group>
@@ -30,7 +30,7 @@
           <el-form-item label="授权有效期:" prop="validTime">
             <el-date-picker
                 v-model="form.validTime"
-                type="daterange"
+                type="datetimerange"
                 range-separator="至"
                 start-placeholder="开始日期"
                 end-placeholder="结束日期"
@@ -91,7 +91,6 @@
         userInfo: {
           postName: '',
         },
-        // datasource: [],
         deviceOptions: [],
         bindDeviceData: [],
       };
@@ -193,45 +192,8 @@
 
     },
     methods: {
-      async datasource({ page, limit, where, order }) {
-        console.log(this.list, 'this.list');
-        const res = await listDevice({ ...where, ...order, pageNum: page, size: limit });
-        // 与已绑定设备对比,标记绑定状态
-        if (res.list && this.list.length > 0) {
-          console.log(this.list, 'this.list~~~');
-          const bindDeviceIds = this.list.map(item => item.deviceId);
-          console.log(bindDeviceIds, 'bindDeviceIds');
-          res.list = res.list.map(item => ({
-            ...item,
-            isBind: bindDeviceIds.includes(item.id) ? true : false
-          }));
-        }
-        console.log(res, 'res');
-        return res;
-      },
- 
-      bindUserDevice(row) {
-        console.log(row, 'row');
-        bindDevice({
-          deviceId: row.id,
-          userId: this.current.id,
-          jobNumber: this.current.jobNumber,
-        }).then(res => {
-          console.log(res, 'res');
-          this.$message({
-            message: '绑定成功',
-            type: 'success'
-          });
-          row.isBind = true;
-     
-          this.$emit('success');
-        }).catch(err => {
-          console.log(err, 'err');
-          // this.$message({
-          //   message: '绑定失败',
-          //   type: 'error'
-          // });
-        })
+      handleChange(val) {
+        console.log('handleChange', val);
       },
 
       submitForm() {
@@ -274,7 +236,12 @@
       visible(visible) {
         console.log(visible, 'visible');
         if (visible) {
-        
+          if(this.deviceInfo) {
+            this.form.isPermanent = this.deviceInfo.isPermanent;
+            this.form.validStart = this.deviceInfo.validStart;
+            this.form.validEnd = this.deviceInfo.validEnd;
+            this.form.validTime = [this.deviceInfo.validStart, this.deviceInfo.validEnd];
+          }
         } else {
           this.$refs.form?.clearValidate();
           this.form = { ...this.defaultForm };

+ 6 - 2
src/views/‌doorSecurity‌/personnelAuthorization/components/door-bind.vue

@@ -290,11 +290,13 @@
           jobNumber: this.current.jobNumber,
         }).then(res => {
           console.log(res, 'res');
+          this.$set(row, 'isBind', true);
+          // 同时更新父组件传入的已绑定设备列表,确保 datasource 重新计算时正确
+          this.list.push({ deviceId: row.id });
           this.$message({
             message: '绑定成功',
             type: 'success'
           });
-          row.isBind = true;
           // this.reload();
           this.$emit('success');
         }).catch(err => {
@@ -322,7 +324,9 @@
       visible(visible) {
         console.log(visible, 'visible');
         if (visible) {
-          this.reload();
+          this.$nextTick(() => {
+            this.reload();
+          })
         } else {
           this.$refs.form?.clearValidate();
           this.form = { ...this.defaultForm };

+ 4 - 2
src/views/‌doorSecurity‌/personnelAuthorization/components/door-modal.vue

@@ -84,6 +84,7 @@
                 授权
               </el-link>
               <el-link
+                v-if="row.syncStatus != 1"
                 type="primary"
                 :underline="false"
                 @click="handleSync(row)"
@@ -297,9 +298,10 @@
         this.showBind = true;
       },
       async handleSync(row) {
-        await syncDevice(row.id);
+        const res =await syncDevice(row.id);
+        console.log(res, 'sync result');
         this.$message({
-          message: '同步成功',
+          message: res.message || '同步失败',
           type: 'success'
         });
         this.getData();

+ 1 - 1
src/views/‌doorSecurity‌/personnelAuthorization/components/org-user-edit.vue

@@ -1180,7 +1180,7 @@
   import dictMixins from '@/mixins/dictMixins';
   import aptitudeDialog from './aptitudeDialog.vue';
   import criticalProcess from './criticalProcess.vue';
-  import { parameterGetByCode } from '@/api/system/dictionary/index.js';
+  import { parameterGetByCode } from '@/api/main/index.js';
 
   // D:\中赢\kd-aiot-frontend\src\views\system\user
 

+ 2 - 2
src/views/‌doorSecurity‌/personnelAuthorization/components/org-user-list.vue

@@ -151,13 +151,13 @@
       @done="reload"
       ref="userEditRef"
     />
-    <addUsers
+    <!-- <addUsers
       :visible.sync="showEdit1"
       @done="reload"
       :data="null"
       ref="userEdit"
       :organizationList="organizationList"
-    />
+    /> -->
     <importDialog
       :defModule="moudleName"
       ref="importDialogRef"