forked from dk96/QuotationMaker
updates
parent
6cd69bf69d
commit
90199c88ba
|
|
@ -25,6 +25,345 @@ namespace QuotationMaker.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("addEditDelGetSubItem")]
|
||||||
|
public ActionResult AddEditDelSubItem(IFormCollection obj) {
|
||||||
|
authSubItemResult ret = new authSubItemResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.user_perm != "system")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "90001";
|
||||||
|
ret.message = "此帳號無此api使用權限!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string dept_uid = obj["dept_uid"].ToString();
|
||||||
|
string mainItem_uid = obj["mainItem_uid"].ToString();
|
||||||
|
string subItem_uid = obj["subItem_uid"].ToString();
|
||||||
|
string subItem_name = obj["subItem_name"].ToString();
|
||||||
|
string subItem_descript = obj["subItem_descript"].ToString();
|
||||||
|
string subItem_priceStr = obj["subItem_price"].ToString();
|
||||||
|
string subItem_unitType = obj["subItem_unitType"].ToString();
|
||||||
|
string method = obj["method"].ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (method == "") {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0001";
|
||||||
|
ret.message = "沒有method!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dept_uid.Trim() == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0003";
|
||||||
|
ret.message = "沒有dept_uid!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "add")
|
||||||
|
{
|
||||||
|
double subItem_price = 0.0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
subItem_price = Double.Parse(subItem_priceStr);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "subItem_price非數字!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
subItem_uid = GlobalClass.CreateRandomCode(24);
|
||||||
|
subItem newItem = new subItem();
|
||||||
|
newItem.subItem_name = subItem_name;
|
||||||
|
newItem.mainItem_uid = mainItem_uid;
|
||||||
|
newItem.subItem_uid = subItem_uid;
|
||||||
|
newItem.subItem_descript = subItem_descript;
|
||||||
|
newItem.subItem_price = subItem_price;
|
||||||
|
newItem.subItem_unitType = subItem_unitType;
|
||||||
|
|
||||||
|
newItem.subItem_lastmodify_uid = token.user_uid;
|
||||||
|
newItem.subItem_createdate = DateTime.Now;
|
||||||
|
newItem.subItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
conn.Insert(newItem);
|
||||||
|
ret.subItems.Add(newItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subItem_uid.Trim() == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0002";
|
||||||
|
ret.message = "沒有mainItem_uid!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
subItem editItem = conn.QueryFirstOrDefault<subItem>("select * from subItem where subItem_uid = @subItem_uid ", new { subItem_uid = subItem_uid });
|
||||||
|
|
||||||
|
if (editItem == null) {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0004";
|
||||||
|
ret.message = "沒有subItem_uid此筆資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "edit") {
|
||||||
|
double subItem_price = 0.0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
subItem_price = Double.Parse(subItem_priceStr);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "subItem_price非數字!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subItem_name.Trim() == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0002";
|
||||||
|
ret.message = "沒有mainItem_name!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
editItem.subItem_name = subItem_name;
|
||||||
|
editItem.subItem_descript = subItem_descript;
|
||||||
|
editItem.subItem_price = subItem_price;
|
||||||
|
editItem.subItem_unitType = subItem_unitType;
|
||||||
|
|
||||||
|
editItem.subItem_lastmodify_uid = token.user_uid;
|
||||||
|
editItem.subItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
conn.Update(editItem);
|
||||||
|
ret.subItems.Add(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "get") {
|
||||||
|
ret.subItems.Add(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "del") {
|
||||||
|
conn.Delete(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("authSubItemList")]
|
||||||
|
public ActionResult AuthSubItemList(IFormCollection obj) {
|
||||||
|
authSubItemResult ret = new authSubItemResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.user_perm != "system")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "90001";
|
||||||
|
ret.message = "此帳號無此api使用權限!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string dept_uid = obj["dept_uid"].ToString();
|
||||||
|
string mainItem_uid = obj["mainItem_uid"].ToString();
|
||||||
|
|
||||||
|
ret.subItems = conn.Query<subItem>("select * from subItem where mainItem_uid = @mainItem_uid", new { mainItem_uid = mainItem_uid }).ToList();
|
||||||
|
ret.ret = "yes";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("addEditDelGetMainItem")]
|
||||||
|
public ActionResult AddEditDelMainItem(IFormCollection obj) {
|
||||||
|
authMainItemResult ret = new authMainItemResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.user_perm != "system")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "90001";
|
||||||
|
ret.message = "此帳號無此api使用權限!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string dept_uid = obj["dept_uid"].ToString();
|
||||||
|
string mainItem_uid = obj["mainItem_uid"].ToString();
|
||||||
|
string mainItem_name = obj["mainItem_name"].ToString();
|
||||||
|
string method = obj["method"].ToString();
|
||||||
|
|
||||||
|
if (method == "") {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0001";
|
||||||
|
ret.message = "沒有method!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dept_uid.Trim() == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0003";
|
||||||
|
ret.message = "沒有dept_uid!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "add")
|
||||||
|
{
|
||||||
|
mainItem_uid = GlobalClass.CreateRandomCode(12);
|
||||||
|
mainItem newItem = new mainItem();
|
||||||
|
newItem.mainItem_name = mainItem_name;
|
||||||
|
newItem.mainItem_uid = mainItem_uid;
|
||||||
|
newItem.dept_uid = dept_uid;
|
||||||
|
newItem.mainItem_lastmodify_uid = token.user_uid;
|
||||||
|
newItem.mainItem_createdate = DateTime.Now;
|
||||||
|
newItem.mainItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
conn.Insert(newItem);
|
||||||
|
ret.mainItems.Add(newItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainItem_uid.Trim() == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0002";
|
||||||
|
ret.message = "沒有mainItem_uid!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mainItem editItem = conn.QueryFirstOrDefault<mainItem>("select * from mainItem where mainItem_uid = @mainItem_uid ", new { mainItem_uid = mainItem_uid });
|
||||||
|
|
||||||
|
if (editItem == null) {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0004";
|
||||||
|
ret.message = "沒有mainItem_uid此筆資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "edit") {
|
||||||
|
if (mainItem_name.Trim() == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0002";
|
||||||
|
ret.message = "沒有mainItem_name!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
editItem.mainItem_name = mainItem_name;
|
||||||
|
editItem.mainItem_lastmodify_uid = token.user_uid;
|
||||||
|
editItem.mainItem_modifydate= DateTime.Now;
|
||||||
|
|
||||||
|
conn.Update(editItem);
|
||||||
|
ret.mainItems.Add(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "get") {
|
||||||
|
ret.mainItems.Add(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "del") {
|
||||||
|
conn.Delete(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("authMainItemList")]
|
||||||
|
public ActionResult AuthMainItemList(IFormCollection obj) {
|
||||||
|
authMainItemResult ret = new authMainItemResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.user_perm != "system")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "90001";
|
||||||
|
ret.message = "此帳號無此api使用權限!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string dept_uid = obj["dept_uid"].ToString();
|
||||||
|
|
||||||
|
ret.mainItems = conn.Query<mainItem>("select * from mainItem where dept_uid = @dept_uid", new { dept_uid = dept_uid }).ToList();
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
[Route("addGroupUser")]
|
[Route("addGroupUser")]
|
||||||
public ActionResult AddGroupUser(IFormCollection obj) {
|
public ActionResult AddGroupUser(IFormCollection obj) {
|
||||||
groupUserListResult ret = new groupUserListResult();
|
groupUserListResult ret = new groupUserListResult();
|
||||||
|
|
@ -524,7 +863,7 @@ namespace QuotationMaker.Controllers
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
elabUser = elabConn.QueryFirstOrDefault<new_userdata>("select * from new_userdata where userid = @user_id", new { user_id = user_id });
|
elabUser = elabConn.QueryFirstOrDefault<new_userdata>("select * from new_userdata where userid = @user_id order by mail, userid", new { user_id = user_id });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -630,7 +969,7 @@ namespace QuotationMaker.Controllers
|
||||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
new_userdata elabUser = elabConn.QueryFirstOrDefault("select * from new_userdata where userid = @user_id", new { user_id = user_id });
|
new_userdata elabUser = elabConn.QueryFirstOrDefault("select * from new_userdata where userid = @user_id order by mail", new { user_id = user_id });
|
||||||
|
|
||||||
if (elabUser != null)
|
if (elabUser != null)
|
||||||
{
|
{
|
||||||
|
|
@ -849,7 +1188,7 @@ namespace QuotationMaker.Controllers
|
||||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.userList = elabConn.Query<new_userdata>("select * from new_userdata where onjob = 0 order by usersn desc ").ToList();
|
ret.userList = elabConn.Query<new_userdata>("select * from new_userdata where onjob = 0 order by mail ").ToList();
|
||||||
ret.ret = "yes";
|
ret.ret = "yes";
|
||||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
@ -1006,7 +1345,7 @@ namespace QuotationMaker.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new_userdata elabUser = elabConn.QueryFirstOrDefault<new_userdata>("select * from new_userdata where userid = @userid", new { userid = webUser.user_id });
|
new_userdata elabUser = elabConn.QueryFirstOrDefault<new_userdata>("select * from new_userdata where userid = @userid order by mail, userid", new { userid = webUser.user_id });
|
||||||
|
|
||||||
if (input_PWD != GlobalClass.Sha256(elabUser.userpw))
|
if (input_PWD != GlobalClass.Sha256(elabUser.userpw))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,22 @@ namespace QuotationMaker.Controllers
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult RateList()
|
||||||
|
{
|
||||||
|
if (checkToken() == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
return Redirect("~/Home/Login");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._objToken.user_perm != "system")
|
||||||
|
{
|
||||||
|
return Redirect("~/");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult GroupList()
|
public IActionResult GroupList()
|
||||||
{
|
{
|
||||||
if (checkToken() == false)
|
if (checkToken() == false)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,37 @@ using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
public class DbTableClass
|
public class DbTableClass
|
||||||
{
|
{
|
||||||
|
[Table("subItem")]
|
||||||
|
public class subItem
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[Key]
|
||||||
|
public int subItem_sn { get; set; }
|
||||||
|
public string subItem_uid { get; set; } = "";
|
||||||
|
public string mainItem_uid { get; set; } = "";
|
||||||
|
public string subItem_name { get; set; } = "";
|
||||||
|
public string subItem_descript { get; set; } = "";
|
||||||
|
public double subItem_price { get; set; } = 0.0;
|
||||||
|
public string subItem_unitType { get; set; } = "";
|
||||||
|
public DateTime subItem_createdate { get; set; } = DateTime.Now;
|
||||||
|
public DateTime subItem_modifydate { get; set; } = DateTime.Now;
|
||||||
|
public string subItem_lastmodify_uid { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table("mainItem")]
|
||||||
|
public class mainItem
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[Key]
|
||||||
|
public int mainItem_sn { get; set; }
|
||||||
|
public string mainItem_uid { get; set; } = "";
|
||||||
|
public string dept_uid { get; set; } = "";
|
||||||
|
public string mainItem_name { get; set; } = "";
|
||||||
|
public DateTime mainItem_createdate { get; set; } = DateTime.Now;
|
||||||
|
public DateTime mainItem_modifydate { get; set; } = DateTime.Now;
|
||||||
|
public string mainItem_lastmodify_uid { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
[Table("userDept")]
|
[Table("userDept")]
|
||||||
public class userDept
|
public class userDept
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,23 @@ using Dapper;
|
||||||
using static DbTableClass;
|
using static DbTableClass;
|
||||||
public class resultClass
|
public class resultClass
|
||||||
{
|
{
|
||||||
public class deptListResult
|
public class authMainItemResult
|
||||||
|
{
|
||||||
|
public string ret = "no";
|
||||||
|
public string err_code = "0000";
|
||||||
|
public string message = "";
|
||||||
|
public List<mainItem> mainItems = new List<mainItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class authSubItemResult
|
||||||
|
{
|
||||||
|
public string ret = "no";
|
||||||
|
public string err_code = "0000";
|
||||||
|
public string message = "";
|
||||||
|
public List<subItem> subItems = new List<subItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class deptListResult
|
||||||
{
|
{
|
||||||
public string ret = "no";
|
public string ret = "no";
|
||||||
public string err_code = "0000";
|
public string err_code = "0000";
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
@*
|
||||||
|
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
*@
|
||||||
|
@{
|
||||||
|
Layout = "_LooperLayout";
|
||||||
|
}
|
||||||
|
|
||||||
|
@section Style {
|
||||||
|
<link rel="stylesheet" href="~/assets/vendor/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css">
|
||||||
|
}
|
||||||
|
@section Script {
|
||||||
|
<script src="~/assets/vendor/datatables.net/js/jquery.dataTables.min.js"></script>
|
||||||
|
<script src="~/assets/vendor/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
|
||||||
|
<script src="~/assets/vendor/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>
|
||||||
|
<script src="~/assets/javascript/pages/dataTables.bootstrap.js"></script>
|
||||||
|
<script src="~/assets/javascript/custom/ratelist.js" asp-append-version="true"></script>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="page-inner">
|
||||||
|
<!-- .page-title-bar -->
|
||||||
|
<header class="page-title-bar">
|
||||||
|
<!-- .breadcrumb -->
|
||||||
|
<nav aria-label="breadcrumb">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item active">
|
||||||
|
<a href="#"><i class="breadcrumb-icon fa fa-angle-left mr-2"></i>主項目清單</a>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</nav><!-- /.breadcrumb -->
|
||||||
|
<!-- title -->
|
||||||
|
<h1 class="page-title"> 主項目清單 </h1>
|
||||||
|
<p class="text-muted"> </p><!-- /title -->
|
||||||
|
</header><!-- /.page-title-bar -->
|
||||||
|
<!-- .page-section -->
|
||||||
|
<div class="page-section">
|
||||||
|
<button type="button" id="maintItemNewModal" class="btn btn-primary btn-floated position-absolute" title="Add new client"><i class="fa fa-plus"></i></button>
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<!-- .card-body -->
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="dept_select">單位</label>
|
||||||
|
<select class="custom-select custom-select-sm" id="dept_select" name="dept_select" required="">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="search_btn" style="display: block;"> </label>
|
||||||
|
<button type="button" class="btn btn-info btn-sm" id="search_btn">切換單位</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div><!-- /.card-body -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<!-- .card-body -->
|
||||||
|
<div class="card-body">
|
||||||
|
<!-- .table -->
|
||||||
|
<table id="dt-responsive" class="table dt-responsive nowrap w-100">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 75%;"> 主項目名稱 </th>
|
||||||
|
|
||||||
|
<th> 功能 </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
</table><!-- /.table -->
|
||||||
|
</div><!-- /.card-body -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /.page-section -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- .modal -->
|
||||||
|
<form id="clientItemEditForm" name="clientItemEditForm">
|
||||||
|
<div class="modal fade" id="mainItemModal" tabindex="-1" role="dialog" aria-labelledby="mainItemModalLabel" data-backdrop="static"
|
||||||
|
data-keyboard="false" 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="mainItemModalLabel" class="modal-title inline-editable">
|
||||||
|
<span class="sr-only">主項目內容</span> <input id="group_content" 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="mainItem_method" />
|
||||||
|
<input type="hidden" id="mainItem_uid" />
|
||||||
|
<input type="hidden" id="dept_uid" />
|
||||||
|
<!-- .form-group -->
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-label-group">
|
||||||
|
<input type="text" id="modal_mainItem_name" class="form-control" value="" placeholder="主項目名稱" maxlength="12" required=""> <label for="modal_mainItem_name">主項目名稱</label>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.form-group -->
|
||||||
|
|
||||||
|
</div><!-- /.modal-body -->
|
||||||
|
<!-- .modal-footer -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" id="mainItemDialogSaveBtn" class="btn btn-primary">Save</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
|
||||||
|
</div><!-- /.modal-footer -->
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
</form><!-- /.modal -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- .modal -->
|
||||||
|
<form id="clientSubItemListForm" name="clientSubItemListForm">
|
||||||
|
<div class="modal fade" id="clientSubItemListModal" tabindex="-1" role="dialog" aria-labelledby="clientSubItemListModalLabel" data-backdrop="static"
|
||||||
|
data-keyboard="false" aria-hidden="true">
|
||||||
|
<!-- .modal-dialog -->
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<!-- .modal-content -->
|
||||||
|
<div class="modal-content">
|
||||||
|
<!-- .modal-header -->
|
||||||
|
<div class="modal-header">
|
||||||
|
<h6 id="clientNewModalLabel" class="modal-title inline-editable">
|
||||||
|
<span class="sr-only">子項目列表</span> <input id="mainItemTitle" type="text" class="form-control form-control-lg" placeholder="子項目列表" required="">
|
||||||
|
</h6>
|
||||||
|
<button type="button" class="close" data-dismiss="modal">
|
||||||
|
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
||||||
|
</button>
|
||||||
|
</div><!-- /.modal-header -->
|
||||||
|
<!-- .modal-body -->
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" id="subItemList_method" />
|
||||||
|
<input type="hidden" id="subItemList_mainItem_uid" />
|
||||||
|
<!-- .page-section -->
|
||||||
|
<div class="page-section">
|
||||||
|
<button type="button" id="subItemListNewBtn" class="btn btn-primary btn-floated position-absolute" title="Add new client"><i class="fa fa-plus"></i></button>
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<!-- .card-body -->
|
||||||
|
<div class="card-body">
|
||||||
|
<!-- .table -->
|
||||||
|
<table id="dt-responsive-subItem" class="table dt-responsive nowrap w-100">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> 子項目名稱 </th>
|
||||||
|
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
</table><!-- /.table -->
|
||||||
|
</div><!-- /.card-body -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /.page-section -->
|
||||||
|
</div><!-- /.modal-body -->
|
||||||
|
<!-- .modal-footer -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" id="kolSaveBtn" style="visibility:hidden;" class="btn btn-primary">儲存</button> <button id="closeBtn" type="button" class="btn btn-light" data-dismiss="modal">關閉</button>
|
||||||
|
</div><!-- /.modal-footer -->
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
</form><!-- /.modal -->
|
||||||
|
|
@ -135,6 +135,9 @@
|
||||||
<li class="menu-item has-child" id="authMenu" style='@ViewData["authMenu"]'>
|
<li class="menu-item has-child" id="authMenu" style='@ViewData["authMenu"]'>
|
||||||
<a href="#" class="menu-link"><span class="menu-icon oi oi-wrench"></span> <span class="menu-text">Auth</span></a> <!-- child menu -->
|
<a href="#" class="menu-link"><span class="menu-icon oi oi-wrench"></span> <span class="menu-text">Auth</span></a> <!-- child menu -->
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
|
<li class="menu-item">
|
||||||
|
<a href="~/Home/RateList" class="menu-link">報價項目管理</a>
|
||||||
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="~/Home/GroupList" class="menu-link">群組管理</a>
|
<a href="~/Home/GroupList" class="menu-link">群組管理</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@ var mainPos;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
});db
|
});
|
||||||
|
|
@ -0,0 +1,484 @@
|
||||||
|
|
||||||
|
var mainItemTable;
|
||||||
|
var mainItemRowID;
|
||||||
|
var mainItemRowPos;
|
||||||
|
|
||||||
|
var subItemTable;
|
||||||
|
var subItemRowID;
|
||||||
|
var subItemRowPos;
|
||||||
|
$(document).ready(function () {
|
||||||
|
deptList();
|
||||||
|
|
||||||
|
|
||||||
|
$('#maintItemNewModal').on('click', function () {
|
||||||
|
$("#mainItem_method").val('add');
|
||||||
|
$("#dept_uid").val($("#dept_select").val()).trigger('change');
|
||||||
|
|
||||||
|
|
||||||
|
$('#mainItemModal').modal('toggle');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#mainItemDialogSaveBtn').on('click', function () {
|
||||||
|
var method = $('#mainItem_method').val();
|
||||||
|
var dept_uid = $("#dept_uid").val();
|
||||||
|
var mainItem_uid = $('#mainItem_uid').val();
|
||||||
|
var mainItem_name = $('#modal_mainItem_name').val();
|
||||||
|
|
||||||
|
if (mainItem_name == "") {
|
||||||
|
alert('請輸入主項目名稱');
|
||||||
|
retur;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
method: method,
|
||||||
|
dept_uid: dept_uid,
|
||||||
|
mainItem_uid: mainItem_uid,
|
||||||
|
mainItem_name: mainItem_name
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelGetMainItem",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.mainItems[0];
|
||||||
|
|
||||||
|
if (method == "add") {
|
||||||
|
mainItemTable.fnAddData(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "edit") {
|
||||||
|
mainItemTable.fnUpdate(obj, mainItemRowPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#mainItemModal').modal('toggle');
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadSubItemDataTable() {
|
||||||
|
var dataTables = {
|
||||||
|
init: function init() {
|
||||||
|
|
||||||
|
this.bindUIActions();
|
||||||
|
},
|
||||||
|
bindUIActions: function bindUIActions() {
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
this.table = this.handleDataTables();
|
||||||
|
|
||||||
|
// add buttons
|
||||||
|
//this.table.buttons().container().appendTo('#dt-buttons').unwrap();
|
||||||
|
},
|
||||||
|
handleDataTables: function handleDataTables() {
|
||||||
|
//$('#myTable').append("<tfoot><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tfoot>");
|
||||||
|
return $('#dt-responsive-subItem').DataTable({
|
||||||
|
dom: '<\'text-muted\'Bif>\n <\'table-responsive\'trl>\n <\'mt-4\'p>',
|
||||||
|
lengthChange: true,
|
||||||
|
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
|
||||||
|
pageLength: 25,
|
||||||
|
buttons: [
|
||||||
|
//{
|
||||||
|
// text: '休假設定',
|
||||||
|
// action: function (e, dt, node, config) {
|
||||||
|
// vacationBtnFun();
|
||||||
|
|
||||||
|
// }
|
||||||
|
//},
|
||||||
|
//'excelHtml5'
|
||||||
|
],
|
||||||
|
language: {
|
||||||
|
paginate: {
|
||||||
|
previous: '<i class="fa fa-lg fa-angle-left"></i>',
|
||||||
|
next: '<i class="fa fa-lg fa-angle-right"></i>'
|
||||||
|
},
|
||||||
|
buttons: {
|
||||||
|
copyTitle: 'Data copied',
|
||||||
|
copyKeys: 'Use your keyboard or menu to select the copy command'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
autoWidth: false,
|
||||||
|
rowId: 'subItem_uid',
|
||||||
|
deferRender: true,
|
||||||
|
initComplete: function () {
|
||||||
|
subItemTable = $('#dt-responsive-subItem').dataTable();
|
||||||
|
$('#dt-responsive-subItem').on('click', 'a', function () {
|
||||||
|
buttonSubItemClick(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#dt-responsive-subItem').on('click', 'button', function () {
|
||||||
|
buttonSubItemClick(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
order: [[0, 'desc']],
|
||||||
|
info: true,
|
||||||
|
search: "搜尋:",
|
||||||
|
searching: true,
|
||||||
|
columns: [
|
||||||
|
{ data: 'subItem_name', className: 'align-top text-left', orderable: true, searchable: true },
|
||||||
|
{ data: 'subItem_uid', className: 'align-top text-center', orderable: false, searchable: false }
|
||||||
|
],
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: 0,
|
||||||
|
className: 'align-middle text-left',
|
||||||
|
orderable: false,
|
||||||
|
searchable: true,
|
||||||
|
render: function render(data, type, row, meta) {
|
||||||
|
|
||||||
|
|
||||||
|
return '<a href="javascript: void(0);" data-uid="' + row.subItem_uid + '" data-method="preview" >' + row.subItem_name + '</a>';
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: 1,
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
render: function render(data, type, row, meta) {
|
||||||
|
var ret = '';
|
||||||
|
|
||||||
|
ret += '<button type="button" data-uid="' + row.subItem_uid + '" data-method="edit" class="btn btn-sm btn-icon btn-secondary" ><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
|
||||||
|
ret += '<button type="button" data-uid="' + row.subItem_uid + '" data-method="del" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
responsive: {
|
||||||
|
details: {
|
||||||
|
display: $.fn.dataTable.Responsive.display.childRowImmediate,
|
||||||
|
type: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSearchRecords: function handleSearchRecords() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
$('#table-search, #filterBy').on('keyup change focus', function (e) {
|
||||||
|
var filterBy = $('#filterBy').val();
|
||||||
|
var hasFilter = filterBy !== '';
|
||||||
|
var value = $('#table-search').val();
|
||||||
|
|
||||||
|
self.table.search('').columns().search('').draw();
|
||||||
|
|
||||||
|
if (hasFilter) {
|
||||||
|
self.table.columns(filterBy).search(value).draw();
|
||||||
|
} else {
|
||||||
|
self.table.search(value).draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTables.init();
|
||||||
|
}
|
||||||
|
function loadDataTable() {
|
||||||
|
var dataTables = {
|
||||||
|
init: function init() {
|
||||||
|
|
||||||
|
this.bindUIActions();
|
||||||
|
},
|
||||||
|
bindUIActions: function bindUIActions() {
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
this.table = this.handleDataTables();
|
||||||
|
|
||||||
|
// add buttons
|
||||||
|
//this.table.buttons().container().appendTo('#dt-buttons').unwrap();
|
||||||
|
},
|
||||||
|
handleDataTables: function handleDataTables() {
|
||||||
|
//$('#myTable').append("<tfoot><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tfoot>");
|
||||||
|
return $('#dt-responsive').DataTable({
|
||||||
|
dom: '<\'text-muted\'Bif>\n <\'table-responsive\'trl>\n <\'mt-4\'p>',
|
||||||
|
lengthChange: true,
|
||||||
|
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
|
||||||
|
pageLength: 50,
|
||||||
|
buttons: [
|
||||||
|
//{
|
||||||
|
// text: '休假設定',
|
||||||
|
// action: function (e, dt, node, config) {
|
||||||
|
// vacationBtnFun();
|
||||||
|
|
||||||
|
// }
|
||||||
|
//},
|
||||||
|
//'excelHtml5'
|
||||||
|
],
|
||||||
|
language: {
|
||||||
|
paginate: {
|
||||||
|
previous: '<i class="fa fa-lg fa-angle-left"></i>',
|
||||||
|
next: '<i class="fa fa-lg fa-angle-right"></i>'
|
||||||
|
},
|
||||||
|
buttons: {
|
||||||
|
copyTitle: 'Data copied',
|
||||||
|
copyKeys: 'Use your keyboard or menu to select the copy command'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
autoWidth: false,
|
||||||
|
ajax: {
|
||||||
|
url: '/authApi/authMainItemList',
|
||||||
|
type: 'POST',
|
||||||
|
data: function (d) {
|
||||||
|
Object.assign(d, {
|
||||||
|
dept_uid: $('#dept_select').val()
|
||||||
|
});
|
||||||
|
|
||||||
|
return d;
|
||||||
|
},
|
||||||
|
dataSrc: 'mainItems'
|
||||||
|
},
|
||||||
|
rowId: 'mainItem_uid',
|
||||||
|
deferRender: true,
|
||||||
|
initComplete: function () {
|
||||||
|
mainItemTable = $('#dt-responsive').dataTable();
|
||||||
|
$('#dt-responsive').on('click', 'a', function () {
|
||||||
|
buttonClick(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#dt-responsive').on('click', 'button', function () {
|
||||||
|
buttonClick(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
order: [[1, 'desc']],
|
||||||
|
info: true,
|
||||||
|
search: "搜尋:",
|
||||||
|
searching: true,
|
||||||
|
columns: [
|
||||||
|
{ data: 'mainItem_name', className: 'align-top text-left', orderable: true, searchable: true },
|
||||||
|
{ data: 'mainItem_uid', className: 'align-top text-center', orderable: false, searchable: false }
|
||||||
|
],
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: 0,
|
||||||
|
className: 'align-middle text-left',
|
||||||
|
orderable: false,
|
||||||
|
searchable: true,
|
||||||
|
render: function render(data, type, row, meta) {
|
||||||
|
|
||||||
|
|
||||||
|
return '<a href="javascript: void(0);" data-uid="' + row.mainItem_uid + '" data-method="preview" >' + row.mainItem_name + '</a>';
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: 1,
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
render: function render(data, type, row, meta) {
|
||||||
|
var ret = '';
|
||||||
|
|
||||||
|
ret += '<button type="button" data-uid="' + row.mainItem_uid + '" data-method="edit" class="btn btn-sm btn-icon btn-secondary" ><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
|
||||||
|
ret += '<button type="button" data-uid="' + row.mainItem_uid + '" data-method="del" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
responsive: {
|
||||||
|
details: {
|
||||||
|
display: $.fn.dataTable.Responsive.display.childRowImmediate,
|
||||||
|
type: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSearchRecords: function handleSearchRecords() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
$('#table-search, #filterBy').on('keyup change focus', function (e) {
|
||||||
|
var filterBy = $('#filterBy').val();
|
||||||
|
var hasFilter = filterBy !== '';
|
||||||
|
var value = $('#table-search').val();
|
||||||
|
|
||||||
|
self.table.search('').columns().search('').draw();
|
||||||
|
|
||||||
|
if (hasFilter) {
|
||||||
|
self.table.columns(filterBy).search(value).draw();
|
||||||
|
} else {
|
||||||
|
self.table.search(value).draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTables.init();
|
||||||
|
}
|
||||||
|
function deptList() {
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/authDeptList",
|
||||||
|
type: "post",
|
||||||
|
data: null,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.depts;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (i, item) {
|
||||||
|
|
||||||
|
|
||||||
|
$("#dept_select").append($("<option>", {
|
||||||
|
value: item.dept_uid,
|
||||||
|
text: item.dept_name
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
loadDataTable();
|
||||||
|
loadSubItemDataTable();
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function buttonClick(obj) {
|
||||||
|
|
||||||
|
var type = obj.getAttribute('data-method');
|
||||||
|
var uid = obj.getAttribute('data-uid');
|
||||||
|
var dept_uid = $('#dept_select').val();
|
||||||
|
|
||||||
|
mainItemRowID = $('#' + uid);
|
||||||
|
|
||||||
|
mainItemRowPos = mainItemTable.fnGetPosition($('#' + uid)[0]);
|
||||||
|
|
||||||
|
if (type == "preview") {
|
||||||
|
var mainItem_name = obj.innerText.trim();
|
||||||
|
var formData = {
|
||||||
|
dept_uid: dept_uid,
|
||||||
|
mainItem_uid: uid
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/authSubItemList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.subItems;
|
||||||
|
|
||||||
|
$('#dt-responsive-subItem').dataTable().fnClearTable();
|
||||||
|
if (obj.length > 0) {
|
||||||
|
|
||||||
|
$('#dt-responsive-subItem').dataTable().fnAddData(obj);
|
||||||
|
}
|
||||||
|
$('#mainItemTitle').val(mainItem_name + ' 的子項目列表').trigger('change');
|
||||||
|
$('#clientSubItemListModal').modal('toggle');
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "edit") {
|
||||||
|
var formData = {
|
||||||
|
method: 'get',
|
||||||
|
mainItem_uid: uid,
|
||||||
|
dept_uid: dept_uid
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelGetMainItem",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.mainItems[0];
|
||||||
|
|
||||||
|
$("#mainItem_method").val('edit');
|
||||||
|
$("#mainItem_uid").val(obj.mainItem_uid);
|
||||||
|
$("#dept_uid").val(obj.dept_uid).trigger('change');
|
||||||
|
$("#modal_mainItem_name").val(obj.mainItem_name).trigger('change');
|
||||||
|
|
||||||
|
|
||||||
|
$('#mainItemModal').modal('toggle');
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "del") {
|
||||||
|
if (confirm('確定刪除此筆資料? 所有子項目也會一併刪除~')) {
|
||||||
|
if (confirm('再次確認是否刪除所有此項目與子項目?')) {
|
||||||
|
var formData = {
|
||||||
|
method: 'del',
|
||||||
|
mainItem_uid: uid,
|
||||||
|
dept_uid: dept_uid
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelGetMainItem",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var row = mainItemTable.api().row(mainItemRowID).remove().draw(false);
|
||||||
|
alert('刪除成功');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ function buttonClick(obj) {
|
||||||
|
|
||||||
var type = obj.getAttribute('data-method');
|
var type = obj.getAttribute('data-method');
|
||||||
var uid = obj.getAttribute('data-uid');
|
var uid = obj.getAttribute('data-uid');
|
||||||
|
|
||||||
|
|
||||||
userRowID = $('#' + uid);
|
userRowID = $('#' + uid);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue