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.

images.js 3.6 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import Images from '../components/Images.vue';
  2. import Vue from 'vue';
  3. export default async function initImage(){
  4. function validate() {
  5. $("#form_image")
  6. .form({
  7. on: 'blur',
  8. // inline:true,
  9. fields: {
  10. tag: {
  11. identifier : 'tag',
  12. rules: [
  13. {
  14. type: 'regExp[/^[A-Za-z0-9_.-]{1,100}[A-Za-z0-9_.]$/]',
  15. }
  16. ]
  17. },
  18. description:{
  19. identifier : 'description',
  20. rules: [
  21. {
  22. type: 'empty',
  23. }
  24. ]
  25. },
  26. }
  27. })
  28. }
  29. function initDropdown(){
  30. $('#dropdown_image')
  31. .dropdown({
  32. allowAdditions: true,
  33. onChange: function(value, text, $selectedItem) {
  34. $('#course_label_item').empty()
  35. }
  36. })
  37. $('#dropdown_image input.search').bind('input propertychange', function (event) {
  38. // $("#dropdown_container").removeAttr("style");
  39. const query = $('input.search').val()
  40. if(!query){
  41. $('#course_label_item').empty()
  42. }else{
  43. $.get(`/api/v1/topics/search?q=${query}`,(data)=>{
  44. if(data.topics.length!==0){
  45. let html=''
  46. $('#course_label_item').empty()
  47. data.topics.forEach(element => {
  48. html += `<div class="item" data-value="${element.topic_name}">${element.topic_name}</div>`
  49. });
  50. $('#course_label_item').append(html)
  51. }
  52. })
  53. }
  54. });
  55. }
  56. validate()
  57. initDropdown()
  58. let link = $('.submit-image-tmplvalue').data('link')
  59. $('.ui.create_image.green.button').click(()=>{
  60. console.log($('#form_image').serialize())
  61. $.ajax({
  62. url:link,
  63. type:'POST',
  64. data:$('#form_image').serialize(),
  65. success:function(res){
  66. console.log("res",res)
  67. if(res.Code===1){
  68. $('.alert').html(res.Message).removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  69. }
  70. },
  71. error: function(xhr){
  72. // 隐藏 loading
  73. // 只有请求不正常(状态码不为200)才会执行
  74. // $('.ui.error.message').text(xhr.responseText)
  75. // $('.ui.error.message').css('display','block')
  76. $('.alert').html(xhr.responseText).removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  77. },
  78. complete:function(xhr){
  79. $("#mask").css({"display":"none","z-index":"1"})
  80. }
  81. })
  82. })
  83. $('#cancel_submit_image').click(()=>{
  84. if(link.includes('cloudbrain')){
  85. let repoLink = link.split('cloudbrain')[0]
  86. location.href = `${window.config.AppSubUrl}${repoLink}debugjob?debugListType=all`
  87. }
  88. })
  89. console.log("initImage")
  90. function initVueImages() {
  91. const el = document.getElementById('images');
  92. console.log(el)
  93. if (!el) {
  94. return;
  95. }
  96. new Vue({
  97. el:el,
  98. render: h => h(Images)
  99. });
  100. }
  101. initVueImages()
  102. }