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.

index.vue 16 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <div>
  3. <TopHeader :menu="-1"></TopHeader>
  4. <div class="ui container">
  5. <div class="title">您申请的项目将在2030科技项目页面展示</div>
  6. <div class="form-c" v-show="!selectTechPrj">
  7. <div class="form-wrap">
  8. <div class="form-header">申请展示项目</div>
  9. <div class="form-content">
  10. <div class="form-row">
  11. <div class="row-label required">申请项目存放于</div>
  12. <div class="row-content">
  13. <el-radio v-model="form.type" label="openi" @input="changeType()">启智社区</el-radio>
  14. <el-radio v-model="form.type" label="no-openi" @input="changeType()">非启智社区</el-radio>
  15. </div>
  16. </div>
  17. <div class="form-row">
  18. <div class="row-label required">现项目地址</div>
  19. <div class="row-content">
  20. <el-input size="medium" v-model="form.url" @input="changeUrl"
  21. placeholder='请输入现有项目的 HTTP(s) 或 Git " clone" URL,如:https://openi.pcl.ac.cn/OpenI/aiforge'></el-input>
  22. </div>
  23. </div>
  24. <div v-show="form.type == 'no-openi'">
  25. <div class="form-row" :class="form.alias_err ? 'form-row-err' : ''">
  26. <div class="row-label required baseline">启智项目名称</div>
  27. <div class="row-content">
  28. <div>
  29. <el-input size="medium" v-model="form.repo_alias" @input="changeAlias"></el-input>
  30. </div>
  31. <div class="tips">
  32. 请输入中文、字母、数字和-_ .,最多100个字符。
  33. </div>
  34. </div>
  35. </div>
  36. <div class="form-row" :class="form.name_err ? 'form-row-err' : ''">
  37. <div class="row-label required baseline">启智项目路径</div>
  38. <div class="row-content">
  39. <div class="reop-url-c">
  40. <el-select size="medium" v-model="form.uid"></el-select>
  41. <span style="margin: 0 8px;font-size:22px;"> / </span>
  42. <el-input size="medium" v-model="form.repo_name" @input="changeRepoName"></el-input>
  43. </div>
  44. <div class="tips">
  45. 启智项目地址:<span class="openi-repo-url">{{ form.repo_url }}</span>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="form-row">
  50. <div class="row-label">关键词</div>
  51. <div class="row-content">
  52. <el-select style="width:100%" size="medium" v-model="form.topics" multiple filterable remote
  53. allow-create default-first-option placeholder="请选择标签" :remote-method="searchTopics"
  54. :loading="form.topicLoading">
  55. <el-option v-for="item in topicsList" :key="item.value" :label="item.label" :value="item.value">
  56. </el-option>
  57. </el-select>
  58. </div>
  59. </div>
  60. <div class="form-row">
  61. <div class="row-label baseline">项目简介</div>
  62. <div class="row-content">
  63. <el-input size="medium" type="textarea" :rows="3" placeholder="请输入项目简介(长度不超过255)" :maxLength="255"
  64. v-model="form.description"></el-input>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="form-row">
  69. <div class="row-label required">科技项目</div>
  70. <div class="row-content">
  71. <el-input placeholder="请选择科技项目" size="medium" v-model="form.tech_show" :readonly="true">
  72. <el-button size="medium" slot="append" @click="goSelectTechPrj">选择科技项目</el-button>
  73. </el-input>
  74. </div>
  75. </div>
  76. <div class="form-row">
  77. <div class="row-label required">成果贡献单位</div>
  78. <div class="row-content">
  79. <el-select style="width:100%" size="medium" v-model="form.institution" multiple>
  80. <el-option v-for="item in institutionList" :key="item.key" :label="item.value"
  81. :value="item.value"></el-option>
  82. </el-select>
  83. </div>
  84. </div>
  85. <div class="form-btn-group">
  86. <el-button size="medium" type="primary" class="btn confirm-btn" @click="submit">提交申请</el-button>
  87. <el-button size="medium" class="btn" @click="cancel">{{ $t('cancel') }}</el-button>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="form-select-tech-prj" v-show="selectTechPrj">
  93. <div class="form-wrap">
  94. <div class="form-header">选择科技项目</div>
  95. <div class="form-content">
  96. <div class="form-row">
  97. <div class="row-label required">请输入科技项目</div>
  98. <div class="row-content">
  99. <el-input placeholder="请输入内容" size="medium" v-model="form.tech_search_keyword"
  100. @keyup.enter.native="searchTechList" class="input-with-select">
  101. <el-select v-model="form.tech_search_sel" style="width:142px" size="medium" slot="prepend"
  102. placeholder="请选择">
  103. <el-option label="项目立项编号" value="0"></el-option>
  104. <el-option label="参与单位" value="1"></el-option>
  105. <el-option label="项目名称" value="2"></el-option>
  106. </el-select>
  107. <el-button size="medium" slot="append" icon="el-icon-search" @click="searchTechList"></el-button>
  108. </el-input>
  109. </div>
  110. </div>
  111. <div class="form-table">
  112. <div style="margin: 0 20px 30px 20px">
  113. <el-table ref="tableRef" border :data="tableData" style="width:100%" v-loading="loading" stripe>
  114. <el-table-column prop="no" label="项目立项编号" align="center" header-align="center"
  115. width="120"></el-table-column>
  116. <el-table-column prop="name" label="科技项目名称" align="center" header-align="center"
  117. width="150"></el-table-column>
  118. <el-table-column prop="unit" label="项目承担单位" align="center" header-align="center"
  119. width="150"></el-table-column>
  120. <el-table-column prop="allunit" label="所有参与单位" align="center" header-align="center"></el-table-column>
  121. <el-table-column width="100" label="操作" align="center" header-align="center">
  122. <template slot-scope="scope">
  123. <el-button type="primary">选择</el-button>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </template>
  135. <script>
  136. import TopHeader from '../components/TopHeader.vue';
  137. import { getTechs, setOpenIApply, setNoOpenIApply, getCreateRepoUser, getCheckRepoName, getTopics } from '~/apis/modules/tech';
  138. export default {
  139. data() {
  140. return {
  141. form: {
  142. type: 'openi',
  143. url: '',
  144. repo_alias: '',
  145. alias_err: false,
  146. uid: '',
  147. repo_name: '',
  148. name_err: false,
  149. repo_url: '',
  150. topics: [],
  151. topicLoading: false,
  152. description: '',
  153. tech_search_sel: '0',
  154. tech_search_keyword: '',
  155. tech_show: '',
  156. institution: [],
  157. },
  158. selectTechPrj: false,
  159. loading: false,
  160. tableData: [{
  161. selected: '0',
  162. no: 'xxxxxxxxxx1',
  163. name: 'Name NameName',
  164. unit: '项目承担单位项目承担单位1',
  165. allunit: '所有参与单位1、所有参与单位、所有参与单位、所有参与单位、所有参与单位',
  166. }, {
  167. selected: '0',
  168. no: 'xxxxxxxxxx2',
  169. name: 'Name NameName2',
  170. unit: '项目承担单位项目承担单位2',
  171. allunit: '所有参与单位2、所有参与单位、所有参与单位',
  172. }],
  173. topicsList: [],
  174. institutionList: [],
  175. };
  176. },
  177. components: {
  178. TopHeader,
  179. },
  180. methods: {
  181. resetData() {
  182. this.form.url = '';
  183. this.form.repo_alias = '';
  184. this.form.alias_err = false;
  185. this.form.uid = '';
  186. this.form.repo_name = '';
  187. this.form.repo_url = '';
  188. this.form.name_err = false;
  189. this.form.topics = [];
  190. this.form.topicLoading = false;
  191. this.form.description = '';
  192. this.form.tech_search_sel = '0';
  193. this.form.tech_search_keyword = '';
  194. this.form.tech_show = '';
  195. this.form.institution = [];
  196. this.tableData = [];
  197. this.topicsList = [];
  198. },
  199. changeType() {
  200. this.resetData();
  201. },
  202. checkRepoAlias() {
  203. const reg = /^[\u4E00-\u9FA5A-Za-z0-9_.-]{1,100}$/;
  204. const res = reg.test(this.form.repo_alias);
  205. this.form.alias_err = !res;
  206. return res;
  207. },
  208. checkRepoName() {
  209. const reg = /^[A-Za-z0-9_.-]{1,100}$/;
  210. const res = reg.test(this.form.repo_name);
  211. this.form.name_err = !res;
  212. return res;
  213. },
  214. changeUrl() {
  215. if (this.form.type == 'openi') return;
  216. const owner = 'Itx003';
  217. const urlAdd = location.href.split("/")[0] + "//" + location.href.split("/")[2];
  218. const repoValue = this.form.url.match(/^(.*\/)?((.+?)(\.git)?)$/)[3];
  219. this.form.repo_alias = repoValue;
  220. getCheckRepoName({ owner: 'Itx003', q: repoValue }).then(res => {
  221. const repo_name = res.data.name;
  222. this.form.repo_name = repo_name;
  223. this.form.repo_url = `${urlAdd}/${owner}/${repo_name}.git`;
  224. }).catch(err => {
  225. console.log(err);
  226. this.form.repo_name = '';
  227. this.form.repo_url = '';
  228. });
  229. },
  230. changeAlias() {
  231. const owner = 'Itx003';
  232. const aliasValue = this.form.repo_alias;
  233. const urlAdd = location.href.split("/")[0] + "//" + location.href.split("/")[2];
  234. if (aliasValue && this.checkRepoAlias()) {
  235. getCheckRepoName({ owner: 'Itx003', q: aliasValue }).then(res => {
  236. const repo_name = res.data.name;
  237. this.form.repo_name = repo_name;
  238. this.form.repo_url = `${urlAdd}/${owner}/${repo_name}.git`;
  239. }).catch(err => {
  240. console.log(err);
  241. this.form.repo_name = '';
  242. this.form.repo_url = '';
  243. });
  244. } else {
  245. this.form.repo_name = '';
  246. this.form.repo_url = '';
  247. }
  248. },
  249. changeRepoName() {
  250. const owner = 'Itx003';
  251. const repo_name = this.form.repo_name;
  252. const urlAdd = location.href.split("/")[0] + "//" + location.href.split("/")[2];
  253. if (this.checkRepoName()) {
  254. this.form.repo_url = `${urlAdd}/${owner}/${repo_name}.git`;
  255. } else {
  256. this.form.repo_url = '';
  257. }
  258. },
  259. searchTopics(query) {
  260. if (query !== '') {
  261. this.form.topicLoading = true;
  262. getTopics({ q: query }).then(res => {
  263. this.form.topicLoading = false;
  264. const topics = res.data.topics || [];
  265. this.topicsList = topics.map(item => {
  266. return {
  267. value: item.topic_name,
  268. label: item.topic_name,
  269. }
  270. });
  271. }).catch(err => {
  272. this.topicsList = [];
  273. });
  274. } else {
  275. this.topicsList = [];
  276. }
  277. },
  278. goSelectTechPrj() {
  279. this.selectTechPrj = true;
  280. },
  281. searchTechList() {
  282. getTechs({
  283. no: this.form.tech_search_sel == '0' ? this.form.tech_search_keyword : '',
  284. institution: this.form.tech_search_sel == '1' ? this.form.tech_search_keyword : '',
  285. name: this.form.tech_search_sel == '2' ? this.form.tech_search_keyword : '',
  286. }).then(res => {
  287. console.log(res);
  288. }).catch(err => {
  289. console.log(err);
  290. })
  291. },
  292. changeTableSelect(row) {
  293. for (let i = 0, iLen = this.tableData.length; i < iLen; i++) {
  294. this.tableData[i].selected = '0';
  295. }
  296. row.selected = '1';
  297. this.$refs.tableRef.setCurrentRow(row);
  298. },
  299. submit() {
  300. console.log(this.form);
  301. },
  302. cancel() {
  303. window.history.back();
  304. }
  305. },
  306. beforeMount() {
  307. getCreateRepoUser().then(res => {
  308. console.log(res);
  309. }).catch(err => {
  310. console.log(err);
  311. });
  312. },
  313. mounted() {
  314. },
  315. beforeDestroy() { },
  316. };
  317. </script>
  318. <style scoped lang="less">
  319. .title {
  320. text-align: center;
  321. margin: 30px 0;
  322. font-size: 14px;
  323. color: rgb(16, 16, 16);
  324. }
  325. .form-c,
  326. .form-select-tech-prj {
  327. display: flex;
  328. justify-content: center;
  329. .form-wrap {
  330. width: 1000px;
  331. background: rgb(255, 255, 255);
  332. border-color: rgb(212, 212, 213);
  333. border-width: 1px;
  334. border-style: solid;
  335. border-radius: 5px;
  336. box-sizing: border-box;
  337. .form-header {
  338. height: 45px;
  339. background: rgb(240, 240, 240);
  340. border-bottom: 1px solid rgb(212, 212, 213);
  341. color: rgb(16, 16, 16);
  342. padding-left: 16px;
  343. font-size: 16px;
  344. font-weight: 700;
  345. display: flex;
  346. align-items: center;
  347. }
  348. .form-content {
  349. margin-top: 40px;
  350. .form-row {
  351. display: flex;
  352. align-items: center;
  353. width: 80%;
  354. margin: 20px auto;
  355. padding-right: 50px;
  356. .row-label {
  357. flex: 2;
  358. text-align: right;
  359. margin-right: 24px;
  360. position: relative;
  361. &.required {
  362. &::after {
  363. position: absolute;
  364. top: -2px;
  365. right: -10px;
  366. content: '*';
  367. color: #db2828;
  368. }
  369. }
  370. &.baseline {
  371. align-self: baseline;
  372. margin-top: 11px;
  373. }
  374. }
  375. .row-content {
  376. flex: 9;
  377. .tips {
  378. margin-top: 4px;
  379. font-size: 14px;
  380. color: rgb(136, 136, 136);
  381. }
  382. }
  383. .reop-url-c {
  384. display: flex;
  385. align-items: center;
  386. }
  387. .openi-repo-url {
  388. color: rgba(16, 16, 16, 1);
  389. }
  390. &.form-row-err {
  391. .row-label {
  392. color: #9f3a38;
  393. }
  394. /deep/ .el-input__inner:not([readonly="readonly"]) {
  395. color: #9f3a38;
  396. background: #fff6f6;
  397. border-color: #e0b4b4;
  398. }
  399. }
  400. }
  401. .form-table {
  402. margin-top: 30px;
  403. margin-bottom: 30px;
  404. /deep/ .el-table__header {
  405. th {
  406. background: rgb(249, 249, 249);
  407. font-size: 12px;
  408. color: rgb(136, 136, 136);
  409. font-weight: normal;
  410. }
  411. }
  412. /deep/ .el-table__body {
  413. td {
  414. font-size: 12px;
  415. }
  416. }
  417. /deep/ .el-radio__label {
  418. display: none;
  419. }
  420. }
  421. .form-btn-group {
  422. display: flex;
  423. justify-content: center;
  424. align-items: center;
  425. margin: 30px 0 40px;
  426. }
  427. }
  428. }
  429. }
  430. .btn {
  431. color: rgb(2, 0, 4);
  432. background-color: rgb(194, 199, 204);
  433. border-color: rgb(194, 199, 204);
  434. &.confirm-btn {
  435. color: #fff;
  436. background-color: rgb(56, 158, 13);
  437. border-color: rgb(56, 158, 13);
  438. margin-right: 20px;
  439. }
  440. }
  441. </style>