Browse Source

到访预约完善

塔里木分支
hwh2023 1 year ago
parent
commit
07fbdef3f7
7 changed files with 216 additions and 104 deletions
  1. +119
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/VisitManageController.cs
  2. +9
    -8
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/VisitManage/Form.cshtml
  3. +32
    -21
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/VisitManage/Form.js
  4. +25
    -15
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/VisitManage/Index.js
  5. +29
    -60
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Weixin/Controllers/VisitManageController.cs
  6. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Weixin/Views/VisitManage/Index.cshtml
  7. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/VisitManage/VisitManageEntity.cs

+ 119
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/VisitManageController.cs View File

@@ -3,6 +3,8 @@ using System.Data;
using Learun.Application.TwoDevelopment.LR_Desktop;
using System.Web.Mvc;
using System.Collections.Generic;
using Learun.Util.Operat;
using Newtonsoft.Json;

namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
{
@@ -16,6 +18,8 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
public class VisitManageController : MvcControllerBase
{
private VisitManageIBLL VisitManageIBLL = new VisitManageBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();

#region 视图功能

@@ -105,13 +109,128 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
public ActionResult SaveForm(string keyValue, string strEntity)
{
VisitManageEntity entity = strEntity.ToObject<VisitManageEntity>();
if (entity.IsNotice=="1")
{
entity.Noticetime = System.DateTime.Now;
}
if (entity.IsNotice == "2")
{
entity.Cancelnoticetime= System.DateTime.Now;
}
VisitManageIBLL.SaveEntity(keyValue,entity);
if (string.IsNullOrEmpty(keyValue))
{
PushWeixin(entity, "到访预约通知");
}
return Success("保存成功!");
}
#endregion

#region 导出

[HttpPost, ValidateInput(false)]
public void ExportExcel(string fileName, string columnJson, string dataJson, string exportField)
{
//设置导出格式
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.Title = Server.UrlDecode(fileName);
excelconfig.TitleFont = "微软雅黑";
excelconfig.TitlePoint = 15;
excelconfig.FileName = Server.UrlDecode(fileName) + ".xls";
excelconfig.IsAllSizeColumn = true;
excelconfig.ColumnEntity = new List<ColumnModel>();
//表头
List<jfGridModel> columnList = columnJson.ToList<jfGridModel>();
//行数据
DataTable rowData = dataJson.ToTable();
//写入Excel表头
Dictionary<string, string> exportFieldMap = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(exportField))
{
string[] exportFields = exportField.Split(',');
foreach (var field in exportFields)
{
if (!exportFieldMap.ContainsKey(field))
{
exportFieldMap.Add(field, "1");
}
}
}

foreach (jfGridModel columnModel in columnList)
{
if (exportFieldMap.ContainsKey(columnModel.name) || string.IsNullOrEmpty(exportField))
{
excelconfig.ColumnEntity.Add(new ColumnModel()
{
Column = columnModel.name,
ExcelColumn = columnModel.label,
Alignment = columnModel.align,
});
}
}
ExcelHelper.ExcelDownload(rowData, excelconfig);
}
#endregion


#region 推送


public void PushWeixin(VisitManageEntity vdata, string title)
{
//mNQx_dn1eIVyzQ2dB9lkHxqat1DoXyvJgtJ-xz5t5Zk
var WeChatConfigentity = weChatConfigIbll.GetEnableEntity();
string appid = WeChatConfigentity.APPId;
string secret = WeChatConfigentity.secret;
var wechatemplete = weChatTempletIbll.GetWeChatTemplateEntityByCodeConfigId(WeChatConfigentity.ID, "task");
string weixintaskurl = wechatemplete.TUrl;
string weixintasktempid = wechatemplete.TempId;
var responsejson = Util.HttpMethods.HttpGet("https://capi.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);

OperateLogModel operateLogModel = new OperateLogModel();
operateLogModel.title = title;
operateLogModel.type = OperationType.Other;
operateLogModel.url = "ArrangeLessonTermController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = responsejson;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);


if (!string.IsNullOrEmpty(vdata.Openid))
{
//执行推送任务
if (!string.IsNullOrEmpty(appid) && !string.IsNullOrEmpty(secret) && !string.IsNullOrEmpty(weixintaskurl) && !string.IsNullOrEmpty(weixintasktempid))
{
if (!string.IsNullOrEmpty(responsejson))
{
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
if (string.IsNullOrEmpty(weixintokenobj.errcode))
{
string access_token = weixintokenobj.access_token;
string jsondata = "{\"touser\":\"" + vdata.Openid + "\"," +
"\"template_id\":\"" + weixintasktempid + "\"," +
"\"url\":\"" + weixintaskurl + "\"," +
"\"data\":{" +
"\"thing3\": {\"value\":\"" + vdata.Name + "\",\"color\":\"#173177\"}," +
"\"character_string4\":{\"value\":\"您提交的到访预约申请已通过,请按预约时间到校。\",\"color\":\"#173177\"}," +
"\"time2\": {\"value\":\"" + vdata.Visitdate + " " + vdata.Visittime + "\",\"color\":\"#173177\"}," +
"\"const1\": {\"value\":\"待查看\",\"color\":\"#173177\"}" +
"}" +
"}";
string pushresult = Util.HttpMethods.HttpPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token, jsondata);

operateLogModel.title = title;
operateLogModel.type = OperationType.Other;
operateLogModel.url = "ArrangeLessonTermController";
operateLogModel.sourceObjectId = "002";
operateLogModel.sourceContentJson = pushresult;
OperatorHelper.Instance.WriteOperateLog(operateLogModel);
}
}
}
}
}
#endregion
}
}

+ 9
- 8
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/VisitManage/Form.cshtml View File

@@ -39,17 +39,18 @@
<div class="lr-form-item-title">身份证(正面)</div>
<div id="Files" name="Files"></div>
</div>
<div class="col-xs-12 lr-form-item" data-table="VisitManage">
@*<div class="col-xs-12 lr-form-item" data-table="VisitManage">
<div class="lr-form-item-title">审核通知</div>
<div id="IsNotice"></div>
</div>
<div class="col-xs-12 lr-form-item" data-table="VisitManage" id="noticetime">
<div class="lr-form-item-title">通知时间</div>
<input id="Noticetime" type="text" class="form-control lr-input-wdatepicker" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',onpicked: function () { $('#Noticetime').trigger('change'); } })" />
</div>
<input id="IsNotice" name="IsNotice" class="form-control" />
</div>*@
@*
<div class="col-xs-12 lr-form-item" data-table="VisitManage" id="noticetime">
<div class="lr-form-item-title">通知时间</div>
<input id="Noticetime" type="text" class="form-control lr-input-wdatepicker" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',onpicked: function () { $('#Noticetime').trigger('change'); } })" />
</div>*@
<div class="col-xs-12 lr-form-item" data-table="VisitManage" id="reason">
<div class="lr-form-item-title">取消原因</div>
<textarea id="CancelReason" name="CancelReason" class="form-control" style="height:100px" ></textarea>
<textarea id="CancelReason" name="CancelReason" class="form-control" style="height:100px"></textarea>
</div>
</div>
@Html.AppendJsFile("/Areas/LR_Desktop/Views/VisitManage/Form.js")

+ 32
- 21
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/VisitManage/Form.js View File

@@ -6,36 +6,45 @@
*/
var acceptClick;
var keyValue = request('keyValue');
var IsNotice = request('isnotice');
var bootstrap = function ($, learun) {
"use strict";
var page = {
init: function () {
$('.lr-form-wrap').lrscroll();
console.log(IsNotice)
$("#IsNotice").val(IsNotice)
if (IsNotice == "1") {
$("#reason").hide();
}
if (IsNotice=="2") {
$("#reason").show();
}
page.bind();
page.initData();
},
bind: function () {
$('#Files').lrUploader({ isUpload: false });
$('#IsNotice').lrDataItemSelect({
code: 'visitstatus',
select: function (item) {
console.log(item)
if (item) {
if (item.title == "是") {
$("#noticetime").show();
$("#reason").hide();
}
if (item.title == "否") {
$("#noticetime").hide();
}
if (item.title == "取消") {
$("#noticetime").hide();
$("#reason").show();
}
}
}
});
$('#IsNotice').lrselectSet("0");
//$('#IsNotice').lrDataItemSelect({
// code: 'visitstatus',
// select: function (item) {
// console.log(item)
// if (item) {
// if (item.title == "是") {
// $("#noticetime").show();
// $("#reason").hide();
// }
// if (item.title == "否") {
// $("#noticetime").hide();
// }
// if (item.title == "取消") {
// $("#noticetime").hide();
// $("#reason").show();
// }
// }
// }
//});
//$('#IsNotice').lrselectSet("0");
},
initData: function () {
if (!!keyValue) {
@@ -57,8 +66,10 @@ var bootstrap = function ($, learun) {
if (!$('body').lrValidform()) {
return false;
}
var data = $('body').lrGetFormData()
data.IsNotice = IsNotice
var postData = {
strEntity: JSON.stringify($('body').lrGetFormData())
strEntity: JSON.stringify(data)
};
$.lrSaveForm(top.$.rootUrl + '/LR_Desktop/VisitManage/SaveForm?keyValue=' + keyValue, postData, function (res) {
// 保存成功后才回调


+ 25
- 15
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/VisitManage/Index.js View File

@@ -53,7 +53,7 @@ var bootstrap = function ($, learun) {
learun.layerForm({
id: 'form',
title: '编辑',
url: top.$.rootUrl + '/LR_Desktop/VisitManage/Form?keyValue=' + keyValue,
url: top.$.rootUrl + '/LR_Desktop/VisitManage/Form?keyValue=' + keyValue+"&isnotice=1",
width: 900,
height: 700,
callBack: function (id) {
@@ -69,7 +69,7 @@ var bootstrap = function ($, learun) {
learun.layerForm({
id: 'form',
title: '编辑',
url: top.$.rootUrl + '/LR_Desktop/VisitManage/Form?keyValue=' + keyValue,
url: top.$.rootUrl + '/LR_Desktop/VisitManage/Form?keyValue=' + keyValue + "&isnotice=2",
width: 900,
height: 700,
callBack: function (id) {
@@ -99,24 +99,34 @@ var bootstrap = function ($, learun) {
headData: [
{ label: "姓名", name: "Name", width: 100, align: "left"},
{ label: "联系电话", name: "Tel", width: 100, align: "left"},
{ label: "到访日期", name: "Visitdate", width: 100, align: "left"},
{
label: "到访日期", name: "Visitdate", width: 100, align: "left",
formatterAsync: function (callback, value, row, op, $cell) {
callback(row.Visitdate.substring(0,10));
}
},
{ label: "到访时间", name: "Visittime", width: 100, align: "left"},
{ label: "到访部门", name: "VisitDept", width: 100, align: "left"},
{ label: "学校联系人", name: "Contact", width: 100, align: "left"},
//{ label: "到访事项", name: "Reason", width: 100, align: "left"},
{ label: "身份证(正面)", name: "Files", width: 100, align: "left"},
{ label: "到访事项", name: "Reason", width: 100, align: "left"},
//{ label: "身份证(正面)", name: "Files", width: 100, align: "left"},
{ label: "提交时间", name: "Createtime", width: 100, align: "left"},
{ label: "审核通知", name: "IsNotice", width: 100, align: "left",
formatterAsync: function (callback, value, row, op,$cell) {
learun.clientdata.getAsync('dataItem', {
key: value,
code: 'visitstatus',
callback: function (_data) {
callback(_data.text);
}
});
}},
{ label: "通知时间", name: "Noticetime", width: 100, align: "left"},
formatterAsync: function (callback, value, row, op, $cell) {
if (row.IsNotice.trim()=="0") {
callback("否");
}
if (row.IsNotice.trim() == "1") {
callback("是");
}
if (row.IsNotice.trim() == "2") {
callback("取消");
}
}
},
{ label: "通知时间", name: "Noticetime", width: 100, align: "left" },
{ label: "取消原因", name: "CancelReason", width: 100, align: "left" },
{ label: "取消通知时间", name: "Cancelnoticetime", width: 100, align: "left" },
],
mainId:'V_id',
isPage: true


+ 29
- 60
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Weixin/Controllers/VisitManageController.cs View File

@@ -1,6 +1,10 @@
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Util;
using Learun.Util.Operat;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
@@ -12,14 +16,33 @@ using System.Web.Mvc;

namespace Learun.Application.Web.Areas.Weixin.Controllers
{
public class VisitManageController : MvcControllerBase
public class VisitManageController : Controller
{
private VisitManageIBLL VisitManageIBLL = new VisitManageBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();
private WeChatTempletIBLL weChatTempletIbll = new WeChatTempletBLL();
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
// GET: Weixin/VisitManage
public ActionResult Index()
public ActionResult Index(string code)
{
string redirect_url = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["redirect_url"]);
var weichatdevelop = weChatConfigIbll.GetEnableEntity();
//微信appid
string appid = weichatdevelop.APPId;
string secret = weichatdevelop.secret;
if (!string.IsNullOrEmpty(code))
{
string response = Util.HttpMethods.HttpGet("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code");
JObject jo = (JObject)JsonConvert.DeserializeObject(response);
ViewBag.openid = jo["openid"].ToString();
}
else
{

return Redirect("https://open.weixin.qq.com/connect/qrconnect?appid=" + appid + "&redirect_uri=" + redirect_url + "%2fLogin%2fLoginForWeixin&response_type=code&scope=snsapi_login&state=one#wechat_redirect");
}
return View();
}

@@ -37,7 +60,7 @@ namespace Learun.Application.Web.Areas.Weixin.Controllers
{
VisitManageEntity entity = strEntity.ToObject<VisitManageEntity>();
VisitManageIBLL.SaveEntity(keyValue, entity);
return Success(new { data = entity, info = "保存成功" });
return Json(new { data = entity, info = "保存成功" });
}
#endregion

@@ -50,7 +73,7 @@ namespace Learun.Application.Web.Areas.Weixin.Controllers
{
if (Request.Files.Count > 0)
{
return Success(new { folderId = annexesFileIBLL.SaveAnnexesInfo(Request.Files[0]) });
return Json(new { folderId = annexesFileIBLL.SaveAnnexesInfo(Request.Files[0]) });

}
else
@@ -58,67 +81,13 @@ namespace Learun.Application.Web.Areas.Weixin.Controllers
return HttpNotFound();
}
}
return Success("保存成功");
return Json("保存成功");
}
#endregion



public ActionResult LoginForWeixin()
{
string redirect_url = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["redirect_url"]);
var weichatdevelop = weChatDevelopIbll.GetEnableEntity();
//微信appid
string appid = weichatdevelop.APPId;
string secret = weichatdevelop.secret;
ViewBag.login = Request.QueryString["login"];
ViewBag.CODE = Request.QueryString["CODE"];
return Redirect("https://open.weixin.qq.com/connect/qrconnect?appid=" + appid + "&redirect_uri=" + redirect_url + "%2fLogin%2fLoginForWeixin&response_type=code&scope=snsapi_login&state=one#wechat_redirect");
}


[HttpPost, ValidateInput(false)]
public void ExportExcel(string fileName, string columnJson, string dataJson, string exportField)
{
//设置导出格式
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.Title = Server.UrlDecode(fileName);
excelconfig.TitleFont = "微软雅黑";
excelconfig.TitlePoint = 15;
excelconfig.FileName = Server.UrlDecode(fileName) + ".xls";
excelconfig.IsAllSizeColumn = true;
excelconfig.ColumnEntity = new List<ColumnModel>();
//表头
List<jfGridModel> columnList = columnJson.ToList<jfGridModel>();
//行数据
DataTable rowData = dataJson.ToTable();
//写入Excel表头
Dictionary<string, string> exportFieldMap = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(exportField))
{
string[] exportFields = exportField.Split(',');
foreach (var field in exportFields)
{
if (!exportFieldMap.ContainsKey(field))
{
exportFieldMap.Add(field, "1");
}
}
}

foreach (jfGridModel columnModel in columnList)
{
if (exportFieldMap.ContainsKey(columnModel.name) || string.IsNullOrEmpty(exportField))
{
excelconfig.ColumnEntity.Add(new ColumnModel()
{
Column = columnModel.name,
ExcelColumn = columnModel.label,
Alignment = columnModel.align,
});
}
}
ExcelHelper.ExcelDownload(rowData, excelconfig);
}
}
}

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/Weixin/Views/VisitManage/Index.cshtml View File

@@ -27,6 +27,7 @@
<div class="fromSec">
<div class="chickT">到访预约</div>
<form class="layui-form" action="">
<input id="openid" name="openid" value="@ViewBag.openid" hidden/>
<!-- / chickForm_sec1 -->
<div class="chickForm_sec1">
<div class="chickInput">


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/VisitManage/VisitManageEntity.cs View File

@@ -112,6 +112,7 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop
/// </summary>
public void Create()
{
this.IsNotice = "0";
this.Createtime = DateTime.Now;
this.V_id = Guid.NewGuid().ToString();
}


Loading…
Cancel
Save