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 7.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.QueueCode" placeholder="" :disabled="type === 'edit'"></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" :disabled="type === 'edit'">
  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.AiCenterCode" :disabled="type === 'edit'">
  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.ComputeResource" :disabled="type === 'edit'">
  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.AccCardType" :disabled="type === 'edit'">
  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.CardsTotalNum" 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 { addResQueue, updateResQueue } 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. QueueCode: '',
  118. Cluster: '',
  119. AiCenterCode: '',
  120. ComputeResource: '',
  121. AccCardType: '',
  122. CardsTotalNum: '',
  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. this.$emit("open");
  134. },
  135. opened() {
  136. this.$emit("opened");
  137. },
  138. close() {
  139. this.$emit("close");
  140. },
  141. closed() {
  142. this.$emit("closed");
  143. this.$emit("update:visible", false);
  144. },
  145. confirm() {
  146. if (!this.dataInfo.QueueCode || !this.dataInfo.Cluster || !this.dataInfo.AiCenterCode || !this.dataInfo.ComputeResource || !this.dataInfo.AccCardType || !this.dataInfo.CardsTotalNum) {
  147. this.$message({
  148. type: 'info',
  149. message: '请先完善信息!'
  150. });
  151. return;
  152. }
  153. if (parseInt(this.dataInfo.CardsTotalNum) != Number(this.dataInfo.CardsTotalNum)) {
  154. this.$message({
  155. type: 'info',
  156. message: '请输入正整数的卡数!'
  157. });
  158. return;
  159. }
  160. const setApi = this.type === 'add' ? addResQueue : updateResQueue;
  161. setApi({ ...this.dataInfo, CardsTotalNum: Number(this.dataInfo.CardsTotalNum) }).then(res => {
  162. res = res.data;
  163. if (res.Code === 0) {
  164. this.$message({
  165. type: 'success',
  166. message: '提交成功!'
  167. });
  168. this.$emit("confirm");
  169. } else {
  170. this.$message({
  171. type: 'error',
  172. message: '提交失败!'
  173. });
  174. }
  175. }).catch(err => {
  176. console.log(err);
  177. this.$message({
  178. type: 'error',
  179. message: '提交失败!'
  180. });
  181. })
  182. },
  183. cancel() {
  184. this.dialogShow = false;
  185. this.$emit("update:visible", false);
  186. }
  187. },
  188. mounted() {
  189. this.resetDataInfo();
  190. },
  191. };
  192. </script>
  193. <style scoped lang="less">
  194. .dlg-content {
  195. margin: 20px 0 25px 0;
  196. display: flex;
  197. justify-content: center;
  198. .form {
  199. width: 600px;
  200. .form-row {
  201. display: flex;
  202. min-height: 42px;
  203. margin-bottom: 4px;
  204. .title {
  205. width: 160px;
  206. display: flex;
  207. justify-content: flex-end;
  208. align-items: center;
  209. margin-right: 20px;
  210. color: rgb(136, 136, 136);
  211. font-size: 14px;
  212. &.required {
  213. span {
  214. position: relative;
  215. }
  216. span::after {
  217. position: absolute;
  218. right: -10px;
  219. top: -2px;
  220. vertical-align: top;
  221. content: '*';
  222. color: #db2828;
  223. }
  224. }
  225. }
  226. .content {
  227. width: 300px;
  228. display: flex;
  229. align-items: center;
  230. /deep/ .el-select {
  231. width: 100%;
  232. }
  233. }
  234. }
  235. }
  236. .btn {
  237. color: rgb(2, 0, 4);
  238. background-color: rgb(194, 199, 204);
  239. border-color: rgb(194, 199, 204);
  240. &.confirm-btn {
  241. color: #fff;
  242. background-color: rgb(56, 158, 13);
  243. border-color: rgb(56, 158, 13);
  244. }
  245. }
  246. }
  247. </style>