selectStore.vue 5.93 KB
<template>
  <GLDialog
    bigTitle="选择商户"
    mode="big"
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    :close-on-click-modal="false"
    @onOk="handleConfirm"
    @onCancel="handleClose"
    class="select-store"
  >
    <glsx-combi-form
      ref="showSearch"
      labelWidth="105px"
      :formObj="searchForm"
      :formData="searchFormData"
    >
      <span slot="footer">
        <el-button
          :size="size"
          type="primary"
          @click="getTable"
        >查询</el-button>
        <el-button
          :size="size"
          @click="resetTable"
        >重置</el-button>
      </span>
    </glsx-combi-form>
    <GLTable
      ref="storeRef"
      :tableTotal="total"
      :searchForm="searchForm"
      :tableParams="tableParams"
      :pageConf="pageConf"
      @refreshTable="getList"
      :tableData="storeList"
      :hasNum="false"
      :setTableFinishFun="setTableFinishFun"
    >
      <div
        slot="radioHtml"
        class="store-table"
        slot-scope="scope"
      >
        <el-radio
          v-model="merchantId"
          :label="scope.scope.merchantNo"
          @click.native="handleClick(scope.scope)"
        ></el-radio>
      </div>
    </GLTable>
  </GLDialog>
</template>
<script>
export default {
  name: 'selectStore',
  data () {
    return {
      searchForm: {
        merchantId: '',
        merchantName: ''
      },
      total: 0,
      storeList: [],
      merchantId: '',
      merchantName: '',
      // 搜索
      searchFormData: [
        {
          label: '商户名称',
          name: 'merchantName',
          type: 'input',
          placeholder: '请输入商户名称',
          width: '300px',
          labelWidth: '10px'
        },
        {
          label: '商户ID',
          name: 'merchantId',
          type: 'input',
          inputType: 'number',
          placeholder: '请输入商户ID',
          width: '300px',
          labelWidth: '10px'
        }
      ],
      pageConfig: {
        pageSize: 10,
        currentPage: 1
      },
      tableParams: {
        listName: 'list',
        // tableOption: true,
        // 行数据的key
        // mutiSelectUniqueKey: 'staffId',
        // checkSelectKey: 'staffId',
        // checkSelectVal: [],
        // 多选ref的名称
        // mutiSelectName: 'list',
        tableColumns: [
          {
            label: '',
            prop: '',
            width: 80,
            addHtml: 'radioHtml'
          },
          {
            label: '序号',
            prop: 'idx',
            width: 80
          },
          {
            label: '商户名称',
            prop: 'merchantName',
            formatter: cellValue => {
              return cellValue.merchantName || '-'
            }
          },
          {
            label: '商户id',
            prop: 'merchantNo',
            formatter: cellValue => {
              return cellValue.merchantNo || '-'
            }
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      baseData: {}
    }
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    storeSearchForm: {
      type: Object
    },
    merchantInfo: {
      required: true
    }
    // merchantId: {
    //   type: String,
    //
    // }
    // orderCode: {
    //   type: String,
    //   required: true
    // }
  },
  watch: {
    dialogVisible (n) {
      if (n) this.init()
    }
  },
  mounted () {
  },
  methods: {
    init () {
      this.merchantId = String(this.merchantInfo.merchantId)
      this.merchantName = this.merchantInfo.merchantName
      this.getList()
    },
    getList (pageCon) {
      pageCon && (this.pageConfig = pageCon)
      var params = {
        merchantId: this.merchantId,
        ...this.searchForm,
        ...this.pageConfig
      }
      this.$apis.common.getMerchantList(params).then(res => {
        this.storeList = res.list
        this.total = res.total
        let nowIndex = this.pageConfig.pageSize * (this.pageConfig.currentPage - 1)
        this.storeList.forEach((item, index) => {
          item.idx = index + 1 + nowIndex
        })
      })
    },
    getTable () {
      this.$refs.storeRef.page.currentPage = 1
      this.getList()
    },
    setTableFinishFun () {
      //接收到的数据为空
      this.$refs.staffRef.tableHeightValues = '460px'
    },
    handleClick (val) {
      this.merchantId = val.merchantNo
      this.merchantName = val.merchantName
    },
    resetTable () {
      this.searchForm = {}
      this.getTable()
    },
    handleClose () {
      this.$emit('handleRelateStoreClose')
    },
    handleConfirm () {
      const { merchantId, merchantName } = this
      if (merchantId && merchantName) this.$emit('handleRelateStoreConfirm', {
        merchantId,
        merchantName
      })
      else this.handleClose()
    }
  }
}
</script>
<style lang="scss">
.select-store {
  .storeDailog {
    width: 500px;
  }
  .title {
    margin-bottom: 12px;
  }
  .customer-tag-box {
    display: flex;
    margin: 20px 16px;
    .tag-label {
      display: inline-block;
      height: 30px;
      line-height: 30px;
    }
    .input-tag-wrapper {
      max-height: 75px;
      overflow: auto;
      position: relative;
      font-size: 14px;
      background-color: #fff;
      background-image: none;
      border-radius: 4px;
      border: 1px solid #dcdfe6;
      box-sizing: border-box;
      color: #666;
      display: inline-block;
      outline: none;
      padding: 5px;
      flex-wrap: wrap;
      transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
      width: 648px;
      display: flex;
      align-items: center;
      cursor: pointer;
      i {
        color: #75acff;
        margin-right: 3px;
        font-size: 14px;
      }
    }
  }
  // .customer-list {
  //   width: calc(100% - 280px);
  //   margin-right: 10px;
  // }
  .p-16 {
    padding: 16px;
  }
  .store-table .el-radio__label {
    display: none;
  }
}
</style>