couple.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. Namespace.register("Couple");//注册命名空间
  2. Couple.Bind=function () {
  3. var userName=$(".userName")[0]//获取用户名
  4. var ul = $(".asideMenu ul")[0];//获取项目列表ul
  5. var asideMenu = $(".asideMenu")[0];
  6. var informationtSet = $(".informationtSet")[0];
  7. var informationtInfo = $(".informationtInfo")[0];//获取反馈信息
  8. var informationtTime = $(".informationtTime")[0];//获取反馈时间
  9. var informationtPermissions = $(".informationtPermissions")[0];//获取成员管理
  10. var informationtAddUser = $(".informationtAddUser")[0];
  11. var AddUserMembers = $(".AddUserMembers")[0];
  12. var NoPowerMembers = $(".NoPowerMembers")[0];
  13. var informationtcreateItem = $(".informationtcreateItem")[0]//创建项目按钮
  14. // userName.innerText = document.URL.split('?')[1].split("=")[1];
  15. userName.innerText = U.UF.Cookie.get("usestudiosso","username")[0];
  16. window.onscroll = function(){
  17. var scrollTop = document.documentElement.scrollTop;
  18. if(scrollTop>=1){
  19. asideMenu.style.top = "0";
  20. }else{
  21. asideMenu.style.top = "70px";
  22. }
  23. }
  24. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "GetProductByUserId",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){//获取项目列表
  25. if(r.value){
  26. for(var i=0;i<r.value.length;i++){
  27. var li=$$("li", {
  28. "className": "asideItem","productId":r.value[i].FeedbackId
  29. }, ul);
  30. var a=$$("a", {}, li);
  31. var icon=$$("span", {
  32. "className": "icon icon-times icon-2x",
  33. }, a);
  34. var span=$$("span", {
  35. "className": "asideItemText","innerText":r.value[i].ProductName
  36. }, a);
  37. ul.onclick = function(ev) {//点击项目列表
  38. ev = ev || event;
  39. var target = ev.target || ev.srcElement;
  40. var productId = target.parentNode.parentElement.productId;
  41. if(informationtTime.firstChild==null){
  42. Couple.createInfo(productId)
  43. }else{
  44. informationtTime.removeChild(informationtTime.firstChild)
  45. Couple.createInfo(productId)
  46. }
  47. if(informationtPermissions.firstChild !== null){
  48. informationtPermissions.style.display = "none";
  49. }
  50. if(AddUserMembers.firstChild !== null){
  51. AddUserMembers.removeChild(AddUserMembers.firstChild)
  52. informationtAddUser.style.display = "none";
  53. }
  54. if(informationtcreateItem.firstChild !== null){
  55. informationtcreateItem.removeChild(informationtcreateItem.firstChild)
  56. informationtcreateItem.style.display = "none";
  57. }
  58. var informationtTitle=$$("h4", {
  59. "className": "informationtTitle",
  60. }, informationtTime.children[0]);
  61. var addUser=$$("button", {
  62. "className": "addUser","innerText":"添加用户","onclick":"Couple.OnclickaddUser()"
  63. }, informationtTime.children[0]);
  64. informationtTitle.innerHTML = "当前项目:"+target.innerText;
  65. Couple.OnclickaddUser=function(){
  66. U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetJurisdictionName",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){
  67. if(r.value[0].JurisdictionName!=="管理员"){
  68. informationtAddUser.style.display = "block";
  69. if(AddUserMembers.firstChild == null){}else{
  70. AddUserMembers.removeChild(AddUserMembers.firstChild);
  71. }
  72. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "GetUserIdByProductId",target.parentNode.parentNode.productId],function (r){//获取没有权限用户的列表
  73. if(r.value){
  74. NoPowerMembers.innerText = r.value.length;
  75. var tbody = $$("tbody", {//创建表格
  76. "className": "tbMain",
  77. }, AddUserMembers);
  78. for(var i=0;i<r.value.length;i++){
  79. var trow = Couple.getUserRow(r.value[i],i+1,target.parentNode.parentNode.productId);
  80. tbody.appendChild(trow);
  81. }
  82. }
  83. })
  84. }else{
  85. alert("你无权限!");
  86. }
  87. })
  88. }
  89. Couple.OnclickTime=function(id,time){//点击时间对应获取信息
  90. U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetFeedback",id,time],function (r){//获取产品的反馈信息
  91. if(r.value){
  92. if(informationtInfo.firstChild==null){}else{
  93. informationtInfo.removeChild(informationtInfo.firstChild);
  94. informationtTime.removeChild(informationtTime.firstChild);
  95. Couple.createInfo(productId)
  96. }
  97. var tbody = $$("tbody", {//创建表格
  98. "className": "tbMain",
  99. }, informationtInfo);
  100. var tr = $$("tr", {}, tbody);
  101. var td = $$("td", {
  102. "className":"infoTitle","innerText":"排序"
  103. }, tr);
  104. var td = $$("td", {
  105. "className":"infoTitle trTitle","innerText":"标题"
  106. }, tr);
  107. var td = $$("td", {
  108. "className":"infoTitle trContent","innerText":"内容",
  109. }, tr);
  110. var td = $$("td", {
  111. "className":"infoTitle trCoupleTime","innerText":"反馈时间"
  112. }, tr);
  113. if(r.value.length === 0){
  114. var coupleData = $$("div", {
  115. "className":"coupleData","innerText":"暂无数据"
  116. }, tbody);
  117. }
  118. var td = $$("td", {}, tr);
  119. for(var i=0;i<r.value.length;i++){
  120. var trow = Couple.getDataRow(r.value[i],i+1);
  121. tbody.appendChild(trow);
  122. }
  123. }
  124. })
  125. }
  126. };
  127. }
  128. }
  129. })
  130. Couple.Permissions()
  131. }
  132. Couple.Permissions=function(){
  133. var informationtSet = $(".informationtSet")[0]//获取管理员设置
  134. var informationtPermissions = $(".informationtPermissions")[0];//获取成员管理
  135. var permissionsMembers = $(".permissionsMembers")[0];//获取用户成员信息
  136. var AddItem = $(".AddItem")[0];//获取创建项目
  137. var informationtcreateItem = $(".informationtcreateItem")[0]//获取创建项目
  138. var createItem = $(".createItem")[0]//获取创建按钮
  139. U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetUser"],function (r){//查询用户
  140. if(r.value){
  141. var tbody = $$("tbody", {//创建表格
  142. "className": "tbMain",
  143. }, permissionsMembers);
  144. for(var i=0;i<r.value.length;i++){
  145. var trow = Couple.getMembersRow(r.value[i],i+1);
  146. tbody.appendChild(trow);
  147. }
  148. }
  149. })
  150. U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetJurisdictionName",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){//传入用户Id获取权限名称
  151. if(r.value){
  152. if(r.value[0].JurisdictionName === "超级管理员"){
  153. informationtSet.style.display = "inline-block";
  154. informationtSet.onclick=function(){
  155. informationtPermissions.style.display = "block"
  156. }
  157. AddItem.onclick=function(){
  158. var form = $$("div", {}, informationtcreateItem);
  159. var input = $$("input", {
  160. "className":"createItemName","placeholder":"请输入项目名称","type":"text"
  161. }, form);
  162. var createItem = $$("button", {
  163. "className":"createItem","innerHTML":"创建","onclick":"Couple.OnclickcreateItem()"
  164. }, form);
  165. informationtcreateItem.style.display = "block";
  166. }
  167. Couple.OnclickcreateItem=function(){
  168. U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","InsertProductList",$(".createItemName")[0].value],function (r){//查询用户
  169. if(r.value){
  170. U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","InsertUserProduct",U.UF.Cookie.get("usestudiosso","userid")[0],r.value[0].FeedbackId],function (r){//查询用户
  171. location.reload()
  172. })
  173. }
  174. })
  175. console.log(1)
  176. return false;
  177. }
  178. }
  179. }
  180. })
  181. }
  182. Couple.createInfo=function(productId){
  183. var informationtTime = $(".informationtTime")[0]//获取反馈时间
  184. Date.prototype.Format = function (fmt) {//时间处理对Date的扩展
  185. var o = {
  186. "M+": this.getMonth() + 1, // 月份
  187. "d+": this.getDate(), // 日
  188. "h+": this.getHours(), // 小时
  189. "m+": this.getMinutes(), // 分
  190. "s+": this.getSeconds(), // 秒
  191. "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
  192. "S": this.getMilliseconds() // 毫秒
  193. };
  194. if (/(y+)/.test(fmt))
  195. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  196. for (var k in o)
  197. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  198. return fmt;
  199. }
  200. var time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");//获取时间
  201. var timeSequence=$$("div", {
  202. "className": "timeSequence"
  203. }, informationtTime);
  204. var oneDay=$$("button", {
  205. "className": "timeItem","innerText":"今天","onclick":"Couple.OnclickTime('"+productId+"','today')"
  206. }, timeSequence);
  207. var threeDay=$$("button", {
  208. "className": "timeItem","innerText":"最近三天","onclick":"Couple.OnclickTime('"+productId+"','3days')"
  209. }, timeSequence);
  210. var oneWeek=$$("button", {
  211. "className": "timeItem","innerText":"最近一周","onclick":"Couple.OnclickTime('"+productId+"','7days')"
  212. }, timeSequence)
  213. var oneMonth=$$("button", {
  214. "className": "timeItem","innerText":"最近一月","onclick":"Couple.OnclickTime('"+productId+"','30days')"
  215. }, timeSequence)
  216. }
  217. Couple.getUserRow = function(h,i,productId){//创建表格下用户数据库循环数据
  218. var row = document.createElement('tr');
  219. var trUserId = document.createElement('td');
  220. trUserId.setAttribute('class','trUserId');
  221. trUserId.innerText = h.UserId;
  222. row.appendChild(trUserId);
  223. var trUserName = document.createElement('td');
  224. trUserName.setAttribute('class','trUserName');
  225. trUserName.innerText = h.UserName;
  226. row.appendChild(trUserName);
  227. var trJurisdictionName = document.createElement('td');
  228. trJurisdictionName.setAttribute('class','trJurisdictionName');
  229. trJurisdictionName.innerText = h.JurisdictionName;
  230. row.appendChild(trJurisdictionName);
  231. var setCell = document.createElement('td');
  232. setCell.setAttribute('class','trAdd');
  233. row.appendChild(setCell);
  234. var btnAdd = document.createElement('input');
  235. btnAdd.setAttribute('type','button');
  236. btnAdd.setAttribute('value','添加权限');
  237. btnAdd.setAttribute('class','btnAdd');
  238. btnAdd.onclick=function(){ //设置操作
  239. if(confirm("确定添加权限吗")){
  240. this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
  241. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "InsertUserProduct",h.UserId,productId],function (r){})//插入用户权限
  242. }
  243. }
  244. setCell.appendChild(btnAdd);
  245. return row;
  246. }
  247. Couple.getDataRow = function(h,i){//创建表格下的反馈数据库循环数据
  248. var row = document.createElement('tr');
  249. var sortCell = document.createElement('td');
  250. sortCell.innerText = i;
  251. row.appendChild(sortCell);
  252. var trTitle = document.createElement('td');
  253. trTitle.setAttribute('class','trTitle');
  254. trTitle.innerText = h.FeedbackName;
  255. row.appendChild(trTitle);
  256. var trContent = document.createElement('td');
  257. trContent.setAttribute('class','trContent');
  258. trContent.innerText = h.FeedbackContent;
  259. row.appendChild(trContent);
  260. var trCoupleTime = document.createElement('td');
  261. trCoupleTime.setAttribute('class','trCoupleTime');
  262. trCoupleTime.innerText = U.UF.D.getYearMonthDay(h.FeedbackTime)
  263. row.appendChild(trCoupleTime);
  264. //每行末尾添加删除按钮
  265. var delCell = document.createElement('td');
  266. delCell.setAttribute('class','trDel');
  267. row.appendChild(delCell);
  268. var btnDel = document.createElement('input');
  269. btnDel.setAttribute('type','button');
  270. btnDel.setAttribute('value','删除');
  271. btnDel.setAttribute('class','delectInfo');
  272. btnDel.onclick=function(){ //删除操作
  273. if(confirm("确定删除这一行嘛?")){
  274. this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
  275. }
  276. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "DeleteFeedback",h.FeedbackId],function (r){})
  277. }
  278. delCell.appendChild(btnDel);
  279. return row;
  280. }
  281. Couple.getMembersRow = function(h,i){//创建表格下的用户数据库循环数据
  282. var row = document.createElement('tr');
  283. var trUserId = document.createElement('td');
  284. trUserId.setAttribute('class','trUserId');
  285. trUserId.innerText = h.UserId;
  286. row.appendChild(trUserId);
  287. var trUserName = document.createElement('td');
  288. trUserName.setAttribute('class','trUserName');
  289. trUserName.innerText = h.UserName;
  290. row.appendChild(trUserName);
  291. var trJurisdictionName = document.createElement('td');
  292. trJurisdictionName.setAttribute('class','trJurisdictionName');
  293. trJurisdictionName.innerText = h.JurisdictionName;
  294. row.appendChild(trJurisdictionName);
  295. var setCell = document.createElement('td');
  296. setCell.setAttribute('class','trSet');
  297. row.appendChild(setCell);
  298. var btnSet = document.createElement('input');
  299. btnSet.setAttribute('type','button');
  300. btnSet.setAttribute('value','修改');
  301. btnSet.setAttribute('class','setInfo');
  302. btnSet.onclick=function(){ //设置操作
  303. if(confirm("确定修改管理员信息吗")){
  304. if(this.parentNode.parentNode.children[2].innerText === "管理员"){
  305. this.parentNode.parentNode.children[2].innerHTML = "超级管理员"
  306. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "UpdateJurisdictionName",this.parentNode.parentNode.children[0].innerText,"超级管理员"],function (r){//修改权限
  307. console.log(r)
  308. })
  309. }else{
  310. alert("你已经是超级管理员")
  311. }
  312. }
  313. }
  314. setCell.appendChild(btnSet);
  315. //每行末尾添加删除按钮
  316. var delCell = document.createElement('td');
  317. delCell.setAttribute('class','trDel');
  318. row.appendChild(delCell);
  319. var btnDel = document.createElement('input');
  320. btnDel.setAttribute('type','button');
  321. btnDel.setAttribute('value','删除');
  322. btnDel.setAttribute('class','delectInfo');
  323. btnDel.onclick=function(){ //删除操作
  324. if(confirm("确定删除这一行嘛?")){
  325. this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
  326. U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "DeleteFeedback",h.FeedbackId],function (r){})
  327. }
  328. }
  329. delCell.appendChild(btnDel);
  330. return row;
  331. }
  332. Couple.logout=function(){//退出
  333. U.UF.CD.loadAjaxCrossDomain(function(){
  334. U.A.Request(US.AUTH, ["UserOffline", U.UF.Cookie.get("usestudiosso","userid")[0]],function(r){
  335. U.UF.Cookie.del("usestudiosso")
  336. window.location.href="http://couple.1473.cn/login.html";
  337. });
  338. });
  339. }
  340. Couple.Init=function () {
  341. Couple.Bind();
  342. }();