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