您好,我正在尝试从下拉菜单中删除重复的值。但是以某种方式我无法理解该怎么做。
这是我的代码:
const obj ={"allenp":10,"amber.ebow@enron.com":13,"amelia.alland@enron.com":13,"andrea.ring@enron.com":15,"andy.zipper@enron.com":9,"anne.bike@enron.com":10,"anne.koehler@enron.com":4,"arnold-j":9,"barbara.gray@enron.com":6,"barton.clark@enron.com":9,"bass-e":6,"gary.lamphier@enron.com":6,"gay-r":13,"gerald.nemec@enron.com":12}
const result = {}
for([k, v] of Object.entries(obj)) (result[v] = (result[v] || [])).push(k)
console.log(Object.values(result))
这是我的观点:
/**
* Get order ticket details
*/
public function ticketDetailsAction()
{
$orderId = $this->getRequest()->getParam('orderId', 0);
$contactId = $this->getRequest()->getParam('contactId', 0);
$bootstrap = $this->getInvokeArg('bootstrap');
$ticketService = new Tickets_Service_Ticket($bootstrap->getOptions());
$userId = $this->getUserInfo()->getId();
$params = array(
'depotAndAffiliateIds' => array_keys($this->_affiliatedDepotMastersWithActiveDepot),
'orderId' => $orderId,
'contactId' => (int)$contactId,
'user' => $userId,
);
$options = array(
'language' => BAS_Shared_Model_Ticket::LANGUAGE_DEFAULT,
'user' => $userId,
'translate' => $bootstrap->getResource('translate'),
'config' => $bootstrap->getResource('config'),
);
$ticketGridService = new Ticket_Service_Grid($ticketService, $options);
if (0 < (int)$contactId) {
$this->view->ticketGridObject = $ticketGridService->getGrid(Ticket_Service_Grid::GRID_TYPE_ORDERTICKETOVERVIEW, $params);
}
if (empty($this->view->ticketGridObject)) {
$where = array('depot_id in (?)' => array_keys($this->_affiliatedDepotMastersWithActiveDepot));
$this->view->ticketSources = $ticketService->getTicketSourceList($where);
}
}
/**
* Get ticket source list
*
* @param array $whereCondition
* @return array
*/
public function getTicketSourceList($whereCondition = array())
{
/** @var BAS_Shared_Model_TicketSourceMapper */
$ticketSource = $this->getMapper('TicketSource');
return $ticketSource->findAllByCondition($whereCondition, 'source ASC');
}
/**
* @param string|array|Zend_Db_Table_Select|null $where
* @param string|array|null $order
* @param int|null $count
* @param int|null $offset
* @return array|BAS_Shared_Model_AbstractModel[]
*/
public function findAllByCondition($where = null, $order = null, $count = null, $offset = null)
{
$rows = $this->getDao()->fetchAll($where, $order, $count, $offset);
$models = [];
while(($row = $rows->current()) !== null) {
$models[] = $this->mapRow($row);
$rows->next();
}
$this->resetMapToModel();
return $models;
}
如何在此处添加不同的条件。我已经添加了完整的控制器功能和其余功能。并且我添加了将创建下拉代码的查看页面代码。
谁能帮我
谢谢。