<template>
  <div class="app-container">
    <tinymce v-model="shoppingNotes" :height="300" />
    <div slot="footer" class="dialog-footer" style="float: right;padding:80px 0 80px 0;">
      <el-button type="primary" style="width:100px;" :loading="loadingbut" @click="onSubmite()">{{ loadingbuttext }}</el-button>
    </div>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce'
import { getOrganizeInfo, updateOrganizeInfo } from '@/api/other'
export default {
  components: {
    Tinymce
  },
  data() {
    return {
      isContent: false,
      shoppingNotes: '',
      loadingbut: false,
      loadingbuttext: '提交'
    }
  },
  computed: {
    organizeID() {
      return this.$store.getters.organizeID
    }
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      getOrganizeInfo({ id: this.organizeID }).then(response => {
        console.log(response)
        this.shoppingNotes = response.data.shoppingNotes
      })
    },
    onSubmite() {
      this.loadingbut = true
      this.loadingbuttext = '提交中'
      updateOrganizeInfo({ id: this.organizeID, afterSale: this.shoppingNotes }).then(response => {
        this.$message({ message: response.msg, type: 'success', center: true })
        this.loadingbut = false
        this.loadingbuttext = '提交'
        setTimeout(() => {
          this.initData()
        }, 1000)
      }).catch(() => {
        this.loadingbut = false
        this.loadingbuttext = '提交'
      })
    }
  }
}
</script>

<style scoped>

</style>
