make-dom.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. function create_options(page) {
  2. if (page == null) return;
  3. return page.reduce(function (accumulator, item) {
  4. return accumulator + `<option value="${item.Value}">${item.Caption}</option>`;
  5. }, '');
  6. }
  7. function custom_create_options(value_name, caption_name, page) {
  8. if (page == null) return;
  9. return page.reduce(function (accumulator, item) {
  10. return accumulator + `<option value="${item[value_name]}">${item[caption_name]}</option>`;
  11. }, '');
  12. }
  13. makeSelectBtnOptions = (parentId, filterOptions, domId) => {
  14. if (isEmpty(filterOptions)) return false;
  15. let options = create_options(filterOptions)
  16. $(parentId).find(domId).html(options);
  17. $(`${domId} option:eq(0)`).prop("selected", true);
  18. return true;
  19. }
  20. // function change_self_to_format_decimal(dom_val, number, type = 1) {
  21. // if (type == 1) {
  22. // $(dom_val).val( format_decimal(minusComma($(dom_val).val()), number) )
  23. // } else if (type == 2) {
  24. // $(dom_val).text( format_decimal(minusComma($(dom_val).text()), number) )
  25. // }
  26. // }
  27. function make_dynamic_table_px(data) {
  28. let sum = 0;
  29. for (const key in data) {
  30. if (isEmpty(data[`${key}`])) continue;
  31. sum += parseInt(data[`${key}`])
  32. }
  33. return sum;
  34. }
  35. function make_dynamic_table_css(dom_val, count) {
  36. if (count < 100) {
  37. $(dom_val).css('min-width', '1024px')
  38. } else {
  39. $(dom_val).css('min-width', `${count * 10}px`)
  40. }
  41. $(dom_val).css('table-layout', 'fixed')
  42. }
  43. async function include_media_library(setup_code) {
  44. let response = await get_api_data('setup-pick', { Page: [ { SetupCode: setup_code } ] })
  45. const setup = JSON.parse(response.data.Page[0]['SetupJson'])
  46. response = await get_para_data('formB', '/popup/popup-form1/form-b/media', getParameterByName('bpa'));
  47. const media_parameter = response['data']['data']
  48. response = await get_para_data('modal', '/search/media-search/image')
  49. let media_modal = response['data']
  50. media_modal['Setup'] = setup;
  51. media_modal['MediaParameter'] = media_parameter;
  52. get_blades_html('front.outline.static.media', media_modal, function (html) {
  53. if (! $('#element_in_which_to_insert').find('#modal-media').length) {
  54. $('#element_in_which_to_insert').append(html);
  55. }
  56. });
  57. return media_modal;
  58. }