Authored by 马力

Merge branch 'hotfix_资源位权限控制' into grey

# Conflicts:
#	code/static/js.jquery/module/resource/resourceManage/ContentManage.js
@@ -40,9 +40,14 @@ module.exports=function(app) { @@ -40,9 +40,14 @@ module.exports=function(app) {
40 /*删除资源位下所有tab*/ 40 /*删除资源位下所有tab*/
41 app.post("/resources/deleteAllResourceByCode","resourceManage_deleteAllResourceByCode"); 41 app.post("/resources/deleteAllResourceByCode","resourceManage_deleteAllResourceByCode");
42 42
  43 + app.post("/resources/updateLock","resourceManage_updateLock");
  44 +
43 /*根据id获取资源内容*/ 45 /*根据id获取资源内容*/
44 app.post("/resources/resContentIndex","resourceManage_resContentIndex"); 46 app.post("/resources/resContentIndex","resourceManage_resContentIndex");
45 47
  48 + /*根据是否可编辑*/
  49 + app.post("/resources/checkLock","resourceManage_checkLock");
  50 +
46 /*添加资源内容*/ 51 /*添加资源内容*/
47 app.post("/resources/addResContent","resourceManage_addResContent"); 52 app.post("/resources/addResContent","resourceManage_addResContent");
48 53
@@ -51,6 +51,14 @@ module.exports={ @@ -51,6 +51,14 @@ module.exports={
51 {name: "code", type: "string"} 51 {name: "code", type: "string"}
52 ] 52 ]
53 }, 53 },
  54 + updateLock:{
  55 + title: "解除锁定",
  56 + url: "/resources/updateLock",
  57 + params: [
  58 + {name: "id", type: "number"},
  59 + {name: "status", type: "number"}
  60 + ]
  61 + },
54 getUrlAction:{ 62 getUrlAction:{
55 title: "获取跳转链接", 63 title: "获取跳转链接",
56 url: "/resources/getUrlAction" 64 url: "/resources/getUrlAction"
@@ -62,6 +70,13 @@ module.exports={ @@ -62,6 +70,13 @@ module.exports={
62 {name: "id", type: "number"} 70 {name: "id", type: "number"}
63 ] 71 ]
64 }, 72 },
  73 + checkLock:{
  74 + title: "查询是否可编辑",
  75 + url: "/resources/checkLock",
  76 + params: [
  77 + {name: "id", type: "number"}
  78 + ]
  79 + },
65 addResContent:{ 80 addResContent:{
66 title: "添加资源内容", 81 title: "添加资源内容",
67 url: "/resources/addResContent", 82 url: "/resources/addResContent",
@@ -10,6 +10,7 @@ require('../../../common/util/datepicker'); @@ -10,6 +10,7 @@ require('../../../common/util/datepicker');
10 var resources = []; 10 var resources = [];
11 var times = []; 11 var times = [];
12 var currIndex = 0; 12 var currIndex = 0;
  13 +var lockStatus = 0;
13 //资源id 14 //资源id
14 var param = location.href.substring(location.href.lastIndexOf("/") + 1); 15 var param = location.href.substring(location.href.lastIndexOf("/") + 1);
15 common.util.__ajax({ 16 common.util.__ajax({
@@ -20,6 +21,13 @@ common.util.__ajax({ @@ -20,6 +21,13 @@ common.util.__ajax({
20 resources = res.data; 21 resources = res.data;
21 console.log(resources); 22 console.log(resources);
22 }, true); 23 }, true);
  24 +common.util.__ajax({
  25 + url: "/resources/updateLock",
  26 + data: {id: param,
  27 + status:1},
  28 + async: false
  29 +}, function (res) {
  30 +}, true);
23 31
24 /*配置模块*/ 32 /*配置模块*/
25 var edit = new common.edit2(".modal-body", { 33 var edit = new common.edit2(".modal-body", {
@@ -68,6 +76,9 @@ var Bll = { @@ -68,6 +76,9 @@ var Bll = {
68 value: "保存", 76 value: "保存",
69 callback: function () { 77 callback: function () {
70 console.log(module.contentData); 78 console.log(module.contentData);
  79 + if(!checkLockStatus()){
  80 + return false;
  81 + }
71 var couponFlag = true; 82 var couponFlag = true;
72 if (Validate[module.contentData.template_name]) { 83 if (Validate[module.contentData.template_name]) {
73 Validate[module.contentData.template_name].forEach(function (item) { 84 Validate[module.contentData.template_name].forEach(function (item) {
@@ -297,7 +308,6 @@ function Unique(Array,key) { @@ -297,7 +308,6 @@ function Unique(Array,key) {
297 Bll.__render("#content-list", "content-template", resources[currIndex]); 308 Bll.__render("#content-list", "content-template", resources[currIndex]);
298 Bll.__render(".contents", "template_content_btns", {btns: Button}); 309 Bll.__render(".contents", "template_content_btns", {btns: Button});
299 Bll.__render("#times-list", "times-template", {times:times, selected:0}); 310 Bll.__render("#times-list", "times-template", {times:times, selected:0});
300 -  
301 /*第二部,把楼层数据转化成数组*/ 311 /*第二部,把楼层数据转化成数组*/
302 for(var i = 0; i < resources.length; i++) { 312 for(var i = 0; i < resources.length; i++) {
303 Bll.contentDatas[i] = []; 313 Bll.contentDatas[i] = [];
@@ -441,6 +451,9 @@ $(document).on("change", ".observe", function () { @@ -441,6 +451,9 @@ $(document).on("change", ".observe", function () {
441 451
442 /*删除*/ 452 /*删除*/
443 $(document).on("click", ".del", function () {//删除 453 $(document).on("click", ".del", function () {//删除
  454 + if(!checkLockStatus()){
  455 + return false;
  456 + }
444 var index = $(this).data("index"); 457 var index = $(this).data("index");
445 common.dialog.confirm("警告", 458 common.dialog.confirm("警告",
446 common.util.__template2("是否确认删除?", {}), 459 common.util.__template2("是否确认删除?", {}),
@@ -556,6 +569,7 @@ function secondsToStrDate(seconds) { @@ -556,6 +569,7 @@ function secondsToStrDate(seconds) {
556 return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss"); 569 return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
557 } 570 }
558 571
  572 +
559 function dateStrToSeconds(date) { 573 function dateStrToSeconds(date) {
560 if(date) { 574 if(date) {
561 return new Date(date).getTime() / 1000; 575 return new Date(date).getTime() / 1000;
@@ -564,6 +578,23 @@ function dateStrToSeconds(date) { @@ -564,6 +578,23 @@ function dateStrToSeconds(date) {
564 return 0; 578 return 0;
565 } 579 }
566 580
  581 +
  582 +function checkLockStatus(){
  583 + common.util.__ajax({
  584 + url: "/resources/checkLock",
  585 + data: {id: param},
  586 + async: false
  587 + }, function (res) {
  588 + lockStatus = res.data;
  589 + }, true);
  590 + if(lockStatus == '2') {
  591 + common.util.__tip("该资源位已被锁定,不能操作");
  592 + return false;
  593 + }else{
  594 + return true;
  595 + }
  596 +}
  597 +
567 //获取品牌 598 //获取品牌
568 Bll.getBrands(); 599 Bll.getBrands();
569 //打开品牌选择模态 600 //打开品牌选择模态
@@ -642,6 +673,9 @@ $(document).on("click", '.icon-number', function () { @@ -642,6 +673,9 @@ $(document).on("click", '.icon-number', function () {
642 //**********************************************************************************/ 673 //**********************************************************************************/
643 //复制 674 //复制
644 $(document).on("click", "#copyTab", function() { 675 $(document).on("click", "#copyTab", function() {
  676 + if(!checkLockStatus()){
  677 + return false;
  678 + }
645 common.util.__ajax({ 679 common.util.__ajax({
646 url: "/resources/copyResContent", 680 url: "/resources/copyResContent",
647 data: {rId:resources[currIndex].resource.id} 681 data: {rId:resources[currIndex].resource.id}
@@ -651,6 +685,9 @@ $(document).on("click", "#copyTab", function() { @@ -651,6 +685,9 @@ $(document).on("click", "#copyTab", function() {
651 }); 685 });
652 //保存时间 686 //保存时间
653 $(document).on("click", "#saveTime", function() { 687 $(document).on("click", "#saveTime", function() {
  688 + if(!checkLockStatus()){
  689 + return false;
  690 + }
654 if(times[currIndex].status == "进行中") { 691 if(times[currIndex].status == "进行中") {
655 common.util.__tip("进行中的页面不能更改时间"); 692 common.util.__tip("进行中的页面不能更改时间");
656 return false; 693 return false;
@@ -722,6 +759,9 @@ $(document).on("click", "#delTab", function() { @@ -722,6 +759,9 @@ $(document).on("click", "#delTab", function() {
722 759
723 /*保存事件*/ 760 /*保存事件*/
724 $(document).on("click", "#sub_btn", function () { 761 $(document).on("click", "#sub_btn", function () {
  762 + if(!checkLockStatus()){
  763 + return false;
  764 + }
725 var data = { 765 var data = {
726 "content": {}, 766 "content": {},
727 "data_id": {}, 767 "data_id": {},
@@ -47,15 +47,23 @@ var g = new common.grid({ @@ -47,15 +47,23 @@ var g = new common.grid({
47 {display: "分类", name: "sortName"}, 47 {display: "分类", name: "sortName"},
48 {display: "平台", name: "platformName"}, 48 {display: "平台", name: "platformName"},
49 {display: "位置码", name: "code"}, 49 {display: "位置码", name: "code"},
50 - {display: "匹配码", name: "matchCode"},  
51 {display: "创建时间", name: "", render: function(item) { 50 {display: "创建时间", name: "", render: function(item) {
52 return Bll.getLocalTime(item.createTime); 51 return Bll.getLocalTime(item.createTime);
53 }}, 52 }},
  53 + {display: "锁定人", name: "lockPersonName"},
  54 + {display: "锁定时间", name: "",render:function(item){
  55 + if(item.lockPersonName !=''){
  56 + return Bll.getLocalTime(item.lockTime);
  57 + }
  58 + }},
54 {display: "操作", name: "",render: function(item) { 59 {display: "操作", name: "",render: function(item) {
55 var arr = []; 60 var arr = [];
56 arr.push('<a target="_blank" class="btn btn-xs btn-info contentManage" data-index="' + item.__index + '" href="/resource/content/index/' + item.id + '">内容管理</a>'); 61 arr.push('<a target="_blank" class="btn btn-xs btn-info contentManage" data-index="' + item.__index + '" href="/resource/content/index/' + item.id + '">内容管理</a>');
57 arr.push('<a class="btn btn-xs btn-primary add2" data-index="' + item.__index + '">编辑</a>'); 62 arr.push('<a class="btn btn-xs btn-primary add2" data-index="' + item.__index + '">编辑</a>');
58 arr.push('<a class="btn btn-xs btn-danger delbtn" data-index="' + item.__index + '">删除</a>'); 63 arr.push('<a class="btn btn-xs btn-danger delbtn" data-index="' + item.__index + '">删除</a>');
  64 + if(item.lockPersonName !=''){
  65 + arr.push('<a class="btn btn-xs btn-danger updateLockBtn" data-index="' + item.__index + '">解除锁定</a>');
  66 + }
59 return arr.join(""); 67 return arr.join("");
60 }} 68 }}
61 ] 69 ]
@@ -140,3 +148,19 @@ $(document).on("click", ".delbtn", function() { @@ -140,3 +148,19 @@ $(document).on("click", ".delbtn", function() {
140 }); 148 });
141 }); 149 });
142 }); 150 });
  151 +
  152 +/**
  153 + * 解除锁定
  154 + */
  155 +$(document).on("click", ".updateLockBtn", function() {
  156 + var item = g.rows[$(this).data("index")];
  157 + common.dialog.confirm("警告", "是否确认解除锁定?",function() {
  158 + common.util.__ajax({
  159 + url: "/resources/updateLock",
  160 + data: {id: item.id,
  161 + status:0}
  162 + }, function () {
  163 + g.reload();
  164 + });
  165 + });
  166 +});