feat: 建立顺运宝采购处理状态 (#67)
This commit is contained in:
+31
-21
@@ -203,33 +203,43 @@
|
||||
var slot = modal.querySelector("[data-detail-slot]");
|
||||
var base = modal.getAttribute("data-detail-url") || "";
|
||||
|
||||
function loadDetail(id) {
|
||||
slot.innerHTML = "<div class='modal-body'>正在加载…</div>";
|
||||
openModal(modal);
|
||||
|
||||
var separator = base.indexOf("?") === -1 ? "?" : "&";
|
||||
fetch(base + separator + "id=" + encodeURIComponent(id), {
|
||||
headers: { "X-Requested-With": "fetch" }
|
||||
})
|
||||
.then(function (resp) {
|
||||
if (!resp.ok) throw new Error("HTTP " + resp.status);
|
||||
return resp.text();
|
||||
})
|
||||
.then(function (html) {
|
||||
slot.innerHTML = html;
|
||||
})
|
||||
.catch(function (err) {
|
||||
/* 出错也要说清楚,不能让弹窗一直停在"正在加载…" */
|
||||
slot.innerHTML =
|
||||
"<div class='modal-body'><p class='missing'>打不开详情:" +
|
||||
err.message +
|
||||
"。刷新页面后重试。</p></div>" +
|
||||
"<div class='modal-foot'><button type='button' data-modal-close>关闭</button></div>";
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll("tr[data-detail-id]").forEach(function (row) {
|
||||
row.addEventListener("dblclick", function (e) {
|
||||
/* 双击到勾选框或链接上时不要弹窗,那是另一个动作 */
|
||||
if (e.target.closest("input, a, button")) return;
|
||||
|
||||
slot.innerHTML = "<div class='modal-body'>正在加载…</div>";
|
||||
openModal(modal);
|
||||
loadDetail(row.getAttribute("data-detail-id"));
|
||||
});
|
||||
});
|
||||
|
||||
var separator = base.indexOf("?") === -1 ? "?" : "&";
|
||||
fetch(base + separator + "id=" + encodeURIComponent(row.getAttribute("data-detail-id")), {
|
||||
headers: { "X-Requested-With": "fetch" }
|
||||
})
|
||||
.then(function (resp) {
|
||||
if (!resp.ok) throw new Error("HTTP " + resp.status);
|
||||
return resp.text();
|
||||
})
|
||||
.then(function (html) {
|
||||
slot.innerHTML = html;
|
||||
})
|
||||
.catch(function (err) {
|
||||
/* 出错也要说清楚,不能让弹窗一直停在"正在加载…" */
|
||||
slot.innerHTML =
|
||||
"<div class='modal-body'><p class='missing'>打不开详情:" +
|
||||
err.message +
|
||||
"。刷新页面后重试。</p></div>" +
|
||||
"<div class='modal-foot'><button type='button' data-modal-close>关闭</button></div>";
|
||||
});
|
||||
document.querySelectorAll("[data-detail-open-id]").forEach(function (button) {
|
||||
button.addEventListener("click", function () {
|
||||
loadDetail(button.getAttribute("data-detail-open-id"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user