Browse Source

增加字段展示,增加同步确认弹框

qule 3 years ago
parent
commit
93588af01f
1 changed files with 65 additions and 24 deletions
  1. 65 24
      src/views/syncManage/index.vue

+ 65 - 24
src/views/syncManage/index.vue

@@ -19,7 +19,7 @@
                <div>     
                     <el-input style="width: 220px" placeholder="请输入内容" @input="httpInputChange" @blur="httpInputBlur" :value="httpValue" />
                     <el-button type="primary" style="margin-left: 8px" :loading='httpBtnLoading' :disabled='!httpValue' @click="httpExportHandle">导出Excel</el-button>
-                    <el-button type="primary"  :loading='syncBtnLoading' :disabled='!httpValue' @click="syncDataHandle">同步</el-button>       
+                    <el-button type="primary"  :loading='syncBtnLoading' :disabled='!httpValue || !isExported' @click="syncDataHandle">同步</el-button>       
                </div> 
             </div>
             <el-divider />    
@@ -27,7 +27,7 @@
                 <p>筛选条件</p>
                 <ul class="screen-list">
                     <li>
-                        <span>操作符:</span>
+                        <span>&emsp;操作符:</span>
                         <el-select v-model="operationValue" :clearable="true" @change="operationChange" placeholder="请选择">
                             <el-option v-for="item in operation" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                         </el-select>
@@ -52,7 +52,7 @@
                     </li>
                    
                 </ul>
-                <ul>
+                <ul class="screen-list">
                      <li v-if="tableName === 'dt_object'">
                         <span>对象类型:</span>
                         <el-select v-model="objTypeValue" :clearable="true" @change="objTypeChange" placeholder="请选择">
@@ -90,12 +90,12 @@
                     <template v-if="tableName === 'dt_relation'">
                         <el-table-column label="fromId" >
                             <template slot-scope="scope">
-                                <span style="margin-left: 10px">{{ scope.row.targetId ? scope.row.targetId : "--" }}</span>
+                                <span style="margin-left: 10px">{{ scope.row.fromId ? scope.row.fromId : "--" }}</span>
                             </template>
                         </el-table-column>
                         <el-table-column label="toId" >
                             <template slot-scope="scope">
-                                <span style="margin-left: 10px">{{ scope.row.targetId ? scope.row.targetId : "--" }}</span>
+                                <span style="margin-left: 10px">{{ scope.row.toId ? scope.row.toId : "--" }}</span>
                             </template>
                         </el-table-column>
                     </template>
@@ -125,6 +125,26 @@
                             </template>
                         </el-table-column>
                     </template>
+                    <el-table-column label="状态" >
+                        <template slot-scope="scope">
+                            <span style="margin-left: 10px">{{ scope.row.sign ? (scope.row.sign === 1 ? '失败' : '成功') : "--" }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="创建时间" >
+                        <template slot-scope="scope">
+                            <span style="margin-left: 10px">{{ scope.row.creationTime | timeFormat }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="修改时间" >
+                        <template slot-scope="scope">
+                            <span style="margin-left: 10px">{{ scope.row.modifiedTime | timeFormat }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="错误信息" >
+                        <template slot-scope="scope">
+                            <span style="margin-left: 10px">{{ scope.row.error ? scope.row.error : "--" }}</span>
+                        </template>
+                    </el-table-column>
                 </el-table>
                 <!-- {/* 分页 */} -->
                 <div class="pages">
@@ -234,6 +254,7 @@ export default {
             httpBtnLoading: false,  //域名导出按钮状态
             httpBtnDisable: true, //域名导出按钮禁用状态
             httpValue: '', //域名内容
+            isExported: false,  //是否已导出excel,未导出则不可同步
 
             syncBtnLoading: false,  //同步按钮状态
         }
@@ -252,24 +273,38 @@ export default {
 
         syncDataHandle() {
             this.$message.closeAll();
-            this.syncBtnLoading = true;          
-            syncData(
-                {
-                    targetUrl: this.httpValue
-                },
-                res => {
-                    this.pageObj = {
-                        ...this.pageObj,
-                        pageNumber: 1
+            this.$confirm('同步前,请确认导出表格数据正确?', '警告', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                this.syncBtnLoading = true;          
+                syncData(
+                    {
+                        targetUrl: this.httpValue
+                    },
+                    res => {
+                        this.pageObj = {
+                            ...this.pageObj,
+                            pageNumber: 1
+                        }
+                        this.syncBtnLoading = false;
+                        this.isExported = false;   //同步成功后禁用同步按钮
+                        this.getData();
+                    },
+                    err => {
+                        this.syncBtnLoading = false;
+                        // this.getData();
                     }
-                    this.syncBtnLoading = false
-                    this.getData();
-                },
-                err => {
-                    this.syncBtnLoading = false;
-                    // this.getData();
-                }
-            )
+                )
+                
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '已取消同步操作'
+                });          
+            });
+            
         },
 
         httpInputChange(val) {               
@@ -279,10 +314,15 @@ export default {
             const value = e.target.value;
             const regExp = /^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/  //域名校验正则   
             this.$message.closeAll();
+            const { origin } = location;
+            if ( origin == value) {
+                this.httpValue = '';
+                this.$message.warning('不可同步当前域名数据!')
+            }
             if (value && !regExp.test(value)) {
                 this.httpValue = '';
                 this.$message.warning('请输入合法的域名')
-            }   
+            }  
         },
         httpExportHandle() {
             this.httpBtnLoading = true;
@@ -292,7 +332,8 @@ export default {
                     targetUrl: this.httpValue
                 },
                 () => {
-                    this.httpBtnLoading = false
+                    this.httpBtnLoading = false;
+                    this.isExported = true
                 }
             )