<template>
  <div class="app-container">
    <el-form ref="form" :model="shopInfo" label-width="120px">
      <el-row>
        <el-col :span="20">
          <el-form-item label="名称" prop="title">
            <el-input
              readonly
              type="text"
              style="width: 300px"
              placeholder="请输入名称"
              v-model="shopInfo.title"
            ></el-input>
          </el-form-item>

          <el-form-item
            label="活动时间"
            prop="dateRange"
            style="margin-top: 30px"
          >
            <el-date-picker
              readonly
              v-model="shopInfo.dateRange"
              type="datetimerange"
              range-separator="-"
              value-format="yyyy-MM-dd HH:mm:ss"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @change="datePicker"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item
            label="满减条件"
            prop="fullAmount"
            style="margin-top: 30px"
          >
            满
            <el-input
              readonly
              type="text"
              style="width: 130px"
              v-model="shopInfo.fullAmount"
            ></el-input>

            元 减
            <el-input
              readonly
              type="text"
              style="width: 130px"
              v-model="shopInfo.returnAmount"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="满减条件"
            prop="sendAmount"
            style="margin-top: 30px"
          >
            <el-table
              v-if="shopInfo.spuList && shopInfo.spuList.length > 0"
              v-loading="loading"
              :data="shopInfo.spuList"
              @selection-change="handleSelectionChange"
              row-key="id"
            >
              <el-table-column
                type="selection"
                width="55"
                align="center"
                :selectable="checkSelectable"
              />
              <el-table-column label="商品Id" align="center" prop="id" />
              <el-table-column label="商品信息" align="center">
                <template slot-scope="scope">
                  <div
                    style="
                      display: flex;
                      flex-direction: row;
                      justify-content: space-between;
                      align-items: center;
                    "
                  >
                    <el-image
                      style="width: 30px; height: 30px"
                      :src="scope.row.pic"
                      :preview-src-list="[scope.row.pic]"
                    >
                    </el-image>
                    <div
                      :title="scope.row.spuName"
                      style="
                        width: 80px;
                        height: auto;
                        word-wrap: break-word;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                      "
                    >
                      {{ scope.row.spuName }}
                    </div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                label="分类"
                align="center"
                prop="categoryName"
              />
              <el-table-column label="商品状态" align="center">
                <template slot-scope="scope">
                  {{
                    scope.row.spuStatus == 2
                      ? "售罄"
                      : scope.row.spuStatus == 0
                      ? "上架"
                      : scope.row.spuStatus == 1
                      ? "下架"
                      : ""
                  }}
                </template>
              </el-table-column>
              <el-table-column label="销量" align="center" prop="salesVolume" />
              <el-table-column label="价格" align="center" width="120">
                <template slot-scope="scope">
                  {{ scope.row.originalPrice }}元/{{ scope.row.unit }}
                </template>
              </el-table-column>
              <el-table-column label="类型" align="center" width="120">
                <template slot-scope="scope">
                  {{
                    scope.row.scope == 1
                      ? "农商批发商品"
                      : scope.row.scope == 3
                      ? "同城秒送商品"
                      : scope.row.scope == 4
                      ? "会员专区"
                      : scope.row.scope == 2
                      ? "同城特价商品"
                      : ""
                  }}
                </template>
              </el-table-column>
            </el-table>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import moment from "moment";
import { storeMarketingActivityInfo } from "@/api/marketing/activity";
export default {
  data() {
    return {
      shopInfo: {
        type: 1,
        showType: 0,
      },
      tabList: [],
    };
  },
  mounted() {
    this.getInfoActivity();
  },
  methods: {
    getInfoActivity() {
      storeMarketingActivityInfo(this.$route.query.id).then((res) => {
        if (res.code == 200) {
          this.shopInfo = res.data;
          if (this.shopInfo.orderStartTime) {
            const orderStartTime = new Date(this.shopInfo.orderStartTime);
            const orderEndTime = new Date(this.shopInfo.orderEndTime);
            this.shopInfo.dateRange = [orderStartTime, orderEndTime];
            console.log(this.shopInfo);
          }
        }
      });
    },
  },
};
</script>

<style>
.el-dialog__body {
  padding: 0px 20px;
}
</style>
