spring
2025-02-26 d5a26ba2eab0a966c1754ef1d9918bfcb6e1e289
src/components/view/b1-expenses.vue
@@ -50,9 +50,9 @@
      <div>
        <el-row class="title">
          <el-col :span="12" style="padding-left: 20px;text-align: left;">费用统计</el-col>
          <el-col :span="12" style="text-align: right;">
          <!-- <el-col :span="12" style="text-align: right;">
            <el-button size="small" type="primary">OA推送</el-button>
          </el-col>
          </el-col> -->
        </el-row>
      </div>
      <div class="search">
@@ -73,7 +73,7 @@
            <el-select @focus="getCompanyOptions" @change="refreshTable()" clearable
                       size="small" v-model="componentData.entity.company" style="width: 100%">
              <el-option v-for="item in companyOptions" :key="item.value"
                         :label="item.label" :value="item.value">
                         :label="item.label" :value="item.label">
              </el-option>
            </el-select>
          </div>
@@ -83,10 +83,14 @@
          <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
        </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" v-if="isExport">导出</el-button>
        </div>
      </div>
      <div class="table">
        <ValueTable ref="ValueTable" :url="$api.insOrder.costStatistics" :componentData="componentData" :key="upIndex"
          @handleWeave="handleWeave" />
        <ValueTable ref="ValueTable" :url="$api.insOrder.costStatistics"
                    :componentData="componentData" :key="upIndex"
          @handleWeave="handleWeave" :column-min-width="'140'"/>
      </div>
    </div>
    <el-dialog title="在线编制" :visible.sync="claimVisible" width="70%" :modal-append-to-body="false">
@@ -101,11 +105,9 @@
<script>
  import ValueTable from '../tool/value-table.vue'
  import Word from '../tool/word.vue'
  export default {
    components: {
      ValueTable,
      Word,
    },
    data() {
      return {
@@ -114,7 +116,7 @@
            company: null,
            dates: null,
            orderBy: {
              field: 'id,ins_sample_id',
              field: 'id',
              order: 'asc'
            }
          },
@@ -135,6 +137,14 @@
                name: 'entrustCode',
                index: 2
              },
              /* {
                name: 'sample',
                index: 3
              },
              {
                name: 'model',
                index: 4
              }, */
              {
                name: 'company',
                index: 8
@@ -145,8 +155,8 @@
              },
            ],
            // 特殊的合并行,根据main和rows的name来合并
            special: {
              main: 'insSampleId',
            /* special: {
              main: 'entrustCode',
              rows: [{
                  name: 'sample',
                  index: 3
@@ -164,7 +174,7 @@
                  index: 6
                },
              ]
            }
            } */
          },
          tagField: {
            type: {
@@ -188,7 +198,8 @@
          },
          selectField: {},
          requiredAdd: [],
          requiredUp: []
          requiredUp: [],
          needSort: ['createTime', 'sample'],
        },
        entityCopy: {},
        upIndex: 0,
@@ -207,6 +218,8 @@
          current: -1,
          size: -1,
        },
        outLoading:false,
        isExport:false
      }
    },
    mounted() {
@@ -216,6 +229,50 @@
      this.getPower()
    },
    methods: {
      handleDown(){
        let entity = {...this.componentData.entity}
        // entity.dates = JSON.stringify(entity.dates)
        delete entity.orderBy
        this.outLoading = true
        this.$axios.post(this.$api.insOrder.export,{
          entity:entity
        },{
            headers: {
              'Content-Type': 'application/json'
            }
          ,responseType: "blob"}).then(res => {
          this.outLoading = false
          const blob = new Blob([res],{ type: 'application/octet-stream' });
          //将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(){
        this.$axios.post(this.$api.insOrder.costStatistics2, {
          entity:this.componentData.entity
@@ -297,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)