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

<script>
export default {
  name: "remarks",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    options: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      remarks: "",
    };
  },

  mounted() {},

  methods: {
    init() {
      if (this.options?.length > 1) {
        this.remarks = "";
      } else {
        this.remarks = this.options[0].remarks;
      }
    },
    close() {
      this.remarks = "";
    },
    submitForm() {
      const data = {
        orderIdList: this.options.map((i) => i.orderId),
        orderSnList: this.options.map((i) => i.orderSn),
        remark: this.remarks,
      };
      this.$api.systemtoporderupdateremark(data).then((res) => {
        this.isShow = false;
        this.$parent.$refs.tableList.clearMoreActive();
        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>
