<template>
  <basicLayout
    style="padding-top: 0 !important"
    ref="basicLayout"
    :oldFormPath="{ add: 'WebsiteManagement/marketproductMag/modules' }"
    tableName="marketproductMagTable"
    idName="sa_fadid"
    :apiId="{ query: 20240920101703, del: '' }"
    :isExport="false"
    :autoQuery="false"
  >
    <template #custom>
      <div class="mt-10">
        <label class="search__label">{{ $t("状态") }}:</label>
        <el-select
          class="inline-24"
          v-model="whereSelect.isonsale"
          :placeholder="$t('请选择状态')"
          @change="selectChange"
          size="small"
          clearable
        >
          <el-option :label="$t('新建')" value="0"></el-option>
          <el-option :label="$t('发布')" value="1"></el-option>
        </el-select>
      </div>
    </template>
    <template v-slot:tbList="scope">
      <div v-if="scope.data.column.columnname === 'isonsale'">
        <div
          :style="[
            {
              color:
                scope.data.column.data[scope.data.column.columnname] == 0
                  ? '#3874f6'
                  : '#52c41a',
            },
          ]"
        >
          {{
            $t(
              scope.data.column.data[scope.data.column.columnname] == 0
                ? "新建"
                : "发布"
            )
          }}
        </div>
      </div>
      <div v-else-if="scope.data.column.columnname === 'classmx'">
        <span v-if="scope.data.column.data.class && scope.data.column.data[scope.data.column.columnname]">
          {{$t(scope.data.column.data.class) + '/' + $t(scope.data.column.data.classmx)}}
        </span>
        <span v-else-if="scope.data.column.data.class && !scope.data.column.data[scope.data.column.columnname]">
          {{$t(scope.data.column.data.class)}}
        </span>
        <span v-else>
          --
        </span>
      </div>
      <div v-else>
        {{
          $t(scope.data.column.data[[scope.data.column.columnname]])
            ? $t(scope.data.column.data[[scope.data.column.columnname]])
            : "--"
        }}
      </div>
    </template>
    <template v-slot:tbOpreation="scope">
      <detail :data="scope.data" @onClose="listData"></detail>
    </template>
  </basicLayout>
</template>

<script>
import detail from "./modules/detail";
export default {
  name: "index",
  components: { detail },
  data() {
    return {
      siteid: JSON.parse(sessionStorage.getItem("active_account")).siteid,
      date: [],
      whereSelect: {
        condition: "",
        isonsale: "",
        class: "",
      },
    };
  },
  methods: {
    listData() {
      this.$refs.basicLayout.param.content.siteid = this.siteid;
      this.$refs.basicLayout.listData(
        (this.$refs.basicLayout.param.content.pageNumber = 1)
      );
    },
    selectChange() {
      this.$refs.basicLayout.param.content.siteid = this.siteid;
      this.$refs.basicLayout.param.content.where = this.whereSelect;
      this.listData();
    },
  },
  mounted() {
    this.listData();
  },
};
</script>

<style scoped>
</style>
