<template>
  <div>
    <el-card :body-style="cardBodyStyle">
      <el-form :inline="true">
        <el-form-item label="合同编号" style="margin-bottom: 5px;" prop="contrNo">
          <el-input v-model="query.contrNo" placeholder="请输入合同编号"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="合同名称" style="margin-bottom: 5px;" prop="contrNm">
          <el-input v-model="query.contrNm" placeholder="请输入合同名称"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="对方合同编号" style="margin-bottom: 5px;" prop="khContrNo">
          <el-input v-model="query.khContrNo" placeholder="请输入对方合同编号"
                    clearable></el-input>
        </el-form-item>
      </el-form>
    </el-card>
      <ButtonBar @search="handleSearch" @add="handleAdd" @remove="handleRemoveBatch" @edit="handleEditBatch"
                 @upload="handleUpload" @download="handleDownload" @import="handleImport"
                 @export="handleExport" @batchExport="batchExport" @handleExportAll="handleExportAll" ></ButtonBar>

      <!--          <el-button type="primary" @click="handleGroupApproval">集团审批</el-button>
                <el-button type="primary" @click="handleApprovalPrint">审批打印</el-button>-->
    <el-card :body-style="cardBodyStyle">
      <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange">
        <el-table-column type="selection" fixed></el-table-column>
        <el-table-column type="index" label="序号" align="center" width="60">
          <template #default="scope">
            <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="true" prop="contrNo" label="合同编号" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>

        <el-table-column v-if="true" prop="contrNm" label="合同名称" width="120"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="contrTy" label="合同类型" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="khContrNo" label="对方合同编号" width="150"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="contrForm" label="合同分类" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="checkYn" label="争议所在地法院" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="riskInfo" label="风险提示" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="signReqNo" label="签约请示" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="delvDays" label="发货天数" width="100"
                         header-align="center" align="right"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="delvDate" label="预计交货日期" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="priceDcnMth" label="定价方式" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="signReqId" label="签约请示id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="supplierNm" label="交易方名称" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="ifAnnual" label="长协合同" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="delvMth" label="交货方式" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>

        <el-table-column v-if="false" prop="" label="流程状态" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="" label="流程id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="ifBid" label="招投标" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="tempNm" label="合同模板名称" width="120"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="contrReq" label="合同要求" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="invMth" label="结算方式" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="totalAmt" label="合同金额" width="100"
                         header-align="center" align="right"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="toPlace" label="到达地" width="180"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="fromPlace" label="出发地" width="180"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="tempId" label="合同模板id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>

        <el-table-column v-if="false" prop="qty" label="重量" width="120"
                         header-align="center" align="right"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="contrSts" label="合同状态（删掉）" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>


        <el-table-column v-if="false" prop="delvPlace" label="交货地点" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="trsMth" label="运输方式" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="salMth" label="销售方式" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="contrDt" label="合同日期" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>

        <el-table-column v-if="false" prop="dataAccord" label="结算依据" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="deptCd" label="部门编码" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>

        <el-table-column v-if="false" prop="supplierCd" label="交易方编码" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="supplierId" label="供应商\客户id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>


        <el-table-column v-if="true" prop="approveDt" label="审批结束时间" width="180"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <!--        <el-table-column v-if="true" prop="compCd" label="公司代码" width="100"
                                 header-align="center" align="center"
                                 show-overflow-tooltip>
                </el-table-column>-->
        <el-table-column v-if="false" prop="id" label="主键" width="120"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="process" label="流程id(没用)" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addId" label="添加人id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="processInstance" label="流程状态(没用)" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addCode" label="添加人编码" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addName" label="添加人名称" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addDeptId" label="添加部门id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addDeptCode" label="添加部门编码" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addDeptName" label="添加部门名称" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="addTime" label="录入日期" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="modifyId" label="修改人id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="modifyCode" label="修改人编码" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="modifyName" label="修改人名称" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="modifyTime" label="修改时间" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="cancelId" label="作废人id" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="cancelCode" label="作废人编码" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="cancelName" label="作废人名称" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="cancelTime" label="作废时间" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="cancelFlag" label="作废标记" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="false" prop="belongId" label="BELONG_ID" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="deptNm" label="部门" width="120"
                         header-align="center" align="center"
                         show-overflow-tooltip fixed="right">
        </el-table-column>
        <el-table-column v-if="true" prop="conSts" label="合同状态" width="100"
                         header-align="center" align="center"
                         show-overflow-tooltip fixed="right">
        </el-table-column>
        <el-table-column v-if="true" prop="remark" label="备注" width="180"
                         header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="操作" header-align="center" align="center" width="200px"fixed="right">
          <template #default="scope">
            <el-button plain type="warning" @click="handleEdit(scope.row)">查看</el-button>

          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <el-card :body-style="cardBodyStyle">
      <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes"
                     :total="totalRows" background="background" layout="total, sizes, prev, pager, next, jumper"
                     @size-change="handleSizeChange" @current-change="handleCurrentChange">
      </el-pagination>
    </el-card>


    <el-dialog fullscreen="true" :close-on-click-modal="false" draggable title="编辑" v-model="dialogVisible"
               width="1200px"
               top="5vh" @open="openDialog">
      <el-form :model="form" label-width="120px" label-position="right" inline ref="ruleFormRef" :rules="rules">
        <!--        <el-form-item label="公司代码">
                  <el-input v-model="form.compCd" clearable style="width: 200px"></el-input>
                </el-form-item>-->
        <el-form-item label="合同编号" prop="contrNo">
          <el-input v-model="form.contrNo" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同名称">
          <el-input v-model="form.contrNm" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同类型" prop="contrTy">
          <el-input v-model="form.contrTy" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="结算数据依据">
          <el-input v-model="form.dataAccord" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="审批结束时间">
          <el-date-picker v-model="form.approveDt" type="datetime" style="width: 200px;"
                          value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"></el-date-picker>
        </el-form-item>
        <el-form-item label="争议所在地法院">
          <el-input v-model="form.checkYn" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="风险提示">
          <el-input v-model="form.riskInfo" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同状态">
          <el-input v-model="form.conSts" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="签约请示">
          <el-input v-model="form.signReqNo" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同发货天数">
          <el-input v-model="form.delvDays" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="预计交货日期">
          <el-date-picker v-model="form.delvDate" type="datetime" style="width: 200px;"
                          value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"></el-date-picker>
        </el-form-item>
        <el-form-item label="定价方式">
          <el-input v-model="form.priceDcnMth" clearable style="width: 200px"></el-input>
        </el-form-item>

        <el-form-item label="是否长协合同" prop="ifAnnual">
          <el-input v-model="form.ifAnnual" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="交货方式">
          <el-input v-model="form.delvMth" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同分类">
          <el-input v-model="form.contrForm" clearable style="width: 200px"></el-input>
        </el-form-item>
        <!--        <el-form-item label="流程状态">
                  <el-input v-model="form.processInstanceStatus" clearable style="width: 200px"></el-input>
                </el-form-item>-->
        <el-form-item label="是否招投标">
          <el-input v-model="form.ifBid" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同模板名称">
          <el-input v-model="form.tempNm" clearable style="width: 200px"></el-input>
        </el-form-item>

        <el-form-item label="结算方式">
          <el-input v-model="form.invMth" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="到达地">
          <el-input v-model="form.toPlace" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="出发地">
          <el-input v-model="form.fromPlace" clearable style="width: 200px"></el-input>
        </el-form-item>

        <el-form-item label="合同金额">
          <el-input v-model="form.totalAmt" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="重量">
          <el-input v-model="form.qty" clearable style="width: 200px"></el-input>
        </el-form-item><!--
        <el-form-item label="合同状态">
          <el-input v-model="form.contrSts" clearable style="width: 200px"></el-input>
        </el-form-item>-->
        <el-form-item label="备注">
          <el-input v-model="form.remark" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同要求">
          <el-input v-model="form.contrReq" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="交货地点">
          <el-input v-model="form.delvPlace" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="运输方式">
          <el-input v-model="form.trsMth" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="销售方式">
          <el-input v-model="form.salMth" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="合同日期">
          <el-date-picker v-model="form.contrDt" type="datetime" style="width: 200px;"
                          value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"></el-date-picker>
        </el-form-item>
        <!--        <el-form-item label="部门">
                  <el-input v-model="form.deptNm" clearable style="width: 200px"></el-input>
                </el-form-item>
                <el-form-item label="部门编码">
                  <el-input v-model="form.deptCd" clearable style="width: 200px"></el-input>
                </el-form-item>-->
        <el-form-item label="交易方名称" prop="supplierNm">
          <el-input v-model="form.supplierNm" clearable style="width: 200px"></el-input>
        </el-form-item>
        <!--        <el-form-item label="供应商编码">
                  <el-input v-model="form.supplierCd" clearable style="width: 200px"></el-input>
                </el-form-item>-->

        <el-form-item label="对方合同编号">
          <el-input v-model="form.khContrNo" clearable style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="录入日期">
          <el-date-picker v-model="form.addTime" type="datetime" style="width: 200px;"
                          value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"></el-date-picker>
        </el-form-item>
      </el-form>

      <template #footer>
        <div class="dialog-footer">
          <el-button type="success" @click="handleSave(ruleFormRef)":disabled="form.conSts === '审批中'">保存</el-button>
          <el-button type="danger" @click="handleCancelSave">取消</el-button>
        </div>
      </template>
    </el-dialog>

  </div>
</template>

<script setup>
import ButtonBar from '@/components/ButtonBar.vue'
import addVue from '@/views/cot/input/invtype.vue'
import addLineVue from '@/views/cot/input/line.vue'

import {
  ref,
  reactive,
  onMounted,
  getCurrentInstance
} from 'vue'

const {
  proxy
} = getCurrentInstance()

import tools from '@/tools'

const cardBodyStyle = ref(tools.style.card)
const inputStyle = ref(tools.style.input)

onMounted(() => {
  handleSearch()
})
import Attachment from '@/components/Attachment.vue'


/**
 *   查询
 */




const query = ref({
  contrNo: '',
  contrNm: '',
  khContrNo: ''
})
const tableData = ref([])
const handleSearch = () => {
  currentPage.value = 1
  getTableData()
}

const getTableData = () => {
  var url = 'cot/Head/query'
  var param = {
    page: currentPage.value,
    rows: pageSize.value,
    params: JSON.stringify(query.value)
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      tableData.value = response.data.data.records
      totalRows.value = response.data.data.total
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
}
/**
 *   查询
 */

/**
 * 分页
 */
const currentPage = ref(1)
const totalRows = ref(0)
const pageSizes = ref([5, 10, 20, 30, 40])
const pageSize = ref(5)
const handleSizeChange = (val) => {
  pageSize.value = val
  getTableData()
}
const handleCurrentChange = (val) => {
  currentPage.value = val
  getTableData()
}
/**
 * 分页
 */


/**
 * 新增
 */
const dialogVisible = ref(false)
const form = ref({
  contrNo: '',
  dataAccord: '',
  approveDt: '',
  checkYn: '',
  riskInfo: '',
  conSts: '',
  signReqNo: '',
  delvDays: '',
  delvDate: '',
  priceDcnMth: '',
  signReqId: '',
  ifAnnual: '',
  delvMth: '',
  contrForm: '',
  processInstanceStatus: '',
  processInstanceId: '',
  ifBid: '',
  tempNm: '',
  invMth: '',
  toPlace: '',
  fromPlace: '',
  tempId: '',
  totalAmt: '',
  qty: '',
  contrSts: '',
  remark: '',
  contrReq: '',
  delvPlace: '',
  trsMth: '',
  salMth: '',
  contrDt: '',
  deptNm: '',
  deptCd: '',
  supplierNm: '',
  supplierCd: '',
  supplierId: '',
  contrNm: '',
  khContrNo: '',
  addTime: ''
})
const ruleFormRef = ref()
const rules = reactive({
  contrNo: [{
    required: true,
    message: '请输入合同编号',
    trigger: 'change' | 'blur'
  }],
  ifAnnual: [{
    required: true,
    message: '请输入是否为长协合同',
    trigger: 'change' | 'blur'
  }],

})

const handleAdd = () => {
  form.value = {
    contrNo: '',
    dataAccord: '',
    approveDt: '',
    checkYn: '',
    riskInfo: '',
    conSts: '',
    signReqNo: '',
    delvDays: '',
    delvDate: '',
    priceDcnMth: '',
    signReqId: '',
    ifAnnual: '',
    delvMth: '',
    contrForm: '',
    processInstanceStatus: '',
    processInstanceId: '',
    ifBid: '',
    tempNm: '',
    invMth: '',
    toPlace: '',
    fromPlace: '',
    tempId: '',
    totalAmt: '',
    qty: '',
    contrSts: '',
    remark: '',
    contrReq: '',
    delvPlace: '',
    trsMth: '',
    salMth: '',
    contrDt: '',
    deptNm: '',
    deptCd: '',
    supplierNm: '',
    supplierCd: '',
    supplierId: '',
    contrNm: '',
    khContrNo: '',
    addTime: ''
  }
  dialogVisible.value = true
}
/**
 * 新增
 */


/**
 * 保存、修改、删除
 */
const refUpload = ref()

const openDialog = () => {
  refUpload.value.fId = form.value.id
  refUpload.value.getTableData()
}

const handleSave = (ruleFormRef) => {
  ruleFormRef.validate((valid, fields) => {
    if (valid) {
      var url = 'cot/Head/save'
      var param = {
        json: JSON.stringify(form.value),
      }
      proxy.$axios.post(url, param).then(response => {
        if (response.data.code == 0) {
          form.value = response.data.data
          ElMessage({
            message: '保存成功',
            type: 'success',
          })
          refUpload.value.fId = form.value.id
          refUpload.value.upload()
          getTableData()
          dialogVisible.value = false
        } else {
          // ElMessage.error('操作失败！' + response.data.msg)
          ElMessage({
            message: '操作失败' + response.data.msg,
            type: 'error'
          })
        }
      })

    } else {
      console.log('error submit!', fields)
    }
  })
}
const handleCancelSave = () => {
  dialogVisible.value = false
}
const handleEdit = (row) => {
  dialogVisible.value = true
  form.value = row
}
const batchExport = (row) => {
  ElMessageBox.confirm(
      '是否批量导出?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  )
}
const handleExportAll = (row) => {
  ElMessageBox.confirm(
      '是否全部导出?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  )
}
const handleDelete = (row) => {
  ElMessageBox.confirm(
      '确定删除本条记录?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  )
      .then(() => {
        var url = 'cot/Head/remove'
        var param = {
          id: row.id
        }
        proxy.$axios.post(url, param).then(response => {
          if (response.data.code == 0) {
            ElMessage({
              type: 'success',
              message: '删除成功',
            })
            getTableData()
          } else {
            ElMessage({
              type: 'error',
              message: '删除失败' + response.data.msg
            });
          }
        });
      })
      .catch(() => {
        ElMessage({
          type: 'info',
          message: '已取消',
        })
      })
}

/**
 * 保存、修改、删除
 */

const multipleSelection = ref([])
const handleSelectionChange = (val) => {
  multipleSelection.value = val
}

const handleRemoveBatch = () => {
  console.log('handleRemoveBatch')

  if (multipleSelection.value.length < 1) {
    ElMessage({
      type: 'warning',
      message: '请选择要删除的数据!'
    })
    return
  }

  ElMessageBox.confirm('此操作将删除该数据, 是否继续?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    var ids = []
    multipleSelection.value.forEach((item, index) => {
      ids.push(item.id)
    })
    var url = 'cot/Head/removeBatch'
    var param = {
      ids: JSON.stringify(ids)
    }
    proxy.$axios.post(url, param).then(response => {
      if (response.data.code == '0') {
        ElMessage({
          type: 'success',
          message: '操作成功!',
        });
        getTableData()
        dialogVisible.value = false
      } else {
        ElMessage({
          type: 'error',
          message: '操作失败!' + response.data.msg
        });
      }
    })
  }).catch(() => {
    ElMessage({
      type: 'info',
      message: '已取消删除'
    })
  })
}

const handleEditBatch = () => {
  console.log('handleEditBatch')
  if (multipleSelection.value.length != 1) {
    ElMessage({
      type: 'warning',
      message: '请选择一条数据编辑!'
    })
    return
  }
  handleEdit(multipleSelection.value[0])
}

const handleUpload = () => {
  console.log('handleUpload')
}

const handleDownload = () => {
  console.log('handleDownload')
}

const handleImport = () => {
  console.log('handleImport')
}

const handleExport = () => {
  console.log('handleExport')
}

</script>


<style>


</style>