* [task#137378,doing,1h] optimize code.

This commit is contained in:
liumengyi
2025-02-17 15:40:46 +08:00
committed by 刘刚
parent 5760915ad4
commit 4119c8bb61
4 changed files with 24 additions and 14 deletions
+2
View File
@@ -16,3 +16,5 @@ CREATE TABLE IF NOT EXISTS `zt_extuser` (
`account` char(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `zt_charter` ADD COLUMN `branch` text NULL AFTER `product`;
+1
View File
@@ -15728,6 +15728,7 @@ CREATE TABLE `zt_charter` (
`budget` char(30) NOT NULL DEFAULT '',
`budgetUnit` char(30) NOT NULL DEFAULT '',
`product` text NULL,
`branch` text NULL,
`roadmap` text NULL,
`plan` text NULL,
`type` varchar(30) NOT NULL DEFAULT 'roadmap',
+20 -13
View File
@@ -142,8 +142,8 @@ window.loadPlan = function(product)
{
let productID = product.val();
let branchID = product.closest('.productBox').find('.linkBranch .pick-value').val();
if(typeof branchID == 'undefined') $branchID = '';
let link = $.createLink('charter', 'ajaxGetPlans', 'productID=' + productID + '&branchID' + branchID);
if(typeof branchID == 'undefined') branchID = '';
let link = $.createLink('charter', 'ajaxGetPlans', 'productID=' + productID + '&branchID=' + branchID);
const $items = [{text: '', value: '', key: ''}];
const $plan = product.closest('.productBox').find('.planBox .pick-value');
@@ -162,11 +162,24 @@ window.refreshPicker = function(event)
{
if(typeof event !== "undefined")
{
const objectType = $(event.target).closest('.productsBox').data('objecttype');
if(objectType == 'roadmap') loadRoadmap($(event.target));
if(objectType == 'plan') loadPlan($(event.target));
const $product = $(event.target);
const productID = $product.val();
if(multiBranchProducts[productID])
{
loadBranches($product);
}
else
{
updateItems();
loadBranches($(event.target));
const objectType = $product.closest('.productsBox').data('objecttype');
if(objectType == 'roadmap') loadRoadmap($product);
if(objectType == 'plan') loadPlan($product);
let $formRow = $product.closest('.productBox');
$formRow.find('.form-group').eq(0).addClass('w-1/2').removeClass('w-1/4');
$formRow.find('.form-group').eq(1).addClass('hidden');
}
}
}
@@ -186,11 +199,6 @@ window.loadBranches = function(product)
let $formRow = product.closest('.productBox');
let charterID = $('[name="charter"]').length ? $('[name="charter"]').val() : 0;
const objectType = $('.productsBox').data('linkType');
if(!multiBranchProducts[currentProduct])
{
$formRow.find('.form-group').eq(0).addClass('w-1/2').removeClass('w-1/4');
$formRow.find('.form-group').eq(1).addClass('hidden');
}
if(typeof projectID == 'undefined') projectID = 0;
$.getJSON($.createLink('branch', 'ajaxGetBranches', "productID=" + currentProduct + "&oldBranch=&param=active&projectID=" + projectID + "&withMainBranch=true&isTwins=no&fieldID=0&multiple=&charterID=" + charterID), function(data)
@@ -272,7 +280,7 @@ window.updateItems = function(currentProduct = '', currentBranch = '')
const branchItems = $branch.zui('picker').options.items
if(!chosenBranches[productID]) chosenBranches[productID] = [];
$('[name^=product][value="' + productID + '"]').closest('.productBox').find('[name^="branch"]').each(function()
$branch.each(function()
{
const branchID = $(this).val().toString();
if(!isNaN(branchID) && !chosenBranches[productID].includes(branchID) && branchID !== '') chosenBranches[productID].push(branchID);
@@ -302,5 +310,4 @@ window.updateItems = function(currentProduct = '', currentBranch = '')
window.branchChange = function(event)
{
const productID = $(event.target).closest('.productBox').find('.linkProduct .picker-box').zui('picker').$.value;
updateItems(productID, $(event.target).val());
}
+1 -1
View File
@@ -99,7 +99,7 @@ class productCharterBox extends wg
setClass('branchBox'),
picker
(
set::name('branch[0]'),
set::name("branch[$index]"),
set::items(array()),
setData(array('on' => 'change', 'call' => 'branchChange', 'params' => 'event'))
)