<template>
  <div>
    <el-dialog
      width="1000px"
      title="购买商品"
      :visible.sync="lookVisible"
      :before-close="onClose"
      append-to-body
    >
      <div>
        <descriptions :column="2">
          <descriptions-item label="购买人数：">{{
            statInfo.buyNum | moneyFormat
          }}</descriptions-item>
          <descriptions-item label="销售总额：">{{
            statInfo.totalAmount
          }}</descriptions-item>
        </descriptions>
        <el-alert
          title="直播商品"
          :closable="false"
          type="info"
          style="margin: 20px 0"
        ></el-alert>
        <el-form :inline="true" :model="searchForm">
          <el-form-item>
            <el-input
              v-model.trim="searchForm.search"
              clearable
              @keyup.enter.native="search"
              placeholder="学员编号/姓名/手机号"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="search" type="primary">搜索</el-button>
            <el-button @click="onReSet" type="danger">重置</el-button>
          </el-form-item>
        </el-form>
        <div class="tableWrap">
          <el-table
            style="width: 100%"
            :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
            :data="tableList"
            ref="multipleSelection"
          >
            <el-table-column
              align="center"
              prop="userId"
              label="用户编号"
            ></el-table-column>
            <el-table-column
              align="center"
              prop="userName"
              label="用户姓名"
            ></el-table-column>
            <el-table-column
              align="center"
              prop="phone"
              label="手机号"
            ></el-table-column>
            <el-table-column
              align="center"
              prop="goodsName"
              label="商品名称"
            ></el-table-column>
            <el-table-column
              align="center"
              prop="payTime"
              label="支付时间"
            ></el-table-column>
            <el-table-column align="center" prop="actualPrice" label="现金支付">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.actualPrice | moneyFormat(true) }}
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="balance" label="余额支付">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.balance | moneyFormat(true) }}
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="balance" label="支付总金额">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.expectPrice | moneyFormat(true) }}
                </div>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            sync
            :total.sync="rules.total"
            :page.sync="rules.page"
            :limit.sync="rules.limit"
            :page-sizes="rules.page_size"
            @pagination="getList"
          />
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="onClose">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getGoodsOrderList } from "../api";
import { getLiveGoodsMapperList } from "@/views/liveShopManger/api";
import pagination from "@/components/Pagination/index";
export default {
  name: "eidtPostMsg",
  components: { pagination },
  data() {
    return {
      searchForm: {
        search: "",
      },
      tableList: [],
      organList: [],
      rules: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
      addMuiscVisible: false,
      multipleSelection: [],
      chioseIdList: [],
      isNewPage: false,
      lookVisible: false,
      activeRow: { sendFlag: false },
      statInfo: {
        totalAmount: 0,
        buyNum: 0,
      },
    };
  },

  mounted() {},
  methods: {
    async getList() {
      try {
        const res = await getGoodsOrderList({
          ...this.searchForm,
          page: this.rules.page,
          rows: this.rules.limit,
          roomUid: this.activeRow.roomUid,
        });
        this.tableList = res.data.rows;
        this.rules.total = res.data.total;
        if (res.data.statInfo) {
          this.statInfo = { ...res.data.statInfo };
        }
      } catch (e) {
        console.log(e);
      }
    },
    search() {
      this.rules.page = 1;
      this.getList();
    },
    onReSet() {
      this.searchForm.search = "";
      this.search();
    },

    onClose() {
      this.lookVisible = false;
    },
    openDioag(row) {
      this.activeRow = row;
      this.lookVisible = true;
      this.getList();
    },
  },
};
</script>
<style lang="scss" scoped>
.w100 {
  width: 100%;
}
.btnWrap {
  justify-content: flex-start;
}
</style>
