Browse Source

广告管理列表支持排序

懒得勤快 2 years ago
parent
commit
99603aabf0

+ 345 - 321
src/Masuit.MyBlogs.Core/Controllers/AdvertisementController.cs

@@ -19,324 +19,348 @@ namespace Masuit.MyBlogs.Core.Controllers;
 [Route("partner/[action]")]
 public sealed class AdvertisementController : BaseController
 {
-	public IAdvertisementClickRecordService ClickRecordService { get; set; }
-
-	/// <summary>
-	/// 前往
-	/// </summary>
-	/// <param name="id">广告id</param>
-	/// <returns></returns>
-	[HttpGet("/p{id:int}"), HttpGet("{id:int}", Order = 1), ResponseCache(Duration = 3600)]
-	public async Task<IActionResult> Redirect(int id)
-	{
-		var ad = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("推广链接不存在");
-		if (!Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get<string>("ads" + id)))
-		{
-			HttpContext.Session.Set("ads" + id, id.ToString());
-			ClickRecordService.AddEntity(new AdvertisementClickRecord()
-			{
-				IP = ClientIP.ToString(),
-				Location = Request.Location(),
-				Referer = Request.Headers[HeaderNames.Referer].ToString(),
-				Time = DateTime.Now,
-				AdvertisementId = id
-			});
-			await ClickRecordService.SaveChangesAsync();
-			var start = DateTime.Today.AddYears(-1);
-			await ClickRecordService.GetQuery(a => a.Time < start).DeleteFromQueryAsync();
-		}
-
-		return Redirect(ad.Url);
-	}
-
-	/// <summary>
-	/// 获取分页
-	/// </summary>
-	/// <returns></returns>
-	[MyAuthorize]
-	public ActionResult GetPageData(int page = 1, [Range(1, int.MaxValue, ErrorMessage = "页大小必须大于0")] int size = 10, string kw = "")
-	{
-		Expression<Func<Advertisement, bool>> where = p => true;
-		if (!string.IsNullOrEmpty(kw))
-		{
-			kw = Regex.Escape(kw);
-			where = where.And(p => Regex.IsMatch(p.Title + p.Description + p.Url, kw, RegexOptions.IgnoreCase));
-		}
-
-		var list = AdsService.GetQuery(where).OrderByDescending(p => p.Status == Status.Available).ThenByDescending(a => a.Price).ThenByDescending(a => a.Id).ProjectTo<AdvertisementViewModel>(MapperConfig).ToPagedList(page, size);
-		return Ok(list);
-	}
-
-	/// <summary>
-	/// 保存广告
-	/// </summary>
-	/// <param name="model"></param>
-	/// <returns></returns>
-	[HttpPost, MyAuthorize]
-	public async Task<IActionResult> Save([FromBodyOrDefault] AdvertisementDto model)
-	{
-		var entity = AdsService[model.Id] ?? new Advertisement();
-		model.CategoryIds = model.CategoryIds?.Replace("null", "");
-		model.Regions = Regex.Replace(model.Regions ?? "", @"(\p{P}|\p{Z}|\p{S})+", "|");
-		if (model.RegionMode == RegionLimitMode.All)
-		{
-			model.Regions = null;
-		}
-
-		if (model.Types.Contains(AdvertiseType.Banner.ToString("D")) && string.IsNullOrEmpty(model.ImageUrl))
-		{
-			return ResultData(null, false, "宣传大图不能为空");
-		}
-
-		if (model.Types.Length > 3 && string.IsNullOrEmpty(model.ThumbImgUrl))
-		{
-			return ResultData(null, false, "宣传小图不能为空");
-		}
-
-		Mapper.Map(model, entity);
-		var b = await AdsService.AddOrUpdateSavedAsync(a => a.Id, entity) > 0;
-		return ResultData(null, b, b ? "保存成功" : "保存失败");
-	}
-
-	/// <summary>
-	/// 删除广告
-	/// </summary>
-	/// <param name="id"></param>
-	/// <returns></returns>
-	[HttpPost("{id}"), HttpGet("{id}"), MyAuthorize]
-	public async Task<IActionResult> Delete(int id)
-	{
-		bool b = await AdsService.DeleteByIdAsync(id) > 0;
-		return ResultData(null, b, b ? "删除成功" : "删除失败");
-	}
-
-	/// <summary>
-	/// 广告上下架
-	/// </summary>
-	/// <param name="id">文章id</param>
-	/// <returns></returns>
-	[MyAuthorize, HttpPost("{id}")]
-	public async Task<ActionResult> ChangeState(int id)
-	{
-		var ad = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("广告不存在!");
-		ad.Status = ad.Status == Status.Available ? Status.Unavailable : Status.Available;
-		return ResultData(null, await AdsService.SaveChangesAsync() > 0, ad.Status == Status.Available ? $"【{ad.Title}】已上架!" : $"【{ad.Title}】已下架!");
-	}
-
-	/// <summary>
-	/// 随机前往一个广告
-	/// </summary>
-	/// <returns></returns>
-	[HttpGet("/partner-random")]
-	public async Task<ActionResult> RandomGo()
-	{
-		var ad = AdsService.GetByWeightedPrice((AdvertiseType)new Random().Next(1, 4), Request.Location());
-		if (!Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get<string>("ads" + ad.Id)))
-		{
-			HttpContext.Session.Set("ads" + ad.Id, ad.Id.ToString());
-			ClickRecordService.AddEntity(new AdvertisementClickRecord()
-			{
-				IP = ClientIP.ToString(),
-				Location = Request.Location(),
-				Referer = Request.Headers[HeaderNames.Referer].ToString(),
-				Time = DateTime.Now
-			});
-			await AdsService.SaveChangesAsync();
-			var start = DateTime.Today.AddMonths(-1);
-			await ClickRecordService.GetQuery(a => a.Time < start).DeleteFromQueryAsync();
-		}
-
-		return Redirect(ad.Url);
-	}
-
-	/// <summary>
-	/// 广告访问记录
-	/// </summary>
-	/// <param name="id"></param>
-	/// <param name="page"></param>
-	/// <param name="size"></param>
-	/// <returns></returns>
-	[HttpGet("/partner/{id}/records"), MyAuthorize]
-	public async Task<IActionResult> ClickRecords(int id, int page = 1, int size = 15, string kw = "")
-	{
-		Expression<Func<AdvertisementClickRecord, bool>> where = e => e.AdvertisementId == id;
-		if (!string.IsNullOrEmpty(kw))
-		{
-			kw = Regex.Escape(kw);
-			where = where.And(e => Regex.IsMatch(e.IP + e.Location + e.Referer, kw));
-		}
-
-		var pages = await ClickRecordService.GetPagesAsync<DateTime, AdvertisementClickRecordViewModel>(page, size, where, e => e.Time, false);
-		return Ok(pages);
-	}
-
-	/// <summary>
-	/// 导出广告访问记录
-	/// </summary>
-	/// <param name="id"></param>
-	/// <returns></returns>
-	[HttpGet("/partner/{id}/records-export"), MyAuthorize]
-	public IActionResult ExportClickRecords(int id)
-	{
-		var list = ClickRecordService.GetQuery<DateTime, AdvertisementClickRecordViewModel>(e => e.AdvertisementId == id, e => e.Time, false).ToPooledListScope();
-		using var ms = list.ToExcel();
-		var advertisement = AdsService[id];
-		return this.ResumeFile(ms.ToArray(), ContentType.Xlsx, advertisement.Title + "访问记录.xlsx");
-	}
-
-	/// <summary>
-	/// 广告访问记录图表
-	/// </summary>
-	/// <returns></returns>
-	[HttpGet("/partner/{id}/records-chart"), MyAuthorize]
-	[ProducesResponseType((int)HttpStatusCode.OK)]
-	public async Task<IActionResult> ClickRecordsChart(int id, bool compare, uint period, CancellationToken cancellationToken)
-	{
-		if (compare)
-		{
-			var start1 = DateTime.Today.AddDays(-period);
-			var list1 = await ClickRecordService.GetQuery(e => e.AdvertisementId == id && e.Time >= start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
-			{
-				Date = g.Key,
-				Count = g.Count()
-			}).OrderBy(a => a.Date).ToListAsync(cancellationToken);
-			if (list1.Count == 0)
-			{
-				return Ok(Array.Empty<int>());
-			}
-
-			var start2 = start1.AddDays(-period - 1);
-			var list2 = await ClickRecordService.GetQuery(e => e.AdvertisementId == id && e.Time >= start2 && e.Time < start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
-			{
-				Date = g.Key,
-				Count = g.Count()
-			}).OrderBy(a => a.Date).ToListAsync(cancellationToken);
-
-			// 将数据填充成连续的数据
-			for (var i = start1; i <= DateTime.Today; i = i.AddDays(1))
-			{
-				if (list1.All(a => a.Date != i))
-				{
-					list1.Add(new { Date = i, Count = 0 });
-				}
-			}
-			for (var i = start2; i < start1; i = i.AddDays(1))
-			{
-				if (list2.All(a => a.Date != i))
-				{
-					list2.Add(new { Date = i, Count = 0 });
-				}
-			}
-			return Ok(new[] { list1.OrderBy(a => a.Date), list2.OrderBy(a => a.Date) });
-		}
-
-		var list = await ClickRecordService.GetQuery(e => e.AdvertisementId == id).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
-		{
-			Date = g.Key,
-			Count = g.Count()
-		}).OrderBy(a => a.Date).ToListAsync(cancellationToken);
-		var min = list.Min(a => a.Date);
-		var max = list.Max(a => a.Date);
-		for (var i = min; i < max; i = i.AddDays(1))
-		{
-			if (list.All(a => a.Date != i))
-			{
-				list.Add(new { Date = i, Count = 0 });
-			}
-		}
-
-		return Ok(new[] { list.OrderBy(a => a.Date) });
-	}
-
-	/// <summary>
-	/// 广告访问记录图表
-	/// </summary>
-	/// <returns></returns>
-	[HttpGet("/partner/records-chart"), MyAuthorize]
-	[ProducesResponseType((int)HttpStatusCode.OK)]
-	public async Task<IActionResult> ClickRecordsChart(bool compare, uint period, CancellationToken cancellationToken)
-	{
-		if (compare)
-		{
-			var start1 = DateTime.Today.AddDays(-period);
-			var list1 = await ClickRecordService.GetQuery(e => e.Time >= start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
-			{
-				Date = g.Key,
-				Count = g.Count()
-			}).OrderBy(a => a.Date).ToListAsync(cancellationToken);
-			if (list1.Count == 0)
-			{
-				return Ok(Array.Empty<int>());
-			}
-
-			var start2 = start1.AddDays(-period - 1);
-			var list2 = await ClickRecordService.GetQuery(e => e.Time >= start2 && e.Time < start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
-			{
-				Date = g.Key,
-				Count = g.Count()
-			}).OrderBy(a => a.Date).ToListAsync(cancellationToken);
-
-			// 将数据填充成连续的数据
-			for (var i = start1; i <= DateTime.Today; i = i.AddDays(1))
-			{
-				if (list1.All(a => a.Date != i))
-				{
-					list1.Add(new { Date = i, Count = 0 });
-				}
-			}
-			for (var i = start2; i < start1; i = i.AddDays(1))
-			{
-				if (list2.All(a => a.Date != i))
-				{
-					list2.Add(new { Date = i, Count = 0 });
-				}
-			}
-			return Ok(new[] { list1.OrderBy(a => a.Date), list2.OrderBy(a => a.Date) });
-		}
-
-		var start = DateTime.Now.AddMonths(-1);
-		var list = await ClickRecordService.GetQuery(e => e.Time >= start).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
-		{
-			Date = g.Key,
-			Count = g.Count()
-		}).OrderBy(a => a.Date).ToListAsync(cancellationToken);
-		var min = list.Min(a => a.Date);
-		var max = list.Max(a => a.Date);
-		for (var i = min; i < max; i = i.AddDays(1))
-		{
-			if (list.All(a => a.Date != i))
-			{
-				list.Add(new { Date = i, Count = 0 });
-			}
-		}
-
-		return Ok(new[] { list.OrderBy(a => a.Date) });
-	}
-
-	/// <summary>
-	/// 广告访问记录分析
-	/// </summary>
-	/// <param name="id"></param>
-	/// <returns></returns>
-	[HttpGet("/partner/{id}/insight"), MyAuthorize]
-	public IActionResult ClickRecordsInsight(int id)
-	{
-		return View(Mapper.Map<AdvertisementViewModel>(AdsService[id]));
-	}
-
-	/// <summary>
-	/// 设置分类
-	/// </summary>
-	/// <param name="id"></param>
-	/// <param name="cids"></param>
-	/// <returns></returns>
-	/// <exception cref="NotFoundException"></exception>
-	[HttpPost("/partner/{id}/categories")]
-	public async Task<ActionResult> SetCategories(int id, [FromBodyOrDefault] string cids)
-	{
-		var entity = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("广告未找到");
-		entity.CategoryIds = cids;
-		await AdsService.SaveChangesAsync();
-		return Ok();
-	}
-}
+    public IAdvertisementClickRecordService ClickRecordService { get; set; }
+
+    /// <summary>
+    /// 前往
+    /// </summary>
+    /// <param name="id">广告id</param>
+    /// <returns></returns>
+    [HttpGet("/p{id:int}"), HttpGet("{id:int}", Order = 1), ResponseCache(Duration = 3600)]
+    public async Task<IActionResult> Redirect(int id)
+    {
+        var ad = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("推广链接不存在");
+        if (!Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get<string>("ads" + id)))
+        {
+            HttpContext.Session.Set("ads" + id, id.ToString());
+            ClickRecordService.AddEntity(new AdvertisementClickRecord()
+            {
+                IP = ClientIP.ToString(),
+                Location = Request.Location(),
+                Referer = Request.Headers[HeaderNames.Referer].ToString(),
+                Time = DateTime.Now,
+                AdvertisementId = id
+            });
+            await ClickRecordService.SaveChangesAsync();
+            var start = DateTime.Today.AddYears(-1);
+            await ClickRecordService.GetQuery(a => a.Time < start).DeleteFromQueryAsync();
+        }
+
+        return Redirect(ad.Url);
+    }
+
+    /// <summary>
+    /// 获取分页
+    /// </summary>
+    /// <returns></returns>
+    [MyAuthorize]
+    public ActionResult GetPageData(int page = 1, [Range(1, int.MaxValue, ErrorMessage = "页大小必须大于0")] int size = 10, string kw = "", AdvertiseOrderBy orderBy = AdvertiseOrderBy.Default)
+    {
+        Expression<Func<Advertisement, bool>> where = p => true;
+        if (!string.IsNullOrEmpty(kw))
+        {
+            kw = Regex.Escape(kw);
+            where = where.And(p => Regex.IsMatch(p.Title + p.Description + p.Url, kw, RegexOptions.IgnoreCase));
+        }
+
+        var queryable = AdsService.GetQuery(where).ProjectTo<AdvertisementViewModel>(MapperConfig).OrderByDescending(p => p.Status == Status.Available);
+        switch (orderBy)
+        {
+            case AdvertiseOrderBy.Price:
+                queryable = queryable.ThenByDescending(a => a.Price).ThenByDescending(a => a.Id);
+                break;
+
+            case AdvertiseOrderBy.DisplayCount:
+                queryable = queryable.ThenByDescending(a => a.DisplayCount);
+                break;
+
+            case AdvertiseOrderBy.ViewCount:
+                queryable = queryable.ThenByDescending(a => a.ViewCount);
+                break;
+
+            case AdvertiseOrderBy.AverageViewCount:
+                queryable = queryable.ThenByDescending(a => a.AverageViewCount);
+                break;
+
+            case AdvertiseOrderBy.ClickRate:
+                queryable = queryable.ThenByDescending(a => a.ViewCount * 1m / (a.DisplayCount + 1));
+                break;
+        }
+
+        var list = queryable.ToPagedList(page, size);
+        return Ok(list);
+    }
+
+    /// <summary>
+    /// 保存广告
+    /// </summary>
+    /// <param name="model"></param>
+    /// <returns></returns>
+    [HttpPost, MyAuthorize]
+    public async Task<IActionResult> Save([FromBodyOrDefault] AdvertisementDto model)
+    {
+        var entity = AdsService[model.Id] ?? new Advertisement();
+        model.CategoryIds = model.CategoryIds?.Replace("null", "");
+        model.Regions = Regex.Replace(model.Regions ?? "", @"(\p{P}|\p{Z}|\p{S})+", "|");
+        if (model.RegionMode == RegionLimitMode.All)
+        {
+            model.Regions = null;
+        }
+
+        if (model.Types.Contains(AdvertiseType.Banner.ToString("D")) && string.IsNullOrEmpty(model.ImageUrl))
+        {
+            return ResultData(null, false, "宣传大图不能为空");
+        }
+
+        if (model.Types.Length > 3 && string.IsNullOrEmpty(model.ThumbImgUrl))
+        {
+            return ResultData(null, false, "宣传小图不能为空");
+        }
+
+        Mapper.Map(model, entity);
+        var b = await AdsService.AddOrUpdateSavedAsync(a => a.Id, entity) > 0;
+        return ResultData(null, b, b ? "保存成功" : "保存失败");
+    }
+
+    /// <summary>
+    /// 删除广告
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    [HttpPost("{id}"), HttpGet("{id}"), MyAuthorize]
+    public async Task<IActionResult> Delete(int id)
+    {
+        bool b = await AdsService.DeleteByIdAsync(id) > 0;
+        return ResultData(null, b, b ? "删除成功" : "删除失败");
+    }
+
+    /// <summary>
+    /// 广告上下架
+    /// </summary>
+    /// <param name="id">文章id</param>
+    /// <returns></returns>
+    [MyAuthorize, HttpPost("{id}")]
+    public async Task<ActionResult> ChangeState(int id)
+    {
+        var ad = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("广告不存在!");
+        ad.Status = ad.Status == Status.Available ? Status.Unavailable : Status.Available;
+        return ResultData(null, await AdsService.SaveChangesAsync() > 0, ad.Status == Status.Available ? $"【{ad.Title}】已上架!" : $"【{ad.Title}】已下架!");
+    }
+
+    /// <summary>
+    /// 随机前往一个广告
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet("/partner-random")]
+    public async Task<ActionResult> RandomGo()
+    {
+        var ad = AdsService.GetByWeightedPrice((AdvertiseType)new Random().Next(1, 4), Request.Location());
+        if (!Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get<string>("ads" + ad.Id)))
+        {
+            HttpContext.Session.Set("ads" + ad.Id, ad.Id.ToString());
+            ClickRecordService.AddEntity(new AdvertisementClickRecord()
+            {
+                IP = ClientIP.ToString(),
+                Location = Request.Location(),
+                Referer = Request.Headers[HeaderNames.Referer].ToString(),
+                Time = DateTime.Now
+            });
+            await AdsService.SaveChangesAsync();
+            var start = DateTime.Today.AddMonths(-1);
+            await ClickRecordService.GetQuery(a => a.Time < start).DeleteFromQueryAsync();
+        }
+
+        return Redirect(ad.Url);
+    }
+
+    /// <summary>
+    /// 广告访问记录
+    /// </summary>
+    /// <param name="id"></param>
+    /// <param name="page"></param>
+    /// <param name="size"></param>
+    /// <returns></returns>
+    [HttpGet("/partner/{id}/records"), MyAuthorize]
+    public async Task<IActionResult> ClickRecords(int id, int page = 1, int size = 15, string kw = "")
+    {
+        Expression<Func<AdvertisementClickRecord, bool>> where = e => e.AdvertisementId == id;
+        if (!string.IsNullOrEmpty(kw))
+        {
+            kw = Regex.Escape(kw);
+            where = where.And(e => Regex.IsMatch(e.IP + e.Location + e.Referer, kw));
+        }
+
+        var pages = await ClickRecordService.GetPagesAsync<DateTime, AdvertisementClickRecordViewModel>(page, size, where, e => e.Time, false);
+        return Ok(pages);
+    }
+
+    /// <summary>
+    /// 导出广告访问记录
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    [HttpGet("/partner/{id}/records-export"), MyAuthorize]
+    public IActionResult ExportClickRecords(int id)
+    {
+        var list = ClickRecordService.GetQuery<DateTime, AdvertisementClickRecordViewModel>(e => e.AdvertisementId == id, e => e.Time, false).ToPooledListScope();
+        using var ms = list.ToExcel();
+        var advertisement = AdsService[id];
+        return this.ResumeFile(ms.ToArray(), ContentType.Xlsx, advertisement.Title + "访问记录.xlsx");
+    }
+
+    /// <summary>
+    /// 广告访问记录图表
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet("/partner/{id}/records-chart"), MyAuthorize]
+    [ProducesResponseType((int)HttpStatusCode.OK)]
+    public async Task<IActionResult> ClickRecordsChart(int id, bool compare, uint period, CancellationToken cancellationToken)
+    {
+        if (compare)
+        {
+            var start1 = DateTime.Today.AddDays(-period);
+            var list1 = await ClickRecordService.GetQuery(e => e.AdvertisementId == id && e.Time >= start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
+            {
+                Date = g.Key,
+                Count = g.Count()
+            }).OrderBy(a => a.Date).ToListAsync(cancellationToken);
+            if (list1.Count == 0)
+            {
+                return Ok(Array.Empty<int>());
+            }
+
+            var start2 = start1.AddDays(-period - 1);
+            var list2 = await ClickRecordService.GetQuery(e => e.AdvertisementId == id && e.Time >= start2 && e.Time < start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
+            {
+                Date = g.Key,
+                Count = g.Count()
+            }).OrderBy(a => a.Date).ToListAsync(cancellationToken);
+
+            // 将数据填充成连续的数据
+            for (var i = start1; i <= DateTime.Today; i = i.AddDays(1))
+            {
+                if (list1.All(a => a.Date != i))
+                {
+                    list1.Add(new { Date = i, Count = 0 });
+                }
+            }
+            for (var i = start2; i < start1; i = i.AddDays(1))
+            {
+                if (list2.All(a => a.Date != i))
+                {
+                    list2.Add(new { Date = i, Count = 0 });
+                }
+            }
+            return Ok(new[] { list1.OrderBy(a => a.Date), list2.OrderBy(a => a.Date) });
+        }
+
+        var list = await ClickRecordService.GetQuery(e => e.AdvertisementId == id).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
+        {
+            Date = g.Key,
+            Count = g.Count()
+        }).OrderBy(a => a.Date).ToListAsync(cancellationToken);
+        var min = list.Min(a => a.Date);
+        var max = list.Max(a => a.Date);
+        for (var i = min; i < max; i = i.AddDays(1))
+        {
+            if (list.All(a => a.Date != i))
+            {
+                list.Add(new { Date = i, Count = 0 });
+            }
+        }
+
+        return Ok(new[] { list.OrderBy(a => a.Date) });
+    }
+
+    /// <summary>
+    /// 广告访问记录图表
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet("/partner/records-chart"), MyAuthorize]
+    [ProducesResponseType((int)HttpStatusCode.OK)]
+    public async Task<IActionResult> ClickRecordsChart(bool compare, uint period, CancellationToken cancellationToken)
+    {
+        if (compare)
+        {
+            var start1 = DateTime.Today.AddDays(-period);
+            var list1 = await ClickRecordService.GetQuery(e => e.Time >= start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
+            {
+                Date = g.Key,
+                Count = g.Count()
+            }).OrderBy(a => a.Date).ToListAsync(cancellationToken);
+            if (list1.Count == 0)
+            {
+                return Ok(Array.Empty<int>());
+            }
+
+            var start2 = start1.AddDays(-period - 1);
+            var list2 = await ClickRecordService.GetQuery(e => e.Time >= start2 && e.Time < start1).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
+            {
+                Date = g.Key,
+                Count = g.Count()
+            }).OrderBy(a => a.Date).ToListAsync(cancellationToken);
+
+            // 将数据填充成连续的数据
+            for (var i = start1; i <= DateTime.Today; i = i.AddDays(1))
+            {
+                if (list1.All(a => a.Date != i))
+                {
+                    list1.Add(new { Date = i, Count = 0 });
+                }
+            }
+            for (var i = start2; i < start1; i = i.AddDays(1))
+            {
+                if (list2.All(a => a.Date != i))
+                {
+                    list2.Add(new { Date = i, Count = 0 });
+                }
+            }
+            return Ok(new[] { list1.OrderBy(a => a.Date), list2.OrderBy(a => a.Date) });
+        }
+
+        var start = DateTime.Now.AddMonths(-1);
+        var list = await ClickRecordService.GetQuery(e => e.Time >= start).Select(e => e.Time).GroupBy(t => t.Date).Select(g => new
+        {
+            Date = g.Key,
+            Count = g.Count()
+        }).OrderBy(a => a.Date).ToListAsync(cancellationToken);
+        var min = list.Min(a => a.Date);
+        var max = list.Max(a => a.Date);
+        for (var i = min; i < max; i = i.AddDays(1))
+        {
+            if (list.All(a => a.Date != i))
+            {
+                list.Add(new { Date = i, Count = 0 });
+            }
+        }
+
+        return Ok(new[] { list.OrderBy(a => a.Date) });
+    }
+
+    /// <summary>
+    /// 广告访问记录分析
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    [HttpGet("/partner/{id}/insight"), MyAuthorize]
+    public IActionResult ClickRecordsInsight(int id)
+    {
+        return View(Mapper.Map<AdvertisementViewModel>(AdsService[id]));
+    }
+
+    /// <summary>
+    /// 设置分类
+    /// </summary>
+    /// <param name="id"></param>
+    /// <param name="cids"></param>
+    /// <returns></returns>
+    /// <exception cref="NotFoundException"></exception>
+    [HttpPost("/partner/{id}/categories")]
+    public async Task<ActionResult> SetCategories(int id, [FromBodyOrDefault] string cids)
+    {
+        var entity = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("广告未找到");
+        entity.CategoryIds = cids;
+        await AdsService.SaveChangesAsync();
+        return Ok();
+    }
+}

+ 24 - 0
src/Masuit.MyBlogs.Core/Models/Enum/AdvertiseOrderBy.cs

@@ -0,0 +1,24 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Masuit.MyBlogs.Core.Models.Enum;
+
+public enum AdvertiseOrderBy
+{
+    [Display(Name = nameof(Default))]
+    Default,
+
+    [Display(Name = nameof(Price))]
+    Price,
+
+    [Display(Name = nameof(DisplayCount))]
+    DisplayCount,
+
+    [Display(Name = nameof(ViewCount))]
+    ViewCount,
+
+    [Display(Name = nameof(AverageViewCount))]
+    AverageViewCount,
+
+    [Display(Name = nameof(ClickRate))]
+    ClickRate
+}

+ 12 - 9
src/Masuit.MyBlogs.Core/Models/Enum/AdvertiseType.cs

@@ -7,12 +7,15 @@ namespace Masuit.MyBlogs.Core.Models.Enum;
 /// </summary>
 public enum AdvertiseType
 {
-	[Description("首页头图")]
-	Banner = 1,
-	[Description("文章列表")]
-	ListItem = 2,
-	[Description("边栏")]
-	SideBar = 3,
-	[Description("内页")]
-	InPage = 4
-}
+    [Description("首页头图")]
+    Banner = 1,
+
+    [Description("文章列表")]
+    ListItem = 2,
+
+    [Description("边栏")]
+    SideBar = 3,
+
+    [Description("内页")]
+    InPage = 4
+}

+ 94 - 90
src/Masuit.MyBlogs.Core/Models/ViewModel/AdvertisementViewModel.cs

@@ -7,100 +7,104 @@ namespace Masuit.MyBlogs.Core.Models.ViewModel;
 /// </summary>
 public class AdvertisementViewModel : BaseEntity
 {
-	/// <summary>
-	/// 标题
-	/// </summary>
-	public string Title { get; set; }
-
-	/// <summary>
-	/// 宣传图片
-	/// </summary>
-	public string ImageUrl { get; set; }
-
-	/// <summary>
-	/// 小宣传图片
-	/// </summary>
-	public string ThumbImgUrl { get; set; }
-
-	/// <summary>
-	/// 描述
-	/// </summary>
-	public string Description { get; set; }
-
-	/// <summary>
-	/// 广告url
-	/// </summary>
-	public string Url { get; set; }
-
-	/// <summary>
-	/// 创建时间
-	/// </summary>
-	public DateTime CreateTime { get; set; }
-
-	/// <summary>
-	/// 更新时间
-	/// </summary>
-	public DateTime UpdateTime { get; set; }
-
-	/// <summary>
-	/// 价格
-	/// </summary>
-	public decimal Price { get; set; }
-
-	/// <summary>
-	/// 广告类型
-	/// </summary>
-	public string Types { get; set; }
-
-	/// <summary>
-	/// 访问次数
-	/// </summary>
-	public int ViewCount { get; set; }
-
-	/// <summary>
-	/// 曝光量
-	/// </summary>
-	public int DisplayCount { get; set; }
-
-	/// <summary>
-	/// 日均点击量
-	/// </summary>
-	public double AverageViewCount { get; set; }
-
-	public string CategoryIds { get; set; }
-
-	/// <summary>
-	/// 到期时间
-	/// </summary>
-	public DateTime? ExpireTime { get; set; }
-
-	/// <summary>
-	/// 地区模式
-	/// </summary>
-	public RegionLimitMode RegionMode { get; set; }
-
-	/// <summary>
-	/// 地区,逗号或竖线分隔
-	/// </summary>
-	public string Regions { get; set; }
-
-	/// <summary>
-	/// 广告商
-	/// </summary>
-	public string Merchant { get; set; }
-
+    /// <summary>
+    /// 标题
+    /// </summary>
+    public string Title { get; set; }
+
+    /// <summary>
+    /// 宣传图片
+    /// </summary>
+    public string ImageUrl { get; set; }
+
+    /// <summary>
+    /// 小宣传图片
+    /// </summary>
+    public string ThumbImgUrl { get; set; }
+
+    /// <summary>
+    /// 描述
+    /// </summary>
+    public string Description { get; set; }
+
+    /// <summary>
+    /// 广告url
+    /// </summary>
+    public string Url { get; set; }
+
+    /// <summary>
+    /// 创建时间
+    /// </summary>
+    public DateTime CreateTime { get; set; }
+
+    /// <summary>
+    /// 更新时间
+    /// </summary>
+    public DateTime UpdateTime { get; set; }
+
+    /// <summary>
+    /// 价格
+    /// </summary>
+    public decimal Price { get; set; }
+
+    /// <summary>
+    /// 广告类型
+    /// </summary>
+    public string Types { get; set; }
+
+    /// <summary>
+    /// 访问次数
+    /// </summary>
+    public int ViewCount { get; set; }
+
+    /// <summary>
+    /// 曝光量
+    /// </summary>
+    public int DisplayCount { get; set; }
+
+    /// <summary>
+    /// 日均点击量
+    /// </summary>
+    public double AverageViewCount { get; set; }
+
+    /// <summary>
+    /// 点击率
+    /// </summary>
+    public decimal ClickRate => ViewCount * 1m / (DisplayCount + 1);
+
+    public string CategoryIds { get; set; }
+
+    /// <summary>
+    /// 到期时间
+    /// </summary>
+    public DateTime? ExpireTime { get; set; }
+
+    /// <summary>
+    /// 地区模式
+    /// </summary>
+    public RegionLimitMode RegionMode { get; set; }
+
+    /// <summary>
+    /// 地区,逗号或竖线分隔
+    /// </summary>
+    public string Regions { get; set; }
+
+    /// <summary>
+    /// 广告商
+    /// </summary>
+    public string Merchant { get; set; }
 }
 
 public class AdvertisementClickRecordViewModel
 {
-	public string IP { get; set; }
+    public string IP { get; set; }
 
-	[Description("地理位置")]
-	public string Location { get; set; }
+    [Description("地理位置")]
+    public string Location { get; set; }
 
-	[Description("来源页面")]
-	public string Referer { get; set; }
+    [Description("来源页面")]
+    public string Referer { get; set; }
 
-	[Description("访问时间")]
-	public string Time { get; set; }
-}
+    [Description("访问时间")]
+    public string Time { get; set; }
+}

+ 437 - 410
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/partner.js

@@ -1,424 +1,451 @@
 myApp.controller("partner", ["$scope", "$http", "$timeout", "NgTableParams", function ($scope, $http, $timeout, NgTableParams) {
-    var self = this;
-    $scope.isAdd = true;
-    $scope.allowUpload = false;
-    $scope.partner = {};
-    $scope.kw = "";
-    $scope.paginationConf = {
-        currentPage: 1,
-        itemsPerPage: 10,
-        pagesLength: 25,
-        perPageOptions: [10, 15, 20, 30, 50, 100, 200],
-        rememberPerPage: 'perPageItems',
-        onChange: function () {
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        }
-    };
-    this.GetPageData = function (page, size) {
-        $http.get(`/partner/getpagedata?page=${page}&size=${size}&kw=${$scope.kw}`).then(function (res) {
-            $scope.paginationConf.totalItems = res.data.TotalCount;
-            $("div[ng-table-pagination]").remove();
-            self.tableParams = new NgTableParams({
-                count: 50000
-            }, {
-                filterDelay: 0,
-                dataset: res.data.Data
-            });
-            self.data = res.data.Data;
-            $timeout(function () {
-                self.data.forEach(item => {
-                    xmSelect.render({
-                        el: '#category-' + item.Id,
-                        tips: '未选择分类',
-                        prop: {
-                            name: 'Name',
-                            value: 'Id',
-                            children: 'Children',
-                        },
-                        //model: { label: { type: 'text' } },
-                        tree: {
-                            show: true,
-                            strict: false,
-                            expandedKeys: true,
-                        },
-                        filterable: true, //搜索功能
-                        autoRow: true, //选项过多,自动换行
-                        data: $scope.cat,
-                        initValue: (item.CategoryIds || "").split(","),
-                        on: function (data) {
-                            var arr = [];
-                            for (var i = 0; i < data.arr.length; i++) {
-                                arr.push(data.arr[i].Id);
-                            }
-                            $http.post(`/partner/${item.Id}/categories?cids=` + arr.join(",")).then(function (res) {
-                                if (data.status >= 400) {
-                                    layer.msg("操作失败");
-                                }
-                            });
-                        }
-                    });
-                });
-            }, 1);
-        });
-    }
+	var self = this;
+	$scope.isAdd = true;
+	$scope.allowUpload = false;
+	$scope.partner = {};
+	$scope.kw = "";
+	$scope.paginationConf = {
+		currentPage: 1,
+		itemsPerPage: 10,
+		pagesLength: 25,
+		perPageOptions: [10, 15, 20, 30, 50, 100, 200],
+		rememberPerPage: 'perPageItems',
+		onChange: function () {
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		}
+	};
+	
+	xmSelect.render({
+		el: '#orderby',
+		tips: '请选择排序方式',
+		model: {
+			 icon: 'hidden',
+			 label: { type: 'text' }
+		},
+		radio: true,
+		clickClose: true,
+		autoRow: true, //选项过多,自动换行
+		data:[
+				{name:"默认",value:0,selected:$scope.orderby==0},
+				{name:"竞价",value:1,selected:$scope.orderby==1},
+				{name:"曝光量",value:2,selected:$scope.orderby==2},
+				{name:"点击量",value:3,selected:$scope.orderby==3},
+				{name:"日均点击",value:4,selected:$scope.orderby==4},
+				{name:"点击率",value:5,selected:$scope.orderby==5},
+			],
+		on: function (data) {
+			if (data.arr.length>0) {
+				$scope.orderby = data.arr[0].value;
+				self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+			}
+		}
+	});
 
-    $scope.typesDropdown = xmSelect.render({
-        el: '#types',
-        tips: '请选择推广区域',
-        direction: 'up',
-        autoRow: true, //选项过多,自动换行
-        data: [{ name: "轮播图", value: 1 }, { name: "列表项", value: 2 }, { name: "边栏", value: 3 }, { name: "内页", value: 4 }],
-        on: function (data) {
-            var arr = [];
-            for (var i = 0; i < data.arr.length; i++) {
-                arr.push(data.arr[i].value);
-            }
-            $scope.partner.Types = arr.join(",");
-        }
-    });
+	this.GetPageData = function (page, size) {
+		$http.get(`/partner/getpagedata?page=${page}&size=${size}&kw=${$scope.kw}&orderby=${$scope.orderby||0}`).then(function (res) {
+			$scope.paginationConf.totalItems = res.data.TotalCount;
+			$("div[ng-table-pagination]").remove();
+			self.tableParams = new NgTableParams({
+				count: 50000
+			}, {
+				filterDelay: 0,
+				dataset: res.data.Data
+			});
+			self.data = res.data.Data;
+			$timeout(function () {
+				self.data.forEach(item => {
+					xmSelect.render({
+						el: '#category-' + item.Id,
+						tips: '未选择分类',
+						prop: {
+							name: 'Name',
+							value: 'Id',
+							children: 'Children',
+						},
+						//model: { label: { type: 'text' } },
+						tree: {
+							show: true,
+							strict: false,
+							expandedKeys: true,
+						},
+						filterable: true, //搜索功能
+						autoRow: true, //选项过多,自动换行
+						data: $scope.cat,
+						initValue: (item.CategoryIds || "").split(","),
+						on: function (data) {
+							var arr = [];
+							for (var i = 0; i < data.arr.length; i++) {
+								arr.push(data.arr[i].Id);
+							}
+							$http.post(`/partner/${item.Id}/categories?cids=` + arr.join(",")).then(function (res) {
+								if (data.status >= 400) {
+									layer.msg("操作失败");
+								}
+							});
+						}
+					});
+				});
+			}, 1);
+		});
+	}
 
-    $scope.regionDropdown = xmSelect.render({
-        el: '#regionMode',
-        tips: '区域',
-        model: {
-            icon: 'hidden',
-            label: { type: 'text' }
-        },
-        radio: true,
-        clickClose: true,
-        direction: 'up',
-        filterable: false, //搜索功能
-        autoRow: false, //选项过多,自动换行
-        data: [{ name: "不限", value: 0 }, { name: "以内", value: 1 }, { name: "以外", value: 2 }],
-        on: function (data) {
-            if (data.arr.length > 0) {
-                $scope.partner.RegionMode = data.arr[0].value;
-            }
-        }
-    });
-    $scope.regionDropdown.setValue([0]);
-    $scope.getCategory = function () {
-        $http.get("/category/getcategories").then(function (res) {
-            var data = res.data;
-            if (data.Success) {
-                $scope.cat = data.Data;
-                $scope.categoryDropdown = xmSelect.render({
-                    el: '#category',
-                    tips: '请选择分类',
-                    prop: {
-                        name: 'Name',
-                        value: 'Id',
-                        children: 'Children',
-                    },
-                    direction: 'up',
-                    tree: {
-                        show: true,
-                        strict: false,
-                        expandedKeys: true,
-                    },
-                    filterable: true, //搜索功能
-                    autoRow: true, //选项过多,自动换行
-                    data: data.Data,
-                    on: function (data) {
-                        var arr = [];
-                        for (var i = 0; i < data.arr.length; i++) {
-                            arr.push(data.arr[i].Id);
-                        }
-                        $scope.partner.CategoryIds = arr.join(",");
-                    }
-                });
-            } else {
-                window.notie.alert({
-                    type: 3,
-                    text: '获取文章分类失败!',
-                    time: 4
-                });
-            }
-        });
-    }
-    $scope.getCategory();
-    $scope.remove = function (partner) {
-        layer.closeAll();
-        swal({
-            title: '确定移除这条广告吗?',
-            text: partner.Title,
-            showCancelButton: true,
-            confirmButtonColor: '#3085d6',
-            cancelButtonColor: '#d33',
-            confirmButtonText: '确定',
-            cancelButtonText: '取消'
-        }).then(function (isConfirm) {
-            if (isConfirm) {
-                $scope.request("/partner/delete/" + partner.Id, null, function (data) {
-                    window.notie.alert({
-                        type: 1,
-                        text: data.Message,
-                        time: 4
-                    });
-                    self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-                });
-            }
-        }).catch(swal.noop);
-    }
-    $scope.add = function () {
-        $scope.partner = {
-            ExpireTime: "2049-12-31 23:59:59"
-        };
-        $scope.isAdd = true;
-        $scope.allowUpload = false;
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '添加广告推广',
-            area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
-            content: $("#edit"),
-            cancel: function (index, layero) {
-                setTimeout(function () {
-                    $("#edit").css("display", "none");
-                }, 500);
-                return true;
-            }
-        });
-        layui.use('laydate', function () {
-            var laydate = layui.laydate;
-            laydate.render({
-                elem: '#timespan',
-                type: 'datetime',
-                calendar: true,
-                done: function (value, date, endDate) {
-                    $scope.partner.ExpireTime = value;
-                }
-            });
-        });
-    }
+	$scope.typesDropdown = xmSelect.render({
+		el: '#types',
+		tips: '请选择推广区域',
+		direction: 'up',
+		autoRow: true, //选项过多,自动换行
+		data: [{ name: "轮播图", value: 1 }, { name: "列表项", value: 2 }, { name: "边栏", value: 3 }, { name: "内页", value: 4 }],
+		on: function (data) {
+			var arr = [];
+			for (var i = 0; i < data.arr.length; i++) {
+				arr.push(data.arr[i].value);
+			}
+			$scope.partner.Types = arr.join(",");
+		}
+	});
 
-    $scope.edit = function (item) {
-        $scope.partner = angular.copy(item);
-        $scope.partner.ExpireTime = $scope.partner.ExpireTime == null ? "2049-12-31 23:59:59" : new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
-        $scope.isAdd = false;
-        $scope.allowUpload = false;
-        layer.closeAll();
-        $scope.categoryDropdown.setValue((item.CategoryIds || "").split(','));
-        $scope.typesDropdown.setValue(item.Types.split(','));
-        $scope.regionDropdown.setValue([item.RegionMode]);
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '保存广告',
-            area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
-            content: $("#edit"),
-            cancel: function (index, layero) {
-                setTimeout(function () {
-                    $("#edit").css("display", "none");
-                }, 500);
-                return true;
-            }
-        });
-        layui.use('laydate', function () {
-            var laydate = layui.laydate;
-            laydate.render({
-                elem: '#timespan',
-                type: 'datetime',
-                calendar: true,
-                done: function (value, date, endDate) {
-                    $scope.partner.ExpireTime = value;
-                }
-            });
-        });
-    }
+	$scope.regionDropdown = xmSelect.render({
+		el: '#regionMode',
+		tips: '区域',
+		model: {
+			icon: 'hidden',
+			label: { type: 'text' }
+		},
+		radio: true,
+		clickClose: true,
+		direction: 'up',
+		filterable: false, //搜索功能
+		autoRow: false, //选项过多,自动换行
+		data: [{ name: "不限", value: 0 }, { name: "以内", value: 1 }, { name: "以外", value: 2 }],
+		on: function (data) {
+			if (data.arr.length > 0) {
+				$scope.partner.RegionMode = data.arr[0].value;
+			}
+		}
+	});
+	$scope.regionDropdown.setValue([0]);
+	$scope.getCategory = function () {
+		$http.get("/category/getcategories").then(function (res) {
+			var data = res.data;
+			if (data.Success) {
+				$scope.cat = data.Data;
+				$scope.categoryDropdown = xmSelect.render({
+					el: '#category',
+					tips: '请选择分类',
+					prop: {
+						name: 'Name',
+						value: 'Id',
+						children: 'Children',
+					},
+					direction: 'up',
+					tree: {
+						show: true,
+						strict: false,
+						expandedKeys: true,
+					},
+					filterable: true, //搜索功能
+					autoRow: true, //选项过多,自动换行
+					data: data.Data,
+					on: function (data) {
+						var arr = [];
+						for (var i = 0; i < data.arr.length; i++) {
+							arr.push(data.arr[i].Id);
+						}
+						$scope.partner.CategoryIds = arr.join(",");
+					}
+				});
+			} else {
+				window.notie.alert({
+					type: 3,
+					text: '获取文章分类失败!',
+					time: 4
+				});
+			}
+		});
+	}
+	$scope.getCategory();
+	$scope.remove = function (partner) {
+		layer.closeAll();
+		swal({
+			title: '确定移除这条广告吗?',
+			text: partner.Title,
+			showCancelButton: true,
+			confirmButtonColor: '#3085d6',
+			cancelButtonColor: '#d33',
+			confirmButtonText: '确定',
+			cancelButtonText: '取消'
+		}).then(function (isConfirm) {
+			if (isConfirm) {
+				$scope.request("/partner/delete/" + partner.Id, null, function (data) {
+					window.notie.alert({
+						type: 1,
+						text: data.Message,
+						time: 4
+					});
+					self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+				});
+			}
+		}).catch(swal.noop);
+	}
+	$scope.add = function () {
+		$scope.partner = {
+			ExpireTime: "2049-12-31 23:59:59"
+		};
+		$scope.isAdd = true;
+		$scope.allowUpload = false;
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '添加广告推广',
+			area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
+			content: $("#edit"),
+			cancel: function (index, layero) {
+				setTimeout(function () {
+					$("#edit").css("display", "none");
+				}, 500);
+				return true;
+			}
+		});
+		layui.use('laydate', function () {
+			var laydate = layui.laydate;
+			laydate.render({
+				elem: '#timespan',
+				type: 'datetime',
+				calendar: true,
+				done: function (value, date, endDate) {
+					$scope.partner.ExpireTime = value;
+				}
+			});
+		});
+	}
 
-    $scope.copy = function (item) {
-        $scope.partner = angular.copy(item);
-        delete $scope.partner.Id;
-        $scope.partner.ExpireTime = $scope.partner.ExpireTime == null ? "2049-12-31 23:59:59" : new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
-        $scope.isAdd = true;
-        $scope.allowUpload = false;
-        layer.closeAll();
-        $scope.categoryDropdown.setValue((item.CategoryIds || "").split(','));
-        $scope.typesDropdown.setValue(item.Types.split(','));
-        $scope.regionDropdown.setValue([0]);
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '复制广告推广',
-            area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
-            content: $("#edit"),
-            cancel: function (index, layero) {
-                setTimeout(function () {
-                    $("#edit").css("display", "none");
-                }, 500);
-                return true;
-            }
-        });
-        layui.use('laydate', function () {
-            var laydate = layui.laydate;
-            laydate.render({
-                elem: '#timespan',
-                type: 'datetime',
-                calendar: true,
-                done: function (value, date, endDate) {
-                    $scope.partner.ExpireTime = value;
-                }
-            });
-        });
-    }
+	$scope.edit = function (item) {
+		$scope.partner = angular.copy(item);
+		$scope.partner.ExpireTime = $scope.partner.ExpireTime == null ? "2049-12-31 23:59:59" : new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
+		$scope.isAdd = false;
+		$scope.allowUpload = false;
+		layer.closeAll();
+		$scope.categoryDropdown.setValue((item.CategoryIds || "").split(','));
+		$scope.typesDropdown.setValue(item.Types.split(','));
+		$scope.regionDropdown.setValue([item.RegionMode]);
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '保存广告',
+			area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
+			content: $("#edit"),
+			cancel: function (index, layero) {
+				setTimeout(function () {
+					$("#edit").css("display", "none");
+				}, 500);
+				return true;
+			}
+		});
+		layui.use('laydate', function () {
+			var laydate = layui.laydate;
+			laydate.render({
+				elem: '#timespan',
+				type: 'datetime',
+				calendar: true,
+				done: function (value, date, endDate) {
+					$scope.partner.ExpireTime = value;
+				}
+			});
+		});
+	}
 
-    $scope.closeAll = function () {
-        layer.closeAll();
-        setTimeout(function () {
-            $("#edit").css("display", "none");
-        }, 500);
-    }
+	$scope.copy = function (item) {
+		$scope.partner = angular.copy(item);
+		delete $scope.partner.Id;
+		$scope.partner.ExpireTime = $scope.partner.ExpireTime == null ? "2049-12-31 23:59:59" : new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
+		$scope.isAdd = true;
+		$scope.allowUpload = false;
+		layer.closeAll();
+		$scope.categoryDropdown.setValue((item.CategoryIds || "").split(','));
+		$scope.typesDropdown.setValue(item.Types.split(','));
+		$scope.regionDropdown.setValue([0]);
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '复制广告推广',
+			area: (window.screen.width > 650 ? 650 : window.screen.width) + 'px',// '340px'], //宽高
+			content: $("#edit"),
+			cancel: function (index, layero) {
+				setTimeout(function () {
+					$("#edit").css("display", "none");
+				}, 500);
+				return true;
+			}
+		});
+		layui.use('laydate', function () {
+			var laydate = layui.laydate;
+			laydate.render({
+				elem: '#timespan',
+				type: 'datetime',
+				calendar: true,
+				done: function (value, date, endDate) {
+					$scope.partner.ExpireTime = value;
+				}
+			});
+		});
+	}
 
-    $scope.submit = function (partner) {
-        if ($scope.isAdd) {
-            partner.Id = 0;
-        }
-        $scope.request("/partner/save", partner, function (data) {
-            $scope.closeAll();
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-            $scope.partner.ImageUrl = "";
-            $scope.partner.Description = "";
-            $scope.categoryDropdown.setValue([]);
-            $scope.typesDropdown.setValue([]);
-            $scope.regionDropdown.setValue([0]);
-        });
-    }
-    $scope.uploadImage = function (field) {
-        $("#uploadform").ajaxSubmit({
-            url: "/Upload",
-            type: "post",
-            success: function (data) {
-                document.getElementById("uploadform").reset();
-                $scope.$apply(function () {
-                    $scope.partner[field] = data.Data;
-                    layer.close(layer.index);
-                });
-            }
-        });
-    };
+	$scope.closeAll = function () {
+		layer.closeAll();
+		setTimeout(function () {
+			$("#edit").css("display", "none");
+		}, 500);
+	}
 
-    $scope.upload = function (field) {
-        $scope.imgField = field;
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '上传图片',
-            area: [(window.screen.width > 300 ? 300 : window.screen.width) + 'px', '80px'], //宽高
-            content: $("#img-upload"),
-            cancel: function (index, layero) {
-                return true;
-            }
-        });
-    }
+	$scope.submit = function (partner) {
+		if ($scope.isAdd) {
+			partner.Id = 0;
+		}
+		$scope.request("/partner/save", partner, function (data) {
+			$scope.closeAll();
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+			$scope.partner.ImageUrl = "";
+			$scope.partner.Description = "";
+			$scope.categoryDropdown.setValue([]);
+			$scope.typesDropdown.setValue([]);
+			$scope.regionDropdown.setValue([0]);
+		});
+	}
+	$scope.uploadImage = function (field) {
+		$("#uploadform").ajaxSubmit({
+			url: "/Upload",
+			type: "post",
+			success: function (data) {
+				document.getElementById("uploadform").reset();
+				$scope.$apply(function () {
+					$scope.partner[field] = data.Data;
+					layer.close(layer.index);
+				});
+			}
+		});
+	};
 
-    var _timeout;
-    $scope.search = function (kw) {
-        if (_timeout) {
-            $timeout.cancel(_timeout);
-        }
-        _timeout = $timeout(function () {
-            $scope.kw = kw;
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-            _timeout = null;
-        }, 500);
-    }
+	$scope.upload = function (field) {
+		$scope.imgField = field;
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '上传图片',
+			area: [(window.screen.width > 300 ? 300 : window.screen.width) + 'px', '80px'], //宽高
+			content: $("#img-upload"),
+			cancel: function (index, layero) {
+				return true;
+			}
+		});
+	}
 
-    $scope.changeState = function (row) {
-        $scope.request("/partner/ChangeState/" + row.Id, null, function (data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-        });
-    }
+	var _timeout;
+	$scope.search = function (kw) {
+		if (_timeout) {
+			$timeout.cancel(_timeout);
+		}
+		_timeout = $timeout(function () {
+			$scope.kw = kw;
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+			_timeout = null;
+		}, 500);
+	}
 
-    $scope.detail = function (item) {
-        $scope.partner = angular.copy(item);
-        layer.closeAll();
-        $scope.typesDropdown.setValue(item.Types.split(','));
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            offset: '50px',
-            title: item.Title,
-            area: (window.screen.width > 850 ? 850 : window.screen.width) + 'px',// '340px'], //宽高
-            content: $("#detail"),
-            cancel: function (index, layero) {
-                return true;
-            }
-        });
-        xmSelect.render({
-            el: '#category-view',
-            tips: '未选择分类',
-            disabled: true,
-            prop: {
-                name: 'Name',
-                value: 'Id',
-                children: 'Children',
-            },
-            tree: {
-                show: true,
-                strict: false,
-                expandedKeys: true,
-            },
-            autoRow: true, //选项过多,自动换行
-            data: $scope.cat,
-            initValue: (item.CategoryIds || "").split(",")
-        });
-        xmSelect.render({
-            el: '#types-view',
-            disabled: true,
-            autoRow: true, //选项过多,自动换行
-            data: [{ name: "轮播图", value: 1 }, { name: "列表项", value: 2 }, { name: "边栏", value: 3 }, { name: "内页", value: 4 }],
-            initValue: (item.Types || "").split(",")
-        });
-    }
+	$scope.changeState = function (row) {
+		$scope.request("/partner/ChangeState/" + row.Id, null, function (data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+	}
 
-    $scope.delayShow = function (item) {
-        $scope.partner = item;
-        $scope.isAdd = false;
-        $scope.partner.ExpireTime = new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: "延期广告",
-            content: $("#delay"),
-            cancel: function (index, layero) {
-                return true;
-            }
-        });
-        layui.use('laydate', function () {
-            var laydate = layui.laydate;
-            laydate.render({
-                elem: '.timespan',
-                type: 'datetime',
-                calendar: true,
-                done: function (value, date, endDate) {
-                    $scope.partner.ExpireTime = value;
-                }
-            });
-        });
-    }
+	$scope.detail = function (item) {
+		$scope.partner = angular.copy(item);
+		layer.closeAll();
+		$scope.typesDropdown.setValue(item.Types.split(','));
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			offset: '50px',
+			title: item.Title,
+			area: (window.screen.width > 850 ? 850 : window.screen.width) + 'px',// '340px'], //宽高
+			content: $("#detail"),
+			cancel: function (index, layero) {
+				return true;
+			}
+		});
+		xmSelect.render({
+			el: '#category-view',
+			tips: '未选择分类',
+			disabled: true,
+			prop: {
+				name: 'Name',
+				value: 'Id',
+				children: 'Children',
+			},
+			tree: {
+				show: true,
+				strict: false,
+				expandedKeys: true,
+			},
+			autoRow: true, //选项过多,自动换行
+			data: $scope.cat,
+			initValue: (item.CategoryIds || "").split(",")
+		});
+		xmSelect.render({
+			el: '#types-view',
+			disabled: true,
+			autoRow: true, //选项过多,自动换行
+			data: [{ name: "轮播图", value: 1 }, { name: "列表项", value: 2 }, { name: "边栏", value: 3 }, { name: "内页", value: 4 }],
+			initValue: (item.Types || "").split(",")
+		});
+	}
 
-    $scope.insight = function (row) {
-        layer.full(layer.open({
-            type: 2,
-            title: '广告《' + row.Title + '》洞察分析',
-            maxmin: true, //开启最大化最小化按钮
-            area: ['893px', '100vh'],
-            content: '/partner/' + row.Id + '/insight'
-        }));
-    }
-    
+	$scope.delayShow = function (item) {
+		$scope.partner = item;
+		$scope.isAdd = false;
+		$scope.partner.ExpireTime = new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: "延期广告",
+			content: $("#delay"),
+			cancel: function (index, layero) {
+				return true;
+			}
+		});
+		layui.use('laydate', function () {
+			var laydate = layui.laydate;
+			laydate.render({
+				elem: '.timespan',
+				type: 'datetime',
+				calendar: true,
+				done: function (value, date, endDate) {
+					$scope.partner.ExpireTime = value;
+				}
+			});
+		});
+	}
+
+	$scope.insight = function (row) {
+		layer.full(layer.open({
+			type: 2,
+			title: '广告《' + row.Title + '》洞察分析',
+			maxmin: true, //开启最大化最小化按钮
+			area: ['893px', '100vh'],
+			content: '/partner/' + row.Id + '/insight'
+		}));
+	}
+	
 	showCharts=function() {
-        echarts.init(document.getElementById('chart')).dispose();
+		echarts.init(document.getElementById('chart')).dispose();
 		var period = document.getElementById("period").value;
 		window.fetch(`/partner/records-chart?compare=${period > 0}&period=${period}`, {
 			credentials: 'include',
@@ -493,9 +520,9 @@
 						xAxisIndex: index,
 						areaStyle: {},
 						data: item,
-                          lineStyle: {
-                            type: index===1?'dashed':""
-                          },
+						  lineStyle: {
+							type: index===1?'dashed':""
+						  },
 						markPoint: {
 							data: [
 								{ type: 'max', name: '最大值' },

+ 1505 - 1505
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/post.js

@@ -1,373 +1,373 @@
 myApp.controller("postlist", ["$scope", "$http", "NgTableParams", "$timeout", function ($scope, $http, NgTableParams, $timeout) {
-    var self = this;
-    self.stats = [];
-    self.data = {};
-    $scope.kw = "";
-    $scope.orderby = 1;
-    $scope.CategoryId = "";
-    $scope.paginationConf = {
-        currentPage:  1,
-        itemsPerPage: 10,
-        pagesLength: 25,
-        perPageOptions: [10, 15, 20, 30, 50, 100, 200],
-        rememberPerPage: 'perPageItems',
-        onChange: function() {
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        }
-    };
-    var params = JSON.parse(localStorage.getItem("postlist-params"));
-    if (params) {
-        $scope.kw = params["kw"];
-        $scope.orderby= params["orderby"];
-        $scope.CategoryId=params["cid"];
-    }
+	var self = this;
+	self.stats = [];
+	self.data = {};
+	$scope.kw = "";
+	$scope.orderby = 1;
+	$scope.CategoryId = "";
+	$scope.paginationConf = {
+		currentPage:  1,
+		itemsPerPage: 10,
+		pagesLength: 25,
+		perPageOptions: [10, 15, 20, 30, 50, 100, 200],
+		rememberPerPage: 'perPageItems',
+		onChange: function() {
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		}
+	};
+	var params = JSON.parse(localStorage.getItem("postlist-params"));
+	if (params) {
+		$scope.kw = params["kw"];
+		$scope.orderby= params["orderby"];
+		$scope.CategoryId=params["cid"];
+	}
 
-    xmSelect.render({
-        el: '#orderby',
-        tips: '请选择排序方式',
-        model: {
-             icon: 'hidden',
-             label: { type: 'text' }
-        },
-        radio: true,
-        clickClose: true,
-        autoRow: true, //选项过多,自动换行
-        data:[
-                {name:"发表时间",value:0,selected:$scope.orderby==0},
-                {name:"最后修改",value:1,selected:$scope.orderby==1},
-                {name:"访问量最多",value:2,selected:$scope.orderby==2},
-                {name:"支持数最多",value:4,selected:$scope.orderby==4},
-                {name:"每日平均访问量(发布以来)",value:5,selected:$scope.orderby==5},
-                {name:"每日平均访问量(最近一年)",value:6,selected:$scope.orderby==6},
-            ],
-        on: function (data) {
-            if (data.arr.length>0) {
-                $scope.orderby = data.arr[0].value;
-                self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-            }
-        }
-    });
+	xmSelect.render({
+		el: '#orderby',
+		tips: '请选择排序方式',
+		model: {
+			 icon: 'hidden',
+			 label: { type: 'text' }
+		},
+		radio: true,
+		clickClose: true,
+		autoRow: true, //选项过多,自动换行
+		data:[
+				{name:"发表时间",value:0,selected:$scope.orderby==0},
+				{name:"最后修改",value:1,selected:$scope.orderby==1},
+				{name:"访问量最多",value:2,selected:$scope.orderby==2},
+				{name:"支持数最多",value:4,selected:$scope.orderby==4},
+				{name:"每日平均访问量(发布以来)",value:5,selected:$scope.orderby==5},
+				{name:"每日平均访问量(最近一年)",value:6,selected:$scope.orderby==6},
+			],
+		on: function (data) {
+			if (data.arr.length>0) {
+				$scope.orderby = data.arr[0].value;
+				self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+			}
+		}
+	});
 
-    function stat() {
-        fetch("/post/Statistic").then(function(response) {
-            return response.json();
-        }).then(function(res) {
-            if(res.Success) {
-                $scope.agg = res.Data;
-                $scope.$apply();
-            } else {
-                window.notie.alert({
-                    type:3,
-                    text:res.data.Message,
-                    time:4
-                });
-            }
-        });
-    }
+	function stat() {
+		fetch("/post/Statistic").then(function(response) {
+			return response.json();
+		}).then(function(res) {
+			if(res.Success) {
+				$scope.agg = res.Data;
+				$scope.$apply();
+			} else {
+				window.notie.alert({
+					type:3,
+					text:res.data.Message,
+					time:4
+				});
+			}
+		});
+	}
 
-    stat();
-    setInterval(stat,5000);
-    $http.get("/category/getcategories").then(function (res) {
-        var data = res.data;
-        if (data.Success) {
-            data.Data=[{Name:"全部",Id:"",Children:[]}].concat(data.Data);
-            var params = JSON.parse(localStorage.getItem("postlist-params"));
-            if (params) {
-                $scope.kw = params["kw"];
-                $scope.paginationConf.currentPage= params["page"];
-                for (var i = 0; i < data.Data.length; i++) {
-                    for (var j = 0; j < data.Data[i].Children.length; j++) {
-                        data.Data[i].Children[j].selected=data.Data[i].Children[j].Id==params["cid"];
-                    }
-                    data.Data[i].selected=data.Data[i].Id==params["cid"];
-                }
-            }
+	stat();
+	setInterval(stat,5000);
+	$http.get("/category/getcategories").then(function (res) {
+		var data = res.data;
+		if (data.Success) {
+			data.Data=[{Name:"全部",Id:"",Children:[]}].concat(data.Data);
+			var params = JSON.parse(localStorage.getItem("postlist-params"));
+			if (params) {
+				$scope.kw = params["kw"];
+				$scope.paginationConf.currentPage= params["page"];
+				for (var i = 0; i < data.Data.length; i++) {
+					for (var j = 0; j < data.Data[i].Children.length; j++) {
+						data.Data[i].Children[j].selected=data.Data[i].Children[j].Id==params["cid"];
+					}
+					data.Data[i].selected=data.Data[i].Id==params["cid"];
+				}
+			}
 
-            data.Data.sort((a,b)=> (b.selected||b.Children.some(c=>c.selected||c.Children.some(cc=>cc.selected)))- (a.selected||a.Children.some(c=>c.selected||c.Children.some(cc=>cc.selected))));
-            $scope.cat = data.Data;
-            xmSelect.render({
-                el: '#category',
-                tips: '请选择分类',
-                prop: {
-                    name: 'Name',
-                    value: 'Id',
-                    children: 'Children',
-                },
-                model: { label: { type: 'text' } },
-                radio: true,
-                clickClose: true,
-                tree: {
-                    show: true,
-                    strict: false,
-                },
-                filterable: true, //搜索功能
-                autoRow: true, //选项过多,自动换行
-                data:data.Data,
-                on: function (data) {
-                    if (data.arr.length>0) {
-                        $scope.CategoryId = data.arr[0].Id;
-                        self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-                    }
-                }
-            });
-        } else {
-            window.notie.alert({
-                type: 3,
-                text: '获取文章分类失败!',
-                time: 4
-            });
-        }
-    });
-    $scope.request("/seminar/getall", null, function(res) {
-        $scope.Seminars = res.Data;
-    });
+			data.Data.sort((a,b)=> (b.selected||b.Children.some(c=>c.selected||c.Children.some(cc=>cc.selected)))- (a.selected||a.Children.some(c=>c.selected||c.Children.some(cc=>cc.selected))));
+			$scope.cat = data.Data;
+			xmSelect.render({
+				el: '#category',
+				tips: '请选择分类',
+				prop: {
+					name: 'Name',
+					value: 'Id',
+					children: 'Children',
+				},
+				model: { label: { type: 'text' } },
+				radio: true,
+				clickClose: true,
+				tree: {
+					show: true,
+					strict: false,
+				},
+				filterable: true, //搜索功能
+				autoRow: true, //选项过多,自动换行
+				data:data.Data,
+				on: function (data) {
+					if (data.arr.length>0) {
+						$scope.CategoryId = data.arr[0].Id;
+						self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+					}
+				}
+			});
+		} else {
+			window.notie.alert({
+				type: 3,
+				text: '获取文章分类失败!',
+				time: 4
+			});
+		}
+	});
+	$scope.request("/seminar/getall", null, function(res) {
+		$scope.Seminars = res.Data;
+	});
 
-    this.GetPageData = function (page, size) {
-        var params = { page, size, kw: $scope.kw, orderby: $scope.orderby, cid: $scope.CategoryId };
-        $http.get(`/post/getpagedata?page=${page||1}&size=${size}&kw=${$scope.kw}&orderby=${$scope.orderby}&cid=${$scope.CategoryId}`).then(function(res) {
-            $scope.paginationConf.totalItems = res.data.TotalCount;
-            $("div[ng-table-pagination]").remove();
-            self.tableParams = new NgTableParams({ count: 50000 }, {
-                filterDelay: 0,
-                dataset: res.data.Data
-            });
-            self.data = res.data.Data;
-            Enumerable.From(res.data.Data).Select(e => e.Status).Distinct().ToArray().map(function(item, index, array) {
-                self.stats.push({
-                    id: item,
-                    title: item
-                });
-            });
-            self.stats = Enumerable.From(self.stats).Distinct().ToArray();
-            localStorage.setItem("postlist-params",JSON.stringify(params));
-            $timeout(function () {
-                self.data.forEach(item => {
-                    let categories = angular.copy($scope.cat);
-                    categories.sort((a,b)=> (b.Id==item.CategoryId||b.Children.some(c=>c.Id==item.CategoryId||c.Children.some(cc=>cc.Id==item.CategoryId)))- (a.Id==item.CategoryId||a.Children.some(c=>c.Id==item.CategoryId||c.Children.some(cc=>cc.Id==item.CategoryId))));
-                    xmSelect.render({
-                        el: '#category-' + item.Id,
-                        tips: '未选择分类',
-                        radio: true,
-                        prop: {
-                            name: 'Name',
-                            value: 'Id',
-                            children: 'Children',
-                        },
-                        tree: {
-                            show: true,
-                            strict: false,
-                            expandedKeys: true,
-                        },
-                        filterable: true, //搜索功能
-                        data: categories,
-                        initValue: [item.CategoryId],
-                        on: function (data) {
-                            for (var i = 0; i < data.arr.length; i++) {
-                                $http.post(`/post/${item.Id}/ChangeCategory/${data.arr[i].Id}`).then(function (res) {
-                                    if (data.status >= 400) {
-                                        layer.msg("操作失败");
-                                    }
-                                });
-                            }
-                        }
-                    });
-                    xmSelect.render({
-                        el: '#seminar-' + item.Id,
-                        tips: '未选择专题',
-                        prop: {
-                            name: 'Title',
-                            value: 'Id'
-                        },
-                        filterable: true, //搜索功能
-                        autoRow: true, //选项过多,自动换行
-                        data: $scope.Seminars,
-                        initValue: item.Seminars,
-                        on: function (data) {
-                            var arr=[];
-                            for (var i = 0; i < data.arr.length; i++) {
-                                arr.push(data.arr[i].Id);
-                            }
-                            $http.post(`/post/${item.Id}/ChangeSeminar?sids=${arr.join(",")}`).then(function (res) {
-                                if (data.status >= 400) {
-                                    layer.msg("操作失败");
-                                }
-                            });
-                        }
-                    });
-                });
-            }, 1);
-        });
-    }
+	this.GetPageData = function (page, size) {
+		var params = { page, size, kw: $scope.kw, orderby: $scope.orderby, cid: $scope.CategoryId };
+		$http.get(`/post/getpagedata?page=${page||1}&size=${size}&kw=${$scope.kw}&orderby=${$scope.orderby}&cid=${$scope.CategoryId}`).then(function(res) {
+			$scope.paginationConf.totalItems = res.data.TotalCount;
+			$("div[ng-table-pagination]").remove();
+			self.tableParams = new NgTableParams({ count: 50000 }, {
+				filterDelay: 0,
+				dataset: res.data.Data
+			});
+			self.data = res.data.Data;
+			Enumerable.From(res.data.Data).Select(e => e.Status).Distinct().ToArray().map(function(item, index, array) {
+				self.stats.push({
+					id: item,
+					title: item
+				});
+			});
+			self.stats = Enumerable.From(self.stats).Distinct().ToArray();
+			localStorage.setItem("postlist-params",JSON.stringify(params));
+			$timeout(function () {
+				self.data.forEach(item => {
+					let categories = angular.copy($scope.cat);
+					categories.sort((a,b)=> (b.Id==item.CategoryId||b.Children.some(c=>c.Id==item.CategoryId||c.Children.some(cc=>cc.Id==item.CategoryId)))- (a.Id==item.CategoryId||a.Children.some(c=>c.Id==item.CategoryId||c.Children.some(cc=>cc.Id==item.CategoryId))));
+					xmSelect.render({
+						el: '#category-' + item.Id,
+						tips: '未选择分类',
+						radio: true,
+						prop: {
+							name: 'Name',
+							value: 'Id',
+							children: 'Children',
+						},
+						tree: {
+							show: true,
+							strict: false,
+							expandedKeys: true,
+						},
+						filterable: true, //搜索功能
+						data: categories,
+						initValue: [item.CategoryId],
+						on: function (data) {
+							for (var i = 0; i < data.arr.length; i++) {
+								$http.post(`/post/${item.Id}/ChangeCategory/${data.arr[i].Id}`).then(function (res) {
+									if (data.status >= 400) {
+										layer.msg("操作失败");
+									}
+								});
+							}
+						}
+					});
+					xmSelect.render({
+						el: '#seminar-' + item.Id,
+						tips: '未选择专题',
+						prop: {
+							name: 'Title',
+							value: 'Id'
+						},
+						filterable: true, //搜索功能
+						autoRow: true, //选项过多,自动换行
+						data: $scope.Seminars,
+						initValue: item.Seminars,
+						on: function (data) {
+							var arr=[];
+							for (var i = 0; i < data.arr.length; i++) {
+								arr.push(data.arr[i].Id);
+							}
+							$http.post(`/post/${item.Id}/ChangeSeminar?sids=${arr.join(",")}`).then(function (res) {
+								if (data.status >= 400) {
+									layer.msg("操作失败");
+								}
+							});
+						}
+					});
+				});
+			}, 1);
+		});
+	}
 
-    self.takedown = function(row) {
-        swal({
-            title: "确认下架这篇文章吗?",
-            text: row.Title,
-            showCancelButton: true,
-            confirmButtonColor: "#DD6B55",
-            confirmButtonText: "确定",
-            cancelButtonText: "取消",
-            showLoaderOnConfirm: true,
-            animation: true,
-            allowOutsideClick: false
-        }).then(function() {
-            $scope.request("/post/takedown/"+row.Id, null, function(data) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 4
-                });
-            });
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        }, function() {
-        }).catch(swal.noop);
-    }
-    self.truncate = function(row) {
-        swal({
-            title: "确认要彻底删除这篇文章吗?",
-            text: row.Title,
-            showCancelButton: true,
-            confirmButtonColor: "#DD6B55",
-            confirmButtonText: "确定",
-            cancelButtonText: "取消",
-            showLoaderOnConfirm: true,
-            animation: true,
-            allowOutsideClick: false
-        }).then(function() {
-            $scope.request("/post/truncate/" + row.Id, null, function(data) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 4
-                });
-            });
-            _.remove(self.tableParams.settings().dataset, function(item) {
-                return row === item;
-            });
-            self.tableParams.reload().then(function(data) {
-                if (data.length === 0 && self.tableParams.total() > 0) {
-                    self.tableParams.page(self.tableParams.page() - 1);
-                    self.tableParams.reload();
-                }
-            });
-        }, function() {
-        }).catch(swal.noop);
-    }
-    self.pass = function(row) {
-        $scope.request("/post/pass", row, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-            self.stats = [];
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        });
-    }
-    self.takeup = function(row) {
-        $scope.request("/post/Takeup/"+row.Id,null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-            self.stats = [];
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        });
-    }
-    self.fixtop = function(id) {
-        $scope.request("/post/Fixtop/"+id,null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-            self.stats = [];
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        });
-    }
-    var _timeout;
-    $scope.search = function (kw) {
-        if (_timeout) {
-            $timeout.cancel(_timeout);
-        }
-        _timeout = $timeout(function () {
-            $scope.kw = kw;
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-            _timeout = null;
-        }, 500);
-    }
-    
-    $scope.toggleDisableComment= function(row) {
-        $scope.request(`/post/${row.Id}/DisableComment`, null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-        });
-    }
+	self.takedown = function(row) {
+		swal({
+			title: "确认下架这篇文章吗?",
+			text: row.Title,
+			showCancelButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			showLoaderOnConfirm: true,
+			animation: true,
+			allowOutsideClick: false
+		}).then(function() {
+			$scope.request("/post/takedown/"+row.Id, null, function(data) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 4
+				});
+			});
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		}, function() {
+		}).catch(swal.noop);
+	}
+	self.truncate = function(row) {
+		swal({
+			title: "确认要彻底删除这篇文章吗?",
+			text: row.Title,
+			showCancelButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			showLoaderOnConfirm: true,
+			animation: true,
+			allowOutsideClick: false
+		}).then(function() {
+			$scope.request("/post/truncate/" + row.Id, null, function(data) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 4
+				});
+			});
+			_.remove(self.tableParams.settings().dataset, function(item) {
+				return row === item;
+			});
+			self.tableParams.reload().then(function(data) {
+				if (data.length === 0 && self.tableParams.total() > 0) {
+					self.tableParams.page(self.tableParams.page() - 1);
+					self.tableParams.reload();
+				}
+			});
+		}, function() {
+		}).catch(swal.noop);
+	}
+	self.pass = function(row) {
+		$scope.request("/post/pass", row, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+			self.stats = [];
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		});
+	}
+	self.takeup = function(row) {
+		$scope.request("/post/Takeup/"+row.Id,null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+			self.stats = [];
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		});
+	}
+	self.fixtop = function(id) {
+		$scope.request("/post/Fixtop/"+id,null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+			self.stats = [];
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		});
+	}
+	var _timeout;
+	$scope.search = function (kw) {
+		if (_timeout) {
+			$timeout.cancel(_timeout);
+		}
+		_timeout = $timeout(function () {
+			$scope.kw = kw;
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+			_timeout = null;
+		}, 500);
+	}
+	
+	$scope.toggleDisableComment= function(row) {
+		$scope.request(`/post/${row.Id}/DisableComment`, null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+	}
 
-    $scope.toggleDisableCopy= function(row) {
-        $scope.request(`/post/${row.Id}/DisableCopy`, null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-        });
-    }
+	$scope.toggleDisableCopy= function(row) {
+		$scope.request(`/post/${row.Id}/DisableCopy`, null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+	}
 
-    $scope.rssSwitch= function(id) {
-        $scope.request("/post/"+id+"/rss-switch",null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-        });
-    }
+	$scope.rssSwitch= function(id) {
+		$scope.request("/post/"+id+"/rss-switch",null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+	}
 
-    $scope.lockedSwitch= function(id) {
-        $scope.request("/post/"+id+"/locked-switch",null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-        });
-    }
-    
-    $scope.nsfwSwitch= function(id) {
-        $scope.request("/post/"+id+"/nsfw",null, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-        });
-    }
-    
-    self.insight= function(row) {
-        layer.full(layer.open({
-          type: 2,
-          title: '文章《'+row.Title+'》洞察分析',
-          maxmin: true, //开启最大化最小化按钮
-          area: ['893px', '100vh'],
-          content: '/'+row.Id+'/insight'
-        }));
-    }
-    
-    $scope.diffDateFromNow = function(date){
-          var dateOut = new Date(date);
+	$scope.lockedSwitch= function(id) {
+		$scope.request("/post/"+id+"/locked-switch",null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+	}
+	
+	$scope.nsfwSwitch= function(id) {
+		$scope.request("/post/"+id+"/nsfw",null, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+	}
+	
+	self.insight= function(row) {
+		layer.full(layer.open({
+		  type: 2,
+		  title: '文章《'+row.Title+'》洞察分析',
+		  maxmin: true, //开启最大化最小化按钮
+		  area: ['893px', '100vh'],
+		  content: '/'+row.Id+'/insight'
+		}));
+	}
+	
+	$scope.diffDateFromNow = function(date){
+		  var dateOut = new Date(date);
 
-          var timeDiff = Math.abs(new Date().getTime() - dateOut.getTime());
-          var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); 
-          return diffDays;
-    };
-    
-    showCharts=function() {
-        echarts.init(document.getElementById('chart')).dispose();
+		  var timeDiff = Math.abs(new Date().getTime() - dateOut.getTime());
+		  var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); 
+		  return diffDays;
+	};
+	
+	showCharts=function() {
+		echarts.init(document.getElementById('chart')).dispose();
 		var period=document.getElementById("period").value;
 		window.fetch(`/post/records-chart?compare=${period>0}&period=${period}`, {
 			credentials: 'include',
@@ -390,7 +390,7 @@
 				}
 				xSeries.push(x);
 				yCountSeries.push(yCount);
-                yUvSeries.push(yUV);
+				yUvSeries.push(yUV);
 			}
 			var chartDom = document.getElementById('chart');
 			var myChart = echarts.init(chartDom);
@@ -446,9 +446,9 @@
 						symbol: 'none',
 						xAxisIndex: index,
 						data: item,
-                          lineStyle: {
-                            type: index===1?'dashed':""
-                          },
+						  lineStyle: {
+							type: index===1?'dashed':""
+						  },
 						markPoint: {
 							data: [
 								{ type: 'max', name: '最大值' },
@@ -469,1177 +469,1177 @@
 						xAxisIndex: index,
 						areaStyle: {},
 						data: item,
-                          lineStyle: {
-                            type: index===1?'dashed':""
-                          }
+						  lineStyle: {
+							type: index===1?'dashed':""
+						  }
 					}
 				}))
 			};
 			myChart.setOption(option);
 		});
-    }
-    showCharts();
+	}
+	showCharts();
 }]);
 myApp.controller("writeblog", ["$scope", "$http", "$timeout","$location", function ($scope, $http, $timeout,$location) {
-    UEDITOR_CONFIG.initialFrameHeight=null;
-    UEDITOR_CONFIG.autoHeightEnabled=true;
-    UEDITOR_CONFIG.zIndex=1;
-    clearInterval(window.interval);
-    $scope.post = {
-        Title: "",
-        schedule: false,
-        Content: "",
-        CategoryId: 1,
-        Label: "",
-        Seminars: "",
-        Keyword:""
-    };
-    
-    $scope.post.Author =$scope.user.NickName || $scope.user.Username;
-    $scope.post.Email = $scope.user.Email;
-    var refer = $location.search()['refer'];
-    if (refer) {
-        $scope.get("/post/get/"+refer, function (data) {
-            $scope.post = data.Data;
-            delete $scope.post.Id;
-            $scope.keywordsDropdown.update({data: ($scope.post.Keyword||"").split(',')});
-        });
-    }
-    $scope.getCategory = function () {
-        $http.get("/category/getcategories").then(function (res) {
-            var data = res.data;
-            if (data.Success) {
-                $scope.cat = data.Data;
-                $scope.categoryDropdown = xmSelect.render({
-                    el: '#category',
-                    tips: '请选择分类',
-                    prop: {
-                        name: 'Name',
-                        value: 'Id',
-                        children: 'Children',
-                    },
-                    model: { label: { type: 'text' } },
-                    radio: true,
-                    clickClose: true,
-                    tree: {
-                        show: true,
-                        strict: false,
-                        expandedKeys: true,
-                    },
-                    filterable: true, //搜索功能
-                    autoRow: true, //选项过多,自动换行
-                    data:data.Data,
-                    on: function (data) {
-                        if (data.arr.length>0) {
-                            $scope.post.CategoryId=data.arr[0].Id;
-                        }
-                    }
-                });
-            } else {
-                window.notie.alert({
-                    type: 3,
-                    text: '获取文章分类失败!',
-                    time: 4
-                });
-            }
-        });
-    }
-    $scope.getCategory();
-    $scope.get("/post/gettag", function(res) {
-        $scope.Tags = res.Data;
-        var tags=[];
-        for (var i = 0; i < res.Data.length; i++) {
-            tags.push({name:res.Data[i],value:res.Data[i]});
-        }
+	UEDITOR_CONFIG.initialFrameHeight=null;
+	UEDITOR_CONFIG.autoHeightEnabled=true;
+	UEDITOR_CONFIG.zIndex=1;
+	clearInterval(window.interval);
+	$scope.post = {
+		Title: "",
+		schedule: false,
+		Content: "",
+		CategoryId: 1,
+		Label: "",
+		Seminars: "",
+		Keyword:""
+	};
+	
+	$scope.post.Author =$scope.user.NickName || $scope.user.Username;
+	$scope.post.Email = $scope.user.Email;
+	var refer = $location.search()['refer'];
+	if (refer) {
+		$scope.get("/post/get/"+refer, function (data) {
+			$scope.post = data.Data;
+			delete $scope.post.Id;
+			$scope.keywordsDropdown.update({data: ($scope.post.Keyword||"").split(',')});
+		});
+	}
+	$scope.getCategory = function () {
+		$http.get("/category/getcategories").then(function (res) {
+			var data = res.data;
+			if (data.Success) {
+				$scope.cat = data.Data;
+				$scope.categoryDropdown = xmSelect.render({
+					el: '#category',
+					tips: '请选择分类',
+					prop: {
+						name: 'Name',
+						value: 'Id',
+						children: 'Children',
+					},
+					model: { label: { type: 'text' } },
+					radio: true,
+					clickClose: true,
+					tree: {
+						show: true,
+						strict: false,
+						expandedKeys: true,
+					},
+					filterable: true, //搜索功能
+					autoRow: true, //选项过多,自动换行
+					data:data.Data,
+					on: function (data) {
+						if (data.arr.length>0) {
+							$scope.post.CategoryId=data.arr[0].Id;
+						}
+					}
+				});
+			} else {
+				window.notie.alert({
+					type: 3,
+					text: '获取文章分类失败!',
+					time: 4
+				});
+			}
+		});
+	}
+	$scope.getCategory();
+	$scope.get("/post/gettag", function(res) {
+		$scope.Tags = res.Data;
+		var tags=[];
+		for (var i = 0; i < res.Data.length; i++) {
+			tags.push({name:res.Data[i],value:res.Data[i]});
+		}
 
-        $scope.tagDropdown =xmSelect.render({
-            el: '#tags',
-            tips: '请选择标签',
-            toolbar: { //工具条,全选,清空,反选,自定义
-                show: true,
-                list: ['ALL', 'CLEAR', 'REVERSE']
-            },
-            data: tags,
-            //initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
-            filterable: true, //搜索功能
-            autoRow: true, //选项过多,自动换行
-            // repeat: true,//是否支持重复选择
-            //max: 2,//最多选择2个
-            // template({ item, sels, name, value }){
-            //    //template:自定义下拉框的模板
-            //     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
-            // },
-            on: function (data) {
-                var arr=[];
-                for (let j = 0; j < data.arr.length; j++) {
-                    arr.push(data.arr[j].value);
-                }
-                $scope.post.Label=arr.join(",");
-            },
-            filterDone(val, list) { //val: 当前搜索值, list: 过滤后的数据
-                var temp={name:val,value:val}
-                if (tags.find(e=>e.value==val)==undefined) {
-                    tags.push(temp);
-                    $scope.tagDropdown.update({data:tags});
-                    $scope.tagDropdown.setValue(($scope.post.Label||"").split(','));
-                }
-            }
-        });
-    });
-    $scope.request("/seminar/getall", null, function(res) {
-        $scope.Seminars = res.Data;
-        for (var i = 0; i < res.Data.length; i++) {
-            res.Data[i].name=res.Data[i].Title;
-            res.Data[i].value=res.Data[i].Id;
-        }
+		$scope.tagDropdown =xmSelect.render({
+			el: '#tags',
+			tips: '请选择标签',
+			toolbar: { //工具条,全选,清空,反选,自定义
+				show: true,
+				list: ['ALL', 'CLEAR', 'REVERSE']
+			},
+			data: tags,
+			//initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
+			filterable: true, //搜索功能
+			autoRow: true, //选项过多,自动换行
+			// repeat: true,//是否支持重复选择
+			//max: 2,//最多选择2个
+			// template({ item, sels, name, value }){
+			//    //template:自定义下拉框的模板
+			//     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
+			// },
+			on: function (data) {
+				var arr=[];
+				for (let j = 0; j < data.arr.length; j++) {
+					arr.push(data.arr[j].value);
+				}
+				$scope.post.Label=arr.join(",");
+			},
+			filterDone(val, list) { //val: 当前搜索值, list: 过滤后的数据
+				var temp={name:val,value:val}
+				if (tags.find(e=>e.value==val)==undefined) {
+					tags.push(temp);
+					$scope.tagDropdown.update({data:tags});
+					$scope.tagDropdown.setValue(($scope.post.Label||"").split(','));
+				}
+			}
+		});
+	});
+	$scope.request("/seminar/getall", null, function(res) {
+		$scope.Seminars = res.Data;
+		for (var i = 0; i < res.Data.length; i++) {
+			res.Data[i].name=res.Data[i].Title;
+			res.Data[i].value=res.Data[i].Id;
+		}
 
-        $scope.seminarDropdown =xmSelect.render({
-            el: '#seminar',
-            tips: '请选择专题',
-            toolbar: { //工具条,全选,清空,反选,自定义
-                show: true,
-                list: ['ALL', 'CLEAR', 'REVERSE']
-            },
-            data: res.Data,
-            //initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
-            filterable: true, //搜索功能
-            autoRow: true, //选项过多,自动换行
-            // repeat: true,//是否支持重复选择
-            //max: 2,//最多选择2个
-            // template({ item, sels, name, value }){
-            //    //template:自定义下拉框的模板
-            //     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
-            // },
-            on: function (data) {
-                var arr=[];
-                for (let j = 0; j < data.arr.length; j++) {
-                    arr.push(data.arr[j].value);
-                }
-                $scope.post.Seminars=arr.join(",");
-            }
-        })
-    });
+		$scope.seminarDropdown =xmSelect.render({
+			el: '#seminar',
+			tips: '请选择专题',
+			toolbar: { //工具条,全选,清空,反选,自定义
+				show: true,
+				list: ['ALL', 'CLEAR', 'REVERSE']
+			},
+			data: res.Data,
+			//initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
+			filterable: true, //搜索功能
+			autoRow: true, //选项过多,自动换行
+			// repeat: true,//是否支持重复选择
+			//max: 2,//最多选择2个
+			// template({ item, sels, name, value }){
+			//    //template:自定义下拉框的模板
+			//     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
+			// },
+			on: function (data) {
+				var arr=[];
+				for (let j = 0; j < data.arr.length; j++) {
+					arr.push(data.arr[j].value);
+				}
+				$scope.post.Seminars=arr.join(",");
+			}
+		})
+	});
 
-     layui.config({
-        base: './Assets/layui/'
-    }).use(['inputTag', 'jquery'], function () {
-        var $ = layui.jquery, inputTag = layui.inputTag;
-        $scope.keywordsDropdown = inputTag.render({
-            elem: '.keywords',
-            data: [],//初始值
-            permanentData: [],//不允许删除的值
-            removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
-            createKeyNum: 13,//创建按键编号 默认,Enter 键
-            beforeCreate: function (data, value) {//添加前操作,必须返回字符串才有效
-                return value;
-            },
-            onChange: function (data, value, type) {
-                $scope.post.Keyword=data.join(",");
-            }
-        });
-    });
+	 layui.config({
+		base: './Assets/layui/'
+	}).use(['inputTag', 'jquery'], function () {
+		var $ = layui.jquery, inputTag = layui.inputTag;
+		$scope.keywordsDropdown = inputTag.render({
+			elem: '.keywords',
+			data: [],//初始值
+			permanentData: [],//不允许删除的值
+			removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
+			createKeyNum: 13,//创建按键编号 默认,Enter 键
+			beforeCreate: function (data, value) {//添加前操作,必须返回字符串才有效
+				return value;
+			},
+			onChange: function (data, value, type) {
+				$scope.post.Keyword=data.join(",");
+			}
+		});
+	});
 
-    //上传Word文档
-    $scope.upload = function() {
-        $("#docform").ajaxSubmit({
-            url: "/Upload/UploadWord",
-            type: "post",
-            success: function(data) {
-                console.log(data);
-                if (data.Success) {
-                    window.notie.alert({
-                        type: 1,
-                        text: '文档上传成功!',
-                        time: 2
-                    });
-                    $scope.$apply(function() {
-                        $scope.post.Content = data.Data.Content;
-                        $scope.post.Title = data.Data.Title;
-                    });
-                    layer.closeAll();
-                } else {
-                    window.notie.alert({
-                        type: 3,
-                        text: data.Message,
-                        time: 4
-                    });
-                }
-            }
-        });
-        $scope.selectFile = false;
-    }
+	//上传Word文档
+	$scope.upload = function() {
+		$("#docform").ajaxSubmit({
+			url: "/Upload/UploadWord",
+			type: "post",
+			success: function(data) {
+				console.log(data);
+				if (data.Success) {
+					window.notie.alert({
+						type: 1,
+						text: '文档上传成功!',
+						time: 2
+					});
+					$scope.$apply(function() {
+						$scope.post.Content = data.Data.Content;
+						$scope.post.Title = data.Data.Title;
+					});
+					layer.closeAll();
+				} else {
+					window.notie.alert({
+						type: 3,
+						text: data.Message,
+						time: 4
+					});
+				}
+			}
+		});
+		$scope.selectFile = false;
+	}
 
-    //文件上传
-    $scope.showupload = function() {
-        layui.use("layer", function() {
-            var layer = layui.layer;
-            layer.open({
-                type: 1,
-                title: '上传Word文档',
-                area: ['420px', '150px'], //宽高
-                content: $("#docfile")
-            });
-        });
-    }
+	//文件上传
+	$scope.showupload = function() {
+		layui.use("layer", function() {
+			var layer = layui.layer;
+			layer.open({
+				type: 1,
+				title: '上传Word文档',
+				area: ['420px', '150px'], //宽高
+				content: $("#docfile")
+			});
+		});
+	}
 
-    //异步提交表单开始
-    $scope.submit = function(post) {
-        Object.keys(post).forEach(key => post[key] == undefined||post[key] == null ? delete post[key] : '');
-        if (!post.Label) {
-            post.Label = null;
-        }
-        if (post.Title.trim().length <= 2 || post.Title.trim().length > 128) {
-            window.notie.alert({
-                type: 3,
-                text: '文章标题必须在2到128个字符以内!',
-                time: 4
-            });
-            
-            return;
-        }
-        $http.post("/Post/write", post).then(function(res) {
-            var data = res.data;
-            if (data.Success) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 4
-                });
-                $scope.post.Content = "";
-                $scope.post.Title = "";
-                clearInterval(window.interval);
-                localStorage.removeItem("write-post-draft");
-            } else {
-                window.notie.alert({
-                    type: 3,
-                    text: data.Message,
-                    time: 4
-                });
-            }
-        });
-    }
+	//异步提交表单开始
+	$scope.submit = function(post) {
+		Object.keys(post).forEach(key => post[key] == undefined||post[key] == null ? delete post[key] : '');
+		if (!post.Label) {
+			post.Label = null;
+		}
+		if (post.Title.trim().length <= 2 || post.Title.trim().length > 128) {
+			window.notie.alert({
+				type: 3,
+				text: '文章标题必须在2到128个字符以内!',
+				time: 4
+			});
+			
+			return;
+		}
+		$http.post("/Post/write", post).then(function(res) {
+			var data = res.data;
+			if (data.Success) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 4
+				});
+				$scope.post.Content = "";
+				$scope.post.Title = "";
+				clearInterval(window.interval);
+				localStorage.removeItem("write-post-draft");
+			} else {
+				window.notie.alert({
+					type: 3,
+					text: data.Message,
+					time: 4
+				});
+			}
+		});
+	}
 
-    // 定时发布
-    $scope.Scheduled= function() {
-        if ($scope.post.schedule) {
-            layui.use('laydate', function(){
-              var laydate = layui.laydate;
-              laydate.render({
-                elem: '#timespan',
-                type: 'datetime',
-                calendar: true,
-                min: new Date(new Date().setMinutes(new Date().getMinutes()+10)).Format("yyyy-MM-dd hh:mm:ss"),
-                max: new Date(new Date().setDate(new Date().getDate()+3)).Format("yyyy-MM-dd hh:mm:ss"),
-                done: function(value, date, endDate) {
-                    if (value) {
-                        $scope.post.timespan=value;
-                    } else {
-                        delete $scope.post.timespan;
-                    }
-                }
-              });
-            });
-        }
-    }
+	// 定时发布
+	$scope.Scheduled= function() {
+		if ($scope.post.schedule) {
+			layui.use('laydate', function(){
+			  var laydate = layui.laydate;
+			  laydate.render({
+				elem: '#timespan',
+				type: 'datetime',
+				calendar: true,
+				min: new Date(new Date().setMinutes(new Date().getMinutes()+10)).Format("yyyy-MM-dd hh:mm:ss"),
+				max: new Date(new Date().setDate(new Date().getDate()+3)).Format("yyyy-MM-dd hh:mm:ss"),
+				done: function(value, date, endDate) {
+					if (value) {
+						$scope.post.timespan=value;
+					} else {
+						delete $scope.post.timespan;
+					}
+				}
+			  });
+			});
+		}
+	}
 
-    //检查草稿
-    if (localStorage.getItem("write-post-draft")) {
-        notie.confirm({
-            text: "检查到上次有未提交的草稿,是否加载?",
-            submitText: "确定",
-            cancelText: "取消",
-            position: "bottom",
-            submitCallback: function () {
-                $scope.post = JSON.parse(localStorage.getItem("write-post-draft"));
-                $scope.$apply();
-                $timeout(function () {
-                    if ($scope.post.CategoryId>0) {
-                        $scope.categoryDropdown.setValue([$scope.post.CategoryId]);
-                        $scope.categoryDropdown.options.data.sort((a,b)=>(b.Id==$scope.post.CategoryId||b.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId)))-(a.Id==$scope.post.CategoryId||a.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId))));
-                    }
-                    if ($scope.post.Label) {
-                        $scope.tagDropdown.setValue($scope.post.Label.split(','));
-                    }
-                    if ($scope.post.Seminars) {
-                        $scope.seminarDropdown.setValue($scope.post.Seminars.split(','));
-                    }
-                    if ($scope.post.Keyword) {
-                        console.log($scope.keywordsDropdown);
-                        $scope.keywordsDropdown.render({data:$scope.post.Keyword.split(',')})
-                    }
-                    $scope.Scheduled();
-                }, 10);
-                window.interval = setInterval(function () {
-                    localStorage.setItem("write-post-draft",JSON.stringify($scope.post));
-                },5000);
-            },
-            cancelCallback: function() {
-                window.interval = setInterval(function () {
-                    localStorage.setItem("write-post-draft",JSON.stringify($scope.post));
-                },5000);
-            }
-        });
-    } else {
-        window.interval = setInterval(function () {
-            localStorage.setItem("write-post-draft",JSON.stringify($scope.post));
-        },5000);
-    }
+	//检查草稿
+	if (localStorage.getItem("write-post-draft")) {
+		notie.confirm({
+			text: "检查到上次有未提交的草稿,是否加载?",
+			submitText: "确定",
+			cancelText: "取消",
+			position: "bottom",
+			submitCallback: function () {
+				$scope.post = JSON.parse(localStorage.getItem("write-post-draft"));
+				$scope.$apply();
+				$timeout(function () {
+					if ($scope.post.CategoryId>0) {
+						$scope.categoryDropdown.setValue([$scope.post.CategoryId]);
+						$scope.categoryDropdown.options.data.sort((a,b)=>(b.Id==$scope.post.CategoryId||b.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId)))-(a.Id==$scope.post.CategoryId||a.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId))));
+					}
+					if ($scope.post.Label) {
+						$scope.tagDropdown.setValue($scope.post.Label.split(','));
+					}
+					if ($scope.post.Seminars) {
+						$scope.seminarDropdown.setValue($scope.post.Seminars.split(','));
+					}
+					if ($scope.post.Keyword) {
+						console.log($scope.keywordsDropdown);
+						$scope.keywordsDropdown.render({data:$scope.post.Keyword.split(',')})
+					}
+					$scope.Scheduled();
+				}, 10);
+				window.interval = setInterval(function () {
+					localStorage.setItem("write-post-draft",JSON.stringify($scope.post));
+				},5000);
+			},
+			cancelCallback: function() {
+				window.interval = setInterval(function () {
+					localStorage.setItem("write-post-draft",JSON.stringify($scope.post));
+				},5000);
+			}
+		});
+	} else {
+		window.interval = setInterval(function () {
+			localStorage.setItem("write-post-draft",JSON.stringify($scope.post));
+		},5000);
+	}
 
-    $scope.get("/post/GetRegions?name=Regions", function(data) {
-        $scope.Regions=data.Data;
-    });
-    $scope.get("/post/GetRegions?name=ExceptRegions", function(data) {
-        $scope.ExceptRegions=data.Data;
-    });
-    
-    // 绑定过期时间表单元素
-    layui.use('laydate', function(){
-        var laydate = layui.laydate;
-        laydate.render({
-        elem: '#expireAt',
-        type: 'datetime',
-        calendar: true,
-        min: new Date(new Date().setMinutes(new Date().getMinutes()+10)).Format("yyyy-MM-dd hh:mm:ss"),
-        done: function(value, date, endDate) {
-            if (value) {
-                $scope.post.expireAt=value;
-            } else {
-                delete $scope.post.expireAt;
-            }
-        }
-        });
-    });
+	$scope.get("/post/GetRegions?name=Regions", function(data) {
+		$scope.Regions=data.Data;
+	});
+	$scope.get("/post/GetRegions?name=ExceptRegions", function(data) {
+		$scope.ExceptRegions=data.Data;
+	});
+	
+	// 绑定过期时间表单元素
+	layui.use('laydate', function(){
+		var laydate = layui.laydate;
+		laydate.render({
+		elem: '#expireAt',
+		type: 'datetime',
+		calendar: true,
+		min: new Date(new Date().setMinutes(new Date().getMinutes()+10)).Format("yyyy-MM-dd hh:mm:ss"),
+		done: function(value, date, endDate) {
+			if (value) {
+				$scope.post.expireAt=value;
+			} else {
+				delete $scope.post.expireAt;
+			}
+		}
+		});
+	});
 }]);
 
 myApp.controller("postedit", ["$scope", "$http", "$location", "$timeout", function ($scope, $http, $location, $timeout) {
-    UEDITOR_CONFIG.initialFrameHeight=null;
-    UEDITOR_CONFIG.autoHeightEnabled=true;
-    UEDITOR_CONFIG.zIndex=1;
-    $scope.id = $location.search()['id'];
-    $scope.reserve = true;
-    $scope.get("/post/get/" + $scope.id, function (data) {
-        $scope.post = data.Data;
-        if ($scope.post.ExpireAt) {
-            $scope.post.ExpireAt=new Date($scope.post.ExpireAt).Format("yyyy-MM-dd hh:mm:ss");
-        }
-        $scope.get("/post/gettag", function (res) {
-            $scope.Tags = res.Data;
-            var tags=[];
-            for (var i = 0; i < res.Data.length; i++) {
-                tags.push({name:res.Data[i],value:res.Data[i]});
-            }
+	UEDITOR_CONFIG.initialFrameHeight=null;
+	UEDITOR_CONFIG.autoHeightEnabled=true;
+	UEDITOR_CONFIG.zIndex=1;
+	$scope.id = $location.search()['id'];
+	$scope.reserve = true;
+	$scope.get("/post/get/" + $scope.id, function (data) {
+		$scope.post = data.Data;
+		if ($scope.post.ExpireAt) {
+			$scope.post.ExpireAt=new Date($scope.post.ExpireAt).Format("yyyy-MM-dd hh:mm:ss");
+		}
+		$scope.get("/post/gettag", function (res) {
+			$scope.Tags = res.Data;
+			var tags=[];
+			for (var i = 0; i < res.Data.length; i++) {
+				tags.push({name:res.Data[i],value:res.Data[i]});
+			}
 
-            $scope.tagDropdown =xmSelect.render({
-                el: '#tags',
-                tips: '请选择标签',
-                toolbar: { //工具条,全选,清空,反选,自定义
-                    show: true,
-                    list: ['ALL', 'CLEAR', 'REVERSE']
-                },
-                data: tags,
-                //initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
-                filterable: true, //搜索功能
-                autoRow: true, //选项过多,自动换行
-                // repeat: true,//是否支持重复选择
-                //max: 2,//最多选择2个
-                // template({ item, sels, name, value }){
-                //    //template:自定义下拉框的模板
-                //     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
-                // },
-                on: function (data) {
-                    var arr=[];
-                    for (let j = 0; j < data.arr.length; j++) {
-                        arr.push(data.arr[j].value);
-                    }
-                    $scope.post.Label=arr.join(",");
-                },
-                filterDone(val, list) { //val: 当前搜索值, list: 过滤后的数据
-                    var temp={name:val,value:val}
-                    if (tags.find(e=>e.value==val)==undefined) {
-                        tags.push(temp);
-                        $scope.tagDropdown.update({data:tags});
-                        $scope.tagDropdown.setValue(($scope.post.Label||"").split(','));
-                    }
-                }
-            });
-            if ($scope.post.Label) {
-                $scope.tagDropdown.setValue($scope.post.Label.split(','));
-            }
-        });
-        $scope.request("/seminar/getall", null, function (res) {
-            $scope.Seminars = res.Data;
-            for (var i = 0; i < res.Data.length; i++) {
-                res.Data[i].name=res.Data[i].Title;
-                res.Data[i].value=res.Data[i].Id;
-            }
+			$scope.tagDropdown =xmSelect.render({
+				el: '#tags',
+				tips: '请选择标签',
+				toolbar: { //工具条,全选,清空,反选,自定义
+					show: true,
+					list: ['ALL', 'CLEAR', 'REVERSE']
+				},
+				data: tags,
+				//initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
+				filterable: true, //搜索功能
+				autoRow: true, //选项过多,自动换行
+				// repeat: true,//是否支持重复选择
+				//max: 2,//最多选择2个
+				// template({ item, sels, name, value }){
+				//    //template:自定义下拉框的模板
+				//     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
+				// },
+				on: function (data) {
+					var arr=[];
+					for (let j = 0; j < data.arr.length; j++) {
+						arr.push(data.arr[j].value);
+					}
+					$scope.post.Label=arr.join(",");
+				},
+				filterDone(val, list) { //val: 当前搜索值, list: 过滤后的数据
+					var temp={name:val,value:val}
+					if (tags.find(e=>e.value==val)==undefined) {
+						tags.push(temp);
+						$scope.tagDropdown.update({data:tags});
+						$scope.tagDropdown.setValue(($scope.post.Label||"").split(','));
+					}
+				}
+			});
+			if ($scope.post.Label) {
+				$scope.tagDropdown.setValue($scope.post.Label.split(','));
+			}
+		});
+		$scope.request("/seminar/getall", null, function (res) {
+			$scope.Seminars = res.Data;
+			for (var i = 0; i < res.Data.length; i++) {
+				res.Data[i].name=res.Data[i].Title;
+				res.Data[i].value=res.Data[i].Id;
+			}
 
-            $scope.seminarDropdown =xmSelect.render({
-                el: '#seminar',
-                tips: '请选择专题',
-                toolbar: { //工具条,全选,清空,反选,自定义
-                    show: true,
-                    list: ['ALL', 'CLEAR', 'REVERSE']
-                },
-                data: res.Data,
-                //initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
-                filterable: true, //搜索功能
-                autoRow: true, //选项过多,自动换行
-                // repeat: true,//是否支持重复选择
-                //max: 2,//最多选择2个
-                // template({ item, sels, name, value }){
-                //    //template:自定义下拉框的模板
-                //     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
-                // },
-                on: function (data) {
-                    var arr=[];
-                    for (let j = 0; j < data.arr.length; j++) {
-                        arr.push(data.arr[j].value);
-                    }
-                    $scope.post.Seminars=arr.join(",");
-                }
-            });
-            if ($scope.post.Seminars) {
-                $scope.seminarDropdown.setValue($scope.post.Seminars.split(','));
-            }
-        });
-        $scope.getCategory();
-        layui.config({
-            base: './Assets/layui/'
-        }).use(['inputTag', 'jquery'], function () {
-            var $ = layui.jquery, inputTag = layui.inputTag;
-            $scope.keywordsDropdown = inputTag.render({
-                elem: '.keywords',
-                data:  ($scope.post.Keyword||"").split(','),//初始值
-                permanentData: [],//不允许删除的值
-                removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
-                createKeyNum: 13,//创建按键编号 默认,Enter 键
-                beforeCreate: function (data, value) {//添加前操作,必须返回字符串才有效
-                    return value;
-                },
-                onChange: function (data, value, type) {
-                    $scope.post.Keyword=data.join(",");
-                }
-            });
-        });
-    });
-    $scope.getCategory = function () {
-        $http.post("/category/getcategories", null).then(function (res) {
-            var data = res.data;
-            if (data.Success) {
-                $scope.cat = data.Data;
-                $scope.categoryDropdown = xmSelect.render({
-                    el: '#category',
-                    tips: '请选择分类',
-                    prop: {
-                        name: 'Name',
-                        value: 'Id',
-                        children: 'Children',
-                    },
-                    model: { label: { type: 'text' } },
-                    radio: true,
-                    clickClose: true,
-                    tree: {
-                        show: true,
-                        strict: false,
-                        expandedKeys: true,
-                    },
-                    filterable: true, //搜索功能
-                    autoRow: true, //选项过多,自动换行
-                    data:data.Data,
-                    on: function (data) {
-                        if (data.arr.length>0) {
-                            $scope.post.CategoryId=data.arr[0].Id;
-                        }
-                    }
-                });
-                if ($scope.post.CategoryId>0) {
-                        $scope.categoryDropdown.setValue([$scope.post.CategoryId]);
-                        $scope.categoryDropdown.options.data.sort((a,b)=>(b.Id==$scope.post.CategoryId||b.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId)))-(a.Id==$scope.post.CategoryId||a.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId))));
-                    }
-            } else {
-                window.notie.alert({
-                    type: 3,
-                    text: '获取文章分类失败!',
-                    time: 4
-                });
-            }
-        });
-    }
-    //上传Word文档
-    $scope.upload = function () {
-        
-        $("#docform").ajaxSubmit({
-            url: "/Upload/UploadWord",
-            type: "post",
-            success: function (data) {
-                
-                console.log(data);
-                if (data.Success) {
-                    window.notie.alert({
-                        type: 1,
-                        text: '文档上传成功!',
-                        time: 2
-                    });
-                    $scope.$apply(function () {
-                        $scope.post.Content = data.Data.Content;
-                        $scope.post.Title = data.Data.Title;
-                    });
-                    layer.closeAll();
-                } else {
-                    window.notie.alert({
-                        type: 3,
-                        text: data.Message,
-                        time: 4
-                    });
-                }
-            }
-        });
-        $scope.selectFile = false;
-    }
-    //文件上传
-    $scope.showupload = function () {
-        layui.use("layer", function () {
-            var layer = layui.layer;
-            layer.open({
-                type: 1,
-                title: '上传Word文档',
-                area: ['420px', '150px'], //宽高
-                content: $("#docfile")
-            });
-        });
-    }
+			$scope.seminarDropdown =xmSelect.render({
+				el: '#seminar',
+				tips: '请选择专题',
+				toolbar: { //工具条,全选,清空,反选,自定义
+					show: true,
+					list: ['ALL', 'CLEAR', 'REVERSE']
+				},
+				data: res.Data,
+				//initValue: ['shuiguo','shucai'],//默认初始化,也可以数据中selected属性
+				filterable: true, //搜索功能
+				autoRow: true, //选项过多,自动换行
+				// repeat: true,//是否支持重复选择
+				//max: 2,//最多选择2个
+				// template({ item, sels, name, value }){
+				//    //template:自定义下拉框的模板
+				//     return item.name  + '<span style="position: absolute; right: 10px; color: #8799a3">'+value+'</span>'
+				// },
+				on: function (data) {
+					var arr=[];
+					for (let j = 0; j < data.arr.length; j++) {
+						arr.push(data.arr[j].value);
+					}
+					$scope.post.Seminars=arr.join(",");
+				}
+			});
+			if ($scope.post.Seminars) {
+				$scope.seminarDropdown.setValue($scope.post.Seminars.split(','));
+			}
+		});
+		$scope.getCategory();
+		layui.config({
+			base: './Assets/layui/'
+		}).use(['inputTag', 'jquery'], function () {
+			var $ = layui.jquery, inputTag = layui.inputTag;
+			$scope.keywordsDropdown = inputTag.render({
+				elem: '.keywords',
+				data:  ($scope.post.Keyword||"").split(','),//初始值
+				permanentData: [],//不允许删除的值
+				removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
+				createKeyNum: 13,//创建按键编号 默认,Enter 键
+				beforeCreate: function (data, value) {//添加前操作,必须返回字符串才有效
+					return value;
+				},
+				onChange: function (data, value, type) {
+					$scope.post.Keyword=data.join(",");
+				}
+			});
+		});
+	});
+	$scope.getCategory = function () {
+		$http.post("/category/getcategories", null).then(function (res) {
+			var data = res.data;
+			if (data.Success) {
+				$scope.cat = data.Data;
+				$scope.categoryDropdown = xmSelect.render({
+					el: '#category',
+					tips: '请选择分类',
+					prop: {
+						name: 'Name',
+						value: 'Id',
+						children: 'Children',
+					},
+					model: { label: { type: 'text' } },
+					radio: true,
+					clickClose: true,
+					tree: {
+						show: true,
+						strict: false,
+						expandedKeys: true,
+					},
+					filterable: true, //搜索功能
+					autoRow: true, //选项过多,自动换行
+					data:data.Data,
+					on: function (data) {
+						if (data.arr.length>0) {
+							$scope.post.CategoryId=data.arr[0].Id;
+						}
+					}
+				});
+				if ($scope.post.CategoryId>0) {
+						$scope.categoryDropdown.setValue([$scope.post.CategoryId]);
+						$scope.categoryDropdown.options.data.sort((a,b)=>(b.Id==$scope.post.CategoryId||b.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId)))-(a.Id==$scope.post.CategoryId||a.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId))));
+					}
+			} else {
+				window.notie.alert({
+					type: 3,
+					text: '获取文章分类失败!',
+					time: 4
+				});
+			}
+		});
+	}
+	//上传Word文档
+	$scope.upload = function () {
+		
+		$("#docform").ajaxSubmit({
+			url: "/Upload/UploadWord",
+			type: "post",
+			success: function (data) {
+				
+				console.log(data);
+				if (data.Success) {
+					window.notie.alert({
+						type: 1,
+						text: '文档上传成功!',
+						time: 2
+					});
+					$scope.$apply(function () {
+						$scope.post.Content = data.Data.Content;
+						$scope.post.Title = data.Data.Title;
+					});
+					layer.closeAll();
+				} else {
+					window.notie.alert({
+						type: 3,
+						text: data.Message,
+						time: 4
+					});
+				}
+			}
+		});
+		$scope.selectFile = false;
+	}
+	//文件上传
+	$scope.showupload = function () {
+		layui.use("layer", function () {
+			var layer = layui.layer;
+			layer.open({
+				type: 1,
+				title: '上传Word文档',
+				area: ['420px', '150px'], //宽高
+				content: $("#docfile")
+			});
+		});
+	}
 
-    //发布
-    $scope.submit = function (post) {
-        Object.keys(post).forEach(key => post[key] == undefined||post[key] == null ? delete post[key] : '');
-        
-        if (!post.Label) {
-            post.Label = null;
-        }
-        if (post.Title.trim().length <= 2 || post.Title.trim().length > 128) {
-            window.notie.alert({
-                type: 3,
-                text: '文章标题必须在2到128个字符以内!',
-                time: 4
-            });
-            
-            return;
-        }
-        if (post.Author.trim().length <= 0 || post.Author.trim().length > 20) {
-            window.notie.alert({
-                type: 3,
-                text: '再怎么你也应该留个合理的名字吧,非主流的我可不喜欢!',
-                time: 4
-            });
-            
-            return;
-        }
-        if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
-            .test(post.Email.trim())) {
-            window.notie.alert({
-                type: 3,
-                text: '请输入正确的邮箱格式!',
-                time: 4
-            });
-            
-            return;
-        }
-        if (post.Content.length < 20 || post.Content.length > 1000000) {
-            window.notie.alert({
-                type: 3,
-                text: '文章内容过短或者超长,请修改后再提交!',
-                time: 4
-            });
-            
-            return;
-        }
-        post.reserve = $scope.reserve;
-        $http.post("/Post/edit", post).then(function (res) {
-            var data = res.data;
-            
-            if (data.Success) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 4
-                });
-                $scope.post = data.Data;
-                clearInterval(window.interval);
-                localStorage.removeItem("post-draft-"+$scope.id);
-            } else {
-                window.notie.alert({
-                    type: 3,
-                    text: data.Message,
-                    time: 4
-                });
-            }
-        });
-    }
-    
-    //检查草稿
-    if (localStorage.getItem("post-draft-" + $scope.id)) {
-        notie.confirm({
-            text: "检查到上次有未提交的草稿,是否加载?",
-            submitText: "确定",
-            cancelText: "取消",
-            position: "bottom",
-            submitCallback: function () {
-                $scope.post = JSON.parse(localStorage.getItem("post-draft-" + $scope.id));
-                $scope.$apply();
-                if ($scope.post.CategoryId>0) {
-                    $scope.categoryDropdown.setValue([$scope.post.CategoryId]);
-                    $scope.categoryDropdown.options.data.sort((a,b)=>(b.Id==$scope.post.CategoryId||b.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId)))-(a.Id==$scope.post.CategoryId||a.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId))));
-                }
-                if ($scope.post.Label) {
-                    $scope.tagDropdown.setValue($scope.post.Label.split(','));
-                }
-                if ($scope.post.Seminars) {
-                    $scope.seminarDropdown.setValue($scope.post.Seminars.split(','));
-                }
-                if ($scope.post.Keyword) {
-                    console.log($scope.keywordsDropdown);
-                    $scope.keywordsDropdown.render({data:$scope.post.Keyword.split(',')})
-                }
-                window.interval = setInterval(function () {
-                    localStorage.setItem("post-draft-"+$scope.id,JSON.stringify($scope.post));
-                },5000);
-            },
-            cancelCallback: function() {
-                window.interval = setInterval(function () {
-                    localStorage.setItem("post-draft-"+$scope.id,JSON.stringify($scope.post));
-                },5000);
-            }
-        });
-    } else {
-        window.interval = setInterval(function () {
-            localStorage.setItem("post-draft-"+$scope.id,JSON.stringify($scope.post));
-        },5000);
-    }
-    
-    $scope.get("/post/GetRegions?name=Regions", function(data) {
-        $scope.Regions=data.Data;
-    });
-    $scope.get("/post/GetRegions?name=ExceptRegions", function(data) {
-        $scope.ExceptRegions=data.Data;
-    });
-    
-    // 绑定过期时间表单元素
-    layui.use('laydate', function(){
-        var laydate = layui.laydate;
-        laydate.render({
-        elem: '#expireAt',
-        type: 'datetime',
-        calendar: true,
-        min: new Date(new Date().setMinutes(new Date().getMinutes()+10)).Format("yyyy-MM-dd hh:mm:ss"),
-        done: function(value, date, endDate) {
-            if (value) {
-                $scope.post.expireAt=value;
-            } else {
-                delete $scope.post.expireAt;
-            }
-        }
-        });
-    });
+	//发布
+	$scope.submit = function (post) {
+		Object.keys(post).forEach(key => post[key] == undefined||post[key] == null ? delete post[key] : '');
+		
+		if (!post.Label) {
+			post.Label = null;
+		}
+		if (post.Title.trim().length <= 2 || post.Title.trim().length > 128) {
+			window.notie.alert({
+				type: 3,
+				text: '文章标题必须在2到128个字符以内!',
+				time: 4
+			});
+			
+			return;
+		}
+		if (post.Author.trim().length <= 0 || post.Author.trim().length > 20) {
+			window.notie.alert({
+				type: 3,
+				text: '再怎么你也应该留个合理的名字吧,非主流的我可不喜欢!',
+				time: 4
+			});
+			
+			return;
+		}
+		if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
+			.test(post.Email.trim())) {
+			window.notie.alert({
+				type: 3,
+				text: '请输入正确的邮箱格式!',
+				time: 4
+			});
+			
+			return;
+		}
+		if (post.Content.length < 20 || post.Content.length > 1000000) {
+			window.notie.alert({
+				type: 3,
+				text: '文章内容过短或者超长,请修改后再提交!',
+				time: 4
+			});
+			
+			return;
+		}
+		post.reserve = $scope.reserve;
+		$http.post("/Post/edit", post).then(function (res) {
+			var data = res.data;
+			
+			if (data.Success) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 4
+				});
+				$scope.post = data.Data;
+				clearInterval(window.interval);
+				localStorage.removeItem("post-draft-"+$scope.id);
+			} else {
+				window.notie.alert({
+					type: 3,
+					text: data.Message,
+					time: 4
+				});
+			}
+		});
+	}
+	
+	//检查草稿
+	if (localStorage.getItem("post-draft-" + $scope.id)) {
+		notie.confirm({
+			text: "检查到上次有未提交的草稿,是否加载?",
+			submitText: "确定",
+			cancelText: "取消",
+			position: "bottom",
+			submitCallback: function () {
+				$scope.post = JSON.parse(localStorage.getItem("post-draft-" + $scope.id));
+				$scope.$apply();
+				if ($scope.post.CategoryId>0) {
+					$scope.categoryDropdown.setValue([$scope.post.CategoryId]);
+					$scope.categoryDropdown.options.data.sort((a,b)=>(b.Id==$scope.post.CategoryId||b.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId)))-(a.Id==$scope.post.CategoryId||a.Children.some(c=>c.Id==$scope.post.CategoryId||c.Children.some(cc=>cc.Id==$scope.post.CategoryId))));
+				}
+				if ($scope.post.Label) {
+					$scope.tagDropdown.setValue($scope.post.Label.split(','));
+				}
+				if ($scope.post.Seminars) {
+					$scope.seminarDropdown.setValue($scope.post.Seminars.split(','));
+				}
+				if ($scope.post.Keyword) {
+					console.log($scope.keywordsDropdown);
+					$scope.keywordsDropdown.render({data:$scope.post.Keyword.split(',')})
+				}
+				window.interval = setInterval(function () {
+					localStorage.setItem("post-draft-"+$scope.id,JSON.stringify($scope.post));
+				},5000);
+			},
+			cancelCallback: function() {
+				window.interval = setInterval(function () {
+					localStorage.setItem("post-draft-"+$scope.id,JSON.stringify($scope.post));
+				},5000);
+			}
+		});
+	} else {
+		window.interval = setInterval(function () {
+			localStorage.setItem("post-draft-"+$scope.id,JSON.stringify($scope.post));
+		},5000);
+	}
+	
+	$scope.get("/post/GetRegions?name=Regions", function(data) {
+		$scope.Regions=data.Data;
+	});
+	$scope.get("/post/GetRegions?name=ExceptRegions", function(data) {
+		$scope.ExceptRegions=data.Data;
+	});
+	
+	// 绑定过期时间表单元素
+	layui.use('laydate', function(){
+		var laydate = layui.laydate;
+		laydate.render({
+		elem: '#expireAt',
+		type: 'datetime',
+		calendar: true,
+		min: new Date(new Date().setMinutes(new Date().getMinutes()+10)).Format("yyyy-MM-dd hh:mm:ss"),
+		done: function(value, date, endDate) {
+			if (value) {
+				$scope.post.expireAt=value;
+			} else {
+				delete $scope.post.expireAt;
+			}
+		}
+		});
+	});
 }]);
 myApp.controller("category", ["$scope", "$http", "$timeout", function($scope, $http, $timeout) {
-    $scope.category = {};
-    $scope.init = function() {
-        $scope.get("/category/GetCategories", function(data) {
-            $scope.data = data.Data;
-            $scope.collapse = true;
-            $timeout(function() {
-                $scope.expandAll();
-            }, 0);
-        });
-    }
-    var sourceId, destId, index, parent, sourceIndex;
-    $scope.treeOptions = {
-        beforeDrop: function(e) {
-            index = e.dest.index;
-            if (e.dest.nodesScope.$parent.$modelValue) {
-                parent = e.dest.nodesScope.$parent.$modelValue; //找出父级元素
-            }
-        },
-        dropped: function(e) {
-            var dest = e.dest.nodesScope;
-            destId = dest.$id;
-            var pid = dest.node ? dest.node.id : null; //pid
-            var prev = null;
-            var next = null;
-            if (index > sourceIndex) {
-                next = dest.$modelValue[index + 1], prev = dest.$modelValue[index];
-            } else if (index < sourceIndex) {
-                next = dest.$modelValue[index], prev = dest.$modelValue[index - 1];
-            } else {
-                next = dest.$modelValue[index];
-            }
-            var current = e.source.nodeScope.$modelValue;
-            if (destId == sourceId) {
-                if (index == sourceIndex) {
-                    //位置没改变
-                    return;
-                }
-                //同级内改变位置,找出兄弟结点,排序号更新
-                if (prev || next) {
-                    //有多个子节点
-                    if (next) {
-                        current.ParentId = pid;
-                        $scope.request("/category/save", current, function(data) {
-                            window.notie.alert({
-                                type: 1,
-                                text: data.Message,
-                                time: 3
-                            });
-                        });
-                    } else if (prev) {
-                        current.ParentId = pid;
-                        $scope.request("/category/save", current, function (data) {
-                            window.notie.alert({
-                                type: 1,
-                                text: data.Message,
-                                time: 3
-                            });
-                        });
-                    }
-                }
-            } else {
-                //层级位置改变
-                if (parent) {
-                    //非顶级元素
-                    //找兄弟结点
-                    next = dest.$modelValue[index], prev = dest.$modelValue[index - 1];
-                    if (prev || next) {
-                        //有多个子节点
-                        if (next) {
-                            current.ParentId = parent.Id;
-                            $scope.request("/category/save", current, function (data) {
-                                window.notie.alert({
-                                    type: 1,
-                                    text: data.Message,
-                                    time: 3
-                                });
-                            });
-                        } else if (prev) {
-                            current.ParentId = parent.Id;
-                            $scope.request("/category/save", current, function (data) {
-                                window.notie.alert({
-                                    type: 1,
-                                    text: data.Message,
-                                    time: 3
-                                });
-                            });
-                        }
-                    } else {
-                        //只有一个元素
-                        current.ParentId = parent.Id;
-                        $scope.request("/category/save", current, function (data) {
-                            window.notie.alert({
-                                type: 1,
-                                text: data.Message,
-                                time: 3
-                            });
-                        });
-                    }
-                } else {
-                    //顶级元素
-                    sourceIndex = e.source.nodesScope.$parent.index();
-                    if (index < sourceIndex) {
-                        next = dest.$modelValue[index + 1], prev = dest.$modelValue[index];
-                    } else {
-                        next = dest.$modelValue[index], prev = dest.$modelValue[index - 1];
-                    }
-                    if (next) {
-                        current.ParentId = pid;
-                        $scope.request("/category/save", current, function (data) {
-                            window.notie.alert({
-                                type: 1,
-                                text: data.Message,
-                                time: 3
-                            });
-                        });
-                    } else if (prev) {
-                        current.ParentId = pid;
-                        $scope.request("/category/save", current, function (data) {
-                            window.notie.alert({
-                                type: 1,
-                                text: data.Message,
-                                time: 3
-                            });
-                        });
-                    }
-                }
-                parent = null;
-            }
-        },
-        dragStart: function(e) {
-            sourceId = e.dest.nodesScope.$id;
-            sourceIndex = e.dest.index;
-        }
-    };
-    $scope.findNodes = function () {
-        
-    };
-    $scope.visible = function (item) {
-        return !($scope.query && $scope.query.length > 0 && item.Name.indexOf($scope.query) == -1);
-    };
-    $scope.category = {};
-    $scope.newItem = function() {
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '修改菜单信息',
-            area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',// '340px'], //宽高
-            content: $("#modal"),
-            success: function(layero, index) {
-                $scope.category = {};
-            },
-            end: function() {
-                $("#modal").css("display", "none");
-            }
-        });
-    };
-    $scope.subcategory = {};
+	$scope.category = {};
+	$scope.init = function() {
+		$scope.get("/category/GetCategories", function(data) {
+			$scope.data = data.Data;
+			$scope.collapse = true;
+			$timeout(function() {
+				$scope.expandAll();
+			}, 0);
+		});
+	}
+	var sourceId, destId, index, parent, sourceIndex;
+	$scope.treeOptions = {
+		beforeDrop: function(e) {
+			index = e.dest.index;
+			if (e.dest.nodesScope.$parent.$modelValue) {
+				parent = e.dest.nodesScope.$parent.$modelValue; //找出父级元素
+			}
+		},
+		dropped: function(e) {
+			var dest = e.dest.nodesScope;
+			destId = dest.$id;
+			var pid = dest.node ? dest.node.id : null; //pid
+			var prev = null;
+			var next = null;
+			if (index > sourceIndex) {
+				next = dest.$modelValue[index + 1], prev = dest.$modelValue[index];
+			} else if (index < sourceIndex) {
+				next = dest.$modelValue[index], prev = dest.$modelValue[index - 1];
+			} else {
+				next = dest.$modelValue[index];
+			}
+			var current = e.source.nodeScope.$modelValue;
+			if (destId == sourceId) {
+				if (index == sourceIndex) {
+					//位置没改变
+					return;
+				}
+				//同级内改变位置,找出兄弟结点,排序号更新
+				if (prev || next) {
+					//有多个子节点
+					if (next) {
+						current.ParentId = pid;
+						$scope.request("/category/save", current, function(data) {
+							window.notie.alert({
+								type: 1,
+								text: data.Message,
+								time: 3
+							});
+						});
+					} else if (prev) {
+						current.ParentId = pid;
+						$scope.request("/category/save", current, function (data) {
+							window.notie.alert({
+								type: 1,
+								text: data.Message,
+								time: 3
+							});
+						});
+					}
+				}
+			} else {
+				//层级位置改变
+				if (parent) {
+					//非顶级元素
+					//找兄弟结点
+					next = dest.$modelValue[index], prev = dest.$modelValue[index - 1];
+					if (prev || next) {
+						//有多个子节点
+						if (next) {
+							current.ParentId = parent.Id;
+							$scope.request("/category/save", current, function (data) {
+								window.notie.alert({
+									type: 1,
+									text: data.Message,
+									time: 3
+								});
+							});
+						} else if (prev) {
+							current.ParentId = parent.Id;
+							$scope.request("/category/save", current, function (data) {
+								window.notie.alert({
+									type: 1,
+									text: data.Message,
+									time: 3
+								});
+							});
+						}
+					} else {
+						//只有一个元素
+						current.ParentId = parent.Id;
+						$scope.request("/category/save", current, function (data) {
+							window.notie.alert({
+								type: 1,
+								text: data.Message,
+								time: 3
+							});
+						});
+					}
+				} else {
+					//顶级元素
+					sourceIndex = e.source.nodesScope.$parent.index();
+					if (index < sourceIndex) {
+						next = dest.$modelValue[index + 1], prev = dest.$modelValue[index];
+					} else {
+						next = dest.$modelValue[index], prev = dest.$modelValue[index - 1];
+					}
+					if (next) {
+						current.ParentId = pid;
+						$scope.request("/category/save", current, function (data) {
+							window.notie.alert({
+								type: 1,
+								text: data.Message,
+								time: 3
+							});
+						});
+					} else if (prev) {
+						current.ParentId = pid;
+						$scope.request("/category/save", current, function (data) {
+							window.notie.alert({
+								type: 1,
+								text: data.Message,
+								time: 3
+							});
+						});
+					}
+				}
+				parent = null;
+			}
+		},
+		dragStart: function(e) {
+			sourceId = e.dest.nodesScope.$id;
+			sourceIndex = e.dest.index;
+		}
+	};
+	$scope.findNodes = function () {
+		
+	};
+	$scope.visible = function (item) {
+		return !($scope.query && $scope.query.length > 0 && item.Name.indexOf($scope.query) == -1);
+	};
+	$scope.category = {};
+	$scope.newItem = function() {
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '修改菜单信息',
+			area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',// '340px'], //宽高
+			content: $("#modal"),
+			success: function(layero, index) {
+				$scope.category = {};
+			},
+			end: function() {
+				$("#modal").css("display", "none");
+			}
+		});
+	};
+	$scope.subcategory = {};
 
-    $scope.closeAll = function() {
-        layer.closeAll();
-        setTimeout(function() {
-            $("#modal").css("display", "none");
-        }, 500);
-    }
-    $scope.newSubItem = function (scope) {
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '修改菜单信息',
-            area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',// '340px'], //宽高
-            content: $("#modal"),
-            success: function(layero, index) {
-                $scope.category = {};
-            },
-            end: function() {
-                $("#modal").css("display", "none");
-            }
-        });
-        var nodeData = scope.$modelValue;
-        $scope.subcategory = nodeData;
-        $scope.category.ParentId = nodeData.Id;
-    };
-    $scope.expandAll = function() {
-        if ($scope.collapse) {
-            $scope.$broadcast('angular-ui-tree:collapse-all');
-        } else {
-            $scope.$broadcast('angular-ui-tree:expand-all');
-        }
-        $scope.collapse = !$scope.collapse;
-    };
-    
-    $scope.del = function(scope) {
-        var model = scope.$nodeScope.$modelValue;
-        var select = {};
-        Enumerable.From($scope.data).Where(e => e.Id != model.Id).Select(e => {
-            return {
-                id: e.Id,
-                name: e.Name
-            }
-        }).Distinct().ToArray().map(function(item, index, array) {
-            select[item.id] = item.name;
-        });
-        swal({
-            title: '确定删除这个分类吗?',
-            text: "删除后将该分类下的所有文章移动到:",
-            input: 'select',
-            inputOptions: select,
-            inputPlaceholder: '请选择分类',
-            showCancelButton: true,
-            confirmButtonColor: "#DD6B55",
-            confirmButtonText: "确定",
-            cancelButtonText: "取消",
-            inputValidator: function(value) {
-                return new Promise(function(resolve, reject) {
-                    if (value == '') {
-                        reject('请选择一个分类');
-                    } else {
-                        resolve();
-                    }
-                });
-            }
-        }).then(function(result) {
-            if (result) {
-                if (model.Id == 1) {
-                    swal({
-                        type: 'error',
-                        html: "默认分类不能被删除!"
-                    });
-                } else {
-                    $scope.request("/category/delete?id="+model.Id+"&cid="+result, null, function(data) {
-                        swal({
-                            type: 'success',
-                            html: data.Message
-                        });
-                    });
-                    $scope.init();
-                }
-            }
-        }).catch(swal.noop);
-    }
-    
-    $scope.edit= function(category) {
-        $scope.category = category;
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '修改菜单信息',
-            area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',// '340px'], //宽高
-            //area: ['600px', '270px'], //宽高
-            content: $("#modal"),
-            success: function(layero, index) {
-                $scope.category = category;
-            },
-            end: function() {
-                $("#modal").css("display", "none");
-            }
-        });
-    }
-    
-    $scope.submit = function (category) {
-        if (category.Id) {
-            //修改
-            $scope.request("/category/save", category, function (data) {
-                swal(data.Message, null, 'info');
-                $scope.category = {};
-                $scope.closeAll();
-            });
-        }else {
-            //添加
-            $scope.request("/category/save", category, function (data) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 3
-                });
-                $scope.category = {};
-                $scope.closeAll();
-                $scope.init();
-            });
-        }
-    }
-    $scope.init();
+	$scope.closeAll = function() {
+		layer.closeAll();
+		setTimeout(function() {
+			$("#modal").css("display", "none");
+		}, 500);
+	}
+	$scope.newSubItem = function (scope) {
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '修改菜单信息',
+			area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',// '340px'], //宽高
+			content: $("#modal"),
+			success: function(layero, index) {
+				$scope.category = {};
+			},
+			end: function() {
+				$("#modal").css("display", "none");
+			}
+		});
+		var nodeData = scope.$modelValue;
+		$scope.subcategory = nodeData;
+		$scope.category.ParentId = nodeData.Id;
+	};
+	$scope.expandAll = function() {
+		if ($scope.collapse) {
+			$scope.$broadcast('angular-ui-tree:collapse-all');
+		} else {
+			$scope.$broadcast('angular-ui-tree:expand-all');
+		}
+		$scope.collapse = !$scope.collapse;
+	};
+	
+	$scope.del = function(scope) {
+		var model = scope.$nodeScope.$modelValue;
+		var select = {};
+		Enumerable.From($scope.data).Where(e => e.Id != model.Id).Select(e => {
+			return {
+				id: e.Id,
+				name: e.Name
+			}
+		}).Distinct().ToArray().map(function(item, index, array) {
+			select[item.id] = item.name;
+		});
+		swal({
+			title: '确定删除这个分类吗?',
+			text: "删除后将该分类下的所有文章移动到:",
+			input: 'select',
+			inputOptions: select,
+			inputPlaceholder: '请选择分类',
+			showCancelButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			inputValidator: function(value) {
+				return new Promise(function(resolve, reject) {
+					if (value == '') {
+						reject('请选择一个分类');
+					} else {
+						resolve();
+					}
+				});
+			}
+		}).then(function(result) {
+			if (result) {
+				if (model.Id == 1) {
+					swal({
+						type: 'error',
+						html: "默认分类不能被删除!"
+					});
+				} else {
+					$scope.request("/category/delete?id="+model.Id+"&cid="+result, null, function(data) {
+						swal({
+							type: 'success',
+							html: data.Message
+						});
+					});
+					$scope.init();
+				}
+			}
+		}).catch(swal.noop);
+	}
+	
+	$scope.edit= function(category) {
+		$scope.category = category;
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '修改菜单信息',
+			area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',// '340px'], //宽高
+			//area: ['600px', '270px'], //宽高
+			content: $("#modal"),
+			success: function(layero, index) {
+				$scope.category = category;
+			},
+			end: function() {
+				$("#modal").css("display", "none");
+			}
+		});
+	}
+	
+	$scope.submit = function (category) {
+		if (category.Id) {
+			//修改
+			$scope.request("/category/save", category, function (data) {
+				swal(data.Message, null, 'info');
+				$scope.category = {};
+				$scope.closeAll();
+			});
+		}else {
+			//添加
+			$scope.request("/category/save", category, function (data) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 3
+				});
+				$scope.category = {};
+				$scope.closeAll();
+				$scope.init();
+			});
+		}
+	}
+	$scope.init();
 }]);
 myApp.controller("postpending", ["$scope", "$http", "NgTableParams", "$timeout", function ($scope, $http, NgTableParams, $timeout) {
-    var self = this;
-    
-    $scope.kw = "";
-    $scope.orderby = 1;
-    $scope.paginationConf = {
-        currentPage: $scope.currentPage ? $scope.currentPage : 1,
-        //totalItems: $scope.total,
-        itemsPerPage: 10,
-        pagesLength: 25,
-        perPageOptions: [10, 15, 20, 30, 50, 100, 200],
-        rememberPerPage: 'perPageItems',
-        onChange: function() {
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        }
-    };
-    this.GetPageData = function(page, size) {
-        
-        $http.post("/post/GetPending", {
-            page,
-            size,
-            search:$scope.kw
-        }).then(function(res) {
-            $scope.paginationConf.currentPage = page;
-            $scope.paginationConf.totalItems = res.data.TotalCount;
-            $("div[ng-table-pagination]").remove();
-            self.tableParams = new NgTableParams({
-                count: 50000
-            }, {
-                filterDelay: 0,
-                dataset: res.data.Data
-            });
-            
-        });
-    };
-    self.del = function(row) {
-        swal({
-            title: "确认删除这篇文章吗?",
-            text: row.Title,
-            showCancelButton: true,
-            confirmButtonColor: "#DD6B55",
-            confirmButtonText: "确定",
-            cancelButtonText: "取消",
-            showLoaderOnConfirm: true,
-            animation: true,
-            allowOutsideClick: false
-        }).then(function() {
-            $scope.request("/post/delete/"+row.Id, null, function(data) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 4
-                });
-            });
-            _.remove(self.tableParams.settings().dataset, function(item) {
-                return row === item;
-            });
-            self.tableParams.reload().then(function(data) {
-                if (data.length === 0 && self.tableParams.total() > 0) {
-                    self.tableParams.page(self.tableParams.page() - 1);
-                    self.tableParams.reload();
-                }
-            });
-        }, function() {
-        }).catch(swal.noop);
-    }
-    self.pass = function(row) {
-        $scope.request("/post/pass", row, function(data) {
-            window.notie.alert({
-                type: 1,
-                text: data.Message,
-                time: 4
-            });
-            self.stats = [];
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
-        });
-    }
+	var self = this;
+	
+	$scope.kw = "";
+	$scope.orderby = 1;
+	$scope.paginationConf = {
+		currentPage: $scope.currentPage ? $scope.currentPage : 1,
+		//totalItems: $scope.total,
+		itemsPerPage: 10,
+		pagesLength: 25,
+		perPageOptions: [10, 15, 20, 30, 50, 100, 200],
+		rememberPerPage: 'perPageItems',
+		onChange: function() {
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		}
+	};
+	this.GetPageData = function(page, size) {
+		
+		$http.post("/post/GetPending", {
+			page,
+			size,
+			search:$scope.kw
+		}).then(function(res) {
+			$scope.paginationConf.currentPage = page;
+			$scope.paginationConf.totalItems = res.data.TotalCount;
+			$("div[ng-table-pagination]").remove();
+			self.tableParams = new NgTableParams({
+				count: 50000
+			}, {
+				filterDelay: 0,
+				dataset: res.data.Data
+			});
+			
+		});
+	};
+	self.del = function(row) {
+		swal({
+			title: "确认删除这篇文章吗?",
+			text: row.Title,
+			showCancelButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			showLoaderOnConfirm: true,
+			animation: true,
+			allowOutsideClick: false
+		}).then(function() {
+			$scope.request("/post/delete/"+row.Id, null, function(data) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 4
+				});
+			});
+			_.remove(self.tableParams.settings().dataset, function(item) {
+				return row === item;
+			});
+			self.tableParams.reload().then(function(data) {
+				if (data.length === 0 && self.tableParams.total() > 0) {
+					self.tableParams.page(self.tableParams.page() - 1);
+					self.tableParams.reload();
+				}
+			});
+		}, function() {
+		}).catch(swal.noop);
+	}
+	self.pass = function(row) {
+		$scope.request("/post/pass", row, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+			self.stats = [];
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
+		});
+	}
 
-    var _timeout;
-    $scope.search = function (kw) {
-        if (_timeout) {
-            $timeout.cancel(_timeout);
-        }
-        _timeout = $timeout(function () {
-            $scope.kw = kw;
-            self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage, $scope.kw);
-            _timeout = null;
-        }, 500);
-    }
-    
-    $scope.addToBlock= function(row) {
-        swal({
-            title: "确认添加恶意名单吗?",
-            text: "将"+row.Email+"添加到恶意名单",
-            showCancelButton: true,
-            confirmButtonColor: "#DD6B55",
-            confirmButtonText: "确定",
-            cancelButtonText: "取消",
-            animation: true,
-            allowOutsideClick: false,
-            showLoaderOnConfirm: true,
-            preConfirm: function () {
-                return new Promise(function (resolve, reject) {
-                    $http.post("/post/block/"+row.Id).then(function(res) {
-                        resolve(res.data);
-                    }, function() {
-                        reject("请求服务器失败!");
-                    });
-                });
-            }
-        }).then(function (data) {
-            if (data.Success) {
-                swal("添加成功",'','success');
-            } else {
-                swal("添加失败",'','error');
-            }
-        }).catch(swal.noop);
-    }
+	var _timeout;
+	$scope.search = function (kw) {
+		if (_timeout) {
+			$timeout.cancel(_timeout);
+		}
+		_timeout = $timeout(function () {
+			$scope.kw = kw;
+			self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage, $scope.kw);
+			_timeout = null;
+		}, 500);
+	}
+	
+	$scope.addToBlock= function(row) {
+		swal({
+			title: "确认添加恶意名单吗?",
+			text: "将"+row.Email+"添加到恶意名单",
+			showCancelButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			animation: true,
+			allowOutsideClick: false,
+			showLoaderOnConfirm: true,
+			preConfirm: function () {
+				return new Promise(function (resolve, reject) {
+					$http.post("/post/block/"+row.Id).then(function(res) {
+						resolve(res.data);
+					}, function() {
+						reject("请求服务器失败!");
+					});
+				});
+			}
+		}).then(function (data) {
+			if (data.Success) {
+				swal("添加成功",'','success');
+			} else {
+				swal("添加失败",'','error');
+			}
+		}).catch(swal.noop);
+	}
 }]);
 
 myApp.controller("share", ["$scope", "NgTableParams", function ($scope, NgTableParams) {
-    var self = this;
-    self.data = {};
-    this.load = function() {
-        $scope.request("/share", null, function(res) {
-            self.tableParams = new NgTableParams({}, {
-                filterDelay: 0,
-                dataset: res.Data
-            });
-            shares = res.Data;
-        });
-    }
-    self.load();
-    $scope.closeAll = function() {
-        layer.closeAll();
-        setTimeout(function() {
-            $("#modal").css("display", "none");
-        }, 500);
-    }
-    $scope.submit = function (share) {
-        if (share.Id) {
-            //修改
-            $scope.request("/share/update", share, function (data) {
-                swal(data.Message, null, 'info');
-                $scope.share = {};
-                $scope.closeAll();
-                self.load();
-            });
-        }else {
-            $scope.request("/share/add", share, function (data) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 3
-                });
-                $scope.share = {};
-                $scope.closeAll();
-                self.load();
-            });
-        }
-    }
-    self.del = function(row) {
-        swal({
-            title: "确认删除这个分享吗?",
-            text: row.Title,
-            showCancelButton: true,
-            showCloseButton: true,
-            confirmButtonColor: "#DD6B55",
-            confirmButtonText: "确定",
-            cancelButtonText: "取消",
-            showLoaderOnConfirm: true,
-            animation: true,
-            allowOutsideClick: false
-        }).then(function() {
-            $scope.request("/share/remove", {
-                id: row.Id
-            }, function(data) {
-                window.notie.alert({
-                    type: 1,
-                    text: data.Message,
-                    time: 4
-                });
-                self.load();
-            });
-        }, function() {
-        }).catch(swal.noop);
-    }
-    self.edit = function (row) {
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '修改快速分享',
-            area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',
-            content: $("#modal"),
-            success: function(layero, index) {
-                $scope.share = row;
-            },
-            end: function() {
-                $("#modal").css("display", "none");
-            }
-        });
-    }
-    self.add = function() {
-        layer.open({
-            type: 1,
-            zIndex: 20,
-            title: '添加快速分享',
-            area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',
-            content: $("#modal"),
-            success: function(layero, index) {
-                $scope.share = {};
-            },
-            end: function() {
-                $("#modal").css("display", "none");
-            }
-        });
-    }
+	var self = this;
+	self.data = {};
+	this.load = function() {
+		$scope.request("/share", null, function(res) {
+			self.tableParams = new NgTableParams({}, {
+				filterDelay: 0,
+				dataset: res.Data
+			});
+			shares = res.Data;
+		});
+	}
+	self.load();
+	$scope.closeAll = function() {
+		layer.closeAll();
+		setTimeout(function() {
+			$("#modal").css("display", "none");
+		}, 500);
+	}
+	$scope.submit = function (share) {
+		if (share.Id) {
+			//修改
+			$scope.request("/share/update", share, function (data) {
+				swal(data.Message, null, 'info');
+				$scope.share = {};
+				$scope.closeAll();
+				self.load();
+			});
+		}else {
+			$scope.request("/share/add", share, function (data) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 3
+				});
+				$scope.share = {};
+				$scope.closeAll();
+				self.load();
+			});
+		}
+	}
+	self.del = function(row) {
+		swal({
+			title: "确认删除这个分享吗?",
+			text: row.Title,
+			showCancelButton: true,
+			showCloseButton: true,
+			confirmButtonColor: "#DD6B55",
+			confirmButtonText: "确定",
+			cancelButtonText: "取消",
+			showLoaderOnConfirm: true,
+			animation: true,
+			allowOutsideClick: false
+		}).then(function() {
+			$scope.request("/share/remove", {
+				id: row.Id
+			}, function(data) {
+				window.notie.alert({
+					type: 1,
+					text: data.Message,
+					time: 4
+				});
+				self.load();
+			});
+		}, function() {
+		}).catch(swal.noop);
+	}
+	self.edit = function (row) {
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '修改快速分享',
+			area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',
+			content: $("#modal"),
+			success: function(layero, index) {
+				$scope.share = row;
+			},
+			end: function() {
+				$("#modal").css("display", "none");
+			}
+		});
+	}
+	self.add = function() {
+		layer.open({
+			type: 1,
+			zIndex: 20,
+			title: '添加快速分享',
+			area: (window.screen.width > 600 ? 600 : window.screen.width) + 'px',
+			content: $("#modal"),
+			success: function(layero, index) {
+				$scope.share = {};
+			},
+			end: function() {
+				$("#modal").css("display", "none");
+			}
+		});
+	}
 }]);

+ 9 - 2
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/partner.html

@@ -22,6 +22,10 @@
                 <input type="text" class="form-control" ng-change="search(kw)" ng-model="kw" placeholder="全局搜索" />
             </div>
         </div>
+        <div class="input-group">
+            <span class="input-group-addon">排序方式:</span>
+            <div class="form-control" id="orderby" style="width: 220px"></div>
+        </div>
     </div>
     <table ng-table="list.tableParams" class="table table-bordered table-hover table-condensed listTable" ng-form="list.tableForm" tracked-table="list.tableTracker">
         <tr ng-repeat="row in $data" ng-form="rowForm" tracked-table-row="row">
@@ -46,14 +50,17 @@
             <td title="'日均点击'">
                 {{row.AverageViewCount|number:2}}
             </td>
+            <td title="'点击率'">
+                {{row.ClickRate|number:2}}
+            </td>
             <td title="'分类'" style="max-width: 270px">
                 <div id="category-{{row.Id}}"></div>
             </td>
             <td title="'创建时间'">
-                {{row.CreateTime|date:'yyyy-MM-dd HH:mm'}}
+                {{row.CreateTime|date:'yyyy-MM-dd'}}
             </td>
             <td title="'修改时间'">
-                {{row.UpdateTime|date:'yyyy-MM-dd HH:mm'}}
+                {{row.UpdateTime|date:'yyyy-MM-dd'}}
             </td>
             <td title="'状态'">
                 <label class="el-switch">

+ 1 - 2
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/postlist.html

@@ -28,10 +28,9 @@
             <span class="input-group-addon">分类:</span>
             <div class="form-control" id="category" style="width: 200px"></div>
         </div>
-        <div class="input-group">
+        < class="input-group">
             <span class="input-group-addon">排序方式:</span>
             <div class="form-control" id="orderby" style="width: 220px"></div>
-            </div>
         </div>
     <table ng-table="list.tableParams" class="table table-striped table-vmiddle table-bordered table-hover table-condensed">
         <tr ng-repeat="row in $data" ng-class="{'warning':(diffDateFromNow(row.ModifyDate)>365)}">