diff --git a/iframe/export.html b/iframe/export.html
index b92dc8d..6540536 100644
--- a/iframe/export.html
+++ b/iframe/export.html
@@ -267,7 +267,8 @@
let detail = { name: '-', value: '-', footprint: '-', brand: '-', designatorStr: '手动添加', selected: false };
if (devs[0]) {
- const infoRes = await eda.sys_ClientUrl.request('https://client/api/v2/devices/' + devs[0].uuid, 'GET', null, {
+ const EDA_HOST = eda.sys_Environment.isClient() ? 'https://client' : 'https://pro.lceda.cn';
+ const infoRes = await eda.sys_ClientUrl.request(EDA_HOST + '/api/v2/devices/' + devs[0].uuid, 'GET', null, {
headers: { path: '0819f05c4eef4c71ace90d822a990e87' },
});
const info = (await infoRes.json()).result;
@@ -295,8 +296,8 @@
return eda.sys_Message.showToastMessage('请先勾选要出库的器件', ESYS_ToastMessageType.WARNING);
}
- const SERVER = (await eda.sys_Storage.getExtensionUserConfig('server-host')) || 'http://localhost:21816';
- const AUTO_RUN = (await eda.sys_Storage.getExtensionUserConfig('server-auto-run')) || true;
+ const SERVER = (await eda.sys_Storage.getExtensionUserConfig('server-host')) ?? 'http://localhost:21816';
+ const AUTO_RUN = (await eda.sys_Storage.getExtensionUserConfig('server-auto-run')) ?? true;
let successCount = 0;
let failItems = [];
diff --git a/iframe/import.html b/iframe/import.html
index 213ecc6..c901cf9 100644
--- a/iframe/import.html
+++ b/iframe/import.html
@@ -1,142 +1,202 @@
-
-
-
- 器件入库 - LEYE
-
-
-
-
-
-
-
-
-
-
+
+
+
+
器件入库 - LEYE
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
- 待入库项:0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
扫码入库
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+ | 列表为空,请从上方导入数据 |
+
+
+
+
-
-
-
CID:
-
型号:
-
数量:
+
+
+
+
+
+
+
+
+
扫码入库
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+ };
+ });
+
+
diff --git a/iframe/newLeye.html b/iframe/newLeye.html
index b1050b8..46bf58a 100644
--- a/iframe/newLeye.html
+++ b/iframe/newLeye.html
@@ -1,268 +1,362 @@
-
-
-
-
查看库存 - LEYE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
未选择行
-
-
展示 0-0 / 共 0 条
-
-
- 1
-
-
+
+
+
+
查看库存 - LEYE
+
+
+
+
+
-
-
+
-
-
-
-
-
+
+
-
-
-
-
编辑器件信息
- ID: -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
0 →
0
+
+
未选择行
+
+
展示 0-0 / 共 0 条
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
编辑器件信息
+ ID: -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ opSubBtn.onclick = () => {
+ currentOp = 'sub';
+ opSubBtn.className = 'flex-1 py-1.5 border border-red-600 bg-red-50 text-red-600 rounded text-xs font-medium';
+ opAddBtn.className = 'flex-1 py-1.5 border border-gray-300 text-gray-600 rounded text-xs font-medium';
+ const change = parseInt(editQtyInput.value) || 0;
+ const current = parseInt(selectedRowData.quantity) || 0;
+ const target = currentOp === 'add' ? current + change : current - change;
+ targetQtySpan.textContent = target;
+ targetQtySpan.className = target < 0 ? 'text-red-500 font-bold' : 'text-blue-600 font-bold';
+ };
+
+ editQtyInput.oninput = () => {
+ const change = parseInt(editQtyInput.value) || 0;
+ const current = parseInt(selectedRowData.quantity) || 0;
+ const target = currentOp === 'add' ? current + change : current - change;
+ targetQtySpan.textContent = target;
+ targetQtySpan.className = target < 0 ? 'text-red-500 font-bold' : 'text-blue-600 font-bold';
+ };
+ dialogCancel.onclick = () => editDialog.classList.add('hidden');
+
+ dialogConfirm.onclick = async () => {
+ const newName = editNameInput.value.trim();
+ const newLcscId = editLcscInput.value.trim();
+ const changeQty = parseInt(editQtyInput.value) || 0;
+
+ if (!newName || !newLcscId) {
+ eda.sys_Message.showToastMessage('型号和 LCSC ID 不能为空', ESYS_ToastMessageType.ERROR);
+ return;
+ }
+
+ const newQuantity = currentOp === 'add' ? selectedRowData.quantity + changeQty : selectedRowData.quantity - changeQty;
+
+ dialogConfirm.disabled = true;
+ dialogConfirm.textContent = '正在保存...';
+
+ try {
+ const res = await eda.sys_ClientUrl.request(
+ SERVER + '/editLeyeList',
+ 'POST',
+ JSON.stringify({
+ id: selectedRowData.id,
+ name: newName,
+ lcscId: newLcscId,
+ quantity: newQuantity,
+ }),
+ { headers: { 'Content-Type': 'application/json' } },
+ );
+
+ const result = await res.json();
+
+ if (result.success) {
+ eda.sys_Message.showToastMessage('更新成功', ESYS_ToastMessageType.SUCCESS);
+
+ const deviceIndex = allDevicesData.findIndex((d) => d.id === selectedRowData.id);
+ if (deviceIndex !== -1) {
+ allDevicesData[deviceIndex].name = newName;
+ allDevicesData[deviceIndex].lcscId = newLcscId;
+ allDevicesData[deviceIndex].quantity = newQuantity;
+ selectedRowData = { ...allDevicesData[deviceIndex] };
+ }
+
+ await eda.sys_Storage.setExtensionUserConfig(CACHE_KEY, JSON.stringify(allDevicesData));
+
+ handleLocalSearch();
+ editDialog.classList.add('hidden');
+ } else {
+ throw new Error(result.message || '后端处理失败');
+ }
+ } catch (e) {
+ eda.sys_Message.showToastMessage('提交失败: ' + e.message, ESYS_ToastMessageType.ERROR);
+ } finally {
+ dialogConfirm.disabled = false;
+ dialogConfirm.textContent = '提交更改';
+ }
+ };
+
+ document.getElementById('cancel-btn').onclick = () => eda.sys_IFrame.closeIFrame('leye-main');
+
+ initInventoryData();
+ });
+
+