<template>
  <div class="newApply pagePadding">
    <div
      v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
    >
      <el-form
        :disabled="myType !== 4"
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="120px"
      >
        <el-form-item label="验货详情" prop="check_detail">
          <ex-table
            v-loading="false"
            :table="table"
            :data="tableData"
            :columns="columns"
            :page="pageInfo"
            :size="size"
            @page-curr-change="handlePageChange"
            @page-size-change="handleSizeChange"
            @screen-reset="
              pageInfo.curr = 1;
              parmValue.page = 1;
              searchList();
            "
            @screen-submit="
              pageInfo.curr = 1;
              parmValue.page = 1;
              searchList();
            "
          >
            <template #table-header="{}">
              <div style="width: 100%; height: 40px"></div>
            </template>
            <template #operation="{ scope }">
              <el-tooltip
                v-if="powers.some((item) => item == '002')"
                effect="dark"
                content="重置密码"
                placement="top"
              >
                <i
                  class="el-icon-refresh-left tb-icon"
                  @click="openPasswordModal(scope.row.id, false)"
                ></i>
              </el-tooltip>

              <el-tooltip
                v-if="powers.some((item) => item == '007')"
                effect="dark"
                content="详情"
                placement="top"
              >
                <i
                  class="el-icon-view tb-icon"
                  @click="openModal(scope.row.id, true, scope.row)"
                ></i>
              </el-tooltip>
              <el-tooltip
                v-if="powers.some((item) => item == '005')"
                effect="dark"
                content="修改"
                placement="top"
              >
                <i
                  class="el-icon-edit tb-icon"
                  @click="openModal(scope.row.id, false, scope.row)"
                ></i>
              </el-tooltip>
              <el-tooltip
                v-if="
                  powers.some((item) => item == '004') &&
                  scope.row.status === '1'
                "
                effect="dark"
                content="禁用"
                placement="top"
              >
                <i
                  class="el-icon-video-pause tb-icon"
                  @click="statusConfirm(scope.row.id, scope.row.status)"
                ></i>
              </el-tooltip>
              <el-tooltip
                v-if="
                  powers.some((item) => item == '004') &&
                  scope.row.status === '0'
                "
                effect="dark"
                content="启用"
                placement="top"
              >
                <i
                  class="el-icon-video-play tb-icon"
                  @click="statusConfirm(scope.row.id, scope.row.status)"
                ></i>
              </el-tooltip>
            </template>
          </ex-table>
        </el-form-item>
        <el-form-item>
          <el-col :span="24" style="text-align: right; margin-top: 10px">
            <el-button type="primary" @click="save">保 存 </el-button>
          </el-col>
        </el-form-item>
      </el-form>
    </div>
    <div v-else>
      <no-auth></no-auth>
    </div>
  </div>
</template>
   
<script>
import mixinPage from "@/mixins/elPaginationHandle";
import resToken from "@/mixins/resToken";
import asyncRequest from "@/apis/service/stock/newApply";
// import asyncRequest from "@/mock/service/stock/newApply";
import addEdit from "./addEdit-newApply";
import { mapGetters } from "vuex";

export default {
  name: "allotFlow",
  mixins: [mixinPage, resToken],
  props: ["myType"],
  components: {
    addEdit,
  },
  computed: {
    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
    powers() {
      let tran =
        this.$store.getters.btnList.find(
          (item) => item.menu_route == "allotFlow"
        ) || {};
      if (tran && tran.action && tran.action.length > 0) {
        return tran.action;
      } else {
        return [];
      }
    },
  },
  data() {
    return {
      value: "",
      ruleForm: {},
      rules: {
        //出入库规则
        check_detail: [
          {
            required: true,
            message: "请选择发货公司",
            trigger: "blur",
          },
        ],
      },

      loading: true,
      showModel: false,
      isDetail: false,
      modelId: 0,
      tableData: [], //渲染表格
      //
      // 表格 - 数据
      tableData: [],
      // 表格 - 参数
      table: {
        stripe: true,
        border: true,
        // _defaultHeader_: ["setcol"],
      },
      // 表格 - 分页
      pageInfo: {
        size: 15,
        curr: 1,
        total: 0,
      },
      // 表格 - 列参数
      columns: [
        {
          prop: "nickname",
          label: "商品编号",
        },
        {
          prop: "role_name",
          label: "商品名称",
        },
        {
          prop: "mobile",
          label: "总数量",
        },
        {
          prop: "mobile",
          label: "异常数量",
        },
        {
          prop: "mobile",
          label: "异常备注",
        },
        {
          prop: "",
          label: "操作",
          fixed: "right",
          _noset_: true,
          _slot_: "operation",
        },
      ],
      //入参
      parmValue: {
        // page: 1, // 页码
        // size: 15, // 每页显示条数
      },
    };
  },
  mounted() {
    this.searchList();
  },

  methods: {
    restSearch() {
      //重置入参
      this.parmValue = {
        // page: 1, // 页码
        // size: 10, // 每页显示条数
      };
      this.searchList();
    },

    openModal(id, isDetail, sitem) {
      this.showModel = true;
      this.modelId = id;
      this.isDetail = isDetail;
      this.sitem = sitem;
    },
    async searchList() {
      // this.loading = true;
      // const res = await asyncRequest.list(this.parmValue);
      // if (res && res.code === 0 && res.data) {
      //   this.tableData = res.data.list;
      //   this.pageInfo.total = Number(res.data.count);
      // } else if (res && res.code >= 100 && res.code <= 104) {
      //   await this.logout();
      // } else {
      //   this.tableData = [];
      //   this.pageInfo.total = 0;
      // }
      // this.loading = false;
    },
  },
};
</script>
   