update 合約功能

master
嘉祥 詹 2024-03-27 16:52:04 +08:00
parent 633fa6d0b3
commit 43c817d0db
23 changed files with 502 additions and 44 deletions

View File

@ -16,8 +16,9 @@ using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Dapper.Contrib.Extensions;
using System.IO;
using System.IO.Compression;
using System.Threading;
using System.Dynamic;
using NPOI;
@ -36,6 +37,8 @@ using System.Runtime.InteropServices.ObjectiveC;
using static System.Net.WebRequestMethods;
using System.Diagnostics.Eventing.Reader;
using static Journeys_WantHome.Controllers.AuthApiController;
using SixLabors.ImageSharp.Memory;
using Org.BouncyCastle.Utilities;
namespace Journeys_WantHome.Controllers
@ -45,7 +48,7 @@ namespace Journeys_WantHome.Controllers
public class ApiController : ControllerBase
{
private readonly IHttpContextAccessor _httpContextAccessor;
DbConn dbConn = new DbConn();
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
SqlConnection elabConn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:ElabConnectionString"));
@ -56,6 +59,39 @@ namespace Journeys_WantHome.Controllers
this._httpContextAccessor = httpContextAccessor;
}
[HttpGet]
[Route("fileService")]
public ActionResult FileService(string uid) {
authToken token = new authToken(this._httpContextAccessor);
if (token.user_isLogin == false)
{
return Content("尚未登入!", "application/json;charset=utf-8");
}
kolfiles kolfile = conn.QueryFirstOrDefault<kolfiles>("select * from kolfiles where file_uid = @file_uid", new { file_uid = uid });
if (kolfile == null)
{
return Content("無此檔案!", "application/json;charset=utf-8");
}
//for testing purpose
string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot" + kolfile.file_path);
string fileName = System.Net.WebUtility.UrlEncode(kolfile.file_originName);
// Add Content-Disposition Header
string contentDisposition = $"attachment; filename={fileName}";
Response.Headers.Add(Microsoft.Net.Http.Headers.HeaderNames.ContentDisposition, contentDisposition);
// 讀取檔案內容
byte[] fileBytes = System.IO.File.ReadAllBytes(fullPath);
return File(fileBytes, kolfile.file_mimeType);
}
[Route("kolProjectList")]
public ActionResult KolProjectList(IFormCollection obj) {
kolProjectListResult ret = new kolProjectListResult();
@ -108,6 +144,7 @@ namespace Journeys_WantHome.Controllers
string kolProjectEvaluateStr = obj["kolProjectEvaluateStr"].ToString().TrimEnd(',');
string kolProjectLinkArrayJson = obj["kolProjectLinkArrayJson"].ToString().TrimEnd(',');
string kolProjectImageArrayJson = obj["kolProjectImageArrayJson"].ToString().TrimEnd(',');
string kolProjectFileArrayJson = obj["kolProjectFileArrayJson"].ToString().TrimEnd(',');
string kolProject_memo = obj["kolProject_memo"].ToString();
if (method == "del") {
@ -126,7 +163,9 @@ namespace Journeys_WantHome.Controllers
conn.Execute("delete kolProjectPrice where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProjectLink where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProjectImage where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProjectFile where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProject where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
ret.ret = "yes";
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
@ -263,6 +302,34 @@ namespace Journeys_WantHome.Controllers
kolProjectLinks.Add(kpl);
}
dynamic kolProjectFileJsonObj;
try {
kolProjectFileJsonObj = JsonConvert.DeserializeObject(kolProjectFileArrayJson);
}
catch (Exception ex)
{
ret.ret = "no";
ret.err_code = "0003";
ret.message = "kolProjectFile json error" + ex.Message;
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
}
List<kolProjectFile> kolProjectFiles = new List<kolProjectFile>();
foreach (dynamic item in kolProjectFileJsonObj)
{
kolProjectFile kpf = new kolProjectFile();
kpf.kolProjectFile_uid = "kpf_" + GlobalClass.CreateRandomCode(16);
kpf.kolProject_uid = kolProject_uid;
kpf.file_uid = item.file_uid;
kpf.kolProjectFile_path = item.kolProjectFile_path;
kpf.kolProjectFile_originFileName = item.kolProjectFile_originFileName;
kpf.kolProjectFile_createdate = DateTime.Now;
kolProjectFiles.Add(kpf);
}
dynamic kolProjectImageJsonObj;
try
@ -298,7 +365,7 @@ namespace Journeys_WantHome.Controllers
conn.Execute("delete kolProjectPrice where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProjectLink where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProjectImage where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Execute("delete kolProjectFile where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid });
conn.Insert(kolCooperateTypes);
@ -306,7 +373,7 @@ namespace Journeys_WantHome.Controllers
conn.Insert(kolProjectPrices);
conn.Insert(kolProjectLinks);
conn.Insert(kolProjectImages);
conn.Insert(kolProjectFiles);
ret.data.kolProject = kp;
@ -315,6 +382,7 @@ namespace Journeys_WantHome.Controllers
ret.data.kolProjectLinks = kolProjectLinks;
ret.data.kolProjectImages = kolProjectImages;
ret.data.kolCooperateTypes = kolCooperateTypes;
ret.data.kolProjectFiles = kolProjectFiles;
ret.data.project = conn.QueryFirst<project>("select * from project where project_uid = @project_uid ", new { project_uid = kp.project_uid });
ret.ret = "yes";
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
@ -368,6 +436,35 @@ namespace Journeys_WantHome.Controllers
}
}
dynamic kolProjectFileJsonObj;
try
{
kolProjectFileJsonObj = JsonConvert.DeserializeObject(kolProjectFileArrayJson);
}
catch (Exception ex)
{
ret.ret = "no";
ret.err_code = "0003";
ret.message = "kolProjectFile json error" + ex.Message;
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
}
List<kolProjectFile> kolProjectFiles = new List<kolProjectFile>();
foreach (dynamic item in kolProjectFileJsonObj)
{
kolProjectFile kpf = new kolProjectFile();
kpf.kolProjectFile_uid = "kpf_" + GlobalClass.CreateRandomCode(16);
kpf.kolProject_uid = kolProject_uid;
kpf.file_uid = item.file_uid;
kpf.kolProjectFile_path = item.kolProjectFile_path;
kpf.kolProjectFile_originFileName = item.kolProjectFile_originFileName;
kpf.kolProjectFile_createdate = DateTime.Now;
kolProjectFiles.Add(kpf);
}
dynamic kolProjectPriceJsonObj;
try
@ -460,7 +557,7 @@ namespace Journeys_WantHome.Controllers
conn.Insert(kolProjectPrices);
conn.Insert(kolProjectLinks);
conn.Insert(kolProjectImages);
conn.Insert(kolProjectFiles);
ret.data.kolProject = kp;
@ -469,6 +566,7 @@ namespace Journeys_WantHome.Controllers
ret.data.kolProjectLinks = kolProjectLinks;
ret.data.kolProjectImages = kolProjectImages;
ret.data.kolCooperateTypes = kolCooperateTypes;
ret.data.kolProjectFiles = kolProjectFiles;
ret.data.project = conn.QueryFirst<project>("select * from project where project_uid = @project_uid ", new { project_uid = kp.project_uid });
ret.ret = "yes";
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
@ -498,6 +596,96 @@ namespace Journeys_WantHome.Controllers
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
}
[Route("fileUpload")]
[RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue)]
[RequestSizeLimit(int.MaxValue)]
public ActionResult FileUpload([FromForm(Name = "uploadFile")] IFormFile file) {
authToken token = new authToken(this._httpContextAccessor);
if (token.user_isLogin == false)
{
List<errFile> files = new List<errFile>();
errFile newFile = new errFile();
newFile.name = "";
newFile.size = 0;
newFile.error = "尚未登入";
files.Add(newFile);
fileResult obj = new fileResult();
obj.files = files;
return Content(JsonConvert.SerializeObject(files), "application/json;charset=utf-8");
}
string originFileName = file.FileName;
string newFileName = "uid_" + GlobalClass.CreateRandomCode(16) + Path.GetExtension(originFileName);
string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/" + newFileName);
kolfiles objFile = new kolfiles();
objFile.file_uid = "f_" + GlobalClass.CreateRandomCode(22);
objFile.file_originName = originFileName;
objFile.file_path = "/files/" + newFileName;
objFile.file_mimeType = file.ContentType;
objFile.file_createdate = DateTime.Now;
try
{
using (var stream = new FileStream(fullPath, FileMode.Create))
{
file.CopyTo(stream);
}
conn.Insert<kolfiles>(objFile);
List<uploadFile> files = new List<uploadFile>();
uploadFile newFile = new uploadFile();
newFile.name = originFileName;
newFile.url = "/Api/fileService?uid=" + objFile.file_uid;
newFile.size = file.Length;
newFile.thumbnailUrl = "/Api/fileService?uid=" + objFile.file_uid;
newFile.deleteUrl = "/Api/fileService?uid=" + objFile.file_uid;
newFile.uid = objFile.file_uid;
files.Add(newFile);
fileResult obj = new fileResult();
obj.files = files;
return Content(JsonConvert.SerializeObject(obj), "application/json;charset=utf-8");
}
catch (Exception ex)
{
List<errFile> files = new List<errFile>();
errFile newFile = new errFile();
newFile.name = originFileName;
newFile.size = file.Length;
newFile.error = ex.Message;
files.Add(newFile);
fileResult obj = new fileResult();
obj.files = files;
return Content(JsonConvert.SerializeObject(files), "application/json;charset=utf-8");
}
}
[Route("subPhotoUpload")]
[RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue)]
[RequestSizeLimit(int.MaxValue)]
@ -1748,6 +1936,8 @@ namespace Journeys_WantHome.Controllers
public string name { get; set; } = "";
public long size { get; set; } = 0;
public string url { get; set; } = "";
public string uid { get; set; } = "";
public string thumbnailUrl { get; set; } = "";
public string deleteUrl { get; set; } = "";
public string deleteType { get; set; } = "DELETE";

View File

@ -42,6 +42,7 @@
<Folder Include="wwwroot\assets\vendor\toastr\tests\" />
<Folder Include="wwwroot\images\avatar\" />
<Folder Include="wwwroot\images\cut\" />
<Folder Include="wwwroot\files\" />
</ItemGroup>
<ItemGroup>

View File

@ -8,6 +8,35 @@ using Newtonsoft.Json.Linq;
public class DbTableClass
{
[Table("kolfiles")]
public class kolfiles
{
[JsonIgnore]
[Key]
public int file_sn { get; set; }
public string file_uid { get; set; } = "";
public string file_mimeType { get; set; } = "";
public string file_originName { get; set; } = "";
public string file_path { get; set; } = "";
public DateTime file_createdate { get; set; } = DateTime.Now;
}
[Table("kolProjectFile")]
public class kolProjectFile
{
[JsonIgnore]
[Key]
public int kolProjectFile_sn { get; set; }
public string kolProjectFile_uid { get; set; } = "";
public string kolProject_uid { get; set; } = "";
public string file_uid { get; set; } = "";
public string kolProjectFile_path { get; set; } = "";
public string kolProjectFile_originFileName { get; set; } = "";
public DateTime kolProjectFile_createdate { get; set; } = DateTime.Now;
}
[Table("kolProjectEvaluate")]
public class kolProjectEvaluate
{

View File

@ -15,6 +15,7 @@ public class kolProjectDetail
public List<kolProjectPriceDetail> kolProjectPrices = new List<kolProjectPriceDetail>();
public List<kolProjectEvaluate> kolProjectEvaluates = new List<kolProjectEvaluate>();
public List<kolCooperateType> kolCooperateTypes = new List<kolCooperateType>();
public List<kolProjectFile> kolProjectFiles = new List<kolProjectFile>();
public project project = new project();
public kolProjectDetail()
@ -30,6 +31,8 @@ public class kolProjectDetail
kolProjectPrices = conn.Query<kolProjectPriceDetail>("select * from kolProjectPriceDetail where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid }).ToList();
kolProjectEvaluates = conn.Query<kolProjectEvaluate>("select * from kolProjectEvaluate where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid }).ToList();
kolCooperateTypes = conn.Query<kolCooperateType>("select * from kolCooperateType where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid }).ToList();
kolProjectFiles = conn.Query<kolProjectFile>("select * from kolProjectFile where kolProject_uid = @kolProject_uid", new { kolProject_uid = kolProject_uid }).ToList();
project = conn.QueryFirst<project>("select * from project where project_uid = @project_uid ", new { project_uid = kolProject.project_uid });

View File

@ -517,6 +517,33 @@
</div><!-- /.form-group -->
<div class="card-footer">&nbsp;</div>
</div>
<div class="col-md-12" id="fileDiv" style="display: none;">
<h2 class="card-title"> 合約 </h2><!-- .table-responsive -->
<div class="table-responsive">
<table class="table table-hover" style="min-width: 678px" id="file_table">
<thead>
<tr>
<th> 檔名 </th>
<th style="display: none;" ></th>
<th style="width: 20%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle"> https://www.instagram.com/zamy_ding/ </td>
<td class="align-middle" style="display: none;"> </td>
<td class="align-middle text-right">
<button type="button" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>
</td>
</tr>
</tbody>
</table>
</div><!-- /.table-responsive -->
<!-- .card-footer -->
<div class="card-footer">
<a href="javascript: void();" id="addFileBtn" class="card-footer-item"><i class="fa fa-plus-circle mr-1"></i> 上傳合約</a>
</div><!-- /.card-footer -->
</div>
<div class="col-md-12" id="isCooperate_div">
<div class="form-group">
<h2 class="card-title">評價</h2>
@ -545,53 +572,53 @@
<div class="card-footer">&nbsp;</div>
</div>
<div class="col-md-12" id="isCooperate2_div">
<h2 class="card-title"> 上刊連結 </h2><!-- .table-responsive -->
<div class="table-responsive">
<table class="table table-hover" style="min-width: 678px" id="link_table">
<thead>
<tr>
<h2 class="card-title"> 上刊連結 </h2><!-- .table-responsive -->
<div class="table-responsive">
<table class="table table-hover" style="min-width: 678px" id="link_table">
<thead>
<tr>
<th> 連結 </th>
<th style="width: 20%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle"> https://www.instagram.com/zamy_ding/ </td>
<td class="align-middle text-right">
<button type="button" data-uid="" data-method="" class="btn btn-sm btn-icon btn-secondary" data-toggle="modal" data-target="#clientContactEditModal"><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button> <button type="button" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>
</td>
</tr>
</tbody>
</table>
</div><!-- /.table-responsive -->
<th> 連結 </th>
<th style="width: 20%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle"> https://www.instagram.com/zamy_ding/ </td>
<td class="align-middle text-right">
<button type="button" data-uid="" data-method="" class="btn btn-sm btn-icon btn-secondary" data-toggle="modal" data-target="#clientContactEditModal"><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button> <button type="button" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>
</td>
</tr>
</tbody>
</table>
</div><!-- /.table-responsive -->
<!-- .card-footer -->
<div class="card-footer">
<a href="javascript: void();" id="addLinkBtn" class="card-footer-item"><i class="fa fa-plus-circle mr-1"></i> 新增上刊連結</a>
</div><!-- /.card-footer -->
</div>
<div class="col-md-12" id="isCooperate3_div">
<h2 class="card-title"> 截圖 </h2><!-- .table-responsive -->
<div class="table-responsive">
<table class="table table-hover" style="min-width: 678px" id="cut_table">
<thead>
<tr>
<h2 class="card-title"> 截圖 </h2><!-- .table-responsive -->
<div class="table-responsive">
<table class="table table-hover" style="min-width: 678px" id="cut_table">
<thead>
<tr>
<th style ="width: 30%;"> 截圖 </th>
<th> 說明文字</th>
<th style="width: 20%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle"> https://www.instagram.com/zamy_ding/ </td>
<td class="align-middle text-right">
<button type="button" data-uid="" data-method="" class="btn btn-sm btn-icon btn-secondary" data-toggle="modal" data-target="#clientContactEditModal"><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button> <button type="button" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>
</td>
</tr>
</tbody>
</table>
</div><!-- /.table-responsive -->
<th style ="width: 30%;"> 截圖 </th>
<th> 說明文字</th>
<th style="width: 20%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle"> https://www.instagram.com/zamy_ding/ </td>
<td class="align-middle text-right">
<button type="button" data-uid="" data-method="" class="btn btn-sm btn-icon btn-secondary" data-toggle="modal" data-target="#clientContactEditModal"><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button> <button type="button" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>
</td>
</tr>
</tbody>
</table>
</div><!-- /.table-responsive -->
<!-- .card-footer -->
<div class="card-footer">
<a href="javascript: void();" id="addCutBtn" class="card-footer-item"><i class="fa fa-plus-circle mr-1"></i> 新增截圖</a>
@ -777,4 +804,52 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->
<!-- .modal -->
<form id="clientFileForm" name="clientFileForm">
<div class="modal fade" id="clientFileModal" tabindex="-1" role="dialog" aria-labelledby="clientFileModalLabel" data-backdrop="static" aria-hidden="true">
<!-- .modal-dialog -->
<div class="modal-dialog" role="document">
<!-- .modal-content -->
<div class="modal-content">
<!-- .modal-header -->
<div class="modal-header">
<h6 id="socialModalLabel" class="modal-title inline-editable">
<span class="sr-only">合約檔案</span> <input id="optionPhoto_name" type="text" class="form-control form-control-lg" value="" placeholder="合約檔案" readonly="readonly " required="">
</h6>
</div><!-- /.modal-header -->
<!-- .modal-body -->
<div class="modal-body">
<input type="hidden" id="file_method" />
<input type="hidden" id="file_uid" />
<input type="hidden" id="origin_fileName" />
<input type="hidden" id="upload_fileName" />
<div class="form-group">
<div class="card-body">
<!-- .media -->
<div class="media" >
<div class="user-avatar user-avatar-md fileinput-button" id="file_div">
<div class="fileinput-button-label"> 上傳 </div><img src="~/assets/images/upload-file.jpg" alt=""> <input id="fileupload-uploadFile" type="file" name="uploadFile">
</div>
</div><!-- /.media -->
<br></br>
<div>
<p class="card-text text-muted"> 最大容許檔案大小為 50MB. </p>
</div>
</div>
</div>
</div><!-- /.modal-body -->
<!-- .modal-footer -->
<div class="modal-footer">
<button type="button" id="clientFileSaveBtn" class="btn btn-primary">Save</button> <button type="button" class="btn btn-light" data-toggle="modal" data-target="#clientFileModal">Close</button>
</div><!-- /.modal-footer -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -27,6 +27,18 @@ $(document).ready(function () {
clearKolProjectTable();
initSubPhotoUpload();
loadSubDataTable();
initFileUpload();
$('input[type=radio][name=kolProject_isExec]').change(function () {
if (this.value == 'Y') {
// ...
$('#fileDiv').show();
}
else {
// ...
$('#fileDiv').hide();
}
});
$('#kolSaveBtn').on('click', function () {
var method = $('#method').val();
@ -274,6 +286,16 @@ $(document).ready(function () {
$('#clientCutPhotoModal').modal('toggle');
});
$('#addFileBtn').on('click', function () {
$('#fileupload-uploadFile').parent().children('img').prop('src', '/assets/images/upload-file.jpg');
$('#fileupload-uploadFile').parent().show();
$('#file_url').remove();
$('#file_method').val('add');
$('#clientFileModal').modal('toggle');
});
$('#kolProjectLink_url').on('change', function () {
if ($('#kolProjectLink_text').val() == '') {
$('#kolProjectLink_text').val($('#kolProjectLink_url').val()).trigger('change');
@ -295,6 +317,7 @@ $(document).ready(function () {
var kolProjectEvaluateStr = '';
var kolProjectLinkArray = [];
var kolProjectImageArray = [];
var kolProjectFileArray = [];
var kolProject_memo = $('#kolProject_memo').val();
if (kolProject_isExec == 'N') {
@ -332,6 +355,16 @@ $(document).ready(function () {
kolProjectLinkArray.push(item);
});
$('#file_table tbody tr').each(function () {
var item = {
file_uid: $(this).find('td').eq(2).text().trim(),
kolProjectFile_path: '/Api/fileService?uid=' + $(this).find('td').eq(2).text().trim(),
kolProjectFile_originFileName: $(this).find('td').eq(3).text().trim()
}
kolProjectFileArray.push(item);
});
$('#cut_table tbody tr').each(function () {
var tmpphoto_path = $(this).find('td').eq(0).find('img').prop('src').trim();
tmpphoto_path = tmpphoto_path.replace(origin, '');
@ -347,6 +380,7 @@ $(document).ready(function () {
var kolProjectPriceArrayJson = JSON.stringify(kolProjectPriceArray);
var kolProjectLinkArrayJson = JSON.stringify(kolProjectLinkArray);
var kolProjectImageArrayJson = JSON.stringify(kolProjectImageArray);
var kolProjectFileArrayJson = JSON.stringify(kolProjectFileArray);
var err_msg = "";
@ -378,6 +412,7 @@ $(document).ready(function () {
kolProjectEvaluateStr: kolProjectEvaluateStr,
kolProjectLinkArrayJson: kolProjectLinkArrayJson,
kolProjectImageArrayJson: kolProjectImageArrayJson,
kolProjectFileArrayJson: kolProjectFileArrayJson,
kolProject_memo: kolProject_memo
}
@ -413,6 +448,51 @@ $(document).ready(function () {
});
});
//合約儲存
$('#clientFileSaveBtn').on('click', function () {
var file_uid = $('#file_uid').val();
var file_originName = $('#origin_fileName').val();
var file_uploadName = $('#upload_fileName').val();
var src = $('#fileupload-uploadFile').parent().children('img').prop('src');
var origin = location.origin;
src = src.replace(origin, '');
sub_photo = src;
var err_msg = "";
if (src == '/assets/images/upload-file.jpg') {
err_msg += "請上傳合約!\n";
}
if (err_msg != "") {
alert(err_msg);
return;
}
var ret = '';
ret += ' <a href="' + file_uploadName + '" target="_blank">' + file_originName + '</a>';
var trHtml = "";
trHtml += '<tr>';
trHtml += ' <td class="align-middle"> ' + ret + ' </td>';
trHtml += ' <td class="align-middle" style="display: none;"> ' + file_uid + ' </td>';
trHtml += ' <td class="align-middle" style="display: none;"> ' + file_uid + ' </td>';
trHtml += ' <td class="align-middle" style="display: none;"> ' + file_originName + ' </td>';
trHtml += ' <td class="align-middle text-right">';
//trHtml += ' <button type="button" data-uid="" media-uid="' + photo_uid + '" data-method="edit" onclick="buttonPhotoClick(this);" class="btn btn-sm btn-icon btn-secondary" data-toggle="modal" data-target="#clientContactEditModal"><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
trHtml += ' <button type="button" data-uid="" media-uid="' + file_uid + '" data-method="del" onclick="buttonFileClick(this);" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
trHtml += ' </td>';
trHtml += '</tr>';
$('#file_table tbody').append(trHtml);
$('#clientFileModal').modal('toggle');
});
//截圖儲存
$('#clientCutPhotoSaveBtn').on('click', function () {
var method = $('#photo_method').val();
@ -1461,6 +1541,28 @@ function kolProjectTableButtonClick(obj) {
$('#price_table tbody').append(trHtml);
});
$.each(obj.kolProjectFiles, function () {
var ret = '';
ret += ' <a href="' + this.kolProjectFile_path + '" target="_blank">' + this.kolProjectFile_originFileName + '</a>';
var trHtml = "";
trHtml += '<tr>';
trHtml += ' <td class="align-middle"> ' + ret + ' </td>';
trHtml += ' <td class="align-middle" style="display: none;"> ' + this.file_uid + ' </td>';
trHtml += ' <td class="align-middle" style="display: none;"> ' + this.file_uid + ' </td>';
trHtml += ' <td class="align-middle" style="display: none;"> ' + this.kolProjectFile_originFileName + ' </td>';
trHtml += ' <td class="align-middle text-right">';
//trHtml += ' <button type="button" data-uid="" media-uid="' + photo_uid + '" data-method="edit" onclick="buttonPhotoClick(this);" class="btn btn-sm btn-icon btn-secondary" data-toggle="modal" data-target="#clientContactEditModal"><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
trHtml += ' <button type="button" data-uid="" media-uid="' + this.file_uid + '" data-method="del" onclick="buttonFileClick(this);" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
trHtml += ' </td>';
trHtml += '</tr>';
$('#file_table tbody').append(trHtml);
});
$("input[name=kolProject_isExec][value=" + obj.kolProject.kolProject_isExec + "]").prop('checked', true).trigger('change');
$('#kolProject_noExecReason').val(obj.kolProject.kolProject_noExecReason);
@ -1607,6 +1709,17 @@ function linkEditClick(obj) {
}
}
}
function buttonFileClick(obj) {
linkTr = $(obj).closest('tr');
var dataMethod = obj.getAttribute('data-method');
if (dataMethod == "del") {
if (confirm('確定刪除此筆資料?')) {
linkTr.remove();
}
}
}
function specButtonClick(obj) {
specTr = $(obj).closest('tr');
@ -2172,6 +2285,11 @@ function loadprojectList() {
}
function clearKolProjectTable() {
var trList = $("#file_table").find("tbody").find("tr");
$.each(trList, function (index, item) {
$(item).remove();
});
var trList = $("#price_table").find("tbody").find("tr");
$.each(trList, function (index, item) {
$(item).remove();
@ -2192,6 +2310,48 @@ function clearKolProjectTable() {
});
}
function initFileUpload() {
var url = "/Api/fileUpload";
// =============================================================
$('#fileupload-uploadFile').fileupload({
url: url,
dropZone: null,
dataType: 'json',
autoUpload: true,
maxFileSize: 50000000
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index;
var file = data.files[index];
$('#avatar-warning-container').removeClass('show').text('');
if (file.error) {
$('#avatar-warning-container').addClass('show').text(file.error);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress-avatar').addClass('show').children().css('width', progress + '%');
}).on('fileuploaddone', function (e, data) {
var file = data.result.files[0];
var $img = $(this).parent().children('img');
var $old = $img.prop('src');
if (file.url) {
$('#origin_fileName').val(file.name);
$('#upload_fileName').val(file.url);
$('#file_uid').val(file.uid);
$img.prop('src', file.url);
$(this).parent().parent().append('<a target="_blank" id="file_url" href="' + file.url + '">' + file.name + '</a>');
$(this).parent().hide();
} else if (file.error) {
$('#avatar-warning-container').addClass('show').text(file.error);
}
$('#progress-avatar').removeClass('show').children().css('width', 0);
}); // File upload using button
}
function initSubPhotoUpload() {
var url = "/Api/subPhotoUpload";

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.