extendServiceItemsDialog.vue 7.12 KB
<!-- 延保服务项目弹窗 -->
<template>
  <div>
    <d2-dialog title="选择服务项目"
              :is-visible.sync="relateServiceVisible"
              width="1080px"
              btn-ok-label="确定"
              @confirmDialog="handleExtendServiceConfirm"
              @closeDialog="handleextendServiceClose"
              class="relateService">
      <slot />
      <el-row class="tableCon">
        <div class="tableBox">
          <el-table ref="seletingTable"
                    :data="selectingData"
                    height="464px"
                    class="table"
                    border>
            <el-table-column width="55" align="center">
              <template slot-scope="scope">
                <el-radio v-model="curId" @change="handleChangeRadio(scope.row)" :label="scope.row.id">{{''}}</el-radio>
              </template>
            </el-table-column>
            <el-table-column
              prop="serviceName"
              label="服务项目名称"
              :show-overflow-tooltip="true"
              align="center">
            </el-table-column>
            <el-table-column prop="supportPosition"
                            label="保障部件"
                            align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.supportPosition || '-' }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="powerType"
                            label="动力类型"
                            align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.powerType || '-' }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="supportPosition"
                            label="关联合同"
                            align="center">
              <template slot-scope="scope">
                <el-button @click="handlePreview(scope.row)" type="text" size="small">预览</el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-pagination small
                        background
                        @current-change="handleCurrentChange"
                        :current-page.sync="currentPage"
                        :page-size="pageSize"
                        layout="total, prev, pager, next"
                        :total="total" />
        </div>
      </el-row>
    </d2-dialog>
    <div class="pdfDialog">
      <el-dialog :visible.sync="isVisible" title="合同" :before-close="handleClose" :close-on-click-modal="false" width="860px">
        <iframe width="100%" height="700px" scrolling="yes" frameborder="0" :src="pdfUrl"></iframe>
      </el-dialog>
    </div>
    
  </div>
</template>
<script>
import { deepClone } from '@/common/util'
export default {
  name: 'ExtendServiceItemsDialog',
  data() {
    return {
      selectedData: [],
      selectingData: [],
      // 分页
      total: 0,
      currentPage: 1,
      pageSize: 20,
      curId: '',
      isVisible: false,
      pdfUrl: ''
    }
  },

  props: {
    relateServiceVisible: {
      type: Boolean,
      default: false
    },
    serviceApi: {
      type: Function,
      default: () => { }
    },
    serviceSelected: {
      type: Array,
      default: () => []
    },
    extendServiceItemsSearchForm: {
      type: Object,
      default: () => { }
    },
    extendServicePartList: {
      type: Array,
      default: () => []
    }
  },

  mounted() {
    this.selectedData = deepClone(this.serviceSelected)
    this.curId = deepClone(this.serviceSelected)[0]?.gradeId || deepClone(this.serviceSelected)[0]?.id
    this.getSelectingList()
  },

  methods: {
    getSelectingList() {
      let params = deepClone(this.extendServiceItemsSearchForm)
      // 根据下标值传具体的名称,为0时是全部,不传值
      params.supportPosition = params.supportPosition == 0 ? '' : this.extendServicePartList[params.supportPosition]
      this.serviceApi({
        ...params,
        currentPage: this.currentPage,
        pageSize: this.pageSize
      }).then(res => {
        this.selectingData = res.list || []
        this.total = res.total
      })
    },
    // 预览合同
    handlePreview(row) {
      this.pdfUrl = row?.previewUrl
      this.handleClose()
    },
    handleClose() {
      this.isVisible = !this.isVisible
    },
    handleChangeRadio(e) {
      this.selectedData = [e]
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.getSelectingList()
    },
    handleExtendServiceConfirm() {
      if (!this.selectedData?.length) return this.$message.warning('请选择服务项目')
      this.$emit('handleExtendServiceConfirm', this.selectedData)
    },
    handleextendServiceClose() {
      this.$emit('handleextendServiceClose')
    }
  }
}

</script>
<style lang="scss" scoped>
.relateService .table {
  margin: 0 auto 20px !important;
  width: 100%;
}
.relateService .tableCon {
  margin-top: 20px;
  display: flex;
  .tableBox {
    flex: 2;
  }
  .selectedBox{
    flex: 1;
    height: 462px;
    border: 1px solid #E5E5E5;
    margin-left: 10px;
    .title{
      height: 38px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 8px 0 16px;
      border-bottom: 1px solid #E5E5E5;
      .title_txt{
        font-size: 16px;
        font-weight: 600;
        color: #333333;
      }
      .title_btn{
        cursor: pointer;
        font-size: 14px;
        color: #185EFE;
      }
    }
    .content{
      padding: 16px 10px;
      height: calc(100% - 75px);
      overflow-y: scroll;
      .item{
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 32px;
        color: #666666;
        padding: 0 8px;
        .del_item{
          cursor: pointer;
        }
      }
      .item:hover{
        background: #F6F9FF;
      }
    }
  }
}
.service-service .relateService .el-table .cell,
.d2-form .relateService .el-table .cell {
  line-height: 26px !important;
}
.service-service .relateService .el-table--medium td,
.d2-form .relateService .el-table--medium td {
  padding: 6px 8px !important;
}
.relateService .red {
  color: red;
}
.relateService .tip-icon {
  position: absolute;
  display: inline-block;
  height: 10px;
  width: 10px;
  line-height: 10px;
  color: #ffffff;
  background-color: red;
  border: 1px solid red;
  border-radius: 50%;
  cursor: pointer;
  font-size: 6px;
  margin-left: 2px;
}
.text_hide{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

::v-deep .el-table__header-wrapper .has-gutter .el-checkbox{
  display: none;
}
::v-deep .text_hide p{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}
::v-deep .el-radio__original {
  display: none !important;
}

::v-deep .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled)
  .el-radio__inner {
  box-shadow: none !important;
}
.pdfDialog{
  ::v-deep .el-dialog__header {
    padding: 10px 16px 4px;
    background-color: #141516;
    .el-dialog__title {
      color: #fff;
      font-size: 16px;
    }
  }
  ::v-deep .el-dialog__body {
    padding: 0;
    background-color: #202223;
  }
}
</style>