<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>智能配送车辆调度系统</title>
  <link rel="stylesheet" href="./semantic.min.css">
  <style>
    .ui.container {
      margin-top: 2rem;
    }
  </style>
</head>
<body>
  <div class="ui container">
    <h1 class="ui dividing header">智能配送车辆调度系统</h1>
<pre><code>&lt;form class=&quot;ui form&quot;&gt;
  &lt;div class=&quot;field&quot;&gt;
    &lt;label&gt;选择日期&lt;/label&gt;
    &lt;input type=&quot;date&quot; placeholder=&quot;选择日期&quot; required&gt;
  &lt;/div&gt;

  &lt;div class=&quot;field&quot;&gt;
    &lt;label&gt;选择配送区域&lt;/label&gt;
    &lt;select class=&quot;ui dropdown&quot; id=&quot;quyu&quot; name=&quot;area&quot; required&gt;
      &lt;option value=&quot;&quot;&gt;选择配送区域&lt;/option&gt;
      &lt;option value=&quot;区域1&quot;&gt;区域1&lt;/option&gt;
      &lt;option value=&quot;区域2&quot;&gt;区域2&lt;/option&gt;
      &lt;option value=&quot;区域3&quot;&gt;区域3&lt;/option&gt;
    &lt;/select&gt;
  &lt;/div&gt;

  &lt;div class=&quot;field&quot;&gt;
    &lt;label&gt;选择配送车辆&lt;/label&gt;
    &lt;select class=&quot;ui dropdown&quot; id=&quot;cheliang&quot; name=&quot;vehicle&quot; required&gt;
      &lt;option value=&quot;&quot;&gt;选择配送车辆&lt;/option&gt;
      &lt;option value=&quot;车辆1&quot;&gt;车辆1&lt;/option&gt;
      &lt;option value=&quot;车辆2&quot;&gt;车辆2&lt;/option&gt;
      &lt;option value=&quot;车辆3&quot;&gt;车辆3&lt;/option&gt;
    &lt;/select&gt;
  &lt;/div&gt;

  &lt;button class=&quot;ui primary button&quot; type=&quot;submit&quot;&gt;调度车辆&lt;/button&gt;
&lt;/form&gt;

&lt;div id=&quot;assignedTasks&quot; style=&quot;display: none;&quot;&gt;
  &lt;h2 class=&quot;ui dividing header&quot;&gt;已分配任务&lt;/h2&gt;
  &lt;!-- 根据已分配车辆动态创建任务列表 --&gt;
&lt;/div&gt;

&lt;h2 class=&quot;ui dividing header&quot;&gt;配送任务列表&lt;/h2&gt;
&lt;table class=&quot;ui celled table&quot;&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;配送单号&lt;/th&gt;
      &lt;th&gt;配送地址&lt;/th&gt;
      &lt;th&gt;备注&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;001&lt;/td&gt;
      &lt;td&gt;地址1&lt;/td&gt;
      &lt;td&gt;备注1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;002&lt;/td&gt;
      &lt;td&gt;地址2&lt;/td&gt;
      &lt;td&gt;备注2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;!-- 其他配送任务行 --&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</code></pre>
  </div>
  <script src="./jquery.min.js"></script>
  <script src="./semantic.min.js"></script>
  <script>
    $('.ui.dropdown').dropdown();

    const form = document.querySelector('.ui.form');
    const scheduleBtn = form.querySelector('.ui.primary.button');
  
    scheduleBtn.addEventListener('click', function(event) {
      event.preventDefault();
      const selectedDate = form.querySelector('input[type="date"]');
      const selectedDateValue = selectedDate.value;
      const selectedAreaValue = $("#quyu").val();
      const selectedVehicleValue = $("#cheliang").val();
      // 创建任务表格
      const taskTable = form.nextElementSibling.querySelector('.ui.celled.table');
      // 执行配送车辆调度逻辑,将任务分配给选定的车辆

      // 示例:将任务添加到已分配车辆的任务列表中
      const tasks = Array.from(taskTable.querySelectorAll('tbody tr'));
      let assignedTable = document.getElementById(selectedVehicleValue + '-table');

      tasks.forEach(task => {
        if (assignedTable && assignedTable.querySelector('tbody')){
          assignedTable.querySelector('tbody').appendChild(task.cloneNode(true));
          task.parentNode.removeChild(task);
        }
      });

      const assignedTasks = document.getElementById('assignedTasks');
      assignedTasks.style.display = 'block';

      if (!assignedTable) {
        const tableHtml = `
          <table class="ui celled table" id="${selectedVehicleValue}-table">
            <thead>
              <tr>
                <th>配送单号</th>
                <th>配送地址</th>
                <th>备注</th>
              </tr>
            </thead>
            <tbody>
              <!-- 已分配任务行 -->
            </tbody>
          </table>
        `;
        assignedTasks.innerHTML += tableHtml;
        assignedTable = document.getElementById(selectedVehicleValue + '-table');
      }

      form.reset();
    });
  </script>
</body>
</html>
智能配送车辆调度系统

原文地址: https://www.cveoy.top/t/topic/O7p 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录