客户订单管理修复快速选择格式问题,增加规格型号和机型简称
This commit is contained in:
parent
3d2772d165
commit
385b5b2ac0
@ -128,6 +128,8 @@
|
||||
<th>订单编号</th>
|
||||
<th>客户名称</th>
|
||||
<th>物料</th>
|
||||
<th>规格型号</th>
|
||||
<th>机型简称</th>
|
||||
<th>订单数量</th>
|
||||
<th>已发货</th>
|
||||
<th style="color: #f59e0b; font-weight: 700;">未交订单</th>
|
||||
@ -257,7 +259,7 @@
|
||||
}
|
||||
|
||||
if (!data.list || data.list.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="9" class="text-center">暂无数据</td></tr>';
|
||||
tbody.innerHTML = '<tr><td colspan="11" class="text-center">暂无数据</td></tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
@ -274,6 +276,8 @@
|
||||
<td>${order.order_no || '—'}</td>
|
||||
<td>${order.customer_name || '—'}</td>
|
||||
<td style="white-space: pre-line; word-break: break-word;">${order.material || '—'}</td>
|
||||
<td>${order.material_spec || '—'}</td>
|
||||
<td>${order.model_name || '—'}</td>
|
||||
<td>${order.quantity || 0}</td>
|
||||
<td style="color: #3b82f6;">${shippedQty}</td>
|
||||
<td style="${undeliveredStyle}"
|
||||
@ -300,7 +304,7 @@
|
||||
console.error('加载订单失败:', err);
|
||||
const tbody = document.getElementById('order-list');
|
||||
if (tbody) {
|
||||
tbody.innerHTML = '<tr><td colspan="9" class="text-center" style="color: red;">加载失败,请刷新重试</td></tr>';
|
||||
tbody.innerHTML = '<tr><td colspan="11" class="text-center" style="color: red;">加载失败,请刷新重试</td></tr>';
|
||||
}
|
||||
API.toast('加载订单失败', 'error');
|
||||
}
|
||||
@ -336,7 +340,7 @@
|
||||
if (!existingMsg) {
|
||||
const msgRow = document.createElement('tr');
|
||||
msgRow.className = 'no-filter-results';
|
||||
msgRow.innerHTML = '<td colspan="9" class="text-center" style="color: var(--text-2);">没有匹配的物料</td>';
|
||||
msgRow.innerHTML = '<td colspan="11" class="text-center" style="color: var(--text-2);">没有匹配的物料</td>';
|
||||
tbody.appendChild(msgRow);
|
||||
}
|
||||
} else {
|
||||
@ -371,10 +375,10 @@
|
||||
}
|
||||
|
||||
function buildMaterialOptions() {
|
||||
return productList.map(name => `<option value="${name}">`).join('');
|
||||
return productList.map(name => `<option value="${name.replace(/\n/g, ' ')}">`).join('');
|
||||
}
|
||||
|
||||
function addMaterialRow(material = '', quantity = '', unitPrice = '') {
|
||||
function addMaterialRow(material = '', quantity = '', unitPrice = '', materialSpec = '', modelName = '') {
|
||||
const container = document.getElementById('materials-container');
|
||||
const index = materialRowIndex++;
|
||||
const datalistId = `material-options-${index}`;
|
||||
@ -382,19 +386,27 @@
|
||||
const row = document.createElement('div');
|
||||
row.className = 'material-row';
|
||||
row.id = `material-row-${index}`;
|
||||
row.style.cssText = 'display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; margin-bottom: 12px; padding: 16px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border);';
|
||||
row.style.cssText = 'display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; padding: 16px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); align-items: flex-end;';
|
||||
|
||||
row.innerHTML = `
|
||||
<div class="field" style="margin: 0;">
|
||||
<label>物料名称 <span style="color: var(--danger);">*</span></label>
|
||||
<input type="text" class="input material-name" list="${datalistId}" placeholder="输入或选择物料名称" value="${material}" required autocomplete="off" />
|
||||
<div class="field" style="margin: 0; flex: 2 1 180px;">
|
||||
<label>物料编码 <span style="color: var(--danger);">*</span></label>
|
||||
<input type="text" class="input material-name" list="${datalistId}" placeholder="输入或选择物料编码" value="${material}" required autocomplete="off" />
|
||||
<datalist id="${datalistId}">${buildMaterialOptions()}</datalist>
|
||||
</div>
|
||||
<div class="field" style="margin: 0;">
|
||||
<div class="field" style="margin: 0; flex: 1 1 130px;">
|
||||
<label>规格型号</label>
|
||||
<input type="text" class="input material-spec" placeholder="规格型号" value="${materialSpec}" />
|
||||
</div>
|
||||
<div class="field" style="margin: 0; flex: 1 1 130px;">
|
||||
<label>机型简称</label>
|
||||
<input type="text" class="input material-model" placeholder="机型简称" value="${modelName}" />
|
||||
</div>
|
||||
<div class="field" style="margin: 0; flex: 1 1 100px;">
|
||||
<label>数量 <span style="color: var(--danger);">*</span></label>
|
||||
<input type="number" class="input material-quantity" placeholder="数量" value="${quantity}" min="1" required />
|
||||
</div>
|
||||
<div class="field" style="margin: 0;">
|
||||
<div class="field" style="margin: 0; flex: 1 1 100px;">
|
||||
<label>单价 <span style="color: var(--danger);">*</span></label>
|
||||
<input type="number" class="input material-price" placeholder="单价" value="${unitPrice}" step="0.01" min="0" required />
|
||||
</div>
|
||||
@ -445,7 +457,7 @@
|
||||
document.getElementById('customer-name').value = order.customer_name || '';
|
||||
|
||||
// 添加物料信息
|
||||
addMaterialRow(order.material || '', order.quantity || '', order.unit_price || '');
|
||||
addMaterialRow((order.material || '').replace(/\n/g, ' '), order.quantity || '', order.unit_price || '', order.material_spec || '', order.model_name || '');
|
||||
} else {
|
||||
// 新增模式
|
||||
title.textContent = '新增订单';
|
||||
@ -497,6 +509,8 @@
|
||||
|
||||
for (const row of materialRows) {
|
||||
const materialName = row.querySelector('.material-name').value.trim();
|
||||
const materialSpec = row.querySelector('.material-spec').value.trim();
|
||||
const materialModel = row.querySelector('.material-model').value.trim();
|
||||
const quantity = parseInt(row.querySelector('.material-quantity').value);
|
||||
const unitPrice = parseFloat(row.querySelector('.material-price').value);
|
||||
|
||||
@ -517,6 +531,8 @@
|
||||
|
||||
materials.push({
|
||||
material: materialName,
|
||||
material_spec: materialSpec,
|
||||
model_name: materialModel,
|
||||
quantity: quantity,
|
||||
unit_price: unitPrice
|
||||
});
|
||||
@ -579,6 +595,8 @@
|
||||
order_no: orderNo,
|
||||
customer_name: customerName,
|
||||
material: mat.material,
|
||||
material_spec: mat.material_spec,
|
||||
model_name: mat.model_name,
|
||||
quantity: mat.quantity,
|
||||
unit_price: mat.unit_price
|
||||
})
|
||||
@ -605,6 +623,8 @@
|
||||
order_no: orderNo,
|
||||
customer_name: customerName,
|
||||
material: mat.material,
|
||||
material_spec: mat.material_spec,
|
||||
model_name: mat.model_name,
|
||||
quantity: mat.quantity,
|
||||
unit_price: mat.unit_price
|
||||
})
|
||||
|
||||
@ -295,6 +295,14 @@ def init_db():
|
||||
c.execute('ALTER TABLE customer_orders ADD COLUMN manual_undelivered_qty INTEGER')
|
||||
except Exception:
|
||||
pass # 列已存在
|
||||
try:
|
||||
c.execute('ALTER TABLE customer_orders ADD COLUMN material_spec TEXT')
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
c.execute('ALTER TABLE customer_orders ADD COLUMN model_name TEXT')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# BOM物料清单表 - 定义产品的物料组成
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS bom(
|
||||
@ -5446,7 +5454,7 @@ def get_customer_orders():
|
||||
"""获取客户订单列表,包含未交订单数量"""
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
c.execute('''SELECT id, order_date, order_no, customer_name, material, quantity, unit_price,
|
||||
c.execute('''SELECT id, order_date, order_no, customer_name, material, material_spec, model_name, quantity, unit_price,
|
||||
manual_undelivered_qty, created_by, created_at, updated_at
|
||||
FROM customer_orders
|
||||
ORDER BY order_date DESC, id DESC''')
|
||||
@ -5506,6 +5514,8 @@ def get_customer_orders():
|
||||
'order_no': row['order_no'],
|
||||
'customer_name': row['customer_name'] if 'customer_name' in row.keys() else '',
|
||||
'material': row['material'],
|
||||
'material_spec': row['material_spec'] if 'material_spec' in row.keys() else '',
|
||||
'model_name': row['model_name'] if 'model_name' in row.keys() else '',
|
||||
'quantity': row['quantity'],
|
||||
'unit_price': row['unit_price'],
|
||||
'shipped_qty': shipped_qty,
|
||||
@ -5550,11 +5560,14 @@ def create_customer_order():
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
|
||||
material_spec = data.get('material_spec', '').strip()
|
||||
model_name = data.get('model_name', '').strip()
|
||||
|
||||
c.execute('''INSERT INTO customer_orders(
|
||||
order_date, order_no, customer_name, material, quantity, unit_price,
|
||||
order_date, order_no, customer_name, material, material_spec, model_name, quantity, unit_price,
|
||||
created_by, created_at, updated_at
|
||||
) VALUES(?,?,?,?,?,?,?,?,?)''', (
|
||||
order_date, order_no, customer_name, material, quantity, unit_price,
|
||||
) VALUES(?,?,?,?,?,?,?,?,?,?,?)''', (
|
||||
order_date, order_no, customer_name, material, material_spec, model_name, quantity, unit_price,
|
||||
username, now, now
|
||||
))
|
||||
|
||||
@ -5578,6 +5591,8 @@ def update_customer_order(order_id):
|
||||
order_no = data.get('order_no', '').strip()
|
||||
customer_name = data.get('customer_name', '').strip()
|
||||
material = data.get('material', '').strip().replace(' ', '\n') # 空格转换行
|
||||
material_spec = data.get('material_spec', '').strip()
|
||||
model_name = data.get('model_name', '').strip()
|
||||
quantity = data.get('quantity')
|
||||
unit_price = data.get('unit_price')
|
||||
|
||||
@ -5609,10 +5624,10 @@ def update_customer_order(order_id):
|
||||
now = get_beijing_time()
|
||||
c.execute('''UPDATE customer_orders
|
||||
SET order_date=?, order_no=?, customer_name=?, material=?,
|
||||
quantity=?, unit_price=?, updated_at=?
|
||||
material_spec=?, model_name=?, quantity=?, unit_price=?, updated_at=?
|
||||
WHERE id=?''',
|
||||
(order_date, order_no, customer_name, material, quantity, unit_price,
|
||||
now, order_id))
|
||||
(order_date, order_no, customer_name, material, material_spec, model_name,
|
||||
quantity, unit_price, now, order_id))
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user