فهرست منبع

Merge branch 'eta1.9.8'

cxmo 3 ماه پیش
والد
کامیت
846ec452c9

+ 44 - 1
src/api/modules/sheetApi.js

@@ -492,5 +492,48 @@ export const sheetAnalysisInterface = {
 	 */
 	checkSheetRepeat: params => {
 		return http.get('/custom_analysis/excel_by_name',params)
-	}
+	},
+	/**
+	 * 全分类列表
+	 * @param {Object} params
+	 * @param {Boolean} params.IsShare 是否是共享列表
+	 * @returns 
+	 */
+	getSheetTreeList:params=>{
+		return http.get('/custom_analysis/excel_classify/list',params)
+	},
+	/**
+	 * 搜索和分类列表
+	 * @param {Object} params 
+	 * @param {Number} params.PageSize
+	 * @param {Number} params.CurrentIndex
+	 * @param {Number} params.ExcelClassifyId
+	 * @param {String} params.Keyword
+	 * @param {String} params.IsShare
+	 * @returns 
+	 */
+	getSheetList:params=>{
+		return http.get('/custom_analysis/excel/list',params)
+	},
+	/**
+	 * 设置表格分享
+	 * @param {Object} params 
+	 * @param {Number} params.ExcelInfoId
+	 * @param {Number[]} params.ViewUserIds
+	 * @param {Number[]} params.EditUserIds
+	 * @returns 
+	 */
+	setSheetShare:params=>{
+		return http.post('/custom_analysis/excel/share',params)
+	},
+	/**
+	 * 获取表格分享详情
+	 * @param {Object} params 
+	 * @param {Number} params.ExcelInfoId
+	 * @returns 
+	 */
+	getSheetShareDetail:params=>{
+		return http.get('/custom_analysis/excel/share_detail',params)
+	},
+
 }

+ 14 - 0
src/lang/modules/ETATables/En.js

@@ -121,6 +121,20 @@ export default {
     rules_unit: "Unit cannot be empty",
     date_sequence_cannot_msg: "The date sequence cannot be empty",
     numerical_sequence_cannot_msg: "The numerical sequence cannot be empty",
+
+    table_my:'My Table',
+    table_share:'Shared Table',
+    share_btn:'Share Settings',
+    cancel_share_btn:'Cancel Sharing',
+    share_user_btn:'Select User',
+    share_success_msg:'Set Successful',
+    cancel_share_success_msg:'Cancellation Successful',
+    cancel_share_hint:'Confirm to cancel the share?',
+    share_set_user:'Select Sharing User',
+    shart_user:'Sharing User',
+    share_check_text:'Viewable',
+    share_edit_text:'Editable',
+    share_set_hint:'Please select shared user permissions',
   },
 
   ETableChildren: {

+ 14 - 0
src/lang/modules/ETATables/Zh.js

@@ -121,6 +121,20 @@ export default {
     rules_unit: "单位不能为空",
     date_sequence_cannot_msg: "日期序列不能为空",
     numerical_sequence_cannot_msg: "数值序列不能为空",
+
+    table_my:'我的表格',
+    table_share:'共享表格',
+    share_btn:'设置共享',
+    cancel_share_btn:'取消共享',
+    share_user_btn:'选择用户',
+    share_success_msg:'设置共享成功',
+    cancel_share_success_msg:'取消共享成功',
+    cancel_share_hint:'是否确认取消共享?',
+    share_set_user:'设置共享用户',
+    shart_user:'共享用户',
+    share_check_text:'可查看权限',
+    share_edit_text:'可编辑权限',
+    share_set_hint:'未选择用户,请检查',
   },
 
   ETableChildren: {

+ 1 - 0
src/utils/buttonConfig.js

@@ -493,6 +493,7 @@ export const etaTablePermission = {
     etaTable_analysis_del:'etaTable:analysis:del',//删除
     etaTable_analysis_save:'etaTable:analysis:save',//保存
     etaTable_analysis_edit:'etaTable:analysis:edit',//编辑
+    etaTable_analysis_share:'etaTable:analysis:share',//设置共享,取消共享
 
     // 平衡表
     etaTable_customize_balance_sheetAdd:'etaTable:customize:balance:sheetAdd',//添加

+ 7 - 0
src/views/datasheet_manage/components/sheetListWrap.vue

@@ -22,6 +22,13 @@
           <div class="item-bottom">
             <span>{{$t('OnlineExcelPage.creation_time_tle')}}: {{ cell.CreateTime.slice(0, 10) }}</span>
             <div>
+                <span v-if="cell.Source===4&&$parent.isSheetBtnShow('otherSave')&&cell.HaveOperaAuth"
+                    class="editsty"
+                    style="margin-right: 10px"
+                    @click="$emit('saveOther',cell)"
+                >
+                    {{ $t('ETable.Btn.save_as') }}
+                </span>
               <span
                 v-if="$parent.isSheetBtnShow('download')&&cell.HaveOperaAuth"
                 class="editsty"

+ 17 - 3
src/views/datasheet_manage/customAnalysis/addAnalysisSheet.vue

@@ -133,12 +133,26 @@ export default {
 
     /* 获取分类 */
     getClassify() {
-      sheetInterface.excelClassifyOne({Source: 4}).then(res => {
+        sheetInterface.sheetAnalysisInterface.getSheetTreeList({IsShare:false}).then((res) => {
         if(res.Ret !==200) return
-        
-        this.classifyArr = res.Data.AllNodes || [];
+        this.classifyArr = this.formatTreeData(_.cloneDeep(res.Data.AllNodes || []))
+
       })
     },
+    formatTreeData(tree){
+        function dfs(node){
+            if (Array.isArray(node.Children)) {
+                node.Children = node.Children.filter(dfs)
+                if(node.Children.length===0) delete node.Children
+            }
+            
+            if(node.ExcelInfoId) {
+                return null
+            }
+            return node
+        }
+        return tree.filter(dfs)
+    },
 
     loadDataSync() {
       let len = this.sheetConfig.data.length;

+ 262 - 0
src/views/datasheet_manage/customAnalysis/components/shareTableDia.vue

@@ -0,0 +1,262 @@
+<template>
+    <!--  表格设置共享-->
+    <div class="share-table-dialog">
+        <el-dialog
+            :visible.sync="isOpenDialog"
+            :close-on-click-modal="false"
+            :modal-append-to-body='false'
+            :title="$t('CustomAnalysisPage.share_set_user')"
+            @close="$emit('close')"
+            width="760px"
+        >
+            <div class="container">
+                <div class="share-right-box" v-for="(item,index) in [$t('CustomAnalysisPage.share_check_text'),$t('CustomAnalysisPage.share_edit_text')]" :key="index">
+                    <div class="item-header">
+                        <span @click="shareDataList[index].isExpand=!shareDataList[index].isExpand">
+                            <i :class="shareDataList[index].isExpand?'el-icon-caret-bottom':'el-icon-caret-right'"></i>
+                            {{ item }}
+                        </span>
+                    </div>
+                    <div class="select-wrap" v-show="shareDataList[index].isExpand">
+                        <div class="select-box">
+                            <span>{{$t('CustomAnalysisPage.shart_user')}}</span>
+                            <el-cascader
+                                :ref="`user_select_${index}`"
+                                v-model="shareDataList[index].selectList"
+                                :options="shareDataList[index].userList"
+                                :show-all-levels="false"
+                                :key="shareDataList[index].selectKey"
+                                :placeholder="$t('SupplyAnalysis.StockPlant.placeholder03')"
+                                filterable
+                                :props="{
+                                    value:'NodeId',
+                                    label:'NodeName',
+                                    children:'Children',
+                                    emitPath: false,
+                                    multiple: true
+                                }"
+                                collapse-tags
+                                @change="selectListChange(index)"
+                            >
+                            </el-cascader>
+                        </div>
+                        <div class="list-box">
+                            <div class="list-item" v-for="item in shareDataList[index].selectShowList" :key="item.userId">
+                                {{ item.label }}
+                                <span class="close-btn" @click.stop="cancelSelectUser(index,item)">
+                                    <i class="el-icon-error"></i>
+                                </span>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="dia-bot" slot="footer" style="text-align:center;">
+                <el-button type="primary" style="margin-right:20px" @click="saveHandle">{{$t('Dialog.confirm_save_btn')}}</el-button>
+                <el-button type="primary" plain @click="$emit('close')">{{$t('Dialog.cancel_btn')}}</el-button>
+            </div>
+        </el-dialog>
+    </div>
+</template>
+
+<script>
+import { departInterence } from "@/api/api.js";
+import * as sheetInterface from "@/api/modules/sheetApi.js";
+export default {
+    props:{
+        isOpenDialog:{
+            type:Boolean,
+            default:false
+        },
+        tableInfo:{ //table的标识 sheetId?
+            type:Object
+        }
+    },
+    watch:{
+        async isOpenDialog(newval){
+            if(newval){
+                await this.getUserList()
+                this.getTableInfo()
+            }
+        }
+    },
+    data() {
+        return {
+            shareDataList:[
+                {
+                    isExpand:true,
+                    selectList:[],//选择的用户id 
+                    selectShowList:[],//选择的用户
+                    userList:[],//用户列表
+                    selectKey:0,
+                },//可查看
+                {
+                    isExpand:true,
+                    selectList:[]
+                },//可编辑
+            ],
+            userList:[],
+
+        };
+    },
+    methods: {
+        async getUserList(){
+            await departInterence.getSystemUser({
+                KeyWord: ''
+            }).then(res => {
+                if(res.Ret !== 200) return 
+                this.userList = res.Data||[]
+                //去掉Children为空的属性,非用户的叶子节点禁止选中
+                this.formatTreeData({Children:this.userList})
+                this.shareDataList[0].userList = _.cloneDeep(this.userList)
+                this.shareDataList[1].userList = _.cloneDeep(this.userList)
+            })
+        },
+        //遍历树形结构,处理children
+        formatTreeData(tree){
+            function dfs(node) {
+                if (Array.isArray(node.Children)) {
+                    for (let child of node.Children) {
+                        dfs(child); // 递归调用 DFS 函数处理子节点
+                    }
+                    if(node.Children.length===0) delete node.Children
+                }
+                //若为叶子节点,且不为用户,禁止选中
+                if(!node.Children||!Array.isArray(node.Children)){
+                    if(node.NodeType!==3) node.disabled = true
+                }
+            }
+            dfs(tree); 
+        },
+        //将指定节点设置为disabled
+        setListDisabled(arr,nodes){
+            function dfs(node){
+                if (Array.isArray(node.Children)) {
+                    for (let child of node.Children) {
+                        dfs(child); // 递归调用 DFS 函数处理子节点
+                    }
+                }
+                if(arr.includes(node.NodeId)){
+                    node.disabled = true
+                }
+            }
+            dfs({Children:nodes})
+        },
+        //获取表格权限列表
+        getTableInfo(){
+            sheetInterface.sheetAnalysisInterface.getSheetShareDetail({
+                ExcelInfoId:this.tableInfo.ExcelInfoId
+            }).then(res=>{
+                const {ViewUserIds=[],EditUserIds=[]} = res.Data||{}
+                this.shareDataList[0].selectList = ViewUserIds||[]
+                this.shareDataList[1].selectList = EditUserIds||[]
+                //设置选中状态
+                this.selectListChange(0)
+                this.selectListChange(1)
+            })
+        },
+        //筛选框选中变化
+        selectListChange(index){
+            //nextTick获取最新的选中状态
+            this.$nextTick(()=>{
+                const nodes = this.$refs[`user_select_${index}`][0].getCheckedNodes(true)
+                this.shareDataList[index].selectShowList = nodes.map(i=>{
+                    return {
+                        label:i.label,
+                        userId:i.value
+                    }
+                })
+                //将另一个筛选框对应用户置为禁止选中
+                const otherIndex = index===0?1:0
+                //先清除上次选中
+                this.shareDataList[otherIndex].userList = _.cloneDeep(this.userList)
+                this.setListDisabled(nodes.map(i=>i.value),this.shareDataList[otherIndex].userList)
+            })
+        },
+        //取消选择
+        cancelSelectUser(index,user){
+            const selectIndex = this.shareDataList[index].selectList.findIndex(i=>i===user.userId)
+            selectIndex!==-1&&this.shareDataList[index].selectList.splice(selectIndex,1)
+            this.shareDataList[index].selectKey++
+            this.$nextTick(()=>{
+                this.selectListChange(index)
+            })
+        },
+        saveHandle(){
+            //两个都没选,提示
+            const {selectList:checkList=[]} = this.shareDataList[0]
+            const {selectList:editList=[]} = this.shareDataList[1]
+            if(!checkList.length&&!editList.length){
+                return this.$message.warning(/* '未选择用户,请检查' */ this.$t('CustomAnalysisPage.share_set_hint'))
+            }
+            sheetInterface.sheetAnalysisInterface.setSheetShare({
+                ExcelInfoId:this.tableInfo.ExcelInfoId,
+                ViewUserIds:checkList,
+                EditUserIds:editList
+            }).then(res=>{
+                if(res.Ret!==200) return 
+                this.$message.success(`设置共享成功`)
+                this.$emit('setShare')
+            })
+        },
+    },
+};
+</script>
+
+<style lang="scss">
+.share-table-dialog{
+    .el-icon-caret-right:before{
+        content: "\E791" !important;
+    }
+    .el-cascader .el-input{
+        width:100%;
+    }
+}
+</style>
+<style scoped lang="scss">
+.share-table-dialog{
+    .container{
+        margin-left:25px;
+        .share-right-box{
+            margin-bottom:20px;
+            .item-header{
+                cursor:pointer;
+            }
+            .select-wrap{
+                .select-box{
+                    margin-top:10px;
+                    span{
+                        display:inline-block;
+                        width:80px;
+                        text-align:right;
+                        margin-right:15px;
+                    }
+                }
+                .list-box{
+                    margin-top:10px;
+                    margin-left:95px;
+                    display:flex;
+                    flex-wrap: wrap;
+                    gap:15px;
+                    max-height: 200px;
+                    overflow-y: auto;
+                    .list-item{
+                        cursor:pointer;
+                        display:flex;
+                        align-items:center;
+                        padding:5px;
+                        background-color:#D9D9D9;
+                        border-radius:4px;
+                        .close-btn{
+                            margin-left:5px;
+                            &:hover{
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+</style>

+ 243 - 84
src/views/datasheet_manage/customAnalysis/list.vue

@@ -19,8 +19,8 @@
             v-if="permissionBtn.checkPermissionBtn(permissionBtn.etaTablePermission.etaTable_analysis_upload)"
           >{{$t('CustomAnalysisPage.up_file_btn')}}</el-button>
           <input type="file" @change="fileSelected" id="file"  style="display: none;">
-          
-          <el-checkbox v-model="isShowMe"  @change="() => { getTreeData();getPublicList() }">{{$t('Chart.only_see_mine')}}</el-checkbox>
+          <!-- 只看我的 -->
+          <!-- <el-checkbox v-model="isShowMe"  @change="() => { getTreeData();getPublicList() }">{{$t('Chart.only_see_mine')}}</el-checkbox> -->
         </div>
         <div class="search-cont">
           <el-select
@@ -54,6 +54,16 @@
             </el-option>
           </el-select>
         </div>
+        <ul class="left-tab">
+          <li
+            :class="['tab', { act: classify_tab === index }]"
+            v-for="(tab, index) in [$t('CustomAnalysisPage.table_my'), $t('CustomAnalysisPage.table_share')]"
+            :key="tab"
+            @click="changeTab(index)"
+          >
+            {{ tab }}
+          </li>
+        </ul>
         <div class="tree-cont">
           <el-tree
             ref="treeRef"
@@ -65,7 +75,7 @@
             :allow-drop="canDropHandle"
             :current-node-key="select_node"
             :default-expanded-keys="defaultShowNodes"
-            draggable
+            :draggable="classify_tab!==1"
             :expand-on-click-node="false"
             check-strictly
             :empty-text="$t('Common.no_classify_msg')"
@@ -84,7 +94,7 @@
                 :placeholder="$t('OnlineExcelPage.please_value_ipt')"
                 class="label-input"
                 v-model="new_label"
-                v-if="data.isEdit&&isSheetBtnShow('classifyOpt_edit')"
+                v-if="data.isEdit&&isSheetBtnShow('classifyOpt_edit')&&classify_tab!==1"
                 @blur="changeValue(data)"
               />
               <span
@@ -112,21 +122,22 @@
                   src="~@/assets/img/data_m/move_ico.png"
                   alt=""
                   style="width: 14px; height: 14px; margin-right: 8px"
+                  v-if="classify_tab!==1"
+                />
+                 <!-- 目录操作:添加/编辑/删除 -->
+                <img
+                    src="~@/assets/img/set_m/add.png"
+                    alt=""
+                    style="width: 14px; height: 14px; margin-right: 8px"
+                    @click.stop="addNode(node,data)"
+                    v-if="!data.ExcelInfoId&&isSheetBtnShow('classifyOpt_edit')&&node.level<3&&classify_tab!==1"
                 />
-                 <!-- 添加子 -->
-								<img
-									src="~@/assets/img/set_m/add.png"
-									alt=""
-									style="width: 14px; height: 14px; margin-right: 8px"
-									@click.stop="addNode(node,data)"
-									v-if="!data.ExcelInfoId&&isSheetBtnShow('classifyOpt_edit')&&node.level<3"
-								/>
                 <img
                   src="~@/assets/img/set_m/edit.png"
                   alt=""
                   style="width: 15px; height: 14px; margin-right: 8px"
                   @click.stop="editNode(node, data)"
-                  v-if="!data.ExcelInfoId&&isSheetBtnShow('classifyOpt_edit')"
+                  v-if="!data.ExcelInfoId&&isSheetBtnShow('classifyOpt_edit')&&classify_tab!==1"
                 />
                 <img
                   slot="reference"
@@ -134,8 +145,30 @@
                   alt=""
                   style="width: 14px; height: 14px"
                   @click.stop="removeNode(node, data)"
-                  v-if="!data.ExcelInfoId&&isSheetBtnShow('classifyOpt_delete')"
+                  v-if="!data.ExcelInfoId&&isSheetBtnShow('classifyOpt_delete')&&classify_tab!==1"
                 />
+                <!-- 表格操作:共享/取消共享 -->
+                <span v-if="data.ExcelInfoId&&data.ShowShareBtn&&isSheetBtnShow('share')">
+                    <el-dropdown @command="handleShareCommand">
+                        <i class="el-icon-share" style="color:#5cb6ff;"></i>
+                        <el-dropdown-menu slot="dropdown">
+                            <!-- 表格为已共享,有取消共享按钮 -->
+                            <el-dropdown-item v-if="(classify_tab===1||data.HasShare)"
+                                :command="{key:'cancel',item:data}"
+                                class="treenode-dropdown-item"
+                                :class="data.isShare===0?'treenode-dropdown-item-act':''" 
+                            >
+                                {{$t('CustomAnalysisPage.cancel_share_btn')}}
+                            </el-dropdown-item>
+                            <el-dropdown-item :command="{key:'share',item:data}"
+                                class="treenode-dropdown-item"
+                                :class="data.isShare===1?'treenode-dropdown-item-act':''" 
+                            >
+                                {{classify_tab?$t('CustomAnalysisPage.share_user_btn'):$t('CustomAnalysisPage.share_btn')}}
+                            </el-dropdown-item>
+                        </el-dropdown-menu>
+                    </el-dropdown>
+                </span>
               </span>
             </span>
           </el-tree>
@@ -180,61 +213,63 @@
                 @blur="changeValue(sheetDetailInfo, 'edit-tit')"
               />
               <div class="sheet-name"
-                @click="editNodeLabel(sheetDetailInfo, 'edit-tit')"
+                @click="()=>{sheetDetailInfo.Button.OpButton&&editNodeLabel(sheetDetailInfo, 'edit-tit')}"
                 v-else>
                 {{ sheetDetailInfo.ExcelName }}
-                <i class="el-icon-edit"/>
+                <i class="el-icon-edit" v-if="sheetDetailInfo.Button.OpButton"/>
               </div>
               <div class="sheet-anothor-info">
                 <span class="author">{{$t('OnlineExcelPage.author_info')}}{{ sheetDetailInfo.SysUserRealName }}</span>
                 <ul class="action-ul" v-if="sheetDetailInfo.Button">
                   <li style="color:#999999 ;">{{$t('OnlineExcelPage.recent_save_time_info')}}{{ saveTime }}</li>
-                  <el-tooltip effect="dark" :content="$t('CustomAnalysisPage.up_save_tooltip')" 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>{{$t('CustomAnalysisPage.generate_indicators_btn')}}</span>
-                      </li>
-                  </el-tooltip>
-
-                  <el-tooltip effect="dark" :content="$t('CustomAnalysisPage.up_save_tooltip')" 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>{{ isEdbReFreshLoading? $t('CustomAnalysisPage.refreshing_loading'):$t('CustomAnalysisPage.refresh_loading')}}</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>{{$t('ETable.Btn.save_btn')}}</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
-                    class="editsty"
-                    @click="saveOtherHandle"
-                    v-if="isSheetBtnShow('otherSave')&&sheetDetailInfo.Button.CopyButton"
-                  >
-                    <img src="~@/assets/img/icons/save_as_blue_new.png"/>
-                    <span>{{$t('ETable.Btn.save_as')}}</span>
-                  </li>
-                  <li class="editsty" @click="downloadExcel
-                  (sheetDetailInfo)" v-if="isSheetBtnShow('download')&&sheetDetailInfo.Button.DownloadButton">
-                    <img src="~@/assets/img/icons/download_blue.png"/>
-                    <span>{{$t('ETable.Btn.download_btn')}}</span>
-                  </li>
-                  <li
-                    class="deletesty"
-                    v-if="(isSheetBtnShow('del')&&sheetDetailInfo.Button&&sheetDetailInfo.Button.DeleteButton)"
-                    @click="delSheetHandle({cell:sheetDetailInfo, type:'del'})"
-                  >
-                    <img src="~@/assets/img/icons/delete-red.png"/>
-                    <span>{{$t('ETable.Btn.delete_btn')}}</span>
-                  </li>
+                  <template v-if="!editButtonText">
+                        <el-tooltip effect="dark" :content="$t('CustomAnalysisPage.up_save_tooltip')" 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>{{$t('CustomAnalysisPage.generate_indicators_btn')}}</span>
+                            </li>
+                        </el-tooltip>
+                        <el-tooltip effect="dark" :content="$t('CustomAnalysisPage.up_save_tooltip')" 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>{{ isEdbReFreshLoading? $t('CustomAnalysisPage.refreshing_loading'):$t('CustomAnalysisPage.refresh_loading')}}</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>{{$t('ETable.Btn.save_btn')}}</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
+                            class="editsty"
+                            @click="saveOtherHandle(null)"
+                            v-if="isSheetBtnShow('otherSave')&&sheetDetailInfo.Button.CopyButton"
+                        >
+                            <img src="~@/assets/img/icons/save_as_blue_new.png"/>
+                            <span>{{$t('ETable.Btn.save_as')}}</span>
+                        </li>
+                        <li class="editsty" @click="downloadExcel
+                        (sheetDetailInfo)" v-if="isSheetBtnShow('download')&&sheetDetailInfo.Button.DownloadButton">
+                            <img src="~@/assets/img/icons/download_blue.png"/>
+                            <span>{{$t('ETable.Btn.download_btn')}}</span>
+                        </li>
+                        <li
+                            class="deletesty"
+                            v-if="(isSheetBtnShow('del')&&sheetDetailInfo.Button&&sheetDetailInfo.Button.DeleteButton)"
+                            @click="delSheetHandle({cell:sheetDetailInfo, type:'del'})"
+                        >
+                            <img src="~@/assets/img/icons/delete-red.png"/>
+                            <span>{{$t('ETable.Btn.delete_btn')}}</span>
+                        </li>
+                  </template>
+                  <li v-else>{{ editButtonText }}</li>
                 </ul>
               </div>
             </div>
@@ -245,6 +280,7 @@
                 ref="sheetRef"
                 v-if="sheetConfigOpt.data"
                 :option="sheetConfigOpt"
+                :limit="limit"
                 @updated="hasChange=true"
               />
             </div>
@@ -262,6 +298,7 @@
           @detailShowHandle="detailShowHandle"
           @delSheetHandle="delSheetHandle"
           @downloadExcel="downloadExcel"
+          @saveOther="saveOtherHandle"
           ref="sheetListWrap"
         />
       </div>
@@ -309,6 +346,7 @@
                 value: 'ExcelClassifyId',
                 children: 'Children',
                 emitPath: false,
+                checkStrictly:true
               }"
               style="width: 80%"
               :placeholder="$t('OnlineExcelPage.select_appropriate_category_lable')"
@@ -329,6 +367,13 @@
         >
       </div>
     </m-dialog>
+    <!-- 设置共享弹窗 -->
+    <shareTableDia
+        :isOpenDialog="isShowShareDia"
+        :tableInfo="currentTable"
+        @close="isShowShareDia=false"
+        @setShare="isShowShareDia=false;getTreeData();"
+    />
   </div>
 </template>
 
@@ -337,13 +382,20 @@ import * as sheetInterface from "@/api/modules/sheetApi.js";
 import leftMixin from "../mixins/classifyMixin";
 import mDialog from "@/components/mDialog.vue";
 import classifyDia from "../components/sheetClassifyDia.vue";
+import shareTableDia from "./components/shareTableDia"
 import Sheet from "../components/SheetExcel.vue";
 import { getSheetImage } from "../common/option";
 import sheetListWrap from "../components/sheetListWrap.vue"
 export default {
   name: "",
-  components: { mDialog, classifyDia, Sheet, sheetListWrap },
+  components: { mDialog, classifyDia, Sheet, sheetListWrap, shareTableDia },
   mixins: [leftMixin],
+  beforeRouteLeave(to,from,next){
+    if(from.path=='/sheetAnalysisList'){
+      this.markFinishStatus(this.select_id)
+    }
+    next()
+  },
   computed: {
     downExcelFileUrl() {
       let url = `${
@@ -351,14 +403,6 @@ export default {
       }/datamanage/excel_info/table/download?${localStorage.getItem("auth")}`;
       return url;
     },
-    classifyOptions() {
-      let options = this.treeData.map((_) => ({
-        ExcelClassifyId: _.ExcelClassifyId,
-        ExcelClassifyName: _.ExcelClassifyName,
-      }));
-
-      return options;
-    },
     saveOtherFormRule(){
       return {
         name: [
@@ -430,6 +474,15 @@ export default {
       isEdbReFreshLoading: false,//指标刷新
       // 内容是否更新
       hasChange:false,
+
+      classify_tab:0,//tab栏选中的项
+      isShowShareDia:false,
+      limit:{
+        disabled:true
+      },
+      editButtonText:"",
+      currentTable:{},
+      classifyOptions:[]
     };
   },
   watch: {
@@ -441,13 +494,14 @@ export default {
       });
     },
     /* 表格id */
-    select_id(newval) {
+    select_id(newval,oldval) {
       this.sheetDataPage = 2,
       this.sheetAllcellData = [],//全部单元格数据 分页push
       this.dataToalPage = 0;
       this.sheetConfigOpt.data = null;
       this.hasChange=false
       newval && this.getDetailHandle();
+      this.markFinishStatus(oldval)
     },
 
     select_classify(newval) {
@@ -478,15 +532,96 @@ export default {
     },
   },
   methods: {
-
+    formatTreeData(tree){
+        function dfs(node){
+            if (Array.isArray(node.Children)) {
+                node.Children = node.Children.filter(dfs)
+                if(node.Children.length===0) delete node.Children
+            }
+            
+            if(node.ExcelInfoId) {
+                return null
+            }
+            return node
+        }
+        return tree.filter(dfs)
+    },
+    unloadMark(){
+        if(!this.select_id)return
+
+        let url = process.env.VUE_APP_API_ROOT + "/datamanage/excel_info/mark"
+        let params={ExcelInfoId: this.select_id,Status:2}
+        const uuid = localStorage.getItem("uuid") || "";
+        fetch(url, {
+        method: 'POST',
+        headers:{
+            Authorization:localStorage.getItem("auth"),
+            Uuid:uuid,
+            AccessToken:uuid + "--zheshiyigename"
+        },
+        body:JSON.stringify(params),
+        // 保持连接 让请求不会因为页面关闭而中断
+        keepalive: true
+        });
+    },
+    //取消标记表格的编辑状态
+    markFinishStatus(sheet_id){
+        if(!sheet_id)return
+        sheetInterface.markSheetEditStatus({ExcelInfoId: sheet_id,Status:2}).then(res=>{
+            if(res.Ret!==200) return
+        })
+    },
+    //标记表格的编辑状态
+    goEditHandle(){
+        sheetInterface.markSheetEditStatus({ExcelInfoId: this.select_id,Status:1}).then(res=>{
+            if(res.Ret!==200) return
+        })
+    },
+    //切换表格tab
+    changeTab(index){
+        this.classify_tab = index
+        this.search_txt = ''
+        this.select_classify = 0
+        this.select_id = 0
+        this.sheetList = []
+        this.getTreeData()
+        this.getPublicList()
+    },
+    //表格 设置共享/取消共享
+    handleShareCommand(command){
+        if(command.key==='share'){
+            this.currentTable = command.item
+            this.isShowShareDia = true
+        }else{
+            //取消共享就是 两个权限列表都为空 但是要二次确认
+            this.$confirm(/* "是否确认取消共享?" */this.$t('CustomAnalysisPage.cancel_share_hint'), this.$t('Dialog.warn_tit'), {
+                type: "warning",
+           }).then(() => {
+                sheetInterface.sheetAnalysisInterface.setSheetShare({
+                    ExcelInfoId:command.item.ExcelInfoId,
+                    ViewUserIds:[],
+                    EditUserIds:[]
+                }).then(res=>{
+                    if(res.Ret!==200) return 
+                    this.$message.success(this.$t('CustomAnalysisPage.cancel_share_success_msg'))
+                    this.getTreeData()
+                    this.getPublicList()
+                })
+           })
+            .catch(() => {});
+        }
+    },
     /* 获取表格分类 */
     getTreeData(params = null) {
-      sheetInterface.classifyList({Source: this.sourceMap[this.$route.path],IsShowMe: this.isShowMe}).then((res) => {
+      sheetInterface.sheetAnalysisInterface.getSheetTreeList({IsShare:Boolean(this.classify_tab)}).then((res) => {
         const { Ret, Data } = res;
         if (Ret !== 200) return;
 
         this.showData = true;
         this.treeData = Data.AllNodes || [];
+        if(!this.classify_tab){
+            this.classifyOptions = this.formatTreeData(_.cloneDeep(this.treeData))
+        }
         this.$nextTick(() => {
           /* 新增完成后 处理树展开和选中 */
           params && this.selectCurrentNode(params);
@@ -498,12 +633,12 @@ export default {
     searchHandle(query) {
       if (query) {
         /* 查找列表 */
-        sheetInterface
-          .sheetList({
+        sheetInterface.sheetAnalysisInterface
+          .getSheetList({
             Keyword: query,
             CurrentIndex: 1,
             PageSize: 10000,
-            Source: this.sourceMap[this.$route.path]
+            IsShare:Boolean(this.classify_tab)
           })
           .then((res) => {
             if (res.Ret !== 200) return;
@@ -723,13 +858,12 @@ export default {
     },
     /* 获取表格列表 */
     getPublicList() {
-      sheetInterface
-        .sheetList({
+      sheetInterface.sheetAnalysisInterface
+        .getSheetList({
           CurrentIndex: this.sheet_page,
           PageSize: this.sheet_pages_size,
           ExcelClassifyId: this.select_classify || 0,
-          Source: this.sourceMap[this.$route.path],
-          IsShowMe: this.isShowMe 
+          IsShare:Boolean(this.classify_tab)
         })
         .then((res) => {
           if (res.Ret !== 200) return;
@@ -774,6 +908,11 @@ export default {
         this.sheetAllcellData = res.Data.SheetList.map(_ => _.Data ? JSON.parse(_.Data.Data) : []);
 
         this.getCellData(res.Data.SheetList)
+        //判断表格权限
+        //有编辑权限且无人编辑,标记编辑
+        this.limit.disabled = !this.sheetDetailInfo.Button.OpButton
+        this.sheetDetailInfo.Button.OpButton&&!this.sheetDetailInfo.Editor&&this.goEditHandle()
+        this.editButtonText = this.sheetDetailInfo.CanEdit?'':`${this.sheetDetailInfo.Editor}${this.$t('OnlineExcelPage.editing_msg')}...`
       });
     },
 
@@ -831,7 +970,8 @@ export default {
     },
 
     /* 表格另存为 */
-    saveOtherHandle() {
+    saveOtherHandle(cell) {
+      cell&&(this.sheetDetailInfo = cell)
       this.saveOtherForm.name = this.sheetDetailInfo.ExcelName + "(1)";
       this.isSaveOther = true;
     },
@@ -952,13 +1092,14 @@ export default {
       this.getTreeData();
       this.getPublicList();
     }
-
     window.addEventListener("resize", this.reloadRightWid);
     document.addEventListener("click", this.closeHint);
+    window.addEventListener('beforeunload',this.unloadMark)
   },
   destroyed() {
     window.removeEventListener("resize", this.reloadRightWid);
     document.removeEventListener("click", this.closeHint);
+    window.removeEventListener('beforeunload',this.unloadMark)
   },
 };
 </script>
@@ -1016,7 +1157,25 @@ $normal-font: 14px;
       .search-cont {
         padding: 0 20px;
       }
-
+      .left-tab {
+        display: flex;
+        align-items: center;
+        padding: 20px 20px 0;
+        .tab {
+          cursor: pointer;
+          font-size: 16px;
+          border-bottom: 2px solid transparent;
+          margin-right: 40px;
+          padding-bottom: 5px;
+          &.act {
+            color: #409eff;
+            border-color: #409eff;
+          }
+          &:hover {
+            color: #409eff;
+          }
+        }
+      }
       .tree-cont {
         padding: 30px 20px;
         max-height: calc(100vh - 280px);

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

@@ -43,7 +43,7 @@ export default {
     selectCurrentNode({ code, id, type }) {
       let deep_arr = _.cloneDeep(this.treeData);
       // 查找图表的分类父级id
-      let arr = this.findParentNodeHandle(deep_arr, code).slice(1).reverse(); // 父的父的父-父的父-父
+      let arr = (this.findParentNodeHandle(deep_arr, code)||[]).slice(1).reverse(); // 父的父的父-父的父-父
       this.defaultShowNodes = arr;
       this.select_node = code;
       this.$refs.treeRef.setCurrentKey(this.select_node);