- Ext.app.AdSitePopedomForm = Ext.extend(Ext.Window,
- {
- title: '網站功能授權',
- id: 'am-adsitepopedom',
- autoScroll: true,
- xtype: "window",
- width: 400,
- height: 540,
- layout: "absolute",
- modal: true,
- initComponent: function () {
- var userId = Ext.getCmp("am-usergrid").userId;
- var mytree = new Ext.tree.TreePanel({
- id: 'ppdTree',
- x: 5,
- y: 5,
- width: 378,
- height: 470,
- useArrows: true,
- autoScroll: true,
- animate: true,
- enableDD: true,
- containerScroll: true,
- store: new Ext.data.TreeStore
- ({
- proxy:
- {
- type: 'ajax',
- url: 'data/User/UserPopedom.aspx?parameter=ppdTree&userId=' + userId
- },
- root:
- {
- id: 0,
- text: "選擇權限",
- leaf: false,
- expandable: true,
- expanded: true
- },
- sorters: [
- {
- property: 'leaf',
- direction: 'ASC'
- },
- {
- property: 'text',
- direction: 'ASC'
- }]
- })
- });
- mytree.on('checkchange', function (node, checked) {
- node.expand();
- node.checked = checked;
- node.eachChild(function (child) {
- child.set('checked', checked);
- child.fireEvent('checkchange', child, checked);
- });
- }, mytree);
- this.items =
- [
- mytree,
- {
- xtype: "textfield",
- hidden: true,
- name: "Id",
- id: "Id",
- value: userId
- }
- ];
- this.buttons =
- [
- {
- text: '確認',
- xtype: 'button',
- width: 30,
- handler: function () {
- var b = mytree.getChecked();
- var checkids = new Array; // 存放選中id的 數組
- for (var i = 0; i < b.length; i++) {
- if (b.length == 1) {
- checkids = b[i].data.id;
- }
- else {
- if (i < b.length - 1) {
- checkids += b[i].data.id + ",";
- }
- if (i == b.length - 1) {
- checkids += b[i].data.id;
- }
- }
- // checkid.push(b[i].text); // 添加id到數組
- }
- Ext.Ajax.request({
- url: "data/User/UserPopedom.aspx?parameter=poped",
- method: "POST",
- params: { ppdIds: checkids, userId: userId }, //發送的參數
- success: function (response, option) {
- response = Ext.JSON.decode(response.responseText);
- if (response.success == true) {
- if (response.flag == true) {
- Ext.MessageBox.alert("提示", "權限分配成功!");
- //關閉當前窗體
- var adpoped = Ext.getCmp("am-adsitepopedom");
- adpoped.close();
- //刷新列表
- var adGrid = Ext.getCmp("am-usergrid");
- adGrid.store.load();
- }
- else {
- Ext.MessageBox.alert("錯誤信息", "權限分配失敗!");
- }
- }
- else {
- Ext.MessageBox.alert("錯誤信息", response.msg);
- }
- },
- failure: function () {
- Ext.Msg.alert("提示", "權限分配<br>沒有捕獲到異常");
- }
- });
- }
- },
- {
- text: '取消',
- xtype: 'button',
- width: 30,
- handler: function () {
- var windows = Ext.getCmp('am-adsitepopedom');
- windows.close();
- }
- }
- ];
- Ext.app.AdSitePopedomForm.superclass.initComponent.call(this);
- }
- });
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using CtManager.BLL;
- using CtManager.Model;
- using Newtonsoft.Json;
- public partial class Data_User_UserPopedom : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Request["parameter"] == null)
- {
- Response.Write("");
- return;
- }
- string parameter = Request["parameter"];
- if (parameter == "ppdTree") Response.Write(AdvertisingTreePPDData());
- else if (parameter == "poped") Response.Write(DistributeAuthority());
- else Response.Write("");
- }
- /// <summary>
- /// 權限分配方法
- /// </summary>
- /// <returns></returns>
- public string DistributeAuthority()
- {
- try
- {
- if (UserInfoManager.ModifyUserInfoPopedomById(Request["ppdIds"], Request["userId"])) return "{success:true,flag:true}";
- else return "{success:true,flag:false}";
- }
- catch (Exception /*ex*/)
- {
- return "{success:true,flag:false}";
- }
- }
- /// <summary>
- /// 廣告位 樹的Json數據源(用於授權 數據加上覆選框) 用戶權限初始化
- /// </summary>
- /// <returns></returns>
- public string AdvertisingTreePPDData()
- {
- IList<PopeDom> ppdList = UserInfoManager.CreatePopedomTree(Request["userId"]);
- return JavaScriptConvert.SerializeObject(ppdList).Replace("Mchecked", "checked");
- }
- }