contractDialog.vue 3.82 KB
<template>
  <div>
    <GLDialog bigTitle="选择合同" mode="big" :visible.sync="contractObj.visible" :before-close="handleClose" :close-on-click-modal="false" @onOk="handleConfirm" @onCancel="handleClose">
      <glsx-combi-form ref="showSearch" labelWidth="105px" :formObj="searchForm" :formData="searchFormData">
        <span slot="footer">
          <el-button :size="size" type="primary" @click="getTable">查询</el-button>
        </span>
      </glsx-combi-form>
      <GLTable :hasNum="false" ref="contractTableRef" :noDataImg="url" :getListApi="getListApi" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
        <div slot="radioSlot" slot-scope="scope">
          <el-radio v-model="curId" :label="scope.scope.id">&nbsp;</el-radio>
        </div>
        <span slot="numberSlot" slot-scope="scope">{{ scope.index + 1 }}</span>
        <span slot="auth-button" slot-scope="scope" :data="scope.scope">
          <GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="1"></GLTableButton>
        </span>
      </GLTable>
    </GLDialog>
    <pdf-dialog :isVisible="isPdfVisible" title="合同" :pdfUrl="pdfUrl" @closeDialog="handlePdfClose"></pdf-dialog>
  </div>
</template>
<script>
const TABLE_HEAD = [
  {
    label: '',
    prop: 'radioSlot',
    addHtml: 'radioSlot',
    width: '50'
  },
  {
    label: '序号',
    prop: 'index',
    width: '100',
    addHtml: 'numberSlot'
  },
  {
    label: '合同编号',
    prop: 'id'
  }
]
import url from '@/assets/empty.png'
import pdfDialog from '@/views/beforeSale/pdfDialog'
import glsxCombiForm from '@/components/glsx-combi-form'
export default {
  name: 'changeContract',
  components: {
    pdfDialog,
    glsxCombiForm
  },
  props: {
    contractObj: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      size: 'small',
      isPdfVisible: false,
      pdfUrl: '',
      curId: '',
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      getListApi: this.$apis.serviceConfig.getExtendedWarrantyContractListApi,
      searchForm: {
        templateName: ''
      },
      buttonList: [
        {
          type: 'el-button',
          name: row => {
            return '预览'
          },
          attrs: {
            type: 'text'
          },
          listeners: {
            click: row => this.handlePdf(row.scope)
          }
        }
      ],
      searchFormData: [
        {
          label: '合同名称',
          name: 'templateName',
          type: 'input',
          maxlength: 50,
          isClear: true
        }
      ],
      tableParams: {
        listName: 'list',
        tableOption: {
          width: '100px'
        },
        tableColumns: []
      }
    }
  },
  created() {
    this.tableParams.tableColumns = [
      ...TABLE_HEAD,
      {
        label: '合同名称',
        prop: 'templateName'
      }
    ]
    this.curId = this.contractObj?.curId || ''
  },
  mounted() {},
  methods: {
    handlePdfClose() {
      this.isPdfVisible = !this.isPdfVisible
    },

    // 预览
    handlePdf(row) {
      this.pdfUrl = row?.previewUrl
      this.handlePdfClose()
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        resolve()
      })
    },
    setTableFinishFun(data) {
      this.tableData = data || []
    },
    getTable() {
      this.$refs.contractTableRef.refreshTable()
    },
    handleConfirm() {
      if (!this.curId)
        return this.$message({
          message: '请选择合同',
          type: 'error',
          customClass: 'msgHierarchy'
        })
      let params = this.tableData?.find(item => item.id == this.curId)
      this.$emit('confirm', [params])
    },
    handleClose() {
      this.$emit('closeDialog')
    }
  }
}
</script>
<style lang="scss"></style>