couple.js 19 KB

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