<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :span="6">
            <a-form-item label="">
              <j-input
                placeholder="用户账号"
                v-model="queryParam.username"
              ></j-input>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item label="">
              <j-input
                placeholder="姓名"
                v-model="queryParam.realname"
              ></j-input>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item label="">
              <j-input
                placeholder="手机号"
                v-model="queryParam.phone"
              ></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span
              style="float: left; overflow: hidden"
              class="table-page-search-submitButtons"
            >
              <a-button type="primary" @click="searchQuery" icon="search"
                >查询</a-button
              >
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{
          selectedRowKeys: selectedRowKeys,
          onChange: onSelectChange,
        }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic"
            >无图片</span
          >
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic"
            >无文件</span
          >
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)"
          >
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">选择</a>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import "@/assets/less/TableExpand.less";
import { mixinDevice } from "@/utils/mixin";
import { JeecgListMixin } from "@/mixins/JeecgListMixin";
import { httpAction, getAction, postAction } from "@/api/manage";

export default {
  name: "BusMarketCouponsUsedList",
  mixins: [JeecgListMixin, mixinDevice],
  components: {},
  props: {
    couponsId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      description: "sysUserList",
      // 表头
      columns: [
        {
          title: "姓名",
          align: "center",
          dataIndex: "realname",
        },

        {
          title: "用户名",
          align: "center",
          dataIndex: "username",
        },
        {
          title: "手机号",
          align: "center",
          dataIndex: "phone",
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          fixed: "right",
          width: 80,
          scopedSlots: { customRender: "action" },
        },
      ],
      url: {
        list: "/sys/user/list",
        delete: "/sys/user/delete",
        deleteBatch: "/sys/user/deleteBatch",
        exportXlsUrl: "/sys/user/exportXls",
        importExcelUrl: "sys/user/importExcel",
      },
      dictOptions: {},
      superFieldList: [],
    };
  },
  created() {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG["domianURL"]}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    handleEdit(item) {
      var model = { sysUserId: item.id, commission: 0 };
      var _info = JSON.parse(localStorage.getItem("storeInfo"));
      if (_info) {
        model.hotelId = _info.id;
      }
      postAction("/business/busYezhu/add", model).then((res) => {
        if (res.success) {
          this.$message.success(res.message);
          this.$emit("ok");
        } else {
          this.$message.warning(res.message);
        }
      });
    },
  },
};
</script>
<style scoped>
@import "~@assets/less/common.less";
</style>