You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

QueueDialog.vue 6.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="base-dlg">
  3. <BaseDialog :visible.sync="dialogShow" :width="`750px`" :title="type === 'add' ? `新建资源池(队列)` : '修改资源池(队列)'"
  4. @open="open" @opened="opened" @close="close" @closed="closed">
  5. <div class="dlg-content">
  6. <div class="form">
  7. <div class="form-row">
  8. <div class="title required">
  9. <span>资源池(队列)名称</span>
  10. </div>
  11. <div class="content">
  12. <el-input v-model="dataInfo.name" placeholder=""></el-input>
  13. </div>
  14. </div>
  15. <div class="form-row">
  16. <div class="title required">
  17. <span>所属集群</span>
  18. </div>
  19. <div class="content">
  20. <el-select v-model="dataInfo.cluster">
  21. <el-option v-for="item in clusterList" :key="item.k" :label="item.v" :value="item.k" />
  22. </el-select>
  23. </div>
  24. </div>
  25. <div class="form-row">
  26. <div class="title required">
  27. <span>智算中心</span>
  28. </div>
  29. <div class="content">
  30. <el-select v-model="dataInfo.computingCenter">
  31. <el-option v-for="item in computingCenterList" :key="item.k" :label="item.v" :value="item.k" />
  32. </el-select>
  33. </div>
  34. </div>
  35. <div class="form-row">
  36. <div class="title required">
  37. <span>计算资源</span>
  38. </div>
  39. <div class="content">
  40. <el-select v-model="dataInfo.computingType">
  41. <el-option v-for="item in computingTypeList" :key="item.k" :label="item.v" :value="item.k" />
  42. </el-select>
  43. </div>
  44. </div>
  45. <div class="form-row">
  46. <div class="title required">
  47. <span>卡类型</span>
  48. </div>
  49. <div class="content">
  50. <el-select v-model="dataInfo.cardType">
  51. <el-option v-for="item in cardTypeList" :key="item.k" :label="item.v" :value="item.k" />
  52. </el-select>
  53. </div>
  54. </div>
  55. <div class="form-row">
  56. <div class="title required">
  57. <span>卡数</span>
  58. </div>
  59. <div class="content">
  60. <el-input v-model="dataInfo.cardNum" type="number" placeholder=""></el-input>
  61. </div>
  62. </div>
  63. <div class="form-row" style="margin-top: 10px">
  64. <div class="title"><span>备注</span></div>
  65. <div class="content" style="width: 400px">
  66. <el-input type="textarea" :autosize="{ minRows: 3, maxRows: 4 }" :placeholder="'请输入备注'"
  67. v-model="dataInfo.remark">
  68. </el-input>
  69. </div>
  70. </div>
  71. <div class="form-row" style="margin-top: 20px">
  72. <div class="title"></div>
  73. <div class="content">
  74. <el-button type="primary" class="btn confirm-btn" @click="confirm">确定</el-button>
  75. <el-button class="btn" @click="cancel">取消</el-button>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </BaseDialog>
  81. </div>
  82. </template>
  83. <script>
  84. import BaseDialog from '~/components/BaseDialog.vue';
  85. import { getQueueList } from '~/apis/modules/resources';
  86. import { CLUSTERS, AI_CENTER, COMPUTER_RESOURCES, ACC_CARD_TYPE } from '~/const';
  87. export default {
  88. name: "QueueDialog",
  89. props: {
  90. visible: { type: Boolean, default: false },
  91. title: { type: String, default: '' },
  92. type: { type: String, defalut: 'add' },
  93. data: { type: Object, default: () => ({}) },
  94. },
  95. components: {
  96. BaseDialog
  97. },
  98. data() {
  99. return {
  100. dialogShow: false,
  101. clusterList: [...CLUSTERS],
  102. computingCenterList: [...AI_CENTER],
  103. computingTypeList: [...COMPUTER_RESOURCES],
  104. cardTypeList: [...ACC_CARD_TYPE],
  105. dataInfo: {},
  106. };
  107. },
  108. watch: {
  109. visible: function (val) {
  110. this.dialogShow = val;
  111. },
  112. },
  113. methods: {
  114. resetDataInfo() {
  115. this.dataInfo = {
  116. id: '',
  117. name: '',
  118. cluster: '',
  119. computingCenter: '',
  120. computingType: '',
  121. cardType: '',
  122. cardNum: '',
  123. remark: '',
  124. }
  125. },
  126. open() {
  127. this.resetDataInfo();
  128. if (this.type === 'add') {
  129. //
  130. } else if (this.type === 'edit') {
  131. this.dataInfo = Object.assign(this.dataInfo, { ...this.data });
  132. }
  133. console.log('open', this.type, this.data);
  134. this.$emit("open");
  135. },
  136. opened() {
  137. this.$emit("opened");
  138. },
  139. close() {
  140. this.$emit("close");
  141. },
  142. closed() {
  143. this.$emit("closed");
  144. this.$emit("update:visible", false);
  145. },
  146. confirm() {
  147. console.log('confirm', this.dataInfo);
  148. },
  149. cancel() {
  150. this.dialogShow = false;
  151. this.$emit("update:visible", false);
  152. }
  153. },
  154. mounted() {
  155. this.resetDataInfo();
  156. },
  157. };
  158. </script>
  159. <style scoped lang="less">
  160. .dlg-content {
  161. margin: 20px 0 25px 0;
  162. display: flex;
  163. justify-content: center;
  164. .form {
  165. width: 600px;
  166. .form-row {
  167. display: flex;
  168. min-height: 42px;
  169. margin-bottom: 4px;
  170. .title {
  171. width: 160px;
  172. display: flex;
  173. justify-content: flex-end;
  174. align-items: center;
  175. margin-right: 20px;
  176. color: rgb(136, 136, 136);
  177. font-size: 14px;
  178. &.required {
  179. span {
  180. position: relative;
  181. }
  182. span::after {
  183. position: absolute;
  184. right: -10px;
  185. top: -2px;
  186. vertical-align: top;
  187. content: '*';
  188. color: #db2828;
  189. }
  190. }
  191. }
  192. .content {
  193. width: 300px;
  194. display: flex;
  195. align-items: center;
  196. /deep/ .el-select {
  197. width: 100%;
  198. }
  199. }
  200. }
  201. }
  202. .btn {
  203. color: rgb(2, 0, 4);
  204. background-color: rgb(194, 199, 204);
  205. border-color: rgb(194, 199, 204);
  206. &.confirm-btn {
  207. color: #fff;
  208. background-color: rgb(56, 158, 13);
  209. border-color: rgb(56, 158, 13);
  210. }
  211. }
  212. }
  213. </style>