<template>
  <view>
    <!-- 转储备项目 -->
    <u-modal
      :show="modelVisible"
      :showCancelButton="true"
      @confirm="handleConfirm()"
      @cancel="close()"
      :asyncClose="true"
      title="转储备项目">
      <view class="slot-content" style="width: 100%">
        <view class="flex">
          <text>转化原因：</text>
          <u-textarea
            v-model="addFrom.projConversionReason"
            placeholder="请输入转化原因"
            height="180"
            :count="true"
            maxlength="500"></u-textarea>
        </view>
      </view>
    </u-modal>
  </view>
</template>

<script>
  import projectApi from '../../../api/project'
  import to from 'await-to-js'
  export default {
    data() {
      return {
        modelVisible: false,
        addFrom: {
          projConversionReason: '',
          id: null,
        },
      }
    },
    methods: {
      open(id) {
        this.addFrom.id = id
        this.modelVisible = true
      },
      // 移入公海
      async handleConfirm() {
        let params = this.addFrom
        const [err, res] = await to(projectApi.toReserve(params))
        if (err) return this.close()
        if (res.code == 200) {
          this.$refs.uToast.show({
            type: 'loading',
            message: '转储备成功',
            complete: () => {
              this.modelVisible = false
              this.$emit('fetchList')
            },
          })
        } else {
          this.close()
        }
      },
      // 关闭移入公海模块
      close() {
        this.addFrom.id = []
        this.addFrom.projConversionReason = ''
        this.modelVisible = false
      },
    },
  }
</script>

<style></style>
