<script>
import { MODEIFYBUYER } from "@/api/business/purchase/task";
export default {
  name: "ModifyBuyerDialog",
  components: {},
  data() {
    return {
      size: "mini",
      visible: false,
      loading: false,
      params: { id: "", buyer: "", buyerName: "" },
    };
  },
  computed: {},
  watch: {},
  methods: {
    //
    open(prop) {
      this.visible = true;
      this.params.id = prop;
    },
    //
    hide() {
      this.visible = false;
      this.params.id = "";
      this.params.buyer = "";
      this.params.buyerName = "";
    },
    //
    async submit(prop) {
      try {
        this.loading = true;
        const { id, buyer, buyerName } = prop;
        const { code, msg } = await MODEIFYBUYER([
          {
            id,
            buyer,
            buyerName,
          },
        ]);
        if (code === 200) {
          this.hide();
          this.$emit("success");
          this.$notify.success({ title: msg });
        } else {
          this.$notify.warning({ title: msg });
        }
      } catch (err) {
        //
      } finally {
        this.loading = false;
      }
    },
  },
  created() {},
  mounted() {},
  destroyed() {},
};
</script>

<template>
  <el-dialog width="25%" :visible.sync="visible" title="转派" @close="hide">
    <el-alert
      title="转派后，采购任务将会从您的采购任务清单中删除，转移到转派目标人员的已受理采购任务清单中，您确定要转派吗？"
      type="info"
      show-icon
      :closable="false"
      style="margin-bottom: 10px"
    >
    </el-alert>
    <el-form
      :size="size"
      :model="params"
      label-width="0px"
      label-position="right"
    >
      <el-form-item prop="" label="">
        <dr-popover-select
          v-model="params.buyerName"
          title="转派人员"
          type="CONTACTS_PARAM"
          :data-mapping="{ buyer: 'code', buyerName: 'name' }"
          :source.sync="params"
        >
        </dr-popover-select>
      </el-form-item>
    </el-form>
    <span slot="footer">
      <el-button :size="size" @click="visible = false">取 消</el-button>
      <el-button :size="size" type="primary" @click="submit(params)"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<style scoped></style>
