<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
|
<title>新增菜单</title>
|
|
<script type="text/javascript">
|
var pageVue = null;
|
function loadJsCss(callback) {
|
var jscss_urls = [];
|
window.top.initJsCss(document, jscss_urls, callback);
|
};
|
|
function initVue() {
|
new FormVue({
|
el: "#vbody",
|
data: {
|
dataname: "sys_menu",
|
title: "新增菜单",
|
formAttr: {
|
istitle: false,
|
title: "",
|
columnnumber: 1,
|
labelwidth: "120px",
|
labelposition: "left",
|
size: "medium",
|
border: "10px solid #c6c6c600"
|
},
|
|
formFields: [],
|
newformData: {
|
//id: uuid_short(),
|
// code: createCode("BA"),
|
},
|
formData: {},
|
|
dataRequest: [
|
{
|
name: "sys_menunotpage",
|
dataname: "sys_menu",
|
filter: " page_id is null",
|
isnotoption: false, //true:不是选项
|
code:"id",//是下拉选项时设置
|
label:"name",//是下拉选项时设置
|
},
|
|
],
|
dataRequestObj: {},
|
options_menumap: {},
|
options_menutree: [],
|
|
//按键权限设置
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
iscommit: false,//提交标记
|
|
//弹窗参数
|
popupParames: {},
|
//字段设置
|
tablefieldClick: {},
|
formfieldClick: {},
|
},
|
created() {
|
this.popupParames = clone(Root.popupParames);
|
this.title = this.popupParames.title || this.popupParames.text
|
// if (this.popupParames.data) {
|
// this.formData = clone(this.popupParames.data);
|
// }
|
|
if (this.popupParames.data) {
|
console.log(this.popupParames.data);
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == 'add') {
|
this.formData.parent_id = this.popupParames.data.id;
|
} else if (this.popupParames.sceneCode == 'edit') {
|
this.formData = clone(this.popupParames.data);
|
}
|
}
|
}
|
},
|
|
mounted() {
|
var me = this;
|
//预加载数据
|
if (this.dataRequest && this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
//预加载数据后给哪些字段设置options或formatterjson
|
var sys_menunotpage_ = clone(data.sys_menunotpage);
|
sys_menunotpage_.map(m=>{
|
me.options_menumap[m.id] = m;
|
})
|
var sys_menunotpagetree = ArrayToTree(clone(sys_menunotpage_), "title", "parent_id");
|
me.options_menutree = clone(sys_menunotpagetree);
|
|
me.initData();
|
});
|
}
|
else {
|
this.initData();
|
}
|
|
},
|
|
methods:{
|
//关闭弹窗
|
closeDialog() {
|
var me = this;
|
if (me.popupParames.totab){
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, false);
|
}
|
else {
|
Root.hidePopup();
|
}
|
},
|
//关闭前调回调
|
saveAfter() {
|
var me = this;
|
if(this.popupParames.callback) {
|
let obj = {
|
options: this.treeoptions,
|
}
|
this.popupParames.callback(obj, function() {
|
me.closeDialog();
|
});
|
}
|
else {
|
me.closeDialog();
|
}
|
},
|
|
initData() {
|
let me = this;
|
var id_ = null;
|
if (this.formData.id) {
|
id_ = this.formData.id;
|
}
|
this.getRowDataById(id_, function(result) {//查询后的回调,用于获取字段的
|
if (result.meta && result.meta[me.dataname] && result.meta[me.dataname].fields) {
|
var metas = clone(result.meta[me.dataname].fields);
|
var formFields_ = [];
|
|
metas.map(f=>{
|
f.isshow = "T";
|
if (f.field == "parent_id") {
|
// f.notshowalllevels = true;
|
f.props = {value: "id", label: "title", checkStrictly: true};
|
f.options = me.options_menutree;
|
}
|
formFields_.push(clone(f));
|
})
|
if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
|
me.formFields = clone(formFields_);
|
|
//设置字段事件
|
me.tableFieldClick();
|
|
// 以服务的方式调用的 Loading 需要异步关闭
|
me.$nextTick(() => {
|
hideLoading();
|
|
//重新设置弹窗宽高
|
me.$nextTick(function(){
|
let w_ = me.$refs.popup_body.offsetWidth + "px";
|
w_ = "900px";
|
let h_ = me.$refs.popup_body.offsetHeight + "px";
|
Root.setPopupWH(w_, h_);
|
})
|
});
|
}
|
}
|
|
})
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表单字段事件设置
|
this.formfieldClick = {
|
icon: {
|
popup: {
|
onclick: function(obj) {//弹窗点击事件
|
//打开
|
me.open_iconlist()
|
}
|
},
|
},
|
page_id: {
|
popup: {
|
onclick: function(obj) {//弹窗点击事件
|
//打开
|
me.open_pagelist()
|
}
|
},
|
},
|
};
|
},
|
|
open_iconlist() {
|
var me = this;
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "900px",
|
height: "900px",
|
icon: "icon-product",
|
text: "图标选择弹窗",
|
id: "popup_iconfont",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/tool/page/popup_iconfont.html",
|
data: {},
|
delta: {pageobj: me.selectTabObj},
|
sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(obj, callback) {
|
let formData_ = clone(me.formData);
|
formData_.icon = obj.icon;
|
me.formData = formData_;
|
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
open_pagelist() {
|
var me = this;
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "900px",
|
height: "900px",
|
icon: "icon-product",
|
text: "对应页面信息",
|
id: "popup_page",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/config/page/popup_page.html",
|
data: {},
|
delta: {},
|
sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(obj, callback) {
|
let formData_ = clone(me.formData);
|
formData_.page_id = obj.row.id;
|
me.formData = formData_;
|
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
//提交
|
submitRowTable() {
|
this.iscommit = true;
|
this.saveRowTable();
|
},
|
|
//保存
|
saveRowTable() {
|
var me = this;
|
var operator_ = "save";//保存
|
if(me.iscommit) {
|
operator_ = "commit";//提交
|
}
|
|
var entity_ = clone(this.formData);
|
var entity = {};
|
for (var r in entity_) {
|
if (entity_[r] || entity_[r] == "" || entity_[r] == false || entity_[r] == 0) {
|
entity[r] = entity_[r];
|
}
|
}
|
|
let param = {
|
dataname: this.dataname,
|
// operator: operator_,
|
data: {},
|
}
|
param.data[this.dataname] = entity;
|
|
Server.call("root/data/saveEntity", param, function(result) {
|
console.log(result);
|
if (result.success) {
|
if (me.iscommit) {
|
me.iscommit = false;
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
me.saveAfter();
|
}
|
else {
|
let param_ = {
|
dataname: "sys_menu",
|
filter: "page_id is null",
|
}
|
Server.call("root/data/getEntitySet", param_, function(result2){
|
let agm_category_ = ArrayToTree(clone(result2.data.entityset), "title", "parent_id");
|
me.options_menutree = agm_category_;
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
me.saveAfter();
|
});
|
}
|
}
|
});
|
},
|
|
|
}
|
});
|
};
|
|
loadJsCss(function () {
|
initVue();
|
});
|
</script>
|
<style>
|
/* 在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
|
[v-cloak] {
|
display: none !important;
|
}
|
</style>
|
|
</head>
|
|
<body style="margin: 0px;">
|
<div v-cloak id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="padding: 0 20px;">
|
<div class="popup_el-dialog__header">
|
<div class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{title}}</span>
|
</div>
|
</div>
|
<div style="overflow-y: auto;">
|
<div class="el-dialog__body">
|
<h-form
|
ref="form1"
|
:form-attr="formAttr"
|
:table-fields="formFields"
|
:form-data="formData"
|
:table-field-click="formfieldClick"
|
>
|
</h-form>
|
</div>
|
</div>
|
<div class="el-dialog__footer">
|
<el-button size="small" type="default" @click="closeDialog">取 消</el-button>
|
<el-button size="small" type="primary" @click="saveRowTable":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
|
<el-button size="small" v-if="isedit" type="success" @click="submitRowTable":icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</el-button>
|
<el-button size="small" v-if="isrefuseedit" type="success" @click="">再次提交</el-button>
|
|
<el-button size="small" v-if="isapproval" type="primary" @click="">通 过</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="">拒 绝</el-button>
|
<el-button size="small" v-if="isapproval" type="primary" @click="">转 办</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="">退 回</el-button>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
</body>
|
</html>
|