selectStore.vue 7.72 KB
<template>
  <div class="select-store">
    <!--      width="600px" -->
    <GLDialog bigTitle="选择门店"
              mode="big"
              :visible.sync="dialogVisible"
              :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>
          <el-button :size="size"
                     @click="resetTable">重置</el-button>
        </span>
      </glsx-combi-form>
      <!--     :    :hasPage="false"
               :getListApi="getListApi"

                :tableData="storeList" -->
      <GLTable ref="storeRef"
               :noDataImg="url"
               :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>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取 消</el-button>
        <el-button size="small" type="primary" @click="handleConfirm">确 定</el-button>
      </span> -->
    </GLDialog>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
export default {
  name: 'selectStore',
  data() {
    return {
      url: url,
      searchForm: {
        merchantId: '',
        merchantName: ''
      },
      // getListApi: this.$apis.common.getMerchantList,
      total: 0,
      storeList: [],
      heightBox: 200,
      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
    // }
  },

  mounted() {
    // this.userInfo = this.$globalState.session
    let clientHeight = document.documentElement.clientHeight
    this.heightBox = clientHeight - 0.15 * clientHeight - 425
    this.merchantId = this.merchantInfo
    this.getList()
  },

  methods: {
    getList(pageCon) {
      console.log(pageCon, 'pageCon')
      pageCon && (this.pageConfig = pageCon)
      var params = {
        merchantId: this.merchantId,
        ...this.searchForm,
        ...this.pageConfig
        // merchantId: '44209390',
      }
      console.log(params)

      this.$apis.common.getMerchantList(params).then(res => {
        console.log(res)
        this.storeList = res.list
        this.total = res.total

        //   // this.storeList = res.staffUnitList
        //   // var page = this.$refs.staffRef.page
        //   // // 添加序号
        // pageConfig
        let nowIndex = this.pageConfig.pageSize * (this.pageConfig.currentPage - 1)
        console.log(nowIndex)
        this.storeList.forEach((item, index) => {
          item.idx = index + 1 + nowIndex
        })
        console.log(this.storeList)
        //   this.$refs.staffRef.tableHeightValues = '460px'
        // })
      })
    },
    getTable() {
      this.$refs.storeRef.page.currentPage = 1
      this.getList()
    },
    setTableFinishFun() {
      // console.log(this.$refs.staffRef.data)
      // this.storeList = this.$refs.staffRef.data

      //接收到的数据为空
      this.$refs.staffRef.tableHeightValues = '460px'
    },

    handleClick(val) {
      console.log(val)
      //  let { merchantId, merchantName } =val
      this.merchantId = val.merchantNo
      this.merchantName = val.merchantName
      // let temp = JSON.parse(JSON.stringify(val))
      // delete temp.idx
      // this.staffUuid = val.uuid
      // this.store = val
    },
    resetTable() {
      this.searchForm = {}
      this.getTable()
      // this.$refs.showSearch.refreshTable()
    },
    handleClose() {
      this.$emit('handleRelateStoreClose')
    },
    handleConfirm() {
      // if (!this.staffUuid)
      //   return this.$message({
      //     message: '请先选择员工',
      //     type: 'error'
      //   })
      // let parmas = {
      //   subOrderCode: this.orderCode,
      //   staffUuid: this.staffUuid
      // }
      // this.$apis.orderManage.signerOrder(parmas).then(res => {
      //   console.log(res)

      // })
      //  this.staffUuid
      this.$emit('handleRelateStoreConfirm', {
        merchantId: this.merchantId,
        merchantName: this.merchantName
      })
    }
  }
}
</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>