<template>
  <el-dialog
    v-model="setCrewShow"
    :before-close="cancel"
    title="设置班组"
    width="640px"
    @open="open"
    @opened="opened"
  >
    <el-transfer
      v-model="value"
      filterable
      :filter-method="filterMethod"
      filter-placeholder="输入关键字进行确认"
      :titles="['未选择', '已选择']"
      :data="data"
    />
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="submit()">取消</el-button>
        <el-button type="primary" @click="cancel()"> 确认 </el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script>
import { getProcessesTeams, setTeams } from "@/api/processManagement/basicProcesses";

export default {
  name: "SetPersonnel",
  props: {
    setCrewOpen: {
      type: Boolean,
      default: false,
    },
    pId: {
      type: String,
      default: null,
    },
    type: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      url: "",
      setCrewShow: false,
      data: [],
    };
  },
  mounted() {
    this.setCrewShow = this.setCrewOpen;
    console.log(9999, this.pId);
    this.getTeams();
  },
  methods: {
    getTeams() {
      getProcessesTeams(this.pId).then((res) => {
        console.log(9999999, res);
      });
    },
    open() {
      // if (this.type === 'teamSet') {
      //   this.url = 'teamSet/findUserByTeam/' + this.id;
      // } else if (this.type === 'platingAssort') {
      //   this.url = 'bsPlatingAssort/findUserByPlatingAssort/' + this.id;
      // } else if (this.type === 'abnormalConfig') {
      //   this.url = 'bsBasicClass/findUserByAbnormalConfig/' + this.id;
      // }
    },
    submit() {
      // const keyIds = this.$refs["tree-transfer"].getChecked();
      // if (keyIds == null) {
      //   this.$message.warning(this.$t("publics.message.noDataToSave"));
      //   return;
      // }
      // let url = "";
      // if (this.type === "teamSet") {
      //   url = "/teamSet/addOrDeleteUserRight";
      // } else if (this.type === "platingAssort") {
      //   url = "/bsPlatingAssort/addOrDeleteUserRight";
      // } else if (this.type === "abnormalConfig") {
      //   url = "/bsBasicClass/addOrDeleteUserRight";
      // }
      // this.loading = true;
      // this.$ajax
      //   .post(url, {
      //     id: this.id,
      //     keyIdArr: keyIds,
      //   })
      //   .then(() => {
      //     this.loading = false;
      //     this.$message.success(this.$t("videaVueLib.publics.message.success"));
      //     this.cancel(true);
      //   });
    },
    opened() {
      // this.$refs["tree-transfer"].axios();
    },
    cancel(refresh) {
      this.setCrewShow = false;
      this.$emit("setCrewOpeSancel", typeof refresh === "boolean" && refresh);
    },
  },
};
</script>
