Эх сурвалжийг харах

Merge branch 'ETA-table-optimize'

hbchen 1 жил өмнө
parent
commit
a86fcf89e6

+ 0 - 9
src/routes/modules/chartRoutes.js

@@ -142,15 +142,6 @@ export default [
 					pathName: "混合表格",
 				}
 			},
-			{
-				path:"editSheetAnalysis",
-				name:"编辑表格",
-				component:()=>import('@/views/datasheet_manage/customAnalysis/edit.vue'),
-				meta: { 
-					pathFrom: "sheetAnalysisList",
-					pathName: "自定义分析",
-				}
-			},
 			{
 				path:"sheetAnalysisList",
 				name:"自定义分析",

+ 4 - 6
src/views/datasheet_manage/addSheet.vue

@@ -98,11 +98,7 @@ export default {
   methods: {
 
     backHandle() {
-      // if(this.sheetId){
-      //   this.$router.back()
-      // }else{
-        window.close();
-      // }
+      window.close();
     },
 
     /* 获取分类 */
@@ -135,7 +131,8 @@ export default {
         },1000)
         return 
       }
-      const { ExcelInfoId,ExcelName,ExcelClassifyId,ExcelType,ModifyTime,Content,Source} = res.Data;
+      const { ExcelInfoId,ExcelName,ExcelClassifyId,ExcelType,ModifyTime,Content,Source,Button} = res.Data;
+      this.sheetButton=Button
       this.sheetForm = {
         infoId:ExcelInfoId,
         name: ExcelName,
@@ -159,6 +156,7 @@ export default {
 
     },
     autoSaveFun:_.debounce(async function(){
+      // cancelAutoSave -- 由于是延时自动保存 防止用户在聚焦文本框时点击保存,文本框失焦后又发起自动保存的情况
       if(!this.sheetId && this.sheetInit || this.cancelAutoSave) return
       const { name,classify,infoId } = this.sheetForm;
       luckysheet.exitEditMode()

+ 0 - 292
src/views/datasheet_manage/customAnalysis/edit.vue

@@ -1,292 +0,0 @@
-<template>
-  <div class="sheet-detail-wrapper" >
-    <div class="detail-top">
-      <el-input
-        ref="sheetEditTitRef"
-        style="width: 400px"
-        placeholder="请输入表格名称"
-        class="label-input"
-        v-model="sheet_title"
-        v-if="sheetDetailInfo.isEditTit"
-        @blur="changeValue(sheetDetailInfo, 'edit-tit')"
-      />
-      <span
-        class="sheet-name"
-        @click="editNodeLabel(sheetDetailInfo, 'edit-tit')"
-        v-else
-      >
-        {{ sheetDetailInfo.ExcelName }}
-        <i class="el-icon-edit"/>
-      </span>
-      <div class="sheet-anothor-info">
-        <span class="author">作者:{{ sheetDetailInfo.SysUserRealName }}</span>
-        <ul class="action-ul" v-if="sheetDetailInfo.Button">
-          <div v-if="updateTime" style="color:#999999;">最近保存时间:{{ updateTime }}</div>
-          <el-tooltip effect="dark" content="在当前表格选择日期列和数据列生成指标" placement="top-start">
-              <li class="editsty" @click="HandleToPath" v-if="isSheetBtnShow('createedb')&&sheetDetailInfo.Button.OpEdbButton">
-                <img src="~@/assets/img/icons/choose_bluebg_new.png"/>
-                <span>生成指标</span>
-              </li>
-          </el-tooltip>
-
-          <el-tooltip effect="dark" content="根据表格保存的最新内容,更新当前表格生成的所有指标" placement="top-start">
-              <li class="editsty" @click="refreshSheet" v-if="isSheetBtnShow('refresh')&&sheetDetailInfo.Button.RefreshEdbButton">
-                <img src="~@/assets/img/icons/refresh_blue_new.png"/>
-                <span>刷新指标</span>
-              </li>
-          </el-tooltip>
-          <li class="editsty" @click="saveHandle" v-if="isSheetBtnShow('save')&&sheetDetailInfo.Button.OpButton">
-            <img src="~@/assets/img/icons/save_blue_new.png"/>
-            <span>保存</span>
-          </li>
-          <li class="editsty" @click="backHandle">
-            <img src="~@/assets/img/icons/back_arrow_blue_new.png"/>
-            <span>返回</span>
-          </li>
-        </ul>
-      </div>
-    </div>
-
-    <dataLoading :loading="isSheetLoading"/>
-
-    <!-- 表格 -->
-    <div class="sheet-wrap">
-      <Sheet
-        ref="sheetRef"
-        v-if="sheetConfigOpt.data"
-        :option="sheetConfigOpt"
-      />
-    </div>
-  </div>
-</template>
-
-<script>
-import * as sheetInterface from "@/api/modules/sheetApi.js";
-import Sheet from "../components/SheetExcel.vue";
-import leftMixin from "../mixins/classifyMixin";
-import { getSheetImage } from "../common/option";
-
-  export default {
-    components:{Sheet},
-    mixins: [leftMixin],
-    data() {
-      return {
-        sheetDataPage: 2,
-        sheetAllcellData:[],//全部单元格数据 分页push
-        dataToalPage: 0,
-        isSheetLoading: false,
-        code:'',
-        sheetConfigOpt: {
-          showsheetbar: true,
-          data: null
-        },
-        sheet_title: "", //表格标题 双击标题修改时来存储最新值
-        sheetDetailInfo:{},
-        isCanEdit:false,
-        sheetId:'',
-        loading:null,
-        updateTime:''
-      }
-    },
-    beforeRouteLeave(to,from,next){
-      if(to.path!='/editSheetAnalysis'){
-        this.markFinishStatus()
-      }
-      next()
-    },
-    created(){
-      // console.log(this.$route.query.code);
-      if(!this.$route.query.code){
-        this.$message.warning("参数丢失")
-        this.backHandle()
-      }else{
-        this.code = this.$route.query.code
-        this.getDetailHandle()
-      }
-    },
-    mounted() {
-      window.addEventListener('beforeunload',this.markFinishStatus)
-    },
-    beforeDestroy(){
-      window.removeEventListener('beforeunload',this.markFinishStatus)
-    },
-    methods:{
-      /* 获取表格详情 */
-      getDetailHandle() {
-
-        this.isSheetLoading = true;
-        sheetInterface.sheetAnalysisInterface.getExcelDetail({
-          UniqueCode:this.code,
-        }).then((res) => {
-          if (res.Ret !== 200) return;
-          this.isCanEdit = res.Data.ExcelInfo.CanEdit
-          if(!this.isCanEdit){
-            this.$message.warning(`${res.Data.ExcelInfo.Editor}正在编辑中`)
-            setTimeout(()=>{
-              this.backHandle()
-            },1000)
-            return 
-          }
-          this.sheetDetailInfo = res.Data.ExcelInfo;
-          this.updateTime = this.$moment(this.sheetDetailInfo.ModifyTime).format('YYYY-MM-DD HH:mm:ss')||''
-          this.sheetId = this.sheetId || res.Data.ExcelInfo.ExcelInfoId;
-          this.dataToalPage =  Math.max(...res.Data.SheetList.map(_ => _.PageNum));
-          this.sheetAllcellData = res.Data.SheetList.map(_ => _.Data ? JSON.parse(_.Data.Data) : []);
-
-          this.getCellData(res.Data.SheetList)
-        });
-      },
-      //分页获取表格数据
-      async getCellData(sheets) {
-
-        let res = await sheetInterface.sheetAnalysisInterface.getExcelDataByPage({
-          UniqueCode: this.code,
-          Page: this.sheetDataPage
-        })
-
-        if(res.Ret !== 200) return
-        console.log(this.sheetAllcellData)
-
-        for(let i = 0;i<this.sheetAllcellData.length;i++) {
-          if(res.Data[i].Data) {
-            this.sheetAllcellData[i] = [...this.sheetAllcellData[i],...JSON.parse(res.Data[i].Data.Data)]
-          }
-
-          continue
-        }
-        
-        //数据继续加载或渲染表格.
-        if(this.sheetDataPage < this.dataToalPage) {
-          this.sheetDataPage++;
-          this.getCellData(sheets)
-        }else {
-          this.sheetConfigOpt.data = sheets.map((_,index) => ({
-            index: _.Index, //工作表id
-            order: _.Sort, //工作表的下标
-            name: _.SheetName,
-            calcChain: _.CalcChain?JSON.parse(_.CalcChain):[],
-            config: JSON.parse(_.Config),
-            celldata: this.sheetAllcellData[index],
-          }))
-
-          console.log(this.sheetConfigOpt)
-
-          this.isSheetLoading = false;
-        }
-      },
-      backHandle(){
-        let params={
-          code:this.sheetDetailInfo.UniqueCode,
-          id:this.sheetDetailInfo.ExcelInfoId
-        }
-        sessionStorage.setItem('editSheetAnalysisBack',JSON.stringify(params))
-        this.$router.back()
-      },
-      //跳转生成指标
-      HandleToPath() {
-        this.$router.push({ path: '/createTaregtBySheet',query: {
-          code: this.sheetDetailInfo.UniqueCode 
-        }});
-      },
-      /* 刷新表格 */
-      refreshSheet: _.debounce(async function() {
-        let res = await sheetInterface.sheetAnalysisInterface.sheetRefresh({ExcelInfoId: this.sheetDetailInfo.ExcelInfoId})
-
-        if(res.Ret !== 200) return 
-        this.$message.success(res.Msg)
-      },300),
-      /* 保存表格 */
-      saveHandle: _.debounce(async function () {
-        luckysheet.exitEditMode();
-        let data = luckysheet.getAllSheets();
-
-        this.loading = this.$loading({
-          target: ".sheet-detail-wrapper",
-          lock: true,
-          text: "保存中...",
-          spinner: "el-icon-loading",
-          background: "rgba(255, 255, 255, 0.6)",
-        });
-
-        let img = getSheetImage(data[0]);
-        const form = new FormData();
-        form.append("Image", img);
-        const { Data } = await sheetInterface.uploadImg(form);
-
-        data.luckysheet_select_save = [];
-        const { ExcelInfoId, ExcelName, ExcelClassifyId } = this.sheetDetailInfo;
-        const res = await sheetInterface.sheetAnalysisInterface.sheetEdit({
-          ExcelInfoId,
-          ExcelName,
-          ExcelClassifyId,
-          ExcelImage: Data.ResourceUrl,
-          Content: JSON.stringify(data),
-        });
-        this.loading.close();
-        if (res.Ret !== 200) return;
-        this.$message.success("保存成功");
-        this.$router.back()
-      }, 300),
-      markFinishStatus(){
-        if((!this.sheetId) || (!this.isCanEdit)) return
-        sheetInterface.markSheetEditStatus({ExcelInfoId: +this.sheetId,Status:2}).then(res=>{
-          if(res.Ret != 200) return 
-        })
-      }
-    }
-  }
-</script>
-
-<style lang="scss" scoped>
-  .sheet-detail-wrapper {
-    height: 100%;
-    border: 1px solid #ececec;
-    border-radius: 4px;
-    box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
-    overflow: auto;
-    background: #fff;
-    .detail-top {
-      padding: 20px;
-      // display: flex;
-      // justify-content: space-between;
-      // align-items: center;
-      border-bottom: 1px solid #ececec;
-      .sheet-name {
-        font-size: 18px;
-        color: #333333;
-        margin-bottom: 6px;
-        cursor: pointer;
-        max-width: 450px;
-        &:hover {
-          text-decoration: underline;
-        }
-      }
-      .sheet-anothor-info{
-        display: flex;
-        justify-content: space-between;
-        align-items: center;
-        .author{
-          color: #666666;
-          font-size: 16px;
-        }
-        .action-ul {
-          display: flex;
-          li {
-            margin: 0 10px;
-            display: flex;
-            align-items: center;
-            img{
-              height: 16px;
-              width: 16px;
-              margin-right: 4px;
-            }
-          }
-        }
-      }
-    }
-    .sheet-wrap {
-      position: relative;
-      height: calc(100vh - 210px);
-    }
-  }
-</style>

+ 49 - 68
src/views/datasheet_manage/customAnalysis/list.vue

@@ -142,7 +142,7 @@
         <!-- 表格详情 -->
         <div class="sheet-detail-wrapper" v-if="select_id" >
           <div class="detail-top">
-            <!-- <el-input
+            <el-input
               ref="sheetEditTitRef"
               style="width: 400px"
               placeholder="请输入表格名称"
@@ -150,10 +150,12 @@
               v-model="sheet_title"
               v-if="sheetDetailInfo.isEditTit"
               @blur="changeValue(sheetDetailInfo, 'edit-tit')"
-            /> -->
-            <div class="sheet-name">
+            />
+            <div class="sheet-name"
+              @click="editNodeLabel(sheetDetailInfo, 'edit-tit')"
+              v-else>
               {{ sheetDetailInfo.ExcelName }}
-              <!-- <i class="el-icon-edit"/> -->
+              <i class="el-icon-edit"/>
             </div>
             <div class="sheet-anothor-info">
               <span class="author">作者:{{ sheetDetailInfo.SysUserRealName }}</span>
@@ -172,15 +174,18 @@
                       <span>刷新指标</span>
                     </li>
                 </el-tooltip>
-                <!-- <li class="editsty" @click="saveHandle" v-if="isSheetBtnShow('save')&&sheetDetailInfo.Button.OpButton">保存</li> -->
-                <li
+                <li class="editsty" @click="saveHandle" v-if="isSheetBtnShow('save')&&sheetDetailInfo.Button.OpButton">
+                  <img src="~@/assets/img/icons/save_blue_new.png"/>
+                  <span>保存</span>
+                </li>
+                <!-- <li
                   class="editsty"
                   @click="goEdit"
                   v-if="(sheetDetailInfo.Button && sheetDetailInfo.Button.OpButton&&isSheetBtnShow('edit'))"
                 >
                   <img src="~@/assets/img/icons/edit_blue_new.png" v-if="!editButtonText"/>
                   <span>{{ editButtonText?editButtonText:'编辑' }}</span> 
-                </li>
+                </li> -->
                 <li
                   class="editsty"
                   @click="saveOtherHandle"
@@ -214,7 +219,6 @@
               ref="sheetRef"
               v-if="sheetConfigOpt.data"
               :option="sheetConfigOpt"
-              :limit="{disabled:true}"
             />
           </div>
         </div>
@@ -389,9 +393,6 @@ export default {
         '/sheetAnalysisList': 4,
       },
       saveTime:"",
-      editButtonText:'',
-      adminId:localStorage.getItem("AdminId") || '0',
-      excelAdminId:""
     };
   },
   watch: {
@@ -612,54 +613,40 @@ export default {
       };
       request.send();
     },
-    goEdit(){
-      sheetInterface.markSheetEditStatus({ExcelInfoId: this.select_id,Status:1}).then(res=>{
-        if(res.Ret != 200) return 
-        if(res.Data.Status==0){
-          this.$router.push({
-            path: '/editSheetAnalysis',
-            query: { code: this.sheetDetailInfo.UniqueCode },
-          });
-
-        }else if(res.Data.Status==1){
-          this.editButtonText = `${res.Data.Editor}编辑中`
-          this.$message.warning('当前'+this.editButtonText)
-        }
-      })
-    },
     /* 保存表格 */
-    // saveHandle: _.debounce(async function () {
-    //   luckysheet.exitEditMode();
-    //   let data = luckysheet.getAllSheets();
-
-    //   this.loading = this.$loading({
-    //     target: ".dataSheet-container",
-    //     lock: true,
-    //     text: "保存中...",
-    //     spinner: "el-icon-loading",
-    //     background: "rgba(255, 255, 255, 0.6)",
-    //   });
-
-    //   let img = getSheetImage(data[0]);
-    //   const form = new FormData();
-    //   form.append("Image", img);
-    //   const { Data } = await sheetInterface.uploadImg(form);
-
-    //   data.luckysheet_select_save = [];
-    //   const { ExcelInfoId, ExcelName, ExcelClassifyId } = this.sheetDetailInfo;
-
-    //   const res = await sheetInterface.sheetAnalysisInterface.sheetEdit({
-    //     ExcelInfoId,
-    //     ExcelName,
-    //     ExcelClassifyId,
-    //     ExcelImage: Data.ResourceUrl,
-    //     Content: JSON.stringify(data),
-    //   });
-    //   this.loading.close();
-    //   if (res.Ret !== 200) return;
-    //   this.$message.success("保存成功");
-    //   this.getTreeData();
-    // }, 300),
+    saveHandle: _.debounce(async function () {
+      luckysheet.exitEditMode();
+      let data = luckysheet.getAllSheets();
+
+      this.loading = this.$loading({
+        target: ".dataSheet-container",
+        lock: true,
+        text: "保存中...",
+        spinner: "el-icon-loading",
+        background: "rgba(255, 255, 255, 0.6)",
+      });
+
+      let img = getSheetImage(data[0]);
+      const form = new FormData();
+      form.append("Image", img);
+      const { Data } = await sheetInterface.uploadImg(form);
+
+      data.luckysheet_select_save = [];
+      const { ExcelInfoId, ExcelName, ExcelClassifyId } = this.sheetDetailInfo;
+
+      const res = await sheetInterface.sheetAnalysisInterface.sheetEdit({
+        ExcelInfoId,
+        ExcelName,
+        ExcelClassifyId,
+        ExcelImage: Data.ResourceUrl,
+        Content: JSON.stringify(data),
+      });
+      this.loading.close();
+      if (res.Ret !== 200) return;
+      this.saveTime = this.$moment().format('YYYY-MM-DD HH:mm:ss')
+      this.$message.success("保存成功");
+      this.getTreeData();
+    }, 300),
 
     /* 获取表格列表 */
     getPublicList() {
@@ -709,9 +696,7 @@ export default {
         if (res.Ret !== 200) return;
 
         this.sheetDetailInfo = res.Data.ExcelInfo;
-        this.saveTime = this.$moment(this.sheetDetailInfo.ModifyTime).format('YYYY-MM-DD HH:mm:ss')||''
-        this.excelAdminId = this.sheetDetailInfo.SysUserId
-        this.editButtonText = this.sheetDetailInfo.CanEdit?'':`${this.sheetDetailInfo.Editor}编辑中`
+        this.saveTime = this.$moment(this.sheetDetailInfo.ModifyTime).format('YYYY-MM-DD HH:mm:ss')
         this.dataToalPage =  Math.max(...res.Data.SheetList.map(_ => _.PageNum));
         this.sheetAllcellData = res.Data.SheetList.map(_ => _.Data ? JSON.parse(_.Data.Data) : []);
 
@@ -846,7 +831,7 @@ export default {
       this.$router.push({ path: '/createTaregtBySheet',query: {
         code: this.sheetDetailInfo.UniqueCode 
       }});
-    }
+    },
 
   },
   mounted() {
@@ -855,10 +840,6 @@ export default {
         code: this.$route.query.code,
         id: Number(this.$route.query.id),
       });
-    } else if(sessionStorage.getItem('editSheetAnalysisBack')){
-      let params=JSON.parse(sessionStorage.getItem('editSheetAnalysisBack'))
-      this.getTreeData(params);
-      sessionStorage.removeItem('editSheetAnalysisBack')
     }else {
       this.getTreeData();
       this.getPublicList();
@@ -1096,8 +1077,8 @@ $normal-font: 14px;
 <style lang="scss">
 .dataSheet-container {
   .label-input .el-input__inner {
-    height: 25px;
-    line-height: 25px;
+    height: 27px;
+    line-height: 27px;
     padding: 0 10px;
   }
 

+ 1 - 2
src/views/datasheet_manage/mixins/classifyMixin.js

@@ -297,8 +297,7 @@ export default {
         '/sheetList': 'etaTable_excel',
         '/sheetTimeList': 'etaTable_customize_data',
         '/sheetMixedList': 'etaTable_customize_mix',
-        '/sheetAnalysisList': 'etaTable_analysis',
-        '/editSheetAnalysis': 'etaTable_analysis'
+        '/sheetAnalysisList': 'etaTable_analysis'
       }
       return this.permissionBtn.isShowBtn('etaTablePermission',`${sheetType[this.$route.path]}_${type}`)
     }

+ 105 - 19
src/views/datasheet_manage/sheetList.vue

@@ -136,7 +136,7 @@
         <!-- 表格详情 -->
         <div class="sheet-detail-wrapper" v-if="select_id">
           <div class="detail-top">
-            <!-- <el-input
+            <el-input
               ref="sheetEditTitRef"
               style="width: 400px"
               placeholder="请输入表格名称"
@@ -144,18 +144,18 @@
               v-model="sheet_title"
               v-if="sheetDetailInfo.isEditTit"
               @blur="changeValue(sheetDetailInfo, 'edit-tit')"
-            /> -->
-            <!-- <span
+            />
+            <span
               class="sheet-name"
-              @click="editNodeLabel(sheetDetailInfo, 'edit-tit')"
+              @click="editExcelName(sheetDetailInfo, 'edit-tit')"
               v-else
             >
               {{ sheetDetailInfo.ExcelName }}
-              <i class="el-icon-edit" v-if="sheetDetailInfo.Source === 1" />
-            </span> -->
-            <div class="sheet-name">
+              <i class="el-icon-edit" v-if="sheetDetailInfo.Source === 1 && onlineExcelEditing" />
+            </span>
+            <!-- <div class="sheet-name">
               {{ sheetDetailInfo.ExcelName }}
-            </div>
+            </div> -->
             <div class="sheet-anothor-info">
               <span class="author">作者:{{ sheetDetailInfo.SysUserRealName }}</span>
               <ul class="action-ul">
@@ -163,11 +163,19 @@
                 <li
                   class="editsty"
                   @click="goEditHandle"
-                  v-if="(sheetDetailInfo.Button && sheetDetailInfo.Button.OpButton&&isSheetBtnShow('edit'))"
+                  v-if="(sheetDetailInfo.Button && sheetDetailInfo.Button.OpButton&&isSheetBtnShow('edit') && (!onlineExcelEditing))"
                 >
                   <img src="~@/assets/img/icons/edit_blue_new.png" v-if="!editButtonText"/>
                   <span>{{ editButtonText?editButtonText:'编辑' }}</span> 
                 </li>
+                <li
+                  class="editsty"
+                  @click="saveHandle"
+                  v-if="(sheetDetailInfo.Button && sheetDetailInfo.Button.OpButton&&isSheetBtnShow('save') && onlineExcelEditing)"
+                >
+                  <img src="~@/assets/img/icons/save_blue_new.png"/>
+                  <span>保存</span> 
+                </li>
                 <template v-if="[2, 3].includes(sheetDetailInfo.Source)">
                   <li
                     class="editsty"
@@ -218,7 +226,14 @@
                   scrollLeft: 0
                 }]
               }"
-              :limit="{disabled:true}"
+              :sheetInfo="{
+                ExcelInfoId: sheetDetailInfo.ExcelInfoId,
+                ExcelName: sheetDetailInfo.ExcelName,
+                ExcelClassifyId: sheetDetailInfo.ExcelClassifyId,
+                Source: sheetDetailInfo.Source
+              }"
+              :limit="limit"
+              @updated="autoSaveFun"
             />
 
             <!-- 自定义表格  -->
@@ -328,6 +343,12 @@ export default {
   name: "",
   components: { mDialog, classifyDia, Sheet, CustomTable, MixedTable,sheetListWrap },
   mixins: [leftMixin],
+  beforeRouteLeave(to,from,next){
+    if(from.path=='/sheetList' && to.path!='/sheetList'){
+      this.markFinishStatus()
+    }
+    next()
+  },
   computed: {
     downExcelFileUrl() {
       let url = `${
@@ -398,8 +419,12 @@ export default {
       },
       saveTime:"",
       editButtonText:"",
-      adminId:localStorage.getItem("AdminId") || '0',
-      excelAdminId:""
+      onlineExcelEditing:false,
+      limit:{
+        disabled:true
+      },
+      autoSaveType:'',//自动保存类型,有的自动保存后需要其他操作
+      cancelAutoSave:false, //自动保存时延迟的
     };
   },
   watch: {
@@ -411,8 +436,9 @@ export default {
       });
     },
     /* 表格id */
-    select_id(newval) {
+    select_id(newval,oldVlue) {
       newval && this.getDetailHandle();
+      this.markFinishStatus(oldVlue)
     },
 
     select_classify(newval) {
@@ -441,6 +467,18 @@ export default {
         this.select_id = newval;
       }
     },
+    onlineExcelEditing(value){
+      // console.log(value);
+      this.limit.disabled = !value
+    },
+    'sheetDetailInfo.ExcelName':{
+      handler:function(newValue,oldValue){
+        if(newValue && oldValue){
+          this.autoSaveType = 'nameEdit'
+          this.autoSaveFun()
+        }
+      }
+    }
   },
   methods: {
     /* 添加表格 */
@@ -662,7 +700,6 @@ export default {
         spinner: "el-icon-loading",
         background: "rgba(255, 255, 255, 0.6)",
       });
-
       let img = getSheetImage(data);
       const form = new FormData();
       form.append("Image", img);
@@ -670,6 +707,9 @@ export default {
 
       data.luckysheet_select_save = [];
       const { ExcelInfoId, ExcelName, ExcelClassifyId } = this.sheetDetailInfo;
+      
+      this.cancelAutoSave=true
+
       const res = await sheetInterface.sheetEdit({
         ExcelInfoId,
         ExcelName,
@@ -684,7 +724,34 @@ export default {
 
       this.getDetailHandle();
     }, 300),
+    autoSaveFun:_.debounce(async function(){
+      console.log("自动保存");
+      if(!this.onlineExcelEditing || this.cancelAutoSave){
+        this.cancelAutoSave=false
+        return
+      }
+      luckysheet.exitEditMode();
+      //结构类型乱飘 强制定义下
+      let data = {...luckysheet.getAllSheets()[0],status:Number(luckysheet.getAllSheets()[0].status)}
+      if (!data.celldata.length) return this.$message.warning("请输入表格内容");
+
+      data.luckysheet_select_save = [];
+      const { ExcelInfoId, ExcelName, ExcelClassifyId } = this.sheetDetailInfo;
+      const res = await sheetInterface.sheetEdit({
+        ExcelInfoId,
+        ExcelName,
+        ExcelClassifyId,
+        Content: JSON.stringify(data),
+      });
+      if (res.Ret !== 200) return;
+      if(this.autoSaveType == "nameEdit"){
+        this.getTreeData();
+        this.autoSaveType=''
+      }
+      
+      this.saveTime = this.$moment().format('YYYY-MM-DD HH:mm:ss')
 
+    },1500),
     /* 获取表格列表 */
     getPublicList() {
       sheetInterface.sheetList({
@@ -731,10 +798,7 @@ export default {
 
           this.sheetDetailInfo = res.Data;
           this.saveTime = this.$moment(this.sheetDetailInfo.ModifyTime).format('YYYY-MM-DD HH:mm:ss')||''
-          this.excelAdminId = this.sheetDetailInfo.SysUserId
           this.editButtonText = this.sheetDetailInfo.CanEdit?'':`${this.sheetDetailInfo.Editor}编辑中`
-          //从nextTick里面拉出来 更多功能按钮 显示的出来 但是删除表格,请求下一个表格详情时,表格内容不会更新。
-          // this.sheetDetailInfo.Source === 1 && this.$refs.sheetRef && this.$refs.sheetRef.init();
 
           this.$nextTick(() => {
 
@@ -774,8 +838,7 @@ export default {
             3: "/addMixedSheet",
           };
           if(this.sheetDetailInfo.Source === 1) {
-            const { href } = this.$router.resolve({ path: path[this.sheetDetailInfo.Source],query: { id: this.sheetDetailInfo.ExcelInfoId } });
-            window.open(href, "_blank");
+            this.onlineExcelEditing=true
           }else {
             this.$router.push({
               path: path[this.sheetDetailInfo.Source],
@@ -841,6 +904,23 @@ export default {
       let left = $("#left")[0].offsetWidth;
       let rigtWid = total_wid - left - 20 + "px";
       $("#right")[0].style.width = rigtWid;
+    },
+    editExcelName(sheetDetailInfo, type){
+      if(!this.onlineExcelEditing) return
+      this.editNodeLabel(sheetDetailInfo, type)
+    },
+    // 标记 编辑完成
+    markFinishStatus(select_id){
+      // console.log(select_id,'markFinishStatus',this.select_id);
+      let id = select_id || this.select_id
+      if((!this.onlineExcelEditing) || (!id) || id=='0'){
+        this.onlineExcelEditing=false
+        return
+      }
+      sheetInterface.markSheetEditStatus({ExcelInfoId: +id,Status:2}).then(res=>{
+        if(res.Ret != 200) return 
+      })
+      this.onlineExcelEditing=false
     }
   },
   mounted() {
@@ -855,9 +935,15 @@ export default {
     }
 
     window.addEventListener("resize", this.reloadRightWid);
+    if(this.$route.path == '/sheetList'){
+      window.addEventListener('beforeunload',this.markFinishStatus)
+    }
   },
   destroyed() {
     window.removeEventListener("resize", this.reloadRightWid);
+    if(this.$route.path == '/sheetList'){
+      window.removeEventListener('beforeunload',this.markFinishStatus)
+    }
   },
 };
 </script>