增加常用名稱驗證|取消 jquery popper 引用 會導致require出錯
This commit is contained in:
parent
a5334662cf
commit
1389533087
@ -173,6 +173,7 @@
|
||||
name="favoriteName"
|
||||
placeholder="名稱"
|
||||
/>
|
||||
<small class="input_error_text text-danger"></small>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -194,12 +195,6 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js"
|
||||
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
|
||||
<script>
|
||||
var historyTable2 = null;
|
||||
var buildingTag = null;
|
||||
@ -281,7 +276,6 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function showDeviceList(data) {
|
||||
temp_device_list = data;
|
||||
let strHtml = "";
|
||||
@ -332,47 +326,51 @@
|
||||
$(`[data-toggle="collapse"]`).first().click();
|
||||
}
|
||||
|
||||
document.querySelector("#js_nested_list_filter").addEventListener("keyup",(e)=>{
|
||||
|
||||
document
|
||||
.querySelector("#js_nested_list_filter")
|
||||
.addEventListener("keyup", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
let searchDev = [];
|
||||
device_list.forEach((d) => {
|
||||
const devs = d.device_list.filter(({device_name})=>device_name.includes(e.target.value))
|
||||
const devs = d.device_list.filter(({ device_name }) =>
|
||||
device_name.includes(e.target.value)
|
||||
);
|
||||
if (devs.length > 0) {
|
||||
searchDev = [...searchDev, {
|
||||
searchDev = [
|
||||
...searchDev,
|
||||
{
|
||||
...d,
|
||||
device_list: devs
|
||||
}];
|
||||
device_list: devs,
|
||||
},
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
showDeviceList(searchDev)
|
||||
showDeviceList(searchDev);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function selectAllBuildingDevice(e) {
|
||||
let curData=[], curBuisDev=[], checkBui=[];
|
||||
let curData = [],
|
||||
curBuisDev = [],
|
||||
checkBui = [];
|
||||
if (e.target.name === "bui_selected") {
|
||||
if (e.target.dataset.building == "all") {
|
||||
temp_device_list.forEach(({ device_list }) => {
|
||||
curData = [...curData, ...device_list];
|
||||
});
|
||||
curBuisDev = curData.map(
|
||||
({ device_number }) => device_number
|
||||
);
|
||||
curBuisDev = curData.map(({ device_number }) => device_number);
|
||||
if (e.target.checked) {
|
||||
checkBui = temp_device_list.map(({ device_list, building_tag }) => ({
|
||||
building_tag,
|
||||
builing_check:true
|
||||
builing_check: true,
|
||||
}));
|
||||
} else {
|
||||
|
||||
checkBui = temp_device_list.map(({ device_list, building_tag }) => ({
|
||||
building_tag,
|
||||
builing_check:false
|
||||
builing_check: false,
|
||||
}));
|
||||
}
|
||||
|
||||
} else {
|
||||
curData = temp_device_list.find(
|
||||
({ building_tag }) => e.target.dataset.building === building_tag
|
||||
@ -430,10 +428,9 @@
|
||||
e.stopPropagation();
|
||||
}
|
||||
function success(res) {
|
||||
|
||||
device_list = res.data;
|
||||
temp_device_list = res.data;
|
||||
showDeviceList(res.data)
|
||||
showDeviceList(res.data);
|
||||
$(`[name="Device_list"]`).first().click();
|
||||
devPointsList();
|
||||
}
|
||||
@ -676,7 +673,6 @@
|
||||
var editGuid = "";
|
||||
var favorite_setting = [];
|
||||
function openModal(favorite_guid) {
|
||||
console.log(favorite_guid);
|
||||
editGuid = "";
|
||||
if (favorite_guid) {
|
||||
$("#favoriteName").val(
|
||||
@ -689,10 +685,12 @@
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
$("#favoriteName").val("");
|
||||
$("#favoriteModal").modal("hide");
|
||||
}
|
||||
|
||||
async function addFavorite() {
|
||||
$(".input_error_text").text("");
|
||||
let token = cookies.get("JWT-Authorization");
|
||||
const form = $("#device_list_form")[0];
|
||||
const formData = new FormData(form);
|
||||
@ -700,25 +698,36 @@
|
||||
|
||||
const favoriteForm = $("#favoriteForm")[0];
|
||||
const favoriteFormData = new FormData(favoriteForm);
|
||||
const favorite_name = favoriteFormData.get("favoriteName");
|
||||
|
||||
const json = await fetch(baseApiUrl + "/api/History/SaveHistoryFavorite", {
|
||||
if (favorite_name) {
|
||||
const json = await fetch(
|
||||
baseApiUrl + "/api/History/SaveHistoryFavorite",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
favorite_name: favoriteFormData.get("favoriteName"),
|
||||
favorite_name,
|
||||
device_name_tag: $("[name=subRadio]:checked").val(),
|
||||
Type: pageAct.dateType,
|
||||
Points: pageAct.devicePoiName,
|
||||
Device_list,
|
||||
}),
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const res = await json.json();
|
||||
if (res && res.code == "0000") {
|
||||
getFavorite();
|
||||
closeModal();
|
||||
} else {
|
||||
toast_error(res.msg || common.SysErr);
|
||||
}
|
||||
} else {
|
||||
$(".input_error_text").text("請輸入名稱");
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,21 +735,32 @@
|
||||
let token = cookies.get("JWT-Authorization");
|
||||
const favoriteForm = $("#favoriteForm")[0];
|
||||
const favoriteFormData = new FormData(favoriteForm);
|
||||
const favorite_name = favoriteFormData.get("favoriteName");
|
||||
|
||||
const json = await fetch(baseApiUrl + "/api/History/EditHistoryFavorite", {
|
||||
if (favorite_name) {
|
||||
const json = await fetch(
|
||||
baseApiUrl + "/api/History/EditHistoryFavorite",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
favorite_name: favoriteFormData.get("favoriteName"),
|
||||
favorite_name,
|
||||
favorite_guid,
|
||||
}),
|
||||
});
|
||||
}
|
||||
);
|
||||
const res = await json.json();
|
||||
if (res && res.code == "0000") {
|
||||
getFavorite();
|
||||
closeModal();
|
||||
} else {
|
||||
toast_error(res.msg || common.SysErr);
|
||||
}
|
||||
} else {
|
||||
$(".input_error_text").text("請輸入名稱");
|
||||
}
|
||||
}
|
||||
|
||||
@ -772,7 +792,6 @@
|
||||
} else {
|
||||
addFavorite();
|
||||
}
|
||||
closeModal();
|
||||
}
|
||||
|
||||
document
|
||||
|
Loading…
Reference in New Issue
Block a user