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.9 kB

3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="base-dlg">
  3. <BaseDialog :visible.sync="dialogShow" :width="`750px`"
  4. :title="type === 'add' ? $t('resourcesManagement.addResQueue') : $t('resourcesManagement.editResQueue')"
  5. @open="open" @opened="opened" @close="close" @closed="closed">
  6. <div class="dlg-content">
  7. <div class="form">
  8. <div class="form-row">
  9. <div class="title required">
  10. <span>{{ $t('resourcesManagement.resQueueName') }}</span>
  11. </div>
  12. <div class="content">
  13. <el-input v-model="dataInfo.QueueCode" placeholder="" :disabled="type === 'edit'" maxlength="255">
  14. </el-input>
  15. </div>
  16. </div>
  17. <div class="form-row">
  18. <div class="title required">
  19. <span>{{ $t('resourcesManagement.whichCluster') }}</span>
  20. </div>
  21. <div class="content">
  22. <el-select v-model="dataInfo.Cluster" :disabled="type === 'edit'">
  23. <el-option v-for="item in clusterList" :key="item.k" :label="item.v" :value="item.k" />
  24. </el-select>
  25. </div>
  26. </div>
  27. <div class="form-row">
  28. <div class="title required">
  29. <span>{{ $t('resourcesManagement.aiCenter') }}</span>
  30. </div>
  31. <div class="content">
  32. <el-select v-model="dataInfo.AiCenterCode" :disabled="type === 'edit'">
  33. <el-option v-for="item in computingCenterList" :key="item.k" :label="item.v" :value="item.k" />
  34. </el-select>
  35. </div>
  36. </div>
  37. <div class="form-row">
  38. <div class="title required">
  39. <span>{{ $t('resourcesManagement.computeResource') }}</span>
  40. </div>
  41. <div class="content">
  42. <el-select v-model="dataInfo.ComputeResource" :disabled="type === 'edit'">
  43. <el-option v-for="item in computingTypeList" :key="item.k" :label="item.v" :value="item.k" />
  44. </el-select>
  45. </div>
  46. </div>
  47. <div class="form-row">
  48. <div class="title required">
  49. <span>{{ $t('resourcesManagement.accCardType') }}</span>
  50. </div>
  51. <div class="content">
  52. <el-select v-model="dataInfo.AccCardType" :disabled="type === 'edit'">
  53. <el-option v-for="item in cardTypeList" :key="item.k" :label="item.v" :value="item.k" />
  54. </el-select>
  55. </div>
  56. </div>
  57. <div class="form-row">
  58. <div class="title required">
  59. <span>{{ $t('resourcesManagement.cardsTotalNum') }}</span>
  60. </div>
  61. <div class="content">
  62. <el-input v-model="dataInfo.CardsTotalNum" type="number" placeholder=""></el-input>
  63. </div>
  64. </div>
  65. <div class="form-row" style="margin-top: 10px">
  66. <div class="title"><span>{{ $t('resourcesManagement.remark') }}</span></div>
  67. <div class="content" style="width: 400px">
  68. <el-input type="textarea" :autosize="{ minRows: 3, maxRows: 4 }" maxlength="255"
  69. :placeholder="$t('resourcesManagement.pleaseEnterRemark')" v-model="dataInfo.Remark">
  70. </el-input>
  71. </div>
  72. </div>
  73. <div class="form-row" style="margin-top: 20px">
  74. <div class="title"></div>
  75. <div class="content">
  76. <el-button type="primary" class="btn confirm-btn" @click="confirm">{{ $t('confirm') }}</el-button>
  77. <el-button class="btn" @click="cancel">{{ $t('cancel') }}</el-button>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </BaseDialog>
  83. </div>
  84. </template>
  85. <script>
  86. import BaseDialog from '~/components/BaseDialog.vue';
  87. import { addResQueue, updateResQueue } from '~/apis/modules/resources';
  88. import { CLUSTERS, AI_CENTER, COMPUTER_RESOURCES, ACC_CARD_TYPE } from '~/const';
  89. export default {
  90. name: "QueueDialog",
  91. props: {
  92. visible: { type: Boolean, default: false },
  93. title: { type: String, default: '' },
  94. type: { type: String, defalut: 'add' },
  95. data: { type: Object, default: () => ({}) },
  96. },
  97. components: {
  98. BaseDialog
  99. },
  100. data() {
  101. return {
  102. dialogShow: false,
  103. clusterList: [CLUSTERS[0]],
  104. computingCenterList: [AI_CENTER[0], AI_CENTER[1], AI_CENTER[2]],
  105. computingTypeList: [...COMPUTER_RESOURCES],
  106. cardTypeList: [...ACC_CARD_TYPE],
  107. dataInfo: {},
  108. };
  109. },
  110. watch: {
  111. visible: function (val) {
  112. this.dialogShow = val;
  113. },
  114. },
  115. methods: {
  116. resetDataInfo() {
  117. this.dataInfo = {
  118. ID: '',
  119. QueueCode: '',
  120. Cluster: '',
  121. AiCenterCode: '',
  122. ComputeResource: '',
  123. AccCardType: '',
  124. CardsTotalNum: '',
  125. Remark: '',
  126. }
  127. },
  128. open() {
  129. this.resetDataInfo();
  130. if (this.type === 'add') {
  131. //
  132. } else if (this.type === 'edit') {
  133. this.dataInfo = Object.assign(this.dataInfo, { ...this.data });
  134. }
  135. this.$emit("open");
  136. },
  137. opened() {
  138. this.$emit("opened");
  139. },
  140. close() {
  141. this.$emit("close");
  142. },
  143. closed() {
  144. this.$emit("closed");
  145. this.$emit("update:visible", false);
  146. },
  147. confirm() {
  148. if (!this.dataInfo.QueueCode || !this.dataInfo.Cluster || !this.dataInfo.AiCenterCode || !this.dataInfo.ComputeResource || !this.dataInfo.AccCardType || !this.dataInfo.CardsTotalNum) {
  149. this.$message({
  150. type: 'info',
  151. message: this.$t('pleaseCompleteTheInformationFirst'),
  152. });
  153. return;
  154. }
  155. if (parseInt(this.dataInfo.CardsTotalNum) != Number(this.dataInfo.CardsTotalNum)) {
  156. this.$message({
  157. type: 'info',
  158. message: this.$t('pleaseEnterPositiveIntegerCardsTotalNum')
  159. });
  160. return;
  161. }
  162. const setApi = this.type === 'add' ? addResQueue : updateResQueue;
  163. setApi({ ...this.dataInfo, CardsTotalNum: Number(this.dataInfo.CardsTotalNum) }).then(res => {
  164. res = res.data;
  165. if (res.Code === 0) {
  166. this.$message({
  167. type: 'success',
  168. message: this.$t('submittedSuccessfully')
  169. });
  170. this.$emit("confirm");
  171. } else {
  172. this.$message({
  173. type: 'error',
  174. message: this.$t('submittedFailed')
  175. });
  176. }
  177. }).catch(err => {
  178. console.log(err);
  179. this.$message({
  180. type: 'error',
  181. message: this.$t('submittedFailed')
  182. });
  183. })
  184. },
  185. cancel() {
  186. this.dialogShow = false;
  187. this.$emit("update:visible", false);
  188. }
  189. },
  190. mounted() {
  191. this.resetDataInfo();
  192. },
  193. };
  194. </script>
  195. <style scoped lang="less">
  196. .dlg-content {
  197. margin: 20px 0 25px 0;
  198. display: flex;
  199. justify-content: center;
  200. .form {
  201. width: 600px;
  202. .form-row {
  203. display: flex;
  204. min-height: 42px;
  205. margin-bottom: 4px;
  206. .title {
  207. width: 160px;
  208. display: flex;
  209. justify-content: flex-end;
  210. align-items: center;
  211. margin-right: 20px;
  212. color: rgb(136, 136, 136);
  213. font-size: 14px;
  214. &.required {
  215. span {
  216. position: relative;
  217. }
  218. span::after {
  219. position: absolute;
  220. right: -10px;
  221. top: -2px;
  222. vertical-align: top;
  223. content: '*';
  224. color: #db2828;
  225. }
  226. }
  227. }
  228. .content {
  229. width: 300px;
  230. display: flex;
  231. align-items: center;
  232. /deep/ .el-select {
  233. width: 100%;
  234. }
  235. }
  236. }
  237. }
  238. .btn {
  239. color: rgb(2, 0, 4);
  240. background-color: rgb(194, 199, 204);
  241. border-color: rgb(194, 199, 204);
  242. &.confirm-btn {
  243. color: #fff;
  244. background-color: rgb(56, 158, 13);
  245. border-color: rgb(56, 158, 13);
  246. }
  247. }
  248. }
  249. </style>