a
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="120px"
    >
      <el-form-item label="昵称" prop="nick">
        <el-input
          v-model="queryParams.nick"
          placeholder="请输入昵称"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="手机号" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机号"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
          >搜索</el-button
        >
        <el-button
          type="primary"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          >导出</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="configList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="用户id" align="center" prop="userId" />
      <el-table-column label="用户昵称" align="center" prop="nick" />
      <el-table-column label="用户电话" align="center" prop="phone" />
      <el-table-column label="交易金额(元)" align="center" prop="orderAmount" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="成交状态" align="center" prop="dealStatus">
        <template slot-scope="scope">
          {{
            scope.row.dealStatus == 0
              ? "未成交"
              : scope.row.dealStatus == 1
              ? "已成交"
              : ""
          }}
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleLookOrder(scope.row)"
            v-hasPermi="['manage:order:detail']"
            >查看订单</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-drawer
      title="查看订单"
      :visible.sync="drawer"
      direction="rtl"
      size="85%"
      :before-close="handleClose"
    >
      <OrderList type="detail" :userId="userid"></OrderList>
    </el-drawer>
  </div>
</template>

<script>
import OrderList from "./order.vue";
import { customerList, customerExport } from "@/api/manage/client";

export default {
  name: "Config",
  components: { OrderList },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 参数表格数据
      configList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        phone: "",
        nick: "",
      },
      // 表单参数
      form: {},
      // 表单校验
      drawer: false,
      userid: "",
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleLookOrder(record) {
      this.userid = record.userId;
      this.drawer = true;
      // this.$router.push({
      //   path: "/order/manage/order",
      //   query: {
      //     userId: record.userId,
      //   },
      // });
      // customerList(this.queryParams).then((response) => {
      //   this.configList = response.data.records;
      //   this.total = response.data.total;
      //   this.loading = false;
      // });
    },
    handleExport() {
      this.download(
        "/system/order/customer/export",
        {
          ...this.queryParams,
        },
        `客户表_${new Date().getTime()}.xlsx`
      );
    },
    /** 查询参数列表 */
    getList() {
      this.loading = true;
      customerList(this.queryParams).then((response) => {
        this.configList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
<style scoped lang="scss"></style>
