BottomBar.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div class="create-server-result-wrap">
  3. <page-footer>
  4. <template class="content" v-slot:left>
  5. <div
  6. v-for="(tip, idx) of tips"
  7. :key="idx"
  8. class="d-flex flex-column justify-content-center flex-grow-1">
  9. <div
  10. v-for="obj of tip"
  11. :key="obj.label"
  12. class="d-flex align-items-center">
  13. <span class="label" :class="obj.labelClass">{{ obj.label }}:</span>
  14. <template v-if="obj.value">
  15. <span class="value text-truncate" :class="obj.valueClass">{{ obj.value }}</span>
  16. </template>
  17. <template v-else>
  18. <span class="value placeholder text-truncate" :class="obj.valueClass">------</span>
  19. </template>
  20. </div>
  21. </div>
  22. </template>
  23. <template v-slot:right>
  24. <div class="d-flex align-items-center">
  25. <a-button
  26. type="primary"
  27. native-type="submit"
  28. html-type="submit"
  29. :loading="loading"
  30. :disabled="!!errors.length">{{ isOpenWorkflow && !isInstallOperationSystem ? (isInitForm ? $t('common.modify_workflow') : $t('compute.text_288')) : $t('compute.text_289') }}</a-button>
  31. <a-button class="ml-3" @click="handleCancel">{{$t('common.cancel')}}</a-button>
  32. </div>
  33. <side-errors :error-title="$t('compute.text_290')" :errors="errors" @update:errors="changeErrors" />
  34. </template>
  35. </page-footer>
  36. </div>
  37. </template>
  38. <script>
  39. import * as R from 'ramda'
  40. import { RESOURCE_TYPES_MAP, SERVER_TYPE, BILL_TYPES_MAP } from '@Compute/constants'
  41. import { sizestrWithUnit } from '@/utils/utils'
  42. // import { HYPERVISORS_MAP, PROVIDER_MAP } from '@/constants'
  43. import SideErrors from '@/sections/SideErrors'
  44. import { currencyUnitMap } from '@/constants/currency'
  45. export default {
  46. name: 'BottomBar',
  47. components: {
  48. SideErrors,
  49. },
  50. props: {
  51. loading: {
  52. type: Boolean,
  53. default: false,
  54. },
  55. form: {
  56. type: Object,
  57. required: true,
  58. },
  59. selectedSpecItem: {
  60. type: Object,
  61. required: true,
  62. },
  63. errors: {
  64. type: Object,
  65. required: true,
  66. },
  67. type: {
  68. type: String,
  69. required: true,
  70. },
  71. resourceType: { // 资源池类型
  72. type: String,
  73. },
  74. dataDiskSizes: { // 数据盘磁盘大小之和
  75. type: Array,
  76. default: () => [],
  77. },
  78. isOpenWorkflow: {
  79. type: Boolean,
  80. default: false,
  81. },
  82. isServertemplate: {
  83. type: Boolean,
  84. default: false,
  85. },
  86. hasMeterService: {
  87. type: Boolean,
  88. default: true,
  89. },
  90. isInitForm: {
  91. type: Boolean,
  92. default: false,
  93. },
  94. },
  95. data () {
  96. return {
  97. pricesList: [],
  98. fd: this.form.fc.getFieldsValue(),
  99. }
  100. },
  101. computed: {
  102. fi () {
  103. return this.form.fi
  104. },
  105. isPublic () {
  106. return this.type === SERVER_TYPE.public
  107. },
  108. // 是否为预付费资源池
  109. isPrepaid () {
  110. return this.resourceType === RESOURCE_TYPES_MAP.prepaid.key
  111. },
  112. // 是否为包年包月
  113. isPackage () {
  114. return this.fd.billType === BILL_TYPES_MAP.package.key
  115. },
  116. name () {
  117. return this.fd.name
  118. },
  119. zone () {
  120. let ret = this.fd.zone ? this.fd.zone.label : ''
  121. if (this.isPublic && !this.isPrepaid) {
  122. ret = this.fd.sku ? this.fd.sku.zone : ''
  123. }
  124. return ret
  125. },
  126. vmType () {
  127. let ret = this.$t('compute.text_291', [this.$t('dictionary.server')])
  128. if (this.fd.gpuEnable) {
  129. ret = `GPU${this.$t('dictionary.server')}`
  130. }
  131. return ret
  132. },
  133. disk () {
  134. const diskValueArr = [this.fd.systemDiskSize]
  135. R.forEachObjIndexed(value => {
  136. diskValueArr.push(value)
  137. }, this.fd.dataDiskSizes)
  138. return diskValueArr.reduce((prevDisk, diskValue) => prevDisk + diskValue, 0)
  139. },
  140. config () {
  141. const ret = []
  142. const { cpu = 0, mem = '0M' } = this.selectedSpecItem
  143. ret.push(this.$t('compute.text_292', [cpu]))
  144. ret.push(this.$t('compute.text_293', [sizestrWithUnit(mem.substr(0, mem.length - 1), 'M', 1024)]))
  145. return ret.join('、')
  146. },
  147. image () {
  148. return this.fd.image.label
  149. },
  150. tips () {
  151. const ret = [
  152. [
  153. { label: this.$t('compute.text_228'), labelClass: 'label-w-50', value: this.name, valueClass: 'name-value' },
  154. { label: this.$t('compute.text_294'), labelClass: 'label-w-50', value: this.fd.count },
  155. ],
  156. [
  157. { label: this.$t('compute.text_177'), labelClass: 'label-w-50', value: this.zone },
  158. { label: this.$t('compute.text_175'), labelClass: 'label-w-50', value: this.vmType },
  159. ],
  160. [
  161. { label: this.$t('compute.text_295'), labelClass: 'label-w-80', value: this.config },
  162. { label: this.$t('compute.text_267'), labelClass: 'label-w-80', value: this.image },
  163. ],
  164. ]
  165. return ret
  166. },
  167. isInstallOperationSystem () { // 是否是安装操作系统
  168. if (this.$route.query.host_id) {
  169. return true
  170. }
  171. return false
  172. },
  173. },
  174. created () {
  175. this.$bus.$on('updateForm', (values) => {
  176. this.fd = {
  177. ...this.fd,
  178. ...values,
  179. }
  180. }, this)
  181. },
  182. methods: {
  183. changeErrors (errors) {
  184. this.$emit('update:errors', [])
  185. },
  186. formatToPrice (val) {
  187. let ret = `${currencyUnitMap.CNY.sign} ${val.toFixed(2)}`
  188. if (this.isPackage) {
  189. return ret
  190. }
  191. ret += this.$t('compute.text_296')
  192. return ret
  193. },
  194. handleCancel () {
  195. this.$emit('cancel')
  196. },
  197. },
  198. }
  199. </script>
  200. <style lang="less" scoped>
  201. @import '../../../../../src/styles/less/theme';
  202. .create-server-result-wrap {
  203. position: relative;
  204. font-size: 12px;
  205. .content {
  206. width: 80%;
  207. .label {
  208. color: #999;
  209. &.label-w-50 {
  210. width: 50px;
  211. }
  212. &.label-w-80 {
  213. width: 80px;
  214. }
  215. }
  216. .value {
  217. max-width: 300px;
  218. &.name-value {
  219. width: 100px;
  220. }
  221. &.placeholder {
  222. color: #888;
  223. font-style: italic;
  224. }
  225. }
  226. }
  227. .prices {
  228. .hour {
  229. color: @error-color;
  230. font-size: 24px;
  231. }
  232. .tips {
  233. color: #999;
  234. font-size: 12px;
  235. }
  236. }
  237. .btns-wrapper {
  238. position: absolute;
  239. right: 20px;
  240. }
  241. }
  242. </style>