<template>
  <div>
    <basic-form label-width="120px" ref="data" v-bind="$attrs">
      <basic-form-item label="原容量："> {{ itemData.params.size }}GB </basic-form-item>
      <basic-form-item label="变更容量：">
        <el-input-number :min="itemData.params.size" v-model="itemData.newDiskSize" placeholder="请输入大小"></el-input-number>
      </basic-form-item>
    </basic-form>
  </div>
</template>

<script>
import { getServiceDetail } from 'services/services/service.ts'
import { generateSpec, getSpecValue } from 'views/resource-apply/utils/index'

export default {
  props: {
    itemData: {
      type: Object
    }
  },
  data() {
    return {
      generateSpec,
      loading: false
    }
  },
  created() {},
  methods: {
    ok() {
      let data = false
      const { uuid, name, expiredTime, skuId, categoryId, params, newDiskSize } = this.itemData
      const code = `${this.itemData.params.type.toLowerCase()}.standard.volume`
      data = {
        service: code,
        instance: uuid,
        instanceName: name,
        operation: 'EditDisk',
        newDiskSize,
        params: {
          ...params
        },
        upgrade: [
          {
            skuId,
            serviceCode: code,
            categoryId,
            specs: [
              {
                disk: newDiskSize
              }
            ],
            uuid
          }
        ],
        expiredTime
      }
      return data
    },
    getApplyData() {
      const { uuid, categoryId, newDiskSize } = this.itemData
      const code = `${this.itemData.params.type.toLowerCase()}.standard.volume`
      const obj = {
        ...this.itemData,
        newDiskSize: newDiskSize,
        upgrade: []
      }
      obj.upgrade = [
        {
          serviceCode: code,
          categoryId,
          specs: [
            {
              disk: newDiskSize
            }
          ],
          uuid
        }
      ]
      return obj
    }
  }
}
</script>

<style lang="scss" scoped>
.w {
  width: 100px !important;
}
.add-border {
  padding: 2px;
  cursor: pointer;
  border: 1px dashed black;
  text-align: center;
}
</style>
