瀏覽代碼

平衡表预览

jwyu 1 年之前
父節點
當前提交
d2e3353296

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

@@ -231,6 +231,14 @@ export default [
 					name_en:'Balance Sheet'
 				}
 			},
+			{
+				path:"viewBalanceSheet",
+				name:"平衡表",
+				component:()=>import('@/views/datasheet_manage/balanceSheetEdit.vue'),
+				meta:{
+					name_en:'Balance Sheet'
+				}
+			},
 			{
 				path:"editBalanceSheet",
 				name:"编辑平衡表",

+ 177 - 3
src/views/datasheet_manage/balanceSheetEdit.vue

@@ -8,6 +8,7 @@
             :placeholder="$t('OnlineExcelPage.please_table_name_ipt')"
             style="width: 200px"
             clearable
+            :disabled="isView"
           >
           </el-input>
         </li>
@@ -25,6 +26,7 @@
             }"
             clearable
             :placeholder="$t('OnlineExcelPage.select_table_category')"
+            :disabled="isView"
           />
         </li>
         <li>
@@ -44,6 +46,7 @@
             }"
             clearable
             :placeholder="$t('OnlineExcelPage.Co_editor')"
+            :disabled="isView"
           />
         </li>
       </ul>
@@ -60,7 +63,7 @@
             :value="item.key"
           ></el-option>
         </el-select>
-        <el-button type="primary" @click="handleShowSaveStaticTable">{{
+        <el-button type="primary" @click="handleShowSaveStaticTable" v-if="!isView">{{
           $t("BalanceSheet.save_static_table")
         }}</el-button>
         <div>
@@ -80,6 +83,46 @@
           >{{ $t("OnlineExcelPage.recent_save_time_info")
           }}{{ updateTime }}</span
         >
+        <!-- 预览页面操作按钮 -->
+        <template v-if="isView">
+          <!-- <div> -->
+            <span
+            class="editsty"
+            @click="itemHandle(excelInfo, 'edit')"
+            style="margin-right: 10px"
+            v-if="isSheetBtnShow('edit')&&excelInfo.Button.OpButton"
+            >{{excelInfo.CanEdit?$t("ETable.Btn.edit_btn"):excelInfo.Editor+$t('OnlineExcelPage.editing_msg')}}</span
+          >
+          <span
+            class="editsty"
+            @click="itemHandle(excelInfo, 'refresh')"
+            style="margin-right: 10px"
+            v-if="isSheetBtnShow('refresh')&&excelInfo.Button.RefreshButton"
+            >{{ $t("ETable.Btn.refresh_btn") }}</span
+          >
+          <span
+            class="editsty"
+            @click="itemHandle(excelInfo, 'save')"
+            style="margin-right: 10px"
+            v-if="isSheetBtnShow('otherSave')&&excelInfo.Button.CopyButton"
+            >{{ $t("ETable.Btn.save_as") }}</span
+          >
+          <span
+            class="editsty"
+            @click="itemHandle(excelInfo, 'download')"
+            style="margin-right: 10px"
+            v-if="isSheetBtnShow('download')"
+            >{{ $t("ETable.Btn.download_btn") }}</span
+          >
+          <span
+            class="deletesty"
+            @click="itemHandle(excelInfo, 'del')"
+            style="margin-right: 10px"
+            v-if="isSheetBtnShow('del')&&excelInfo.Button.DeleteButton"
+            >{{ $t("Table.delete_btn") }}</span
+          >
+          <!-- </div> -->
+        </template>
         <!-- icon="el-icon-refresh-right" -->
         <el-button
           type="primary"
@@ -87,6 +130,7 @@
           :loading="updating"
           @click="updateHandle"
           style="margin-left: 10px"
+          v-if="!isView"
           >{{
             updating
               ? $t("ETable.Btn.renewing_btn")
@@ -98,6 +142,7 @@
           size="medium"
           @click="saveSheetHandle"
           style="margin-left: 10px"
+          v-if="!isView"
           >{{ $t("ETable.Btn.save_btn") }}</el-button
         >
         <el-button type="primary" size="medium" plain @click="backHandle">{{
@@ -108,6 +153,7 @@
 
     <BalanceTable 
       ref="balanceTableRef"
+      :disabled="isView"
     />
 
     <!-- 存为静态表弹窗 -->
@@ -131,6 +177,60 @@
 				<el-button type="primary" plain @click="showSaveStaticTable=false">{{$t('ETable.Btn.cancel_btn')}}</el-button>
 			</div>
     </el-dialog>
+
+    <!-- 表格另存 -->
+    <m-dialog
+      :show.sync="isSaveOther"
+      width="650px"
+      :title="$t('ETable.Btn.save_as')"
+      @close="cancelSaveOther"
+    >
+      <div style="padding-left: 80px">
+        <el-form
+          ref="formRef"
+          label-position="left"
+          hide-required-asterisk
+          label-width="80px"
+          :model="saveOtherForm"
+          :rules="saveOtherFormRule"
+        >
+          <el-form-item :label="$t('OnlineExcelPage.excel_name_ipt')" prop="name">
+            <el-input
+              v-model="saveOtherForm.name"
+              style="width: 80%"
+              :placeholder="$t('OnlineExcelPage.please_table_name_ipt')"
+            />
+          </el-form-item>
+          <el-form-item :label="$t('OnlineExcelPage.table_classification_label')" prop="classify">
+            <el-cascader
+              v-model="saveOtherForm.classify"
+              :options="classifyOptions"
+              :props="{
+                label: 'ExcelClassifyName',
+                value: 'ExcelClassifyId',
+                children: 'Children',
+                emitPath: false,
+              }"
+              style="width: 80%"
+              :placeholder="$t('OnlineExcelPage.select_appropriate_category_lable')"
+              class="sheet-classify-cascader"
+            />
+          </el-form-item>
+        </el-form>
+      </div>
+      <div style="display: flex; justify-content: center; margin-top: 30px">
+        <el-button
+          type="primary"
+          style="margin-right: 60px"
+          @click="saveCopyOther"
+          >{{$t('Dialog.confirm_save_btn')}}</el-button
+        >
+        <el-button type="primary" plain @click="cancelSaveOther"
+          >{{$t('Dialog.cancel_btn')}}</el-button
+        >
+      </div>
+    </m-dialog>
+
   </div>
 </template>
 
@@ -138,19 +238,50 @@
 import * as sheetInterface from '@/api/modules/sheetApi.js';
 import { departInterence } from "@/api/api.js";
 import moment from 'moment';
+import mDialog from "@/components/mDialog.vue";
 import BalanceTable from './components/BalanceTable.vue';
+import BalanceTableMixin from './mixins/balanceTableMixin'
 export default {
+  mixins:[BalanceTableMixin],
   components: {
-    BalanceTable
+    BalanceTable,
+    mDialog
   },
   computed: {
+    downExcelFileUrl() {
+      let url = `${
+        process.env.VUE_APP_API_ROOT
+      }/datamanage/excel_info/table/download?${localStorage.getItem("auth")}`;
+      return url;
+    },
     rules() {
       return this.$t('OnlineExcelPage.TableInstructionsText') || ''
     },
+    isView(){
+      return this.$route.path==='/viewBalanceSheet'
+    },
+    classifyOptions() {
+      let options = this.classifyArr.map((_) => ({
+        ExcelClassifyId: _.ExcelClassifyId,
+        ExcelClassifyName: _.ExcelClassifyName,
+      }));
+      return options;
+    },
+    saveOtherFormRule(){
+      return {
+        name: [
+          { required: true, message: this.$t('OnlineExcelPage.table_name_empty_msg') , trigger: "blur" },
+        ],
+        classify: [
+          { required: true, message: this.$t('OnlineExcelPage.cannot_be_empty_table') , trigger: "blur" },
+        ],
+      }
+    }
   },
   data() {
     return {
       sheetId: this.$route.query.id || '',
+      excelInfo:{},
 
       updating:false,
 
@@ -171,7 +302,14 @@ export default {
       ],
 
       showSaveStaticTable:false,//存为静态表弹窗
-      staticTableName:''
+      staticTableName:'',
+
+      /* 另存为 */
+      isSaveOther: false,
+      saveOtherForm: {
+        name: '',
+				classify: ''
+      },
 
     }
   },
@@ -192,6 +330,32 @@ export default {
     
   },
   methods: {
+    cancelSaveOther() {
+      this.$refs.formRef.resetFields();
+      this.saveOtherForm = {
+        name: '',
+				classify: ''
+      };
+      this.isSaveOther = false;
+    },
+
+    /* 另存为 */
+    async saveCopyOther() {
+      await this.$refs.formRef.validate();
+      let { classify, name } = this.saveOtherForm;
+
+      const res = await sheetInterface.copyExcel({
+        ExcelInfoId: this.excelInfo.ExcelInfoId,
+        ExcelName: name,
+        ExcelClassifyId: classify,
+      });
+
+      if (res.Ret !== 200) return;
+
+      this.$message.success(this.$t('MsgPrompt.saved_msg') );
+      this.cancelSaveOther();
+    },
+
     handleShowSaveStaticTable(){
       this.staticTableName=''
       this.showSaveStaticTable=true
@@ -222,6 +386,7 @@ export default {
 				ExcelInfoId: Number(this.sheetId)
 			})
       if(res.Ret !== 200)  return
+      this.excelInfo=res.Data
       const { ExcelName,ExcelClassifyId,TableData,ModifyTime,Button } = res.Data;
       this.sheetForm.name=ExcelName
       this.sheetForm.classify=ExcelClassifyId
@@ -321,11 +486,20 @@ export default {
       sheetInterface.markSheetEditStatus({ExcelInfoId:Number(this.sheetId),Status:2}).then(res=>{
         if(res.Ret != 200) return 
       })
+    },
+
+    isSheetBtnShow(type){
+      return this.permissionBtn.isShowBtn('etaTablePermission',`etaTable_customize_balance_${type}`)
     }
   },
 }
 </script>
 
+<style lang="scss">
+.sheet-classify-cascader .el-input {
+	width: 100%;
+}
+</style>
 <style scoped lang="scss">
 * {
   box-sizing: border-box;

+ 7 - 3
src/views/datasheet_manage/components/BalanceSheetChartItem.vue

@@ -16,9 +16,9 @@
                 <!-- 加入我的图库 -->
                 <span class="btn-o" @click="handleAddMyChart">{{$t('Chart.chart_addmy_btn')}}</span>
                 <!-- 编辑 -->
-                <span class="btn-o" @click="handleEditChart">{{$t('Chart.chart_edit_btn')}}</span>
+                <span class="btn-o" v-if="!disabled" @click="handleEditChart">{{$t('Chart.chart_edit_btn')}}</span>
                 <!-- 删除 -->
-                <span class="btn-o" style="color:#f00" @click="handleDelChart">{{$t('Chart.chart_del_btn')}}</span>
+                <span class="btn-o" v-if="!disabled" style="color:#f00" @click="handleDelChart">{{$t('Chart.chart_del_btn')}}</span>
             </div>
         </div>
 
@@ -41,7 +41,11 @@ import addMyClassifyDia from '@/views/dataEntry_manage/components/addMyClassifyD
 export default {
     components:{Chart,addMyClassifyDia},
     props:{
-        chartData:{}
+        chartData:{},
+        disabled: { //是否只预览
+            type: Boolean,
+            default: false,
+        }
     },
     mixins: [chartSetMixin],
     watch: {

+ 8 - 56
src/views/datasheet_manage/components/BalanceSheetList.vue

@@ -14,7 +14,7 @@
           <span v-if="item.key === 'ModifyTime'">{{
             row.ModifyTime | getTime
           }}</span>
-          <span v-else-if="item.key === 'ExcelName'" style="cursor: pointer;">{{
+          <span v-else-if="item.key === 'ExcelName'" style="cursor: pointer;" @click="goDetail(row)">{{
             row.ExcelName
           }}</span>
           <span v-else>{{ row[item.key] }}</span>
@@ -73,8 +73,10 @@
 
 <script>
 import * as sheetInterface from "@/api/modules/sheetApi.js";
+import BalanceTableMixin from '../mixins/balanceTableMixin'
 import moment from 'moment'
 export default {
+  mixins:[BalanceTableMixin],
   props: {
     total: {
       type: Number
@@ -125,66 +127,16 @@ export default {
     this.$refs.tableRef.bodyWrapper.removeEventListener('mousewheel', this.handleScroll)
   },
   methods: {
-    itemHandle(data,type){
-      if(type==='edit'){
-        this.handleEdit(data)
-        return
-      }
-      if(type==='refresh'){
-        this.refreshSheetEdb(data.ExcelInfoId)
-        return
-      }
-      if(type==='save'){
-        this.$parent.sheetDetailInfo=data
-        this.$parent.saveOtherHandle()
-        return
-      }
-      if(type==='download'){
-        this.$emit('downloadExcel',data)
-        return
-      }
-      if(type==='del'){
-        this.$emit('delSheetHandle',{cell:data, type:'del-list'})
-        return
-      }
-
-    },
-
-    // 去编辑
-    async handleEdit(data){
-      const res=await sheetInterface.markSheetEditStatus({ExcelInfoId: data.ExcelInfoId,Status:1})
-      if(res.Ret!==200) return
-      if(res.Data.Status==0){
-        this.$router.push({
-          path:'/editBalanceSheet',
+    //查看平衡表
+    goDetail(data){
+      this.$router.push({
+          path:'/viewBalanceSheet',
           query:{
             id:data.ExcelInfoId
           }
-        })
-      }else if(res.Data.Status==1){//编辑中
-        const text=`${res.Data.Editor}${this.$t('OnlineExcelPage.editing_msg')}`
-        this.$emit('updateEdit',{
-          ExcelInfoId:data.ExcelInfoId,
-          Editor:res.Data.Editor,
-        })
-        this.$message.warning('当前'+text)
-      }
+      })
     },
 
-    /* 刷新表格 */
-    refreshSheetEdb: _.debounce(async function (id) {
-      if(this.sheetRefreshing) return
-      this.sheetRefreshing=true
-      const res = await sheetInterface.refreshCustomSheet({
-        ExcelInfoId: id,
-      });
-      this.sheetRefreshing=false
-
-      if (res.Ret !== 200) return;
-      this.$message.success(this.$t('ETable.Msg.refresh_success_msg') );
-    }, 300),
-
-
     handleScroll(event) {
       const target = event.target;
       //滚动方向

+ 42 - 37
src/views/datasheet_manage/components/BalanceTable.vue

@@ -19,10 +19,11 @@
           @change="updateValueByFormula"
         />
       </div>
+      <!-- startSelectTable?'text-select-disabled111':'' -->
       <div class="table-content-wrap">
         <div class="left-wrap">
-          <!-- <div style="padding:20px;background-color: #fff;" @mouseleave="endSelection"> -->
-          <div :class="['table-wrap',startSelectTable?'text-select-disabled':'']">
+          <div style="padding:20px;background-color: #fff;" @mouseleave="endSelection">
+          <div class="table-wrap">
             <table
               width="auto"
               border="0"
@@ -76,7 +77,10 @@
                     @mousedown="startSelection(index, cell_index)"
                     @mouseover="extendSelection(index, cell_index)"
                     @mouseup="endSelection"
-                    :class="{ 'td_selected': isSelected(index, cell_index) }"
+                    :class="{ 
+                      'td_selected': isSelected(index, cell_index),
+                      'text-select-disabled':startSelectTable
+                    }"
                   >
                     <!-- 插入单元格禁止编辑 -->
                     <!-- [4,5,6,7,8].includes(cell.DataType)&&!cell.CanEdit -->
@@ -195,7 +199,7 @@
               </tbody>
             </table>
           </div>
-          <!-- </div> -->
+          </div>
           <!-- 底部sheet -->
           <div class="bot-sheet-box">
             <ul class="sheet-list">
@@ -233,21 +237,23 @@
                 size="mini"
                 icon="el-icon-plus"
                 @click="handleAddSheet"
-                v-if="sheetOpts.length < 10"
+                v-if="!disabled&&sheetOpts.length < 10"
               ></el-button>
             </ul>
-            <el-button type="text" icon="el-icon-plus" @click="isShowAddChart=true">{{$t('Chart.add_chart_btn')}}</el-button>
+            <el-button type="text" icon="el-icon-plus" @click="isShowAddChart=true" v-if="!disabled">{{$t('Chart.add_chart_btn')}}</el-button>
           </div>
         </div>
         <!-- 图表模块 -->
         <div class="right-wrap" v-if="chartList.length>0">
           <div class="chart-list">
             <BalanceSheetChartItem 
-              :chartData="item" 
+              :chartData="item"
+              :disabled="disabled"
               v-for="item in chartList" 
               :key="item.ChartInfo.ChartInfoId"
               @edit="handleEditChart"
               @delete="handleDelChart"
+
             />
           </div>
           
@@ -429,25 +435,7 @@ export default {
       return getRowHeaderCode(total_length);
     },
   },
-  watch: {
-    // 改为自动保存
-    // 'config.data': {
-    //   handler(newVal) {
-    //     if (!this.disabled && this.hasInit) {
-    //       this.autoSaveChildSheet()
-    //     }
-    //   },
-    //   deep: true
-    // },
-    // insertRelationArr: {
-    //   handler(newVal) {
-    //     if (!this.disabled && this.hasInit) {
-    //       this.autoSaveChildSheet()
-    //     }
-    //   },
-    //   deep: true
-    // },
-  },
+
   data() {
     return {
       config: {
@@ -518,10 +506,13 @@ export default {
     };
   },
   mounted() {
-    // 每分钟自动保存一次
-    autoSaveInterval=setInterval(() => {
-      this.saveChildSheet()
-    }, 60*1000);
+    if(!this.disabled){
+      // 每分钟自动保存一次
+      autoSaveInterval=setInterval(() => {
+        this.saveChildSheet()
+      }, 60*1000);
+    }
+    
   },
   beforeDestroy(){
     // 清除自动保存定时器
@@ -559,6 +550,7 @@ export default {
 
 
     startSelection(startRow, startCol) {
+      if(this.disabled) return
       console.log('开始选择');
       this.startSelectTable=true
       this.selectionStart = { row: startRow, col: startCol };
@@ -566,6 +558,7 @@ export default {
       this.selectedCells = [];
     },
     extendSelection(endRow, endCol) {
+      if(this.disabled) return
       if (this.selectionStart) {
         const start = this.selectionStart;
         const end = { row: endRow, col: endCol };
@@ -584,6 +577,7 @@ export default {
     },
     // 选择表格结束
     endSelection() {
+      if(this.disabled) return
       console.log('结束选择');
       // console.log(this.selectedCells);
       // console.log(this.selectionStart,this.selectionEnd);
@@ -596,11 +590,26 @@ export default {
       
       this.selectionStart = null;
       this.startSelectTable=false
+      this.removeTextSelection()
     },
     isSelected(row, col) {
       return this.selectedCells.some(cell => cell.row === row && cell.col === col);
     },
 
+    removeTextSelection() {
+        if (window.getSelection) {
+            if (window.getSelection().empty) {
+                // Chrome, Firefox, Opera
+                window.getSelection().empty();
+            } else if (window.getSelection().removeAllRanges) {
+                // IE/Edge
+                window.getSelection().removeAllRanges();
+            }
+        } else if (document.selection) { // for IE < 9
+            document.selection.empty();
+        }
+    },
+
     // 点击添加sheet
     async handleAddSheet() {
       // 先自动保存一次
@@ -621,6 +630,7 @@ export default {
     },
     // 双击编辑sheet名称
     handleDbclickSheet(item) {
+      if(this.disabled) return
       clearTimeout(dblclickInterval)//清除双击事件的定时器
       item.isEdit = true
       this.temSheetInputVal = item.ExcelName
@@ -678,6 +688,7 @@ export default {
     },
     // 右键显示删除sheet
     handleShowSheetDel(index) {
+      if(this.disabled) return
       if (this.sheetOpts.length === 1) return
       this.sheetOpts[index].showDel = true
       // 切换到该子表
@@ -713,7 +724,7 @@ export default {
       dblclickInterval=setTimeout(async () => {
         if(item.ExcelInfoId===this.activeSheetId) return
         //保存一次
-        const flag=await this.saveChildSheet()
+        const flag=this.disabled?true:await this.saveChildSheet()
         if(!flag) return
         this.changeSheet(item)
       }, 150);
@@ -813,12 +824,6 @@ export default {
       }
     },
 
-    // 自动保存
-    // autoSaveChildSheet:_.debounce(function(){
-    //   console.log('自动保存');
-    //   this.saveChildSheet()
-    // },1500),
-
     // 保存子表 type:manualSave 手动保存
     async saveChildSheet(type){
       console.log('执行保存表格操作');

+ 111 - 0
src/views/datasheet_manage/mixins/balanceTableMixin.js

@@ -0,0 +1,111 @@
+// 平衡表
+import * as sheetInterface from "@/api/modules/sheetApi.js";
+export default {
+  methods: {
+    itemHandle(data, type) {
+      if (type === "edit") {
+        this.handleEdit(data);
+        return;
+      }
+      if (type === "refresh") {
+        this.refreshSheetEdb(data.ExcelInfoId);
+        return;
+      }
+      if (type === "save") {
+        if(this.$route.path==='/sheetBalanceList'){
+            this.$parent.sheetDetailInfo = data;
+            this.$parent.saveOtherHandle();
+        }else{
+            this.saveOtherForm.name = data.ExcelName + "(1)";
+            this.isSaveOther = true;
+        }
+        
+        return;
+      }
+      if (type === "download") {
+        const value = `${this.downExcelFileUrl}&ExcelInfoId=${data.ExcelInfoId}`;
+
+        const a = document.createElement("a");
+        a.href = value;
+        a.target = "_blank";
+        a.download = data.ExcelName;
+        a.style.display = "none";
+        document.body.append(a);
+        a.click();
+        return;
+      }
+      if (type === "del") {
+        if(this.$route.path==='/sheetBalanceList'){
+            this.$emit("delSheetHandle", { cell: data, type: "del-list" });
+        }else{
+            this.$confirm(this.$t('ETable.Msg.is_del_table_msg') , this.$t('Confirm.prompt') , {
+                confirmButtonText:  this.$t('Dialog.confirm_btn'),
+                cancelButtonText: this.$t('Dialog.cancel_btn'),
+                type: "warning",
+              })
+                .then(() => {
+                    this.handleDelExcel(data)
+                })
+                .catch(() => {});
+            
+        }
+        
+        return;
+      }
+    },
+
+    handleDelExcel(data){
+        sheetInterface.classifyDel({
+          ExcelClassifyId:data.ExcelClassifyId,
+          ExcelInfoId:data.ExcelInfoId,
+          Source: 5
+        })
+        .then((res) => {
+          if (res.Ret !== 200) return;
+          this.$message.success(res.Msg);
+            this.$router.back()
+        });
+    },
+
+    // 去编辑
+    async handleEdit(data) {
+      const res = await sheetInterface.markSheetEditStatus({ ExcelInfoId: data.ExcelInfoId, Status: 1 });
+      if (res.Ret !== 200) return;
+      if (res.Data.Status == 0) {
+        this.$router.push({
+          path: "/editBalanceSheet",
+          query: {
+            id: data.ExcelInfoId,
+          },
+        });
+      } else if (res.Data.Status == 1) {
+        //编辑中
+        const text = `${res.Data.Editor}${this.$t("OnlineExcelPage.editing_msg")}`;
+        if(this.$route.path==='/sheetBalanceList'){
+            this.$emit("updateEdit", {
+                ExcelInfoId: data.ExcelInfoId,
+                Editor: res.Data.Editor,
+            });
+        }else{
+            this.excelInfo.Editor=res.Data.Editor
+            this.excelInfo.CanEdit=false
+        }
+        
+        this.$message.warning("当前" + text);
+      }
+    },
+
+    /* 刷新表格 */
+    refreshSheetEdb: _.debounce(async function (id) {
+      if (this.sheetRefreshing) return;
+      this.sheetRefreshing = true;
+      const res = await sheetInterface.refreshCustomSheet({
+        ExcelInfoId: id,
+      });
+      this.sheetRefreshing = false;
+
+      if (res.Ret !== 200) return;
+      this.$message.success(this.$t("ETable.Msg.refresh_success_msg"));
+    }, 300),
+  },
+};