couple.js 18 KB

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