| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- Namespace.register("Couple");//注册命名空间
- Couple.Bind=function () {
- var userName=$(".userName")[0]//获取用户名
- var ul = $(".asideMenu ul")[0];//获取项目列表ul
- var asideMenu = $(".asideMenu")[0];
- var informationtSet = $(".informationtSet")[0];
- var informationtInfo = $(".informationtInfo")[0];//获取反馈信息
- var informationtTime = $(".informationtTime")[0];//获取反馈时间
- var informationtPermissions = $(".informationtPermissions")[0];//获取成员管理
- var informationtAddUser = $(".informationtAddUser")[0];
- var AddUserMembers = $(".AddUserMembers")[0];
- var NoPowerMembers = $(".NoPowerMembers")[0];
- var informationtcreateItem = $(".informationtcreateItem")[0]//创建项目按钮
- // userName.innerText = document.URL.split('?')[1].split("=")[1];
- userName.innerText = U.UF.Cookie.get("usestudiosso","username")[0];
- window.onscroll = function(){
- var scrollTop = document.documentElement.scrollTop;
- if(scrollTop>=1){
- asideMenu.style.top = "0";
- }else{
- asideMenu.style.top = "70px";
- }
- }
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "GetProductByUserId",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){//获取项目列表
- if(r.value){
- for(var i=0;i<r.value.length;i++){
- var li=$$("li", {
- "className": "asideItem","productId":r.value[i].ProductId
- }, ul);
- var a=$$("a", {}, li);
- var icon=$$("span", {
- "className": "icon icon-times icon-2x",
- }, a);
- var span=$$("span", {
- "className": "asideItemText","innerText":r.value[i].ProductName
- }, a);
- ul.onclick = function(ev) {//点击项目列表
- ev = ev || event;
- var target = ev.target || ev.srcElement;
- var productId = target.parentNode.parentElement.productId;
- if(informationtTime.firstChild==null){
- Couple.createInfo(productId)
- }else{
- informationtTime.removeChild(informationtTime.firstChild)
- Couple.createInfo(productId)
- }
- if(informationtPermissions.firstChild !== null){
- informationtPermissions.style.display = "none";
- }
- if(AddUserMembers.firstChild !== null){
- AddUserMembers.removeChild(AddUserMembers.firstChild)
- informationtAddUser.style.display = "none";
- }
- if(informationtcreateItem.firstChild !== null){
- informationtcreateItem.removeChild(informationtcreateItem.firstChild)
- informationtcreateItem.style.display = "none";
- }
- var informationtTitle=$$("h4", {
- "className": "informationtTitle",
- }, informationtTime.children[0]);
- var delItem=$$("button", {
- "className": "delItem","innerText":"删除项目","onclick":"Couple.OnclickdelITem()"
- }, informationtTime.children[0]);
- var addUser=$$("button", {
- "className": "addUser","innerText":"添加用户","onclick":"Couple.OnclickaddUser()"
- }, informationtTime.children[0]);
- informationtTitle.innerHTML = "当前项目:"+target.innerText;
- Couple.OnclickaddUser=function(){
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetJurisdictionName",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){
- if(r.value[0].JurisdictionName!=="管理员"){
- informationtAddUser.style.display = "block";
- if(AddUserMembers.firstChild == null){}else{
- AddUserMembers.removeChild(AddUserMembers.firstChild);
- }
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "GetUserIdByProductId",target.parentNode.parentNode.productId],function (r){//获取没有权限用户的列表
- if(r.value){
- NoPowerMembers.innerText = r.value.length;
- var tbody = $$("tbody", {//创建表格
- "className": "tbMain",
- }, AddUserMembers);
- for(var i=0;i<r.value.length;i++){
- var trow = Couple.getUserRow(r.value[i],i+1,target.parentNode.parentNode.productId);
- tbody.appendChild(trow);
- }
- }
- })
- }else{
- alert("你无权限!");
- }
- })
- }
- Couple.OnclickdelITem=function(){
- if(confirm("确定啥删除该项目吗")){
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","DeleteProductList",target.parentNode.parentNode.productId],function (r){
- if(r.value){
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","DeleteProduct",target.parentNode.parentNode.productId],function (r){})
- location.reload();
- return false;
- }
- })
- }
- }
- Couple.OnclickTime=function(id,time){//点击时间对应获取信息
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetFeedback",id,time],function (r){//获取产品的反馈信息
- if(r.value){
- if(informationtInfo.firstChild==null){}else{
- informationtInfo.removeChild(informationtInfo.firstChild);
- informationtTime.removeChild(informationtTime.firstChild);
- Couple.createInfo(productId)
- }
- var tbody = $$("tbody", {//创建表格
- "className": "tbMain",
- }, informationtInfo);
- var tr = $$("tr", {}, tbody);
- var td = $$("td", {
- "className":"infoTitle","innerText":"排序"
- }, tr);
- var td = $$("td", {
- "className":"infoTitle trTitle","innerText":"标题"
- }, tr);
- var td = $$("td", {
- "className":"infoTitle trContent","innerText":"内容",
- }, tr);
- var td = $$("td", {
- "className":"infoTitle trCoupleTime","innerText":"反馈时间"
- }, tr);
- if(r.value.length === 0){
- var coupleData = $$("div", {
- "className":"coupleData","innerText":"暂无数据"
- }, tbody);
- }
- var td = $$("td", {}, tr);
- for(var i=0;i<r.value.length;i++){
-
- var trow = Couple.getDataRow(r.value[i],i+1);
- tbody.appendChild(trow);
- }
- }
- })
- }
- };
- }
- }
- })
- Couple.Permissions()
- }
- Couple.Permissions=function(){
- var informationtSet = $(".informationtSet")[0]//获取管理员设置
- var informationtPermissions = $(".informationtPermissions")[0];//获取成员管理
- var permissionsMembers = $(".permissionsMembers")[0];//获取用户成员信息
- var AddItem = $(".AddItem")[0];//获取创建项目
- var informationtcreateItem = $(".informationtcreateItem")[0]//获取创建项目
- var createItem = $(".createItem")[0]//获取创建按钮
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetUser"],function (r){//查询用户
- if(r.value){
- var tbody = $$("tbody", {//创建表格
- "className": "tbMain",
- }, permissionsMembers);
- for(var i=0;i<r.value.length;i++){
- var trow = Couple.getMembersRow(r.value[i],i+1);
- tbody.appendChild(trow);
- }
- }
- })
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","GetJurisdictionName",U.UF.Cookie.get("usestudiosso","userid")[0]],function (r){//传入用户Id获取权限名称
- if(r.value){
- if(r.value[0].JurisdictionName === "超级管理员"){
- informationtSet.style.display = "inline-block";
- informationtSet.onclick=function(){
- informationtPermissions.style.display = "block"
- }
- AddItem.onclick=function(){
- var form = $$("div", {}, informationtcreateItem);
- var input = $$("input", {
- "className":"createItemName","placeholder":"请输入项目名称","type":"text"
- }, form);
- var createItem = $$("button", {
- "className":"createItem","innerHTML":"创建","onclick":"Couple.OnclickcreateItem()"
- }, form);
- informationtcreateItem.style.display = "block";
- }
- Couple.OnclickcreateItem=function(){
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn","UseStudio_FeedBack","InsertProductList",$(".createItemName")[0].value],function (r){//查询用户
- if(r.value){
- 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){//查询用户
- location.reload()
- })
- }
- })
- console.log(1)
- return false;
- }
-
- }
- }
- })
- }
- Couple.createInfo=function(productId){
- var informationtTime = $(".informationtTime")[0]//获取反馈时间
- Date.prototype.Format = function (fmt) {//时间处理对Date的扩展
- var o = {
- "M+": this.getMonth() + 1, // 月份
- "d+": this.getDate(), // 日
- "h+": this.getHours(), // 小时
- "m+": this.getMinutes(), // 分
- "s+": this.getSeconds(), // 秒
- "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
- "S": this.getMilliseconds() // 毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- var time = (new Date()).Format("yyyy-MM-dd hh:mm:ss");//获取时间
- var timeSequence=$$("div", {
- "className": "timeSequence"
- }, informationtTime);
- var oneDay=$$("button", {
- "className": "timeItem","innerText":"今天","onclick":"Couple.OnclickTime('"+productId+"','today')"
- }, timeSequence);
- var threeDay=$$("button", {
- "className": "timeItem","innerText":"最近三天","onclick":"Couple.OnclickTime('"+productId+"','3days')"
- }, timeSequence);
- var oneWeek=$$("button", {
- "className": "timeItem","innerText":"最近一周","onclick":"Couple.OnclickTime('"+productId+"','7days')"
- }, timeSequence)
- var oneMonth=$$("button", {
- "className": "timeItem","innerText":"最近一月","onclick":"Couple.OnclickTime('"+productId+"','30days')"
- }, timeSequence)
- }
- Couple.getUserRow = function(h,i,productId){//创建表格下用户数据库循环数据
- var row = document.createElement('tr');
- var trUserId = document.createElement('td');
- trUserId.setAttribute('class','trUserId');
- trUserId.innerText = h.UserId;
- row.appendChild(trUserId);
- var trUserName = document.createElement('td');
- trUserName.setAttribute('class','trUserName');
- trUserName.innerText = h.UserName;
- row.appendChild(trUserName);
- var trJurisdictionName = document.createElement('td');
- trJurisdictionName.setAttribute('class','trJurisdictionName');
- trJurisdictionName.innerText = h.JurisdictionName;
- row.appendChild(trJurisdictionName);
- var setCell = document.createElement('td');
- setCell.setAttribute('class','trAdd');
- row.appendChild(setCell);
- var btnAdd = document.createElement('input');
- btnAdd.setAttribute('type','button');
- btnAdd.setAttribute('value','添加权限');
- btnAdd.setAttribute('class','btnAdd');
-
- btnAdd.onclick=function(){ //设置操作
- if(confirm("确定添加权限吗")){
- this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "InsertUserProduct",h.UserId,productId],function (r){})//插入用户权限
- }
- }
- setCell.appendChild(btnAdd);
- return row;
- }
- Couple.getDataRow = function(h,i){//创建表格下的反馈数据库循环数据
- var row = document.createElement('tr');
- var sortCell = document.createElement('td');
- sortCell.innerText = i;
- row.appendChild(sortCell);
- var trTitle = document.createElement('td');
- trTitle.setAttribute('class','trTitle');
- trTitle.innerText = h.FeedbackName;
- row.appendChild(trTitle);
- var trContent = document.createElement('td');
- trContent.setAttribute('class','trContent');
- trContent.innerText = h.FeedbackContent;
- row.appendChild(trContent);
- var trCoupleTime = document.createElement('td');
- trCoupleTime.setAttribute('class','trCoupleTime');
- trCoupleTime.innerText = U.UF.D.getYearMonthDay(h.FeedbackTime)
- row.appendChild(trCoupleTime);
- //每行末尾添加删除按钮
- var delCell = document.createElement('td');
- delCell.setAttribute('class','trDel');
- row.appendChild(delCell);
- var btnDel = document.createElement('input');
- btnDel.setAttribute('type','button');
- btnDel.setAttribute('value','删除');
- btnDel.setAttribute('class','delectInfo');
- btnDel.onclick=function(){ //删除操作
- if(confirm("确定删除这一行嘛?")){
- this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
- }
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "DeleteFeedback",h.ProductId],function (r){})
- }
- delCell.appendChild(btnDel);
- return row;
- }
- Couple.getMembersRow = function(h,i){//创建表格下的用户数据库循环数据
- var row = document.createElement('tr');
- var trUserId = document.createElement('td');
- trUserId.setAttribute('class','trUserId');
- trUserId.innerText = h.UserId;
- row.appendChild(trUserId);
- var trUserName = document.createElement('td');
- trUserName.setAttribute('class','trUserName');
- trUserName.innerText = h.UserName;
- row.appendChild(trUserName);
- var trJurisdictionName = document.createElement('td');
- trJurisdictionName.setAttribute('class','trJurisdictionName');
- trJurisdictionName.innerText = h.JurisdictionName;
- row.appendChild(trJurisdictionName);
-
- var setCell = document.createElement('td');
- setCell.setAttribute('class','trSet');
- row.appendChild(setCell);
- var btnSet = document.createElement('input');
- btnSet.setAttribute('type','button');
- btnSet.setAttribute('value','修改');
- btnSet.setAttribute('class','setInfo');
- btnSet.onclick=function(){ //设置操作
- if(confirm("确定修改管理员信息吗")){
- if(this.parentNode.parentNode.children[2].innerText != "超级管理员"){
- this.parentNode.parentNode.children[2].innerHTML = "超级管理员"
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "UpdateJurisdictionName",this.parentNode.parentNode.children[0].innerText,"超级管理员"],function (r){//修改权限
- console.log(r)
- })
- }else{
- alert("你已经是超级管理员")
- }
- }
- }
- setCell.appendChild(btnSet);
- //每行末尾添加删除按钮
- var delCell = document.createElement('td');
- delCell.setAttribute('class','trDel');
- row.appendChild(delCell);
- var btnDel = document.createElement('input');
- btnDel.setAttribute('type','button');
- btnDel.setAttribute('value','删除');
- btnDel.setAttribute('class','delectInfo');
- btnDel.onclick=function(){ //删除操作
- if(confirm("确定删除这一行嘛?")){
- this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
- U.A.Request("http://cd.1473.cn/net",["db.1473.cn", "UseStudio_FeedBack", "DeleteFeedback",h.FeedbackId],function (r){})
- }
- }
- delCell.appendChild(btnDel);
- return row;
- }
- Couple.logout=function(){//退出
- U.UF.CD.loadAjaxCrossDomain(function(){
- U.A.Request(US.AUTH, ["UserOffline", U.UF.Cookie.get("usestudiosso","userid")[0]],function(r){
- U.UF.Cookie.del("usestudiosso")
- window.location.href="http://couple.1473.cn/login.html";
- });
- });
- }
- Couple.Init=function () {
- Couple.Bind();
- }();
|