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 3.8 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div>
  3. <h4 id="about-desc" class="ui header desc-home">简介
  4. <a class="edit-icon" 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="编辑仓库信息"
  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="简介" prop="desc">
  22. <el-input v-model="info.desc" type="textarea" placeholder="请输入内容" :autosize="{minRows:4,maxRows:6}" maxlength="255" show-word-limit></el-input>
  23. </el-form-item>
  24. <el-form-item label="主页" prop="index_web" >
  25. <el-input v-model="info.index_web" placeholder="主页(eg: https://git.openi.org.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. // rule1:[{min:3,max:5,message:'1',trigger:"blur"}],
  52. rule: {
  53. index_web: [
  54. {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']}
  55. ]
  56. }
  57. };
  58. },
  59. methods: {
  60. editClick() {
  61. this.editDataDialog = true;
  62. },
  63. getDesc() {
  64. const el = $('span.description').text();
  65. this.info.desc = el;
  66. },
  67. getWeb() {
  68. const el = $('a.link.edit-link').text();
  69. this.info.index_web = el;
  70. },
  71. getRepoName() {
  72. const el = this.url.split('/')[2];
  73. this.info.repo_name = el;
  74. this.info.alias = $('input#edit-alias').val()
  75. },
  76. initForm(diaolog) {
  77. if (diaolog === false) {
  78. this.getRepoName();
  79. this.getDesc();
  80. this.getWeb();
  81. }
  82. },
  83. editDataFunc(formName) {
  84. this.$refs[formName].validate((valid)=>{
  85. if (valid) {
  86. this.$axios({
  87. method: 'post',
  88. url: this.url,
  89. header: {'content-type': 'application/x-www-form-urlencoded'},
  90. data: this.qs.stringify({
  91. _csrf: csrf,
  92. action: 'update',
  93. alias:this.info.alias,
  94. repo_name: this.info.repo_name,
  95. description: this.info.desc,
  96. website: this.info.index_web
  97. })
  98. }).then((res) => {
  99. location.reload();
  100. this.editDataDialog = false;
  101. }).catch((error) => {
  102. this.editDataDialog = false;
  103. })
  104. }
  105. else {
  106. return false;
  107. }
  108. })
  109. },
  110. getUrl() {
  111. const url = `${window.location.pathname}/settings`;
  112. this.url = url;
  113. }
  114. },
  115. mounted() {
  116. this.getUrl();
  117. this.getRepoName();
  118. this.getDesc();
  119. this.getWeb();
  120. },
  121. watch:{
  122. 'info.desc'(val){
  123. if(val.length===256){
  124. this.info.desc = val.substr(0,255)
  125. }
  126. }
  127. },
  128. created() {
  129. }
  130. };
  131. </script>
  132. <style scoped>
  133. .edit-icon{
  134. color: #8c92a4;
  135. }
  136. .desc-home{
  137. display: flex;
  138. justify-content: space-between;
  139. }
  140. </style>