index.vue 2.56 KB
<template>
  <d2-dialog
    :is-visible="dialogVisible"
    class="accountDailog"
    title="选择门店"
    width="720px"
    @confirmDialog="handleAddConfirm"
    @closeDialog="handleClose">
    <div class="tableBox">
      <div style="padding: 10px 50px">
        <el-input
          v-model="realSearchForm.merchantIdName"
          placeholder="搜索门店名称"
          maxlength="20"
          clearable
          size="small"
          style="width: 300px; margin-right: 12px" />
        <el-button size="small" type="primary" @click="searchList">
          查询
        </el-button>
      </div>
      <d2-table
        ref="merchantTable"
        :search-form="realSearchForm"
        :table-params="tableParams"
        :get-list-api="getListApi"
        :before-search-fn="beforeSearchFn">
      </d2-table>
    </div>
  </d2-dialog>
</template>

<script>
import {
  getAllMerchantList,
  getMerchantListByScene,
  getBrandList
} from "@api/contentManager"
import { deepClone } from "@/common/util"
export default {
  name: "SelectGoodsTypeDialog",
  props: {
    config: {
      type: Object,
      require: true
    },
    dialogVisible: {
      type: Boolean,
      default: false
    },
    selectedRecord: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      getListApi: getAllMerchantList,
      realSearchForm: {
        merchantIdName: ""
      },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        mutiSelectUniqueKey: "id",
        mutiSelectName: "merchantIndex",
        tableColumns: [
          {
            label: "门店名称",
            prop: "merchantName"
          }
        ]
      }
    }
  },
  mounted() {},
  methods: {
    beforeSearchFn() {
      return new Promise((resolve) => {
        if (this.config.scene == 0 || this.config.scene == 4) {
          this.getListApi = getAllMerchantList
        } else {
          this.getListApi = getMerchantListByScene
          this.realSearchForm.scene = this.config.scene
        }
        resolve()
      })
    },
    searchList() {
      this.$refs?.merchantTable?.refreshTable(true, true)
    },
    handleAddConfirm() {
      const selectItemList =
        this.$refs.merchantTable?.mutiSelectArr?.[
          this.tableParams.mutiSelectName
        ] || []
      if (selectItemList.length) {
        this.$emit("confirmDialogFn", selectItemList)
      } else {
        this.$message.error("请勾选门店")
      }
    },
    handleClose() {
      this.$emit("closeDialogFn")
    }
  }
}
</script>

<style></style>