selectStoreDialog.vue 4.5 KB
<template>
  <d2-dialog :title="title"
             :is-visible.sync="selectStoreVisible"
             width="70%"
             btn-ok-label="确定"
             @confirmDialog="handleSelectStoreConfirm"
             @closeDialog="handleSelectStoreClose"
             class="selectStore">
    <d2-search ref="showSearch"
               class="show-search"
               :search-form="searchForm"
               :label-width="'100px'"
               :form-data="showFormData">
    </d2-search>
    <div class="up-btns">
      <el-button :id="tableParams.btnId"
                 size="small"
                 type="primary">
        查询
      </el-button>
    </div>
    <d2-table ref="groundingIndexTable"
              :has-num="false"
              :search-form="searchForm"
              :table-params="tableParams"
              :get-list-api="getListApi"
              :before-search-fn="beforeSearchFn"
              @setTableFinishFun="setTableFinishFun">
      <template slot="select_btn"
                slot-scope="scope">
        <el-radio v-model="selectedRowId"
                  :label="scope.scope.merchantId">{{ '' }}</el-radio>
      </template>
      <div slot="areaOperatorHtml"
           slot-scope="scope">
        <template v-if="
          scope.scope.areaOperatorList && scope.scope.areaOperatorList.length > 1
        ">
          <span>{{ scope.scope.areaOperatorList[0].areaOperatorName + ' ' + scope.scope.areaOperatorList[0].areaOperatorPhone }}</span>
          <el-popover placement="top"
                      width="fit-content"
                      trigger="hover">
            <div :class="{ scrollHeight: scope.scope.areaOperatorList.length >= 10 }">
              <div v-for="(item, index) in scope.scope.areaOperatorList"
                   :key="index">
                {{ item.areaOperatorName + ' ' + item.areaOperatorPhone }}
              </div>
            </div>
            <span class="more-info"
                  slot="reference">...({{ scope.scope.areaOperatorList.length }})</span>
          </el-popover>
        </template>
        <template v-else>
          <span v-if="
            !scope.scope.areaOperatorList || !scope.scope.areaOperatorList.length
          ">--</span>
          <span
                v-else>{{ scope.scope.areaOperatorList[0].areaOperatorName + ' ' + scope.scope.areaOperatorList[0].areaOperatorPhone }}</span>
        </template>
      </div>
    </d2-table>
  </d2-dialog>
</template>

<script>
import { areaOperatorList } from '@api/teachingManage'
export default {
  name: 'SelectStoreDialog',
  props: {
    title: {
      type: String,
      default: "选择门店"
    },
    selectStoreVisible: {
      type: Boolean,
      default: false
    },
    supervisorUuid: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      getListApi: areaOperatorList,
      tableData: [],
      showFormData: [{
        label: '门店名称',
        name: 'merchantName',
        type: 'input',
        maxlength: 50,
        isClear: true,
        keyFn: this.keyDowmGetList
      }],
      searchForm: {
        merchantName: ''
      },
      baseData: {
      },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [{
          label: '',
          width: '60',
          addHtml: 'select_btn'
        }, {
          label: '门店名称',
          prop: 'merchantName'
        }, {
          label: '区域运营',
          prop: 'areaOperatorList',
          addHtml: 'areaOperatorHtml'
        }]
      },
      selectedRowId: ''
    }
  },
  mounted() {
    // this.getList()
  },
  methods: {
    // getList() {
    //   const params = this.searchForm
    //   getDudaoList(params).then(res => {
    //     this.tableData = res || []
    //   })
    // },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm.supervisorUuid = this.supervisorUuid
        resolve()
      })
    },
    setTableFinishFun(data) {
      this.tableData = data
    },
    handleSelectStoreConfirm() {
      const selectData = this.tableData?.find(v => v.merchantId == this.selectedRowId)
      if (!selectData) return this.$message.warning('请选择门店')
      this.$emit('handleSelectStoreConfirm', selectData)
    },
    handleSelectStoreClose() {
      this.$emit('handleSelectStoreClose')
    }
  }
}
</script>
<style lang="scss" scoped>
.show-search {
  ::v-deep .d2-search-block {
    padding: 0;
  }
}
.more-info {
  white-space: nowrap;
  color: #5850ff;
  cursor: pointer;
}
</style>