<template>
  <div>
    <BaseDialog
      width="600px"
      :isShow.sync="isShow"
      title="修改备注"
      @submit="submitForm"
    >
      <el-input
        :rows="6"
        type="textarea"
        placeholder="请输入备注"
        v-model="value"
      ></el-input>
    </BaseDialog>
  </div>
</template>

<script>
import { updateRemark, updateMonthRemark } from "@/api/financed/index";
export default {
  name: "remarks",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    info: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      value: "",
    };
  },

  mounted() {},

  methods: {
    init() {
      this.value = this.info.remark;
    },
    submitForm() {
      let { orderSn, id } = this.info;
      let fn = orderSn ? updateRemark : updateMonthRemark;
      fn({
        orderSn: orderSn,
        remark: this.value,
        id: id,
      }).then((res) => {
        this.$message.success("修改备注成功");
        this.isShow = false;
        this.info.remark = this.value;
        // this.$emit("search");
      });
    },
  },
  computed: {
    isShow: {
      get() {
        if (this.dialogVisible) {
          this.init();
        }
        return this.dialogVisible;
      },
      set(val) {
        this.$emit("update:dialogVisible", false);
      },
    },
  },
};
</script>

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