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.

EditAboutInfo.vue 4.4 kB

3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div>
  3. <h4 id="about-desc" class="ui header desc-home">{{$i18n['introduction']}}
  4. <a class="edit-icon" v-if="IsPermit" id ="editBtn" href="javascript:void(0)" @click="editClick" >
  5. <i class="gray edit outline icon" style="margin-right: 0;"></i>
  6. </a>
  7. </h4>
  8. <edit-dialog-cmpt
  9. :vmContext="vmContext"
  10. :dialogTitle="$i18n['edit_repository_information']"
  11. v-model="editDataDialog"
  12. :deleteCallback="editDataFunc"
  13. :deleteLoading ="editDataListLoading"
  14. deleteParam = "ruleForm"
  15. @input="initForm"
  16. >
  17. <div slot="title">
  18. </div>
  19. <div slot="content">
  20. <el-form label-position="top" :model="info" :rules="rule" ref="ruleForm">
  21. <el-form-item :label="$i18n['introduction']" prop="desc">
  22. <el-input v-model="info.desc" type="textarea" :placeholder="$i18n['please_enter_the_content']" :autosize="{minRows:4,maxRows:6}" maxlength="255" show-word-limit></el-input>
  23. </el-form-item>
  24. <el-form-item :label="$i18n['homePage']" prop="index_web" >
  25. <el-input v-model="info.index_web" :placeholder="`${$i18n['homePage']}(eg: https://openi.pcl.ac.cn)`"></el-input>
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. </edit-dialog-cmpt>
  30. </div>
  31. </template>
  32. <script>
  33. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  34. import editDialogCmpt from './basic/editDialog.vue';
  35. export default {
  36. components: {
  37. editDialogCmpt,
  38. },
  39. data() {
  40. return {
  41. vmContext: this,
  42. editDataDialog: false,
  43. editDataListLoading: false,
  44. url: '',
  45. info: {
  46. desc: '',
  47. index_web: '',
  48. repo_name_name: '',
  49. alias:'',
  50. },
  51. IsPermit: false,
  52. // rule1:[{min:3,max:5,message:'1',trigger:"blur"}],
  53. rule: {
  54. index_web: [
  55. {required: false, pattern: /(^$)|(^(http|https):\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).*)|(^(http|https):\/\/[a-zA-Z0-9]+([_\-\.][a-zA-Z0-9]+)*\.[a-zA-Z]{2,10}(:[0-9]{1,10})?(\?.*)?(\/.*)?$)/,message:'请输入有效的URL',tigger:['change','blur']}
  56. ]
  57. }
  58. };
  59. },
  60. methods: {
  61. getIsSigned(){
  62. var isadmin= document.getElementById("repo-desc").dataset.isadmin;
  63. var isarchived=document.getElementById("repo-desc").dataset.isarchived;
  64. // console.log("IsSigned:",this.IsSigned)
  65. if ((isadmin==true || isadmin=="true")&& (isarchived==false || isarchived=="false")){
  66. this.IsPermit=true;
  67. }
  68. },
  69. editClick() {
  70. if (this.IsPermit){
  71. this.editDataDialog = true;
  72. }
  73. },
  74. getDesc() {
  75. const el = $('span.description').text();
  76. this.info.desc = el;
  77. },
  78. getWeb() {
  79. const el = $('a.link.edit-link').text();
  80. this.info.index_web = el;
  81. },
  82. getRepoName() {
  83. const el = this.url.split('/')[2];
  84. this.info.repo_name = el;
  85. this.info.alias = $('input#edit-alias').val()
  86. },
  87. initForm(diaolog) {
  88. if (diaolog === false) {
  89. this.getRepoName();
  90. this.getDesc();
  91. this.getWeb();
  92. }
  93. },
  94. editDataFunc(formName) {
  95. this.$refs[formName].validate((valid)=>{
  96. if (valid) {
  97. this.$axios({
  98. method: 'post',
  99. url: this.url,
  100. header: {'content-type': 'application/x-www-form-urlencoded'},
  101. data: this.qs.stringify({
  102. _csrf: csrf,
  103. action: 'update',
  104. alias:this.info.alias,
  105. repo_name: this.info.repo_name,
  106. description: this.info.desc,
  107. website: this.info.index_web
  108. })
  109. }).then((res) => {
  110. location.reload();
  111. this.editDataDialog = false;
  112. }).catch((error) => {
  113. this.editDataDialog = false;
  114. })
  115. }
  116. else {
  117. return false;
  118. }
  119. })
  120. },
  121. getUrl() {
  122. const url = `${window.location.pathname}/settings`;
  123. this.url = url;
  124. }
  125. },
  126. mounted() {
  127. this.getIsSigned();
  128. this.getUrl();
  129. this.getRepoName();
  130. this.getDesc();
  131. this.getWeb();
  132. },
  133. watch:{
  134. 'info.desc'(val){
  135. if(val.length===256){
  136. this.info.desc = val.substr(0,255)
  137. }
  138. }
  139. },
  140. created() {
  141. this.$i18n = window.i18n;
  142. this.getIsSigned();
  143. }
  144. };
  145. </script>
  146. <style scoped>
  147. .edit-icon{
  148. color: #8c92a4;
  149. }
  150. .desc-home{
  151. display: flex;
  152. justify-content: space-between;
  153. }
  154. </style>