couple.js 17 KB

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