From 6b88df29ffa14046351653fed3825f4036d8499b Mon Sep 17 00:00:00 2001 From: Zhangyu Date: Mon, 27 May 2024 06:13:02 +0000 Subject: [PATCH] * zin: add method description of thinktableinput. --- lib/zin/wg/thinktableinput/js/v1.js | 39 +++++++++++++++++++++++++++++ lib/zin/wg/thinktableinput/v1.php | 1 + 2 files changed, 40 insertions(+) diff --git a/lib/zin/wg/thinktableinput/js/v1.js b/lib/zin/wg/thinktableinput/js/v1.js index 789a8f5e1b..07cccfe607 100644 --- a/lib/zin/wg/thinktableinput/js/v1.js +++ b/lib/zin/wg/thinktableinput/js/v1.js @@ -1,18 +1,43 @@ +/** + * 处理是否支持添加行值的变化。 + * Does it support adding changes to row values. + * + * @param event $e + * @returns void + */ window.changeSupportAdd = function(e) { $('.can-add-rows').toggleClass('hidden', e.target.value == 0); } + +/** + * 处理是否必填值的变化。 + * Handling changes in mandatory values. + * + * @param event $e + * @returns void + */ window.changeIsRequired = function(e) { $('.required-rows').toggleClass('hidden', e.target.value == 0); } + +/** + * 处理输入框值变化。 + * Handling input box value changes. + * + * @param Event e Event object + * @returns void + */ window.changeInput = function(e) { const value = $(this).val(); const intValue = value < 1 ? 1 : parseInt(value, 10); $(this).val(intValue); } + /** + * 设置行号。 * Set line number. * * @access public @@ -31,6 +56,13 @@ function setLineIndex() }); } +/** + * 添加行。 + * Add rows. + * + * @param event $e + * @returns void + */ window.addRow = function(e) { if($('.rows-group').length >= canAddRows) return; @@ -44,6 +76,13 @@ window.addRow = function(e) setLineIndex(); } +/** + * 删除行。 + * Delete rows. + * + * @access public + * @return void + */ $(document).on('click', '.btn-delete', function() { zui.Modal.confirm({message: deleteTip}).then((res) => { if(res) diff --git a/lib/zin/wg/thinktableinput/v1.php b/lib/zin/wg/thinktableinput/v1.php index c70fec0b87..b0018acd08 100644 --- a/lib/zin/wg/thinktableinput/v1.php +++ b/lib/zin/wg/thinktableinput/v1.php @@ -87,6 +87,7 @@ class thinkTableInput extends thinkQuestion { foreach($customFields as $index => $item) { + /* 结果的索引是后台设置问题数加用户添加问题行的索引。Result index is number of backend setting issues plus custom add problem index.*/ $resultIndex = count($fields) + $index; $tableInputItems[] = formGroup (