<template>
  <div class="source pagePadding">
    <div
      v-if=" powers.some((i) => i == '001')"
      v-loading="loading"
    >
      <el-row style="padding: 8px 0 10px 0">
        <el-col :span="4" style="width: 200px">
          <search-terrace
            :value="parmValue.platform_id"
            :disabled="false"
            :size="'mini'"
            :isDetail="false"
            :is_show="'0'"
            :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="platform_name" label="业务平台">
        </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() {
      const tran =
        this.$store.getters.btnList.find(
          (item) => item.menu_route == "source"
        ) || {};
      const { action } = tran ?? {};
      return action ?? [];
    },
  },
  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>
