<!--修改-订单备注-->
<template>
  <q-dialog v-model="IsShowOrderRemarkDialog" content-class="bg-grey-1" persistent transition-show="scale"
    transition-hide="scale">
    <q-card style="width: 400px;max-width:500px;">
      <q-card-section>
        <div class="text-h6">{{RemarkTitle}}</div>
      </q-card-section>
      <q-card-section class="q-pt-none scroll" style="max-height: 70vh">
        <div class="row wrap">
          <q-input filled stack-label :dense="false" v-model="OrderRemarkMsg.Remark"
          type="textarea" class="col-12" label="备注" />
        </div>
      </q-card-section>
      <q-separator />
      <q-card-actions align="right" class="bg-white">
        <q-btn label="取消" flat color="grey-10" style="font-weight:400 !important" @click="closeRemarkForm" />
        <q-btn label="立即提交" color="accent" class="q-px-md" style="font-weight:400 !important"
          @click="saveOrderRemark" />
      </q-card-actions>
    </q-card>
  </q-dialog>
</template>
<script>
  import {
    updateOrderRemark, //修改订单备注
  } from '../../api/sale/sale'
  export default {
    name: "orderremark-form",
    props: {
      saveObj: {
        type: Object,
        default: null,
      },
      remarkType: {
        type: Number,
        default: 0,
      }
    },
    data() {
      return {
        IsShowOrderRemarkDialog: true,
        RemarkTitle: '',
        OrderRemarkMsg: {
          OrderId: 0,
          Type: 0,
          Remark: ""
        },
      }
    },
    created() {
      this.initData();
    },
    methods: {
      //关闭弹窗
      closeRemarkForm() {
        this.IsShowOrderRemarkDialog = false;
        this.$emit('close');
      },
      //初始化数据
      initData() {
        this.OrderRemarkMsg.OrderId = this.saveObj.OrderId;
        switch (this.remarkType) {
          case 1:
            this.RemarkTitle = "修改销售备注";
            this.OrderRemarkMsg.Type = 1;
            this.OrderRemarkMsg.Remark = this.saveObj.SaleRemark;
            break;
          case 2:
            this.RemarkTitle = "修改教务备注";
            this.OrderRemarkMsg.Type = 2;
            this.OrderRemarkMsg.Remark = this.saveObj.TeacherRemark;
            break;
          case 3:
            this.RemarkTitle = "修改校长备注";
            this.OrderRemarkMsg.Type = 3;
            this.OrderRemarkMsg.Remark = this.saveObj.RectorRemark;
            break;
          case 4:
            this.RemarkTitle = "修改经理备注";
            this.OrderRemarkMsg.Type = 4;
            this.OrderRemarkMsg.Remark = this.saveObj.DirectorRemark;
            break;
        }
      },
      //获取订单信息
      saveOrderRemark() {
        updateOrderRemark(this.OrderRemarkMsg).then(res => {
          if (res.Code == 1) {
            this.$q.notify({
              icon: 'iconfont icon-chenggong',
              color: 'accent',
              timeout: 2000,
              message: '修改成功！',
              position: 'top'
            })
            //调用父页面成功方法
            this.$emit('success');
            // this.IsShowOrderRemarkDialog = false
            this.$emit('close');
          }
        })
      }
    }
  }

</script>
