<template>
  <div class="source pagePadding">
    <div
      v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
      v-loading="loading"
    >
      <el-row>
        <el-col :span="4" style="width: 200px">
          <search-terrace
            :value="parmValue.platform_id"
            :disabled="false"
            :size="'mini'"
            :isDetail="false"
            :placeholder="'业务平台'"
            @searchChange="platform_codesearchChange"
          />
        </el-col>
      </el-row>
      <el-table
        :data="tableData"
        style="width: 100%"
        border
        :size="size"
        stripe
      >
        <el-table-column label="序号" type="index"> </el-table-column>
        <el-table-column prop="date" label="业务平台" width="180">
        </el-table-column>
        <el-table-column prop="source" label="销售渠道"> </el-table-column>
      </el-table>
    </div>

    <no-auth v-else></no-auth>
  </div>
</template>
<script>
import asyncRequest from "@/apis/service/orderEntry/source";
import { mapGetters } from "vuex";
import resToken from "@/mixins/resToken";
export default {
  name: "source",
  mixins: [resToken],
  computed: {
    //组件SIZE设置
    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
    powers() {
      let tran =
        this.$store.getters.btnList.find(
          (item) => item.menu_route == "source"
        ) || {};
      if (tran && tran.action && tran.action.length > 0) {
        return tran.action;
      } else {
        return [];
      }
    },
  },
  data() {
    return {
      loading: true,
      parmValue: {
        platform_id: "",
      },
      tableData: [],
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    restSearch() {
      this.parmValue = {
        platform_id: "",
      };
      this.searchList();
    },

    async platform_codesearchChange(e) {
      const { id } = e;
      this.parmValue.platform_id = id || "";
      await this.searchList();
    },
    // 刷新表格
    async searchList() {
      this.loading = true;
      const { code, data, message } = await asyncRequest.list(this.parmValue);
      if (code === 0) {
        this.tableData = data;
      } else if (code >= 100 && code <= 104) {
        await this.logout();
      } else {
        this.tableData = [];
        this.$message.warning(message);
      }
      this.loading = false;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
