batchcreate.ui.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. window.waitDom("input[name='begin\[1\]']", function()
  2. {
  3. const $beginPicker = $("input[name='begin\[1\]']").zui('picker');
  4. $beginPicker.$.setValue(beginTime);
  5. })
  6. const timeIndex = times.findIndex(key => `${key}` === `${time}`);
  7. window.changeType = function(e)
  8. {
  9. const type = e.target.value;
  10. const $tr = $(e.target).closest('tr');
  11. const $nameBox = $tr.find('[data-name="name"]');
  12. let index = $tr.data('index')
  13. let param = 'userID=' + userID + '&id=' + (+index + 1);
  14. if(type == 'task') param += '&status=wait,doing';
  15. index ++;
  16. if(moduleList.indexOf(type) !== -1)
  17. {
  18. link = $.createLink(type, objectsMethod[type], param);
  19. $.get(link, function(data)
  20. {
  21. data = JSON.parse(data);
  22. data.name = `name[${index}]`;
  23. $nameBox.html("<div class='picker-box' id='name'></div>");
  24. $nameBox.find('#name').picker(data);
  25. })
  26. }
  27. else
  28. {
  29. $nameBox.html($('#nameInputBox').html());
  30. $nameBox.find('input[name=name]').attr('name', `name[${index}]`).attr('id', `name_${index}`)
  31. }
  32. }
  33. window.changeFuture = function()
  34. {
  35. const isChecked = $('#futureDate[type="checkbox"]').prop('checked');
  36. const $todoDate = $('#todoDate').zui('datePicker');
  37. if(isChecked) $todoDate.$.setValue('');
  38. $('.panel-body form [name=futureDate]').val(isChecked ? 1 : 0);
  39. }
  40. window.changeTodoDate = function()
  41. {
  42. const todoDate = $('#todoDate [name=date]').val();
  43. if(todoDate) $('#futureDate[type="checkbox"]').prop('checked', false);
  44. $('.panel-body form [name=date]').val(todoDate);
  45. }
  46. window.initTime = function(e)
  47. {
  48. let $this = $(e.target);
  49. let $tr = $this.closest('tr');
  50. let $picker = $this.zui('picker');
  51. if(typeof $picker == 'undefined')
  52. {
  53. $this = $tr.find('.picker-box[data-name=begin]')
  54. $picker = $this.zui('picker');
  55. }
  56. let value = $picker.$.value;
  57. let $end = $tr.find('[data-name=end]');
  58. const options = $picker.options;
  59. const items = options.items;
  60. const isBegin = options.name.indexOf('begin') === 0;
  61. const index = parseInt($tr.data('index'));
  62. if(isBegin)
  63. {
  64. let endValue = '';
  65. items.forEach(function(item, timeIndex)
  66. {
  67. if(item.value == value)
  68. {
  69. endIndex = timeIndex + 3;
  70. endValue = items.length <= endIndex ? items[items.length - 1].value : items[endIndex].value;
  71. return;
  72. }
  73. });
  74. $end.zui('picker').$.setValue(endValue);
  75. if(typeof endIndex != 'undefined') value = endIndex;
  76. }
  77. $('#batchCreateTodoForm tbody tr').each(function()
  78. {
  79. const trIndex = parseInt($(this).data('index'));
  80. if(trIndex > index)
  81. {
  82. let endValue = '';
  83. items.forEach(function(item, timeIndex)
  84. {
  85. if(item.value == value)
  86. {
  87. endIndex = timeIndex + 3;
  88. endValue = items.length <= endIndex ? value : items[endIndex].value;
  89. return;
  90. }
  91. });
  92. if(value == '2350') value='6000';
  93. $(this).find('[data-name="beginAndEnd"] [data-name="begin"]').zui('picker').$.setValue(value);
  94. $(this).find('[data-name="beginAndEnd"] [data-name="end"]').zui('picker').$.setValue(endValue);
  95. if(typeof endIndex != 'undefined') value = endIndex;
  96. }
  97. });
  98. }
  99. window.togglePending = function(e)
  100. {
  101. $(e.target).closest('.input-group').find('.time-input').each(function()
  102. {
  103. $(this).zui('picker').render({disabled: e.target.checked});
  104. });
  105. }