|
- import Images from '../components/Images.vue';
-
- export default async function initImage(){
- function initDropdown(){
- $('#dropdown_image')
- .dropdown({
- allowAdditions: true,
- onChange: function(value, text, $selectedItem) {
- $('#course_label_item').empty()
- }
- })
- $('#dropdown_image input.search').bind('input propertychange', function (event) {
- // $("#dropdown_container").removeAttr("style");
- const query = $('input.search').val()
- if(!query){
- $('#course_label_item').empty()
- }else{
- $.get(`/api/v1/topics/search?q=${query}`,(data)=>{
- if(data.topics.length!==0){
- let html=''
- $('#course_label_item').empty()
- data.topics.forEach(element => {
- html += `<div class="item" data-value="${element.topic_name}">${element.topic_name}</div>`
- });
- $('#course_label_item').append(html)
- }
- })
- }
- });
- }
- initDropdown()
- let link = $('.submit-image-tmplvalue').data('link')
- $('.ui.create_image.green.button').click(()=>{
- console.log($('#form_image').serialize())
- $.ajax({
- url:link,
- type:'POST',
- data:$('#form_image').serialize(),
- success:function(res){
- console.log("res",res)
- },
- error: function(xhr){
- // 隐藏 loading
- // 只有请求不正常(状态码不为200)才会执行
- // $('.ui.error.message').text(xhr.responseText)
- // $('.ui.error.message').css('display','block')
- },
- complete:function(xhr){
- // $("#mask").css({"display":"none","z-index":"1"})
- }
- })
- })
- console.log("initImage")
- const el = document.getElementById('image-base');
- if (!el) {
- return;
- }
-
- // let defaultText = document.getElementById("default_text").offsetHeight
- // defaultText = defaultText>40 ? defaultText+12 :defaultText
- // $("#dropdown_container").css("height",defaultText)
-
- new Vue({
- delimiters: ['${', '}'],
- el,
- data() {
- return{
-
- }
- },
- components: {
- Images
- },
- mounted(){
- },
- methods:{
- }
- });
-
- }
|