licp
2024-12-24 e4bb381c896015c4b87faa002ba6875c06a2fd16
src/components/view/b1-expenses.vue
@@ -84,11 +84,12 @@
        </div>
        <div class="search_thing" style="padding-left: 70px;">总价:{{total}}</div>
        <div class="search_thing" style="padding-left: 70px;">
          <el-button size="small" type="primary" @click="handleDown" :loading="outLoading">导出</el-button>
          <el-button size="small" type="primary" @click="handleDown" :loading="outLoading" v-if="isExport">导出</el-button>
        </div>
      </div>
      <div class="table">
        <ValueTable ref="ValueTable" :url="$api.insOrder.costStatistics" :componentData="componentData" :key="upIndex"
        <ValueTable ref="ValueTable" :url="$api.insOrder.costStatistics"
                    :componentData="componentData" :key="upIndex"
          @handleWeave="handleWeave" :column-min-width="'140'"/>
      </div>
    </div>
@@ -104,11 +105,9 @@
<script>
  import ValueTable from '../tool/value-table.vue'
  import Word from '../tool/word.vue'
  export default {
    components: {
      ValueTable,
      Word,
    },
    data() {
      return {
@@ -199,7 +198,8 @@
          },
          selectField: {},
          requiredAdd: [],
          requiredUp: []
          requiredUp: [],
          needSort: ['createTime', 'sample'],
        },
        entityCopy: {},
        upIndex: 0,
@@ -218,7 +218,8 @@
          current: -1,
          size: -1,
        },
        outLoading:false
        outLoading:false,
        isExport:false
      }
    },
    mounted() {
@@ -241,14 +242,35 @@
            }
          ,responseType: "blob"}).then(res => {
          this.outLoading = false
          this.$message.success('导出成功')
          const blob = new Blob([res],{ type: 'application/octet-stream' });
          const url = URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = url;
          let date = JSON.parse(entity.dates)
          link.download = (entity.company?entity.company+' ':'')+date[0]+' - '+date[1]+'费用统计.xlsx';
          link.click();
          //将Blob 对象转换成字符串
          let reader = new FileReader();
          reader.readAsText(blob, 'utf-8');
          reader.onload = () => {
            try {
              let result = JSON.parse(reader.result);
              if (result.message) {
                this.$message.error(result.message);
              } else {
                const url = URL.createObjectURL(blob);
                const link = document.createElement('a');
                link.href = url;
                let date = JSON.parse(entity.dates)
                link.download = (entity.company?entity.company+' ':'')+date[0]+' - '+date[1]+'费用统计.xlsx';
                link.click();
                this.$message.success('导出成功')
              }
            } catch (err) {
              console.log(err);
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              let date = JSON.parse(entity.dates)
              link.download = (entity.company?entity.company+' ':'')+date[0]+' - '+date[1]+'费用统计.xlsx';
              link.click();
              this.$message.success('导出成功')
            }
          }
        })
      },
      getTotal(){
@@ -332,6 +354,10 @@
          if (power[i].menuMethod == 'addInsOrder') {
            add = true
          }
          //
          if (power[i].menuMethod == 'export') {
            this.isExport = true
          }
        }
        if (!up) {
          this.componentData.do.splice(4, 1)