updateInspBtn.vue 4.55 KB
<template>
  <div>
    <el-button @click="onPlfh">批量复核</el-button>
    <el-button @click="dcVisible = !dcVisible" style="margin-left: 10px">资金日报导出</el-button>
    <el-dialog title="批量复核" :visible.sync="dialogVisible" width="30%">
      <el-form ref="form" label-width="120px">
        <el-form-item label="复核状态">
          <el-select v-model="fInspStatusName" placeholder="请选择" style="width: 100%">
            <el-option label="通过" value="通过"></el-option>
            <el-option label="不通过" value="不通过"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="复核备注">
          <el-input v-model="fInspNotes"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="onSubmit">确 认</el-button>
      </span>
    </el-dialog>
    <el-dialog title="资金日报导出" :visible.sync="dcVisible" width="30%">
      <el-form>
        <el-form-item label="日期">
          <el-date-picker v-model="date" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
                          style="width: calc(100% - 80px);"></el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="dcVisible = false">取 消</el-button>
        <el-button type="primary" @click="onSubmitDc">导 出</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {updateInsp, dailyFundsByDateExport} from '@/api/service/dailyFunds'
import moment from 'moment'

export default {
  props: {
    row: {
      type: Object
    },
    column: {
      type: Object
    },
    index: {
      type: String
    },
    desc: {
      type: String
    },
    selectRows: {
      type: Object
    }
  },
  data() {
    return {
      dialogVisible: false,
      fInspStatusName: null,
      fInspNotes: null,
      date: null,
      dcVisible: false
    };
  },
  created() {
    let today = new Date();
    today.setDate(today.getDate() - 1);
    let year = today.getFullYear();
    let month = ("0" + (today.getMonth() + 1)).slice(-2);
    let day = ("0" + today.getDate()).slice(-2);
    this.date = year + '-' + month + '-' + day;
  },
  methods: {
    onPlfh() {
      let d = this.selectRows.find(item => {
        return item.wdailyfundsfinspstatusname != '待复核';
      })
      if (d) {
        this.$message.warning("请勾选‘待复核’状态的记录进行审核!");
        return false;
      }
      this.dialogVisible = !this.dialogVisible
    },
    onSubmit() {
      if (!this.selectRows || this.selectRows.length == 0) {
        this.$message.error('请选择数据!');
        return false;
      } else {
        this.$confirm('是否确认批量复核1?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let wDailyFundsList = [];
          this.selectRows.forEach(d => {
            wDailyFundsList.push({
              id: d.id_,
              fDate: d.wdailyfundsfdate + " 00:00:00",
              fOrgName: d.wdailyfundsforgname,
              fOrgId: d.wdailyfundsforgid,
              fOrgType: d.wdailyfundsforgtype
            })
          })
          updateInsp({
            wDailyFundsList: wDailyFundsList,
            fInspStatusName: this.fInspStatusName,
            fInspNotes: this.fInspNotes
          }).then((res) => {
            if (res.state) {
              this.$message.success(res.message)
              this.$emit("RefreshTable");
              this.dialogVisible = false;
            } else {
              this.$emit("RefreshTable");
              this.$message.warning(res.message)
              this.dialogVisible = false;
            }
          })
        });
      }
    },
    onSubmitDc() {
      if (!this.date) {
        this.$message.error('请选择日期!');
        return false;
      }
      dailyFundsByDateExport(this.date).then(_ref => {
        let {data, headers} = _ref;
        // 附件下载
        const blob = new Blob([data]);
        // 附件下载
        const fileName = decodeURIComponent(headers['content-disposition'].split(';')[1].split('filename=')[1]);
        saveAs(blob, fileName);
      }).catch(err => {
        this.$message.error(`模板下载失败:${err}`);
      });
    }
  }
}
</script>


<style scoped lang='scss'>
::v-deep {
  .el-dialog__footer {
    text-align: center !important;

    .el-button {
      margin-left: 20px;
    }
  }
}
</style>