selectSupervisorDialog.vue 2.98 KB
<template>
  <d2-dialog :title="title"
             :is-visible.sync="selectSupervisorVisible"
             width="50%"
             btn-ok-label="确定"
             @confirmDialog="handleSelectSupervisorConfirm"
             @closeDialog="handleSelectSupervisorClose"
             class="selectSupervisor">
    <d2-search ref="showSearch"
               class="show-search"
               :search-form="searchForm"
               :label-width="'100px'"
               :form-data="showFormData">
    </d2-search>
    <div class="up-btns">
      <el-button @click="getList"
                 size="small"
                 type="primary">
        查询
      </el-button>
    </div>
    <d2-table ref="groundingIndexTable"
              :has-num="false"
              :has-page="false"
              :search-form="searchForm"
              :table-params="tableParams"
              :table-data="tableData"
              :before-search-fn="beforeSearchFn">
      <template slot="select_btn"
                slot-scope="scope">
        <el-radio v-model="selectedRowId"
                  :label="scope.scope.id">{{ '' }}</el-radio>
      </template>
    </d2-table>
  </d2-dialog>
</template>

<script>
import { getDudaoList } from '@api/teachingManage'
export default {
  name: 'SelectSupervisorDialog',
  props: {
    title: {
      type: String,
      default: "选择督导"
    },
    selectSupervisorVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      // getListApi: getDudaoList,
      tableData: [],
      showFormData: [{
        label: '督导名称',
        name: 'staffName',
        type: 'input',
        maxlength: 50,
        width: '250px',
        isClear: true,
        keyFn: this.keyDowmGetList
      }],
      searchForm: {
        roleName: '飞行督导',
        staffName: ''
      },
      baseData: {
      },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [{
          label: '',
          width: '60',
          addHtml: 'select_btn'
        }, {
          label: '督导名称',
          prop: 'staffName'
        }, {
          label: '手机号',
          prop: 'staffPhone'
        }]
      },
      selectedRowId: ''
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      const params = this.searchForm
      getDudaoList(params).then(res => {
        this.tableData = res || []
      })
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        resolve()
      })
    },
    handleSelectSupervisorConfirm() {
      const selectData = this.tableData?.find(v => v.id == this.selectedRowId)
      if (!selectData) return this.$message.warning('请选择督导')
      this.$emit('handleSelectSupervisorConfirm', selectData)
    },
    handleSelectSupervisorClose() {
      this.$emit('handleSelectSupervisorClose')
    }
  }
}
</script>
<style lang="scss" scoped>
.show-search {
  ::v-deep .d2-search-block {
    padding: 0;
  }
}
</style>