zhangyanpeng
2024-08-27 a8961c1d00c17a5aa2658884df9479ed6fba94c3
module/config/page/sys_menu_add.html
@@ -32,7 +32,9 @@
                     //id: uuid_short(),
                     // code: createCode("BA"),
                  },
                  formData: {},
                  formData: {
                     title: "",
                  },
                  
                  dataRequest: [
                     {
@@ -48,6 +50,7 @@
                  dataRequestObj: {},
                  options_menumap: {},
                  options_menutree: [],
                  listoptions: [],
                  
                  //按键权限设置
                  isedit: false,//提交前编辑,保存/提交
@@ -63,6 +66,9 @@
                  
                  pageid: "", // 新页面id
                  parent_menuobj: {}, // 父级菜单
                  isAddMenu: false, // 仅添加一个菜单
                  treeoptions: []
               },
               created() {
                  this.popupParames = clone(Root.popupParames);
@@ -72,13 +78,42 @@
                  // }
                  if (this.popupParames.data) {
                     this.parent_menuobj = this.popupParames.data;
                     if (this.popupParames.sceneCode) {
                        if (this.popupParames.sceneCode == 'add') {
                           this.pageid = createCode("R_");
                        if (this.popupParames.sceneCode == 'addmenu') {
                           this.isAddMenu = true;
                           // this.pageid = createCode("M_P");
                           this.parent_menuobj = this.popupParames.data;
                           if (this.parent_menuobj && this.parent_menuobj.id) {
                              this.formData.parent_id = this.parent_menuobj.id
                           }
                        }
                        else if (this.popupParames.sceneCode == 'add') {
                           this.parent_menuobj = this.popupParames.data;
                           this.pageid = createCode("M_P");
                           this.formData.parent_id = this.popupParames.data.id;
                        } else if (this.popupParames.sceneCode == 'edit') {
                        }
                        else if (this.popupParames.sceneCode == 'edit') {
                           this.pageid = this.popupParames.data.page_id;
                           this.parent_menuobj = {
                              id: this.popupParames.data.parent_id,
                              type_code: this.popupParames.data.type_code
                           };
                           if (this.popupParames.data.url &&  this.popupParames.data.url.indexOf("viewlet=") > 0) {
                              var url_ = this.popupParames.data.url.split("viewlet=")
                              var url_parame_ = url_[1].split("&")
                              if (url_parame_[1] && url_parame_[1] == "op=write") {
                                 this.popupParames.data.reporttype = "write"
                              }
                              else if (url_parame_[1] && url_parame_[1] == "op=view") {
                                 this.popupParames.data.reporttype = "view"
                              }
                              else {
                                 this.popupParames.data.reporttype = ""
                              }
                              this.popupParames.data.url = url_parame_[0]
                           }
                           this.formData = clone(this.popupParames.data);
                        }
                     }
@@ -126,7 +161,8 @@
                     var me = this;
                     if(this.popupParames.callback) {
                        let obj = {
                           options: this.treeoptions,
                           treeoptions: this.options_menutree,
                           listoptions: this.listoptions
                        }
                        this.popupParames.callback(obj, function() {
                           me.closeDialog();
@@ -157,8 +193,13 @@
                              }
                              formFields_.push(clone(f));
                           })
                           var page_url = {isshow: "T", field: "url", name: "路径", type: "input", required: true}
                           formFields_.push(clone(page_url));
                           // if (!me.isAddMenu) {
                           //    var page_url = {isshow: "T", field: "url", name: "路径", type: "input", required: true, placeholder: "如:patch_report/DMS_index_mysql.frm", appendix: "报表中的参数包含actor(角色类型Org/Business/Sales/Customer/Admin)、target_id(销售岗位ID/DMS开户ID)、company_id、bu_id", isvalexplain_br: true}
                           //    var page_reporttype = {isshow: "T", field: "reporttype", name: "类型", type: "radio", options: [{code: "", value: "预览"}, {code: "write", value: "填报"},{code: "view", value: "分析"}]}
                           //    formFields_.push(clone(page_url));
                           //    formFields_.push(clone(page_reporttype));
                           // }
                           if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
                              me.formFields = clone(formFields_);
                              
@@ -269,11 +310,12 @@
                     var me = this;
                     if (this.pageid) {
                        var entity_ = clone(this.formData);
                        var entity = {
                           id: this.pageid,
                           code: this.pageid,
                           title: entity_.title,
                           url: "module/report/page/report_iframe.html?viewlet=" + entity_.url,
                           url: entity_.url ? entity_.url : "module/model/model_iframe.html",
                           is_active: "T"
                        };
                        
@@ -298,16 +340,20 @@
                     var me = this;
                     var entity_ = clone(this.formData);
                     var entity = {
                        parent_id: this.parent_menuobj.id,
                        type_code: this.parent_menuobj.type_code,
                        page_id: this.pageid,
                        parent_id: this.parent_menuobj.id || null,
                        type_code: this.parent_menuobj.type_code || "Z",
                        open_type: "arrange",
                        page_id: this.pageid || null,
                        title: entity_.title,
                        icon: entity_.icon,
                        order_no: this.parent_menuobj.children.length + 1,
                        order_no: entity_.order_no ? entity_.order_no : (this.parent_menuobj.children ? this.parent_menuobj.children.length + 1 : 1),
                     };
                     
                     if (entity_.id) {
                        entity.id = entity_.id
                     }
                     else {
                        entity.id = createCode("M")
                     }
                     
                     let param = {
@@ -317,12 +363,36 @@
                     param.data[this.dataname] = entity;
                     Server.call("root/data/saveEntity", param, function(result) {
                        console.log(result);
                        if (me.pageid) {
                           me.onRefreshCacheByPageId(me.pageid);
                        }
                        else if (entity.id) {
                           me.onRefreshCacheByMenuId(entity.id);
                        }
                        else {
                           Root.message({
                              type: 'success',
                              message: '保存成功'
                           });
                           me.saveAfter();
                        }
                     });
                  },
                  // 刷新缓存页面
                  onRefreshCacheByPageId(PageId) {
                     var me = this;
                     let param_ = {
                        page_id: PageId
                     }
                     Server.call("root/system/reloadMenuByPage", param_, function(result) {
                        if (result.success) {
                           let param_ = {
                              dataname: "sys_menu",
                              filter: "page_id is null",
                           }
                           Server.call("root/data/getEntitySet", param_, function(result2){
                              me.listoptions = clone(result2.data.entityset);
                              let agm_category_ = ArrayToTree(clone(result2.data.entityset), "title", "parent_id");
                              me.options_menutree = agm_category_;
                              Root.message({
@@ -335,6 +405,30 @@
                     });
                  },
                  
                  onRefreshCacheByMenuId(MenuId) {
                     var me = this;
                     let param_ = {
                        menu_id: MenuId
                     }
                     Server.call("root/system/reloadOneMenu", param_, function(result) {
                        if (result.success) {
                           let param_ = {
                              dataname: "sys_menu",
                              filter: "page_id is null",
                           }
                           Server.call("root/data/getEntitySet", param_, function(result2){
                              me.listoptions = clone(result2.data.entityset);
                              let agm_category_ = ArrayToTree(clone(result2.data.entityset), "title", "parent_id");
                              me.options_menutree = agm_category_;
                              Root.message({
                                 type: 'success',
                                 message: '保存成功'
                              });
                              me.saveAfter();
                           });
                        }
                     });
                  }
                  
               }
            });