<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
    >
      <el-form-item label="发票代码" >
        <el-input
          v-model="queryParams.invoiceCode"
          placeholder=""
          clearable
        />
      </el-form-item>
      <el-form-item label="数电票号码" >
        <el-input
          v-model="queryParams.invoiceTelexNumber"
          placeholder=""
          clearable
        />
      </el-form-item>
      <el-form-item label="发票号码" >
        <el-input
          v-model="queryParams.invoiceNumber"
          placeholder=""
          clearable
        />
      </el-form-item>
      <el-form-item label="销方名称" >
        <el-input
          v-model="queryParams.sellerName"
          placeholder=""
          clearable
        />
      </el-form-item>
      <el-form-item label="预警情况" >
        <el-select v-model="queryParams.warningType" clearable  filterable placeholder="请选择">
          <el-option
            v-for="item in optionsp"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="单位">
        <el-select
          v-model="selectVal"
          placeholder="请选择..."
          @clear="delValue"
          clearable
          ref="select"
          style="width: 300px"
        >
          <el-option hidden key="id" :value="selectVal" :label="selectName"></el-option>
          <el-tree
            :data="options1"
            :props="defaultProps"
            @node-click="handleNodeClick"
            :expand-on-click-node="false"
            :check-on-click-node="true"
            ref="tree"
            node-key="id"
            :default-expand-all="true"
            :filter-node-method="filterNode"
          >
            <span slot-scope="{ data }">
            <span>{{ data.deptName }}</span>
          <el-tag
            size="mini"
            style="margin: 0 10px"
            v-show="filterorgType(data.tag)"
          >{{ filterorgType(data.tag) }}</el-tag
          >
        </span>
          </el-tree>
        </el-select>
      </el-form-item>
      <el-form-item label="开票起止日期" >
        <el-date-picker
          v-model="queryParams.moment"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="业务分类">
        <el-select v-model="queryParams.businessTypeCode" filterable clearable>
          <el-option
            v-for="item in options"
            :key="item.code"
            :label="item.desc"
            :value="item.code">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否预警" >
        <el-select   v-model="queryParams.isWarningSelect" clearable  filterable placeholder="请选择">
          <el-option   label="是" value="1"></el-option>
          <el-option   label="否" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="handleSech"
        >搜索</el-button>
      </el-form-item>
    </el-form>
    <div style="display: flex">
<!--      <el-button type="text" @click="download">下载模板</el-button>-->
      <el-upload
        class="upload-demo"
        action="#"
        multiple
        :show-file-list="false"
        :on-change="onChange"
        :auto-upload="false"
      >
        <el-button size="small" type="primary">导入数据</el-button>
      </el-upload>
      <el-button   style="margin-left:10px;height: 32px" :disabled="multipleSelection.length===0" type="success" size="mini" @click="hanlsf">批量更新</el-button>
      <el-button   style="margin-left:10px;height: 32px" type="success" size="mini" @click="downloadExport">导出</el-button>
      <el-button   style="margin-left:10px;height: 32px" :disabled="multipleSelection.length===0" type="danger" size="mini" @click="delectp">批量删除</el-button>
    </div>
    <el-row :gutter="10" class="mb8">
    </el-row>
    <div class="table">
      <el-table
        border
        :row-class-name="tableRowClassName"
        v-loading="loading"
        :data="deptList"
        @row-click="handleClick"
        height="55vh"
        @selection-change="handleSelectionChange">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          type="index"
          label="序号"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceCode"
          align="center"
          min-width="100px"
          label="发票代码"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceNumber"
          align="center"
          min-width="100px"
          label="发票号码"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceTelexNumber"
          align="center"
          min-width="100px"
          label="数电票号码"
        >
        </el-table-column>
        <el-table-column
          prop="sellerId"
          align="center"
          min-width="100px"
          label="销方识别号"
        >
        </el-table-column>
        <el-table-column
          prop="sellerName"
          align="center"
          min-width="100px"
          label="销方名称"
        >
        </el-table-column>
        <el-table-column
          prop="makeDate"
          align="center"
          min-width="100px"
          label="开票日期"
        >
        </el-table-column>
        <el-table-column
          prop="spBusinessType"
          align="center"
          min-width="100px"
          label="特定业务类型"
        >
        </el-table-column>
        <el-table-column
          prop="itemDesc"
          align="center"
          min-width="150px"
          label="货物或应税劳务名称"
        >
        </el-table-column>
        <el-table-column
          prop="amount"
          align="center"
          min-width="100px"
          label="金额"
        >
        </el-table-column>
        <el-table-column
          prop="taxRate"
          align="center"
          min-width="100px"
          label="税率"
        >
        </el-table-column>
        <el-table-column
          prop="taxAmt"
          align="center"
          min-width="80px"
          label="税额"
        >
        </el-table-column>
        <el-table-column
          prop="totalAmount"
          align="center"
          min-width="80px"
          label="价税合计"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceSource"
          align="center"
          min-width="80px"
          label="发票来源"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceType"
          align="center"
          min-width="80px"
          label="发票票种"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceStatus"
          align="center"
          min-width="80px"
          label="发票状态"
        >
        </el-table-column>
        <el-table-column
          prop="isZsfp"
          align="center"
          min-width="100px"
          label="是否正数发票"
        >
        </el-table-column>
        <el-table-column
          prop="invoiceWarningLevel"
          align="center"
          min-width="100px"
          label="发票风险等级"
        >
        </el-table-column>
        <el-table-column
          prop="kpr"
          align="center"
          min-width="80px"
          label="开票人"
        >
        </el-table-column>
        <el-table-column
          prop="remark"
          align="center"
          min-width="130px"
          label="备注"
        >
<!--          <template slot-scope="scope">-->
<!--            <div style="display: flex">-->
<!--              <el-button size="small" type="primary" @click="hand(scope.row)">编辑</el-button>-->
<!--              <el-button size="small" type="danger" @click="delect(scope.row)">删除</el-button>-->
<!--            </div>-->
<!--          </template>-->
        </el-table-column>
        <el-table-column
          prop="businessType"
          align="center"
          min-width="100px"
          label="业务分类"
        >
          <template slot-scope="{row}">
            <el-select v-model="row.businessType" @clear="clear(row)" clearable @change="upload(row)" filterable placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.code"
                :label="item.desc"
                :value="item.code">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column
          prop="createUserOrgName"
          align="center"
          min-width="80px"
          label="所属单位"
        >
        </el-table-column>
        <el-table-column
          prop="warningStatusDesc"
          align="center"
          min-width="80px"
          label="风险状态"
        >
        </el-table-column>
<!--        <el-table-column-->
<!--          prop="warningLevel"-->
<!--          align="center"-->
<!--          min-width="80px"-->
<!--          label="风险等级"-->
<!--        >-->
<!--        </el-table-column>-->
        <el-table-column
          align="center"
          min-width="170px"
          label="操作"
        >
          <template slot-scope="scope">
            <div style="display: flex">
              <el-button size="small" type="primary" @click="handM(scope.row)">查看风险</el-button>
              <el-button size="small" type="danger" @click="delect(scope.row)">删除</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        style="display: flex;justify-content: flex-end ;margin: 15px 0px 0px 0px"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNo"
        :page-sizes="[10, 20, 30, 40,100,200,500]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total" />
    </div>
    <el-dialog
      title="编辑"
      :visible.sync="dialogVisible"
      width="70%"
    >
      <el-form
        :model="ruleForm"
        ref="queryForm"
        label-width="100px"
        size="small"
        :inline="true"
      >
        <el-form-item label="合同名称" >
          <el-input
            v-model="ruleForm.contractName"
            placeholder=""
            clearable
          />
        </el-form-item>
        <el-form-item label="合同类型" >
          <el-input
            v-model="ruleForm.contractType"
            placeholder=""
            clearable
          />
        </el-form-item>
        <el-form-item label="合同对方" >
          <el-input
            v-model="ruleForm.counterparty"
            placeholder=""
            clearable
          />
        </el-form-item>
        <el-form-item label="合同金额" >
          <el-input
            v-model="ruleForm.contractAmount"
            placeholder=""
            clearable
          />
        </el-form-item>
        <el-form-item label="税率" >
          <el-input
            v-model="ruleForm.taxRate"
            placeholder=""
            clearable
          />
        </el-form-item>
        <el-form-item label="不含税金额" >
          <el-input
            v-model="ruleForm.preTaxAmount"
            placeholder=""
            clearable
          />
        </el-form-item>
        <el-form-item label="合同生效时间" >
          <el-date-picker
            v-model="ruleForm.effectiveDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="sumbit">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="查看"
      :visible.sync="dialog"
      width="70%"
      :before-close="handleClose"
    >
<!--      <el-table-->
<!--        :data="tableData2"-->
<!--        height="55vh"-->
<!--        row-key="deptId"-->
<!--      >-->
<!--        <el-table-column-->
<!--          type="index"-->
<!--          label="序号"-->
<!--        >-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="sourceType"-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="数据来源"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{scope.row.sourceType==1?'发票信息表':'合同信息表'}}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="checkGist"-->
<!--          align="center"-->
<!--          min-width="200px"-->
<!--          label="风险规则"-->
<!--        >-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="warningLevel"-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="风险等级"-->
<!--        >-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="content"-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="风险提示"-->
<!--        >-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="处理状态"-->
<!--          prop="statusDesc"-->
<!--        >-->
<!--&lt;!&ndash;          <template slot-scope="scope">&ndash;&gt;-->
<!--&lt;!&ndash;            <span>{{scope.row.status===0?'未处理':'已处理'}}</span>&ndash;&gt;-->
<!--&lt;!&ndash;          </template>&ndash;&gt;-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="createTime"-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="预警时间"-->
<!--        >-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          prop="remark"-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="反馈内容"-->
<!--        >-->
<!--        </el-table-column>-->
<!--        <el-table-column-->
<!--          align="center"-->
<!--          min-width="100px"-->
<!--          label="反馈"-->
<!--        >-->
<!--          <template slot-scope="scope">-->
<!--            <el-button type="primary" :disabled="scope.row.statusDesc==='已处理'" @click="chak(scope.row)">手工反馈</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--      </el-table>-->
      <el-table
        :data="tableData2"
        height="55vh"
        row-key="deptId"
      >
        <el-table-column
          type="index"
          label="序号"
        >
        </el-table-column>
        <el-table-column
          prop="sourceType"
          align="center"
          min-width="100px"
          label="数据来源"
        >
          <template slot-scope="scope">
<!--            <span>{{scope.row.sourceType==1?'发票信息表':'合同信息表'}}</span>-->
            <span>发票信息表</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="rule"
          align="center"
          min-width="200px"
          label="风险规则"
        >
        </el-table-column>
        <el-table-column
          prop="level"
          align="center"
          min-width="100px"
          label="风险等级"
        >
        </el-table-column>
        <el-table-column
          prop="description"
          align="center"
          min-width="100px"
          label="风险提示"
        >
        </el-table-column>
        <el-table-column
          prop="warningStatusDesc"
          align="center"
          min-width="100px"
          label="处理状态"
        >
          <!--          <template slot-scope="scope">-->
          <!--            <span>{{scope.row.status===0?'未处理':'已处理'}}</span>-->
          <!--          </template>-->
        </el-table-column>
        <el-table-column
          prop="warningTime"
          align="center"
          min-width="100px"
          label="预警时间"
        >
        </el-table-column>
        <el-table-column
          prop="warningRemark"
          align="center"
          min-width="100px"
          label="反馈内容"
        >
        </el-table-column>
        <el-table-column
          align="center"
          min-width="100px"
          label="反馈"
        >
          <template slot-scope="scope">
            <el-button type="primary" :disabled="scope.row.warningStatusDesc==='已处理'" @click="chak(scope.row)">手工反馈</el-button>
          </template>
        </el-table-column>
      </el-table>
<!--      <el-pagination-->
<!--        style="display: flex;justify-content: flex-end ;margin: 15px 0px 0px 0px"-->
<!--        @size-change="handleSizeChange"-->
<!--        @current-change="handleCurrentChange"-->
<!--        :current-page="pages.pageNo"-->
<!--        :page-sizes="[10, 20, 30, 40]"-->
<!--        :page-size="pages.pageSize"-->
<!--        layout="total, sizes, prev, pager, next, jumper"-->
<!--        :total="pages.total" />-->
    </el-dialog>
    <el-dialog
      title="反馈"
      :visible.sync="dialog1"
      width="70%"
    >
      <el-form ref="form"  label-width="80px">
        <el-form-item label="反馈描述">
          <el-input
            type="textarea"
            style="width: 100%"
            autosize
            placeholder="请输入内容"
            v-model="ruleForm1.remark">
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer" style="display: flex;justify-content: center">
        <el-button @click="dialog1 = false">取 消</el-button>
        <el-button type="primary" @click="sumbit1">保 存</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="业务分类"
      :visible.sync="logVis"
      width="40%"
    >
      <el-form
        :model="ruleFormM"
        ref="ruleFormM"
        label-width="100px"
        size="small"
        :inline="true"
      >
        <el-form-item label="业务分类" >
          <el-select v-model="ruleFormM.stampTaxItemId" clearable  filterable placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.code"
              :label="item.desc"
              :value="item.code">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="logVis = false">取 消</el-button>
        <el-button type="primary" @click="sumbitM">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  adsMatHyxtStampTaxComputeDqueryPage, adsMatHyxtStampTaxContinvinvoiceImport, adsMatHyxtStampTaxContinvoiceImportCheck,
  adsMatHyxtStampTaxContractDL,
  adsMatHyxtStampTaxInvoiceDelc, adsMatHyxtStampTaxqueryWarningList,
  adsMatHyxtStampTaxWarningD, batchDelete,
  batchUpdateBusinessType, batchUpdateBusinessTypeM,
  batchUpdateStampTaxItem,
  businessTypeList, clearStampTaxInvoiceWarning,
  contractImport, dataExportContractD, dataExportTaxInvoiceD,
  deleteadsMatHyxtStampTaxContractD,
  downloadTemplateD,
  downloadTemplateM,
  invoiceDqueryPagee,
  invoiceImportP,
  queryList,
  queryPageNo, updateBusinessType, warningType1, warningType2,queryWarningListNew
} from '@/api/utils'
import  moment from 'moment'
import {listDept} from "@/api/system/dept";

export default {
  components:{
  },
  data() {
    return {
      selectVal:'',
      selectName:'',
      defaultProps: {
        children: "children",
        label: "name",
      },
      // 标签数组
      tagList: [

      ],
      logVis:false,
      multipleSelection:[],
      dialog1:false,
      dialog:false,
      option:null,
      ruleFormM:{
        stampTaxItemId:''
      },
      pages:{
        pageNo:1,
        pageSize:10,
        total:0,
      },
      ruleForm1:{
        remark:'',
      },
      tableData2:[],
      dialogVisible:false,
      deptList:[],
      options:[],
      queryParams:{
        invoiceCode:'',
        invoiceNumber:'',
        sellerName:'',
        businessTypeCode:'',
        moment:null,
        invoiceTelexNumber:'',
        isWarningSelect:'',
      },
      // 遮罩层
      loading: false,
      pageNo:1,
      pageSize:10,
      total:0,
      ruleForm:{},
      row:{},
      options1:[],
      optionsp:[],
    };
  },
  created() {
    this.getList();
    this.getData()
    this.getListM()
    this.getYj()
  },
  computed:{

  },
  methods: {
    handleClose(){
      this.dialog=false
      this.getList();
    },
    getYj(){
      warningType2().then(res=>{
        this.optionsp=res.data || []
      })
    },
    clear(row){
      let data={
        id:row.id,
        businessTypeCode:'',
        businessType:'',
      }
      updateBusinessType(data).then(res=>{
        if(res.code===200){
          this.$message.success('修改成功')
          this.getList()
        }else {
          this.$message.error(res.msg || '修改失败')
        }
      })
    },
    downloadExport(){
      let startDate
      let endDate
      if(this.queryParams.moment){
        endDate=this.queryParams.moment[1]
        startDate=this.queryParams.moment[0]
      }else {
        startDate=''
        endDate=''
      }
      let data={
        endDate:endDate,
        startDate:startDate,
        ...this.queryParams
      }
      let s = JSON.parse(JSON.parse(window.sessionStorage.getItem('queryParams'))) || {}
      dataExportTaxInvoiceD(data).then(res=>{
        const blob = new Blob([res]);
        const url = URL.createObjectURL(blob);
        const link = document.createElement('a');
        link.href = url;
        link.download = '发票信息'+s.homeDate+'.xls';
        link.click();
      })
    },
    getListM() {
      listDept().then((response) => {
        this.options1 = this.handleTree(response.data, "deptId");
      });
    },
    delValue() {
      this.selectVal = ''
      this.selectName = '';
    },
    // 结构树点击事件
    handleNodeClick(data) {
      console.log(data,'----')
      this.selectVal = data.deptId; // select绑定值为点击的选项的value
      this.selectName = data.deptName; // input中显示值为label
      this.treeFilter = ""; // 点击后搜索框清空
      this.$refs.select.blur(); // 点击后关闭下拉框，因为点击树形控件后select不会自动折叠
    },
    // 模糊查询（搜索过滤），实质为筛选出树形控件中符合输入条件的选项，过滤掉其他选项
    filterNode(value, data) {
      if (!value) return true;
      let filterRes = data.label.indexOf(value) !== -1;
      return filterRes;
    },
    // 选项卡标签（可忽略，增值迭代需求）
    filterorgType(val) {
      let arr = this.tagList.filter((item) => {
        return item.value == val;
      });
      return arr.length ? arr[0].label : "";
    },
    hanlsf(){
      this.logVis=true
      this.ruleFormM.stampTaxItemId=''
    },
    sumbitM(){
      let ids=[]
      this.multipleSelection.forEach(item=>{
        ids.push(item.id)
      })
      let list
      let data
      if(this.ruleFormM.stampTaxItemId){
       list = this.options.find(f=>f.code===this.ruleFormM.stampTaxItemId)
       data={
          ids:ids,
          businessTypeCode:list.code?list.code:'',
          businessType:list.desc?list.desc: '',
        }
      }else {
        data={
          ids:ids,
          businessTypeCode:'',
          businessType: '',
        }
      }
      batchUpdateBusinessTypeM(data).then(res=>{
        if(res.code===200){
          this.$message.success('提交成功')
          this.logVis=false
          this.getList()
        }else {
          this.$message.success(res.msg || '提交失败')
        }
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handM(row){
      this.row=row
      this.row.type='fp'
      this.row.sourceId=row.id
      this.row.sourceType=1
      this.dialog=true
      this.getListT()
    },
    chak(row){
      this.dialog1=true
      this.ruleForm1.remark=''
      this.option=JSON.parse(JSON.stringify(row))
    },
    sumbit1(){
      this.option.remark=this.ruleForm1.remark
      clearStampTaxInvoiceWarning(this.option).then((res) => {
        if(res.code===200){
          this.$message.success('提交成功')
          this.dialog1=false
          this.getListT()
        }else {
          this.$message.success(res.msg || '提交失败')
          this.dialog1=false
          this.getListT()
        }
      });
    },
    getListT() {
      // let data={
      //   pageNo:this.pages.pageNo,
      //   pageSize:this.pages.pageSize,
      // }
      this.row.sourceType=1
      // adsMatHyxtStampTaxqueryWarningList(this.row).then((response) => {
      //   if(response && response.data){
      //     this.tableData2 = response.data;
      //     // this.pages.total = response.data.total;
      //   }else {
      //     this.tableData2 =[]
      //     // this.pages.total =0
      //   }
      // });
      queryWarningListNew({businessId:this.row.id}).then((response) => {
        if(response && response.data){
          this.tableData2 = response.data;
          // this.pages.total = response.data.total;
        }else {
          this.tableData2 =[]
          // this.pages.total =0
        }
      });
    },
    handleClick(row){
      // if(row.isWarning===1){
      //   row.type='fp'
      //   row.sourceId=row.id
      //   row.sourceType=1
      //   this.$router.push({
      //     path:'RiskDoubt',
      //     query:row
      //   })
      // }
    },
    tableRowClassName({row, rowIndex}) {
      if(row.isWarning===1){
        return 'danger-row';
      }
      if (row.isWarning===2) {
        return 'warning-row';
      }
      return '';
    },
    hand(row){
      this.dialogVisible=true
      this.ruleForm=JSON.parse(JSON.stringify(row))
    },
    sumbit(){
      adsMatHyxtStampTaxContractDL(this.ruleForm).then(res=>{
        if(res.code===200){
          this.$message.success('修改成功')
          this.dialogVisible=false
          this.getList()
        }else {
          this.$message.error(res.msg || '修改失败')
        }
      })
    },
    delectp(){
      this.$confirm('是否批量删除? 请谨慎此操作', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let ids=[]
        this.multipleSelection.forEach(item=>{
          ids.push(item.id)
        })
        let data={
          ids:ids
        }
        console.log(ids,'ids')
        batchDelete(data).then(res => {
          if (res.code === 200) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.getList()
          } else {
            this.$message({
              type: 'error',
              message: '删除失败，请重试!'
            });
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    delect(row){
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        adsMatHyxtStampTaxInvoiceDelc(row).then(res => {
          if (res.code === 200) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.getList()
          } else {
            this.$message({
              type: 'error',
              message: '删除失败，请重试!'
            });
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    upload(val){
      console.log(val.businessType,'==')
      let list = this.options.find(f=>f.code===val.businessType)
      console.log(list,'==')
      let data={
        id:val.id,
        businessTypeCode:list.code,
        businessType:list.desc,
      }
      updateBusinessType(data).then(res=>{
        if(res.code===200){
          this.$message.success('修改成功')
          this.getList()
        }else {
          this.$message.error(res.msg || '修改失败')
        }
      })
    },
    getData(){
      businessTypeList().then(res=>{
        this.options=res.data || []
      })
    },
    download(){
      downloadTemplateM().then(res=>{
        const blob = new Blob([res]);
        const url = URL.createObjectURL(blob);
        const link = document.createElement('a');
        link.href = url;
        link.download = '发票信息.xls';
        link.click();
      })
    },
    onChange(file){
      let formDataT = new FormData();
      formDataT.append("file", file.raw);
      adsMatHyxtStampTaxContinvoiceImportCheck(formDataT).then(res=>{
        if(res.data.isOk===0){
          this.$confirm(`${res.data.tips}`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let formDataTE = new FormData();
            formDataTE.append("file", file.raw);
            adsMatHyxtStampTaxContinvinvoiceImport(formDataTE).then(res => {
              if (res.code === 200) {
                this.$message({
                  type: 'success',
                  message: '导入成功!'
                });
                this.getList()
              }
            })
          })
        }else {
          let formDataTG = new FormData();
          formDataTG.append("file", file.raw);
          adsMatHyxtStampTaxContinvinvoiceImport(formDataTG).then(res => {
            if (res.code === 200) {
              this.$message({
                type: 'success',
                message: '导入成功!'
              });
              this.getList()
            }
          })
        }
      })
    },
    handleSech(){
      this.pageNo=1
      this.getList()
    },
    moment,
    /** 查询部门列表 */
    getList() {
      this.loading = true;
      let startDate
      let endDate
      if(this.queryParams.moment){
        endDate=this.queryParams.moment[1]
        startDate=this.queryParams.moment[0]
      }else {
        startDate=''
        endDate=''
      }
      let data={
        pageNo:this.pageNo,
        endDate:endDate,
        startDate:startDate,
        pageSize:this.pageSize,
        ...this.queryParams
      }
      this.queryParams.createUserOrgNo=this.selectVal
      queryPageNo(data).then((response) => {
        if(response && response.data && response.data.records){
          this.loading = false;
          this.deptList = response.data.records;
          this.total=response.data.total
        }else {
          this.deptList =[]
          this.loading = false;
          this.total=0
        }
      });
    },
    handleSizeChange(val) {
      this.pageSize=val
      this.getList()
    },
    handleCurrentChange(val) {
      this.pageNo=val
      this.getList()
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-table .danger-row {
  background: #ff6969;
}
::v-deep .el-table .warning-row {
  background: #ffff7e;
}

::v-deep .el-table .success-row {
  //background: #f0f9eb;
}
</style>
