1. 新增帳號寄送信件
2. 點圖放大 part1 3. 運維作業記錄 日期範圍
This commit is contained in:
parent
fce9de630a
commit
886e1aa450
@ -144,7 +144,7 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
UpdatePassword update = new UpdatePassword()
|
UpdatePassword update = new UpdatePassword()
|
||||||
{
|
{
|
||||||
Password = edFunction.GetSHA256Encryption(newPassword),
|
Password = newPassword,
|
||||||
UpdatedBy = user.Id,
|
UpdatedBy = user.Id,
|
||||||
Id = user.Id
|
Id = user.Id
|
||||||
};
|
};
|
||||||
|
|||||||
@ -334,11 +334,6 @@ namespace SolarPower.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
//if (!IsPlatformLayer(myUser.Role.Layer))
|
|
||||||
//{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料
|
|
||||||
// post.SelectedCompanyId = myUser.CompanyId;
|
|
||||||
//}
|
|
||||||
|
|
||||||
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
||||||
|
|
||||||
foreach (var recode in recodes)
|
foreach (var recode in recodes)
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using SolarPower.Models;
|
using SolarPower.Models;
|
||||||
using SolarPower.Models.User;
|
using SolarPower.Models.User;
|
||||||
using SolarPower.Repository.Interface;
|
using SolarPower.Repository.Interface;
|
||||||
|
using SolarPower.Services.Interface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -20,10 +21,13 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IUserRepository userRepository;
|
private readonly IUserRepository userRepository;
|
||||||
|
private readonly ISendEmailService sendEmailService;
|
||||||
private string logoPath = "/upload/company_logo/";
|
private string logoPath = "/upload/company_logo/";
|
||||||
public UserController(IUserRepository userRepository) : base()
|
public UserController(IUserRepository userRepository,
|
||||||
|
ISendEmailService sendEmailService) : base()
|
||||||
{
|
{
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
|
this.sendEmailService = sendEmailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -299,8 +303,7 @@ namespace SolarPower.Controllers
|
|||||||
const string chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
|
const string chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
|
||||||
string random_password = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(chars.Length)]).ToArray());
|
string random_password = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(chars.Length)]).ToArray());
|
||||||
|
|
||||||
//TODO 新增的密碼要寄信
|
var newPassword = edFunction.GetSHA256Encryption(random_password);
|
||||||
random_password = edFunction.GetSHA256Encryption(random_password);
|
|
||||||
|
|
||||||
user = new User()
|
user = new User()
|
||||||
{
|
{
|
||||||
@ -308,7 +311,7 @@ namespace SolarPower.Controllers
|
|||||||
Name = post.Name,
|
Name = post.Name,
|
||||||
Email = post.Email,
|
Email = post.Email,
|
||||||
Account = post.Account,
|
Account = post.Account,
|
||||||
Password = random_password,
|
Password = newPassword,
|
||||||
RoleId = post.RoleId,
|
RoleId = post.RoleId,
|
||||||
Phone = post.Phone,
|
Phone = post.Phone,
|
||||||
CreatedBy = myUser.Id,
|
CreatedBy = myUser.Id,
|
||||||
@ -328,6 +331,16 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
await userRepository.AddAsync(user, properties);
|
await userRepository.AddAsync(user, properties);
|
||||||
|
|
||||||
|
var sendSubject = "新增帳號成功";
|
||||||
|
var sendContent = $"您的新密碼為:{random_password}";
|
||||||
|
|
||||||
|
List<string> recipientEmails = new List<string>()
|
||||||
|
{
|
||||||
|
user.Email
|
||||||
|
};
|
||||||
|
|
||||||
|
sendEmailService.Send(recipientEmails, sendSubject, sendContent);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -212,6 +212,8 @@ namespace SolarPower.Models
|
|||||||
public List<int> PowerStationIds { get; set; } //電站編號
|
public List<int> PowerStationIds { get; set; } //電站編號
|
||||||
public byte WorkType { get; set; } //工作項目
|
public byte WorkType { get; set; } //工作項目
|
||||||
public string Range { get; set; } //取得搜尋範圍
|
public string Range { get; set; } //取得搜尋範圍
|
||||||
|
public string StartTime { get; set; } //起始日期
|
||||||
|
public string EndTime { get; set; } //結束日期
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -58,12 +58,12 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id,int Type)
|
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id, int Type)
|
||||||
{
|
{
|
||||||
List<OperationPlanTable> result;
|
List<OperationPlanTable> result;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
string Wheresql = "oc.PowerStationId = ";
|
string Wheresql = "oc.PowerStationId = ";
|
||||||
if( id.Count > 0 )
|
if (id.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (int too in id)
|
foreach (int too in id)
|
||||||
{
|
{
|
||||||
@ -78,13 +78,13 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Wheresql += "0";
|
Wheresql += "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -106,7 +106,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
ON oc.PowerStationId = ps.Id LEFT JOIN user us
|
ON oc.PowerStationId = ps.Id LEFT JOIN user us
|
||||||
ON us.Id = oc.CreatedBy WHERE ({Wheresql}) AND oc.Deleted = 0";
|
ON us.Id = oc.CreatedBy WHERE ({Wheresql}) AND oc.Deleted = 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result = (await conn.QueryAsync<OperationPlanTable>(sql)).ToList();
|
result = (await conn.QueryAsync<OperationPlanTable>(sql)).ToList();
|
||||||
}
|
}
|
||||||
@ -215,15 +215,19 @@ namespace SolarPower.Repository.Implement
|
|||||||
WHERE opr.Deleted = 0
|
WHERE opr.Deleted = 0
|
||||||
AND ps.Id IN @PowerStationIds";
|
AND ps.Id IN @PowerStationIds";
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(filter.Range))
|
||||||
|
{
|
||||||
|
filter.StartTime = filter.Range.Split('-')[0];
|
||||||
|
filter.EndTime = filter.Range.Split('-')[1];
|
||||||
|
|
||||||
|
sql += " AND opr.StartTime <= @EndDate";
|
||||||
|
sql += " AND opr.EndTime >= @StartDate";
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.WorkType > 0)
|
if (filter.WorkType > 0)
|
||||||
{
|
{
|
||||||
filter.WorkType -= 1;
|
filter.WorkType -= 1;
|
||||||
sql += @" AND opr.WorkType = @WorkType";
|
sql += @" AND opr.WorkType = @WorkType";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter.Range))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -239,9 +243,33 @@ namespace SolarPower.Repository.Implement
|
|||||||
WHERE opr.Deleted = 0
|
WHERE opr.Deleted = 0
|
||||||
AND ps.Id IN @PowerStationIds
|
AND ps.Id IN @PowerStationIds
|
||||||
AND opr.WorkType = 2";
|
AND opr.WorkType = 2";
|
||||||
|
if (!string.IsNullOrEmpty(filter.Range))
|
||||||
|
{
|
||||||
|
filter.StartTime = filter.Range.Split('-')[0];
|
||||||
|
filter.EndTime = filter.Range.Split('-')[1];
|
||||||
|
|
||||||
|
sql += " AND opr.StartTime <= @EndDate";
|
||||||
|
sql += " AND opr.EndTime >= @StartDate";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var today = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
|
var dateLimit = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd");
|
||||||
|
|
||||||
|
sql += $" AND opr.CreatedAt BETWEEN '{dateLimit} 00:00:00' AND '{today} 23:59:59'";
|
||||||
|
|
||||||
|
//sql += $" AND opr.StartTime <= {today}";
|
||||||
|
//sql += $" AND opr.EndTime >= {dateLimit}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql, filter)).ToList();
|
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql,
|
||||||
|
new {
|
||||||
|
PowerStationIds = filter.PowerStationIds,
|
||||||
|
WorkType = filter.WorkType,
|
||||||
|
StartDate = filter.StartTime,
|
||||||
|
EndDate = filter.EndTime
|
||||||
|
})).ToList();
|
||||||
|
|
||||||
var sql_file = "SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
var sql_file = "SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
||||||
foreach (var x in result)
|
foreach (var x in result)
|
||||||
@ -278,7 +306,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
result = await conn.QueryFirstOrDefaultAsync<OperationRecode>(sql, new { Id = id });
|
result = await conn.QueryFirstOrDefaultAsync<OperationRecode>(sql, new { Id = id });
|
||||||
|
|
||||||
if(result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
//取得圖片 or 檔案
|
//取得圖片 or 檔案
|
||||||
var sql_file = @"SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
var sql_file = @"SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
||||||
|
|||||||
@ -29,11 +29,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">近30天</button>
|
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeDate30()">近30天</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input class="form-control" id="example-date" type="text" name="date" value="2023-07-23">
|
<input class="form-control" id="date-range" type="text" name="date" value="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -241,6 +241,7 @@
|
|||||||
var Allids = new Array(0);//全部縣市
|
var Allids = new Array(0);//全部縣市
|
||||||
var Allpowerids = new Array(0);//全部電站
|
var Allpowerids = new Array(0);//全部電站
|
||||||
var Type = 0; // 項目
|
var Type = 0; // 項目
|
||||||
|
var datepicker;
|
||||||
|
|
||||||
//#region Array.Remove
|
//#region Array.Remove
|
||||||
Array.prototype.remove = function (val) {
|
Array.prototype.remove = function (val) {
|
||||||
@ -252,14 +253,28 @@
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$('input[id="example-date"]').daterangepicker({
|
//#region Date Picker
|
||||||
|
datepicker = $('#date-range').daterangepicker({
|
||||||
|
autoUpdateInput: false,
|
||||||
|
locale: { format: 'YYYY/MM/DD' },
|
||||||
opens: 'left'
|
opens: 'left'
|
||||||
}, function (start, end, label) {
|
}, function (start, end, label) {
|
||||||
console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
|
@*console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));*@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#date-range').on('apply.daterangepicker', function (ev, picker) {
|
||||||
|
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
|
||||||
|
$(this).trigger('change');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#date-range').on('cancel.daterangepicker', function (ev, picker) {
|
||||||
|
$(this).val('');
|
||||||
|
$(this).trigger('change');
|
||||||
|
});
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region 預設載入該使用者可以選擇的電站
|
//#region 預設載入該使用者可以選擇的電站
|
||||||
//#region 載入縣市
|
|
||||||
var Nurl = "/PowerStation/GetSolarCitySummary";
|
var Nurl = "/PowerStation/GetSolarCitySummary";
|
||||||
$.post(Nurl, function (rel) {
|
$.post(Nurl, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
@ -306,7 +321,6 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
//#endregion
|
//#endregion
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region 切換電站時,載入該電站運維人員
|
//#region 切換電站時,載入該電站運維人員
|
||||||
$("#power_station_select_modal").change(function () {
|
$("#power_station_select_modal").change(function () {
|
||||||
@ -417,7 +431,7 @@
|
|||||||
"data": function (d) {
|
"data": function (d) {
|
||||||
d.PowerStationIds = powerids;
|
d.PowerStationIds = powerids;
|
||||||
d.WorkType = Type;
|
d.WorkType = Type;
|
||||||
d.Range = $('#company_taxIDNumber').val();
|
d.Range = $('#date-range').val();
|
||||||
},
|
},
|
||||||
"dataSrc": function (rel) {
|
"dataSrc": function (rel) {
|
||||||
if (rel.data.code == "9999") {
|
if (rel.data.code == "9999") {
|
||||||
@ -453,6 +467,12 @@
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 改變日期
|
||||||
|
$('#date-range').on('change', function () {
|
||||||
|
operationRecodeTable.ajax.reload();
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region 新增維修單
|
//#region 新增維修單
|
||||||
function AddRecode() {
|
function AddRecode() {
|
||||||
selected_id = 0;
|
selected_id = 0;
|
||||||
@ -852,5 +872,21 @@
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 查詢近30天
|
||||||
|
function ChangeDate30() {
|
||||||
|
var today = new Date();
|
||||||
|
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
|
||||||
|
|
||||||
|
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
|
||||||
|
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
|
||||||
|
|
||||||
|
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
|
||||||
|
datepicker.data('daterangepicker').setEndDate(today_format);
|
||||||
|
|
||||||
|
$('#date-range').val(dateLimit_format + ' - ' + today_format);
|
||||||
|
$('#date-range').trigger('change');
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
@ -436,7 +436,7 @@
|
|||||||
powerStationSingleLineCard = $("#power-station-image-card > .row");
|
powerStationSingleLineCard = $("#power-station-image-card > .row");
|
||||||
powerStationSingleLineCard.empty();
|
powerStationSingleLineCard.empty();
|
||||||
rel.data.forEach(function (value, index) {
|
rel.data.forEach(function (value, index) {
|
||||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
CreatePowerStationImageBox(powerStationSingleLineCard, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
}, 'json');
|
}, 'json');
|
||||||
@ -1794,7 +1794,7 @@
|
|||||||
function CreatePowerStationImageBox(dom, value) {
|
function CreatePowerStationImageBox(dom, value) {
|
||||||
var str = '<div class="col-xl">' +
|
var str = '<div class="col-xl">' +
|
||||||
'<div class="card border m-auto m-lg-0" style="padding: 9.5px;">' +
|
'<div class="card border m-auto m-lg-0" style="padding: 9.5px;">' +
|
||||||
'<img src="' + value.image + '" class="card-img-top" alt="...">' +
|
'<img src="' + value.image + '" class="card-img-top img-zoom" alt="...">' +
|
||||||
'<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right del-power-station-image-btn" data-id="' + value.id + '">' +
|
'<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right del-power-station-image-btn" data-id="' + value.id + '">' +
|
||||||
'<i class="fal fa-times"></i>' +
|
'<i class="fal fa-times"></i>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body" id="power-station-image-card">
|
<div class="card-body">
|
||||||
<div class="w-100">
|
<div class="w-100">
|
||||||
<table id="Inverter_table" class="table table-bordered table-hover m-0 text-center">
|
<table id="Inverter_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
@ -66,7 +66,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body" id="power-station-image-card">
|
<div class="card-body">
|
||||||
<div class="w-100">
|
<div class="w-100">
|
||||||
<table id="Device_table" class="table table-bordered table-hover m-0 text-center">
|
<table id="Device_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
@ -101,7 +101,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body" id="power-station-image-card">
|
<div class="card-body">
|
||||||
<div class="w-100">
|
<div class="w-100">
|
||||||
<table id="ShareDevice_table" class="table table-bordered table-hover m-0 text-center">
|
<table id="ShareDevice_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body" id="power-station-image-card">
|
<div class="card-body" id="power-station-image-card">
|
||||||
<div class="row d-flex justify-content-between">
|
<div class="row d-flex justify-content-between img-zoom-div">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1094,6 +1094,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.變更密碼 -->
|
<!-- /.變更密碼 -->
|
||||||
|
<!-- Image Zoom Outer Div -->
|
||||||
|
<div id="img-zoom-outer-div" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:9999;width:100%;height:100%;display:none;">
|
||||||
|
<div id="innerdiv" style="position:absolute;">
|
||||||
|
<img id="bigimg" style="border:5px solid #fff;" src="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--Base JS-->
|
<!--Base JS-->
|
||||||
<script src="~/js/vendors.bundle.js"></script>
|
<script src="~/js/vendors.bundle.js"></script>
|
||||||
<script src="~/js/app.bundle.js"></script>
|
<script src="~/js/app.bundle.js"></script>
|
||||||
@ -1116,11 +1123,11 @@
|
|||||||
<script src="~/js/jquery.table2excel.min.js"></script>
|
<script src="~/js/jquery.table2excel.min.js"></script>
|
||||||
<!-- Custome JS -->
|
<!-- Custome JS -->
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
<script src="~/js/image.zoom.js" asp-append-version="true"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
|
||||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
|
||||||
<!--<script src="~/js/daterangepicker.js"></script>-->
|
<!--<script src="~/js/daterangepicker.js"></script>-->
|
||||||
|
|
||||||
@*各頁面的JavaScript*@
|
@*各頁面的JavaScript*@
|
||||||
@RenderSection("Scripts", required: false)
|
@RenderSection("Scripts", required: false)
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
49
SolarPower/wwwroot/js/image.zoom.js
Normal file
49
SolarPower/wwwroot/js/image.zoom.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".img-zoom-div").on("click", "img.img-zoom", function () {
|
||||||
|
var _this = $(this);//將當前的pimg元素作為_this傳入函式
|
||||||
|
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
|
||||||
|
});
|
||||||
|
|
||||||
|
function imgShow(outerdiv, innerdiv, bigimg, _this) {
|
||||||
|
var src = _this.attr("src");//獲取當前點選的pimg元素中的src屬性
|
||||||
|
$(bigimg).attr("src", src);//設定#bigimg元素的src屬性
|
||||||
|
|
||||||
|
/*獲取當前點選圖片的真實大小,並顯示彈出層及大圖*/
|
||||||
|
$(_this).attr("src", src).on("load", function () {
|
||||||
|
var windowW = $(window).width();//獲取當前視窗寬度
|
||||||
|
var windowH = $(window).height();//獲取當前視窗高度
|
||||||
|
var realWidth = this.width;//獲取圖片真實寬度
|
||||||
|
var realHeight = this.height;//獲取圖片真實高度
|
||||||
|
var imgWidth, imgHeight;
|
||||||
|
//var scale = 0.8;//縮放尺寸,當圖片真實寬度和高度大於視窗寬度和高度時進行縮放
|
||||||
|
|
||||||
|
var scale = 1440 / realWidth; //放大圖片到1440p
|
||||||
|
|
||||||
|
if (realHeight > windowH * scale) {//判斷圖片高度
|
||||||
|
imgHeight = windowH * scale;//如大於視窗高度,圖片高度進行縮放
|
||||||
|
imgWidth = imgHeight / realHeight * realWidth;//等比例縮放寬度
|
||||||
|
if (imgWidth > windowW * scale) {//如寬度扔大於視窗寬度
|
||||||
|
imgWidth = windowW * scale;//再對寬度進行縮放
|
||||||
|
}
|
||||||
|
} else if (realWidth > windowW * scale) {//如圖片高度合適,判斷圖片寬度
|
||||||
|
imgWidth = windowW * scale;//如大於視窗寬度,圖片寬度進行縮放
|
||||||
|
imgHeight = imgWidth / realWidth * realHeight;//等比例縮放高度
|
||||||
|
} else {//如果圖片真實高度和寬度都符合要求,高寬不變
|
||||||
|
imgWidth = realWidth;
|
||||||
|
imgHeight = realHeight;
|
||||||
|
}
|
||||||
|
$(bigimg).css("width", imgWidth);//以最終的寬度對圖片縮放
|
||||||
|
|
||||||
|
var w = (windowW - imgWidth) / 2;//計算圖片與視窗左邊距
|
||||||
|
var h = (windowH - imgHeight) / 2;//計算圖片與視窗上邊距
|
||||||
|
$(innerdiv).css({ "top": h, "left": w });//設定#innerdiv的top和left屬性
|
||||||
|
$(outerdiv).fadeIn("fast");//淡入顯示#outerdiv及.pimg
|
||||||
|
});
|
||||||
|
|
||||||
|
$(outerdiv).click(function () {//再次點選淡出消失彈出層
|
||||||
|
$(this).fadeOut("fast");
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user