make-dom.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. function set_min_width_table(dom_val, px) {
  44. $(dom_val).css('min-width', px + 'px')
  45. $(dom_val).css('table-layout', 'fixed')
  46. }
  47. async function include_media_library(setup_code, brand_code, media_search_para = '/search/media-search/image', theme_dir = undefined) {
  48. // let response = await get_api_data('setup-pick', { Page: [ { SetupCode: setup_code } ] })
  49. // const setup = JSON.parse(response.data.Page[0]['SetupJson'])
  50. let response = await get_para_data('formB', '/popup/popup-form1/form-b/media', getParameterByName('bpa'));
  51. const media_parameter = response['data']['data']
  52. response = await get_para_data('modal', media_search_para, undefined, theme_dir)
  53. // response = await get_para_data('modal', media_search_para, undefined, '/erp/genesis_wallet')
  54. let media_modal = response['data']
  55. // media_modal['Setup'] = setup;
  56. media_modal['MediaParameter'] = media_parameter;
  57. get_blades_html('front.outline.static.media', media_modal, function (html) {
  58. if (! $('#element_in_which_to_insert').find('#modal-media').length) {
  59. $('#element_in_which_to_insert').append(html);
  60. }
  61. });
  62. return media_modal;
  63. }