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.

modelmanage-local-create-1.vue 12 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <div>
  3. <div class="header">
  4. <span class="title">{{ type == '1' ? '修改模型信息' : '导入本地模型' }}</span>
  5. </div>
  6. <div class="content">
  7. <div class="guide-c" v-if="type != '1'">
  8. <div class="step focused">
  9. <div class="num">1</div>
  10. <div class="txt">创建模型</div>
  11. </div>
  12. <div class="line"></div>
  13. <div class="step">
  14. <div class="num">2</div>
  15. <div class="txt">上传模型文件</div>
  16. </div>
  17. </div>
  18. <div class="row-c" v-loading="loading">
  19. <div class="row">
  20. <div class="r-title"><label class="required">可用集群</label></div>
  21. <div class="r-content" style="display:flex;">
  22. <div class="cluster-type-btn" v-if="type != 1 || type == 1 && state.type === 0"
  23. :class="state.type === 0 ? 'focused' : ''"
  24. :style="type != 1 ? 'border-top-right-radius:unset;border-bottom-right-radius:unset;' : ''"
  25. @click="state.type = 0">
  26. <svg xmlns="http://www.w3.org/2000/svg"
  27. class="icon styles__StyledSVGIconPathComponent-sc-16fsqc8-0 cSaWDI svg-icon-path-icon fill"
  28. viewBox="0 0 32 32" width="16" height="16">
  29. <defs data-reactroot=""></defs>
  30. <g>
  31. <path
  32. d="M4 3.989c0-0.731 0.593-1.323 1.324-1.323h21.352c0.729 0.005 1.318 0.594 1.324 1.322v24.022c-0.001 0.731-0.593 1.323-1.324 1.323h-21.352c-0.729-0.005-1.318-0.594-1.324-1.322v-24.022zM25.333 14.667v-9.333h-18.667v9.333h18.667zM25.333 17.333h-18.667v9.333h18.667v-9.333zM12 8h8v2.667h-8v-2.667zM12 20h8v2.667h-8v-2.667z">
  33. </path>
  34. </g>
  35. </svg>
  36. <span class="txt">CPU / GPU</span>
  37. </div>
  38. <div class="cluster-type-btn" v-if="type != 1 || type == 1 && state.type === 1"
  39. :class="state.type === 1 ? 'focused' : ''"
  40. :style="type != 1 ? 'border-top-left-radius:unset;border-bottom-left-radius:unset;' : ''"
  41. @click="state.type = 1">
  42. <svg xmlns="http://www.w3.org/2000/svg"
  43. class="icon styles__StyledSVGIconPathComponent-sc-16fsqc8-0 iKfgJk svg-icon-path-icon fill"
  44. viewBox="0 0 32 32" width="16" height="16">
  45. <defs data-reactroot=""></defs>
  46. <g>
  47. <path
  48. d="M4 3.989c0-0.731 0.593-1.323 1.324-1.323h21.352c0.729 0.005 1.318 0.594 1.324 1.322v24.022c-0.001 0.731-0.593 1.323-1.324 1.323h-21.352c-0.729-0.005-1.318-0.594-1.324-1.322v-24.022zM25.333 14.667v-9.333h-18.667v9.333h18.667zM25.333 17.333h-18.667v9.333h18.667v-9.333zM12 8h8v2.667h-8v-2.667zM12 20h8v2.667h-8v-2.667z">
  49. </path>
  50. </g>
  51. </svg>
  52. <span class="txt">Ascend NPU</span>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="row">
  57. <div class="r-title"><label class="required">模型名称</label></div>
  58. <div class="r-content">
  59. <el-input size="medium" :maxLength="25" v-model="state.name" placeholder="请输入模型名称"></el-input>
  60. </div>
  61. </div>
  62. <div class="row">
  63. <div class="r-title"><label class="required">版本</label></div>
  64. <div class="r-content">
  65. <el-input class="input-disabled" style="width:288px;" size="medium" v-model="state.version" readonly>
  66. </el-input>
  67. </div>
  68. </div>
  69. <div class="row">
  70. <div class="r-title"><label class="required">模型框架</label></div>
  71. <div class="r-content">
  72. <el-select style="width:288px;" size="medium" v-model="state.engine" placeholder="请选择">
  73. <el-option v-for="item in engineList" :key="item.k" :label="item.v" :value="item.k">
  74. </el-option>
  75. </el-select>
  76. </div>
  77. </div>
  78. <div class="row">
  79. <div class="r-title"><label>模型标签</label></div>
  80. <div class="r-content">
  81. <el-input size="medium" :maxLength="255" v-model="state.label" placeholder="输入标签,多个标签用空格区分"></el-input>
  82. </div>
  83. </div>
  84. <div class="row" style="align-items:flex-start;">
  85. <div class="r-title"><label>模型描述</label></div>
  86. <div class="r-content">
  87. <el-input type="textarea" :maxLength="255" size="medium" v-model="state.description" :rows="3"
  88. placeholder="描述字数不超过255个字符">
  89. </el-input>
  90. </div>
  91. </div>
  92. <div class="row" style="margin-top:20px">
  93. <div class="r-title"><label></label></div>
  94. <div class="r-content">
  95. <el-button size="medium" class="green" @click="submit">保存模型</el-button>
  96. <el-button size="medium" @click="cancel">取消</el-button>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import { saveLocalModel, getModelInfoByName, modifyModel } from '~/apis/modules/modelmanage';
  105. import { getUrlSearchParams } from '~/utils';
  106. import { MODEL_ENGINES } from '~/const'
  107. const REPO_NAME = location.pathname.split('/')[2];
  108. export default {
  109. data() {
  110. return {
  111. type: '0', // 1-修改,其它-新增
  112. loading: false,
  113. state: {
  114. type: 0,
  115. name: REPO_NAME + '_model_' + Math.random().toString(36).substr(2, 4),
  116. version: '0.0.1',
  117. engine: '0',
  118. label: '',
  119. description: '',
  120. },
  121. engineList: MODEL_ENGINES,
  122. };
  123. },
  124. components: {},
  125. methods: {
  126. submit() {
  127. if (!this.state.name) {
  128. this.$message({
  129. type: 'info',
  130. message: '请输入模型名称',
  131. });
  132. return;
  133. }
  134. const submintApi = this.type == '1' ? modifyModel : saveLocalModel;
  135. submintApi({
  136. repo: location.pathname.split('/').slice(0, 3).join('/'),
  137. ...this.state,
  138. }).then(res => {
  139. res = res.data;
  140. if (res && res.code == '0') {
  141. if (this.type == '1') {
  142. this.cancel();
  143. return;
  144. }
  145. const list = window.location.href.split('/');
  146. list.pop();
  147. list.push('create_local_model_tmpl2');
  148. window.location.href = list.join('/') + '?type=0&name=' + this.state.name + '&id=' + res.id;
  149. } else {
  150. this.$message({
  151. type: 'error',
  152. message: this.type == '1' ? '模型修改失败' : '保存模型失败',
  153. });
  154. }
  155. }).catch(err => {
  156. console.log(err);
  157. });
  158. },
  159. cancel() {
  160. const list = window.location.href.split('/');
  161. list.pop();
  162. list.push('show_model');
  163. window.location.href = list.join('/');
  164. },
  165. },
  166. mounted() {
  167. const urlParams = getUrlSearchParams();
  168. if (urlParams.type == '1' && urlParams.name && urlParams.id) { // update
  169. this.type = urlParams.type;
  170. this.state.name = urlParams.name;
  171. this.state.id = urlParams.id;
  172. this.loading = true;
  173. getModelInfoByName({
  174. repo: location.pathname.split('/').slice(0, 3).join('/'),
  175. name: urlParams.name,
  176. id: urlParams.id
  177. }).then(res => {
  178. this.loading = false;
  179. const list = res.data;
  180. if (list && list.length) {
  181. const data = list[0];
  182. this.state.type = data.type;
  183. this.state.id = data.id;
  184. this.state.name = data.name;
  185. this.state.version = data.version;
  186. this.state.engine = data.engine.toString();
  187. this.state.label = data.label;
  188. this.state.description = data.description;
  189. }
  190. }).catch(err => {
  191. this.loading = false;
  192. console.log(err);
  193. this.cancel();
  194. });
  195. }
  196. },
  197. beforeDestroy() {
  198. },
  199. };
  200. </script>
  201. <style scoped lang="less">
  202. .header {
  203. height: 45px;
  204. border-color: rgb(212, 212, 213);
  205. border-width: 1px;
  206. border-style: solid;
  207. border-radius: 5px 5px 0px 0px;
  208. font-size: 14px;
  209. background: rgb(240, 240, 240);
  210. display: flex;
  211. align-items: center;
  212. .title {
  213. font-weight: 600;
  214. font-size: 16px;
  215. color: rgb(16, 16, 16);
  216. margin-left: 10px;
  217. }
  218. }
  219. .content {
  220. margin-top: -1px;
  221. border-color: rgb(212, 212, 213);
  222. border-width: 1px;
  223. border-style: solid;
  224. padding: 30px 0;
  225. border-top: none;
  226. .guide-c {
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. margin-bottom: 20px;
  231. .step {
  232. display: flex;
  233. align-items: center;
  234. color: rgb(136, 136, 136);
  235. .num {
  236. border: 1px solid rgb(136, 136, 136);
  237. width: 34px;
  238. height: 34px;
  239. font-size: 24px;
  240. text-align: center;
  241. line-height: 34px;
  242. border-radius: 17px;
  243. margin-right: 8px;
  244. }
  245. .txt {
  246. font-weight: 600;
  247. }
  248. &.focused {
  249. color: rgb(22, 132, 252);
  250. .num {
  251. border-color: rgb(22, 132, 252);
  252. }
  253. }
  254. }
  255. .line {
  256. height: 2px;
  257. width: 50px;
  258. background-color: rgb(187, 187, 187);
  259. margin: 0 10px;
  260. }
  261. }
  262. .row-c {
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. flex-direction: column;
  267. margin: 0 auto;
  268. width: 80%;
  269. .row {
  270. width: 100%;
  271. display: flex;
  272. align-items: center;
  273. margin: 8px 0;
  274. margin-left: -190px;
  275. .r-title {
  276. text-align: right;
  277. font-size: .92857143em;
  278. font-weight: 700;
  279. color: rgba(0, 0, 0, .87);
  280. width: 200px;
  281. margin-right: 28px;
  282. position: relative;
  283. .required {
  284. &::after {
  285. position: absolute;
  286. margin: -0.2em 0 0 0.2em;
  287. content: '*';
  288. color: #db2828;
  289. }
  290. }
  291. }
  292. .r-content {
  293. flex: 1;
  294. .cluster-type-btn {
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. border: 1px solid #DCDFE6;
  299. height: 36px;
  300. padding: 10px;
  301. cursor: pointer;
  302. border-radius: 4px;
  303. .icon {
  304. margin-right: 5px;
  305. }
  306. &.focused {
  307. border-color: rgb(50, 145, 248);
  308. color: rgb(50, 145, 248);
  309. cursor: default;
  310. .icon {
  311. :not([stroke]) {
  312. fill: rgb(50, 145, 248);
  313. }
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. .input-disabled {
  322. /deep/ .el-input__inner {
  323. background-color: #f5f5f6 !important;
  324. color: #888888 !important;
  325. }
  326. }
  327. .el-select-dropdown__item.selected {
  328. color: rgba(0, 0, 0, .95);
  329. }
  330. /deep/ .el-button {
  331. background-color: #e0e1e2;
  332. color: rgba(0, 0, 0, .6);
  333. border-color: transparent;
  334. transition: opacity .1s ease, background-color .1s ease, color .1s ease, box-shadow .1s ease, background .1s ease, -webkit-box-shadow .1s ease;
  335. will-change: auto;
  336. -webkit-tap-highlight-color: transparent;
  337. &:hover {
  338. border-color: transparent;
  339. background-color: #cacbcd;
  340. color: rgba(0, 0, 0, .8);
  341. }
  342. &:focus {
  343. background-color: #cacbcd;
  344. color: rgba(0, 0, 0, .8);
  345. border-color: transparent;
  346. }
  347. &:active {
  348. background-color: #babbbc;
  349. color: rgba(0, 0, 0, .9);
  350. border-color: transparent;
  351. }
  352. &.green {
  353. background-color: #5bb973;
  354. color: #fff;
  355. &:hover {
  356. background-color: #16ab39;
  357. border-color: transparent;
  358. }
  359. &:focus {
  360. background-color: #0ea432;
  361. border-color: transparent;
  362. }
  363. &:active {
  364. background-color: #198f35;
  365. border-color: transparent;
  366. }
  367. }
  368. }
  369. /deep/ .el-select {
  370. .is-focus {
  371. .el-input__inner {
  372. border-color: #85b7d9;
  373. }
  374. }
  375. }
  376. /deep/ .el-input__inner {
  377. &:focus {
  378. border-color: #85b7d9;
  379. }
  380. }
  381. /deep/ .el-textarea__inner {
  382. &:focus {
  383. border-color: #85b7d9;
  384. }
  385. }
  386. </style>