Merge branch 'sprint/167_api_doc' into 'sprint/167'
fix many subfiled bug See merge request easycorp/zentaopms!122
This commit is contained in:
+10
-10
@@ -33,6 +33,15 @@ class api extends control
|
||||
*/
|
||||
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0)
|
||||
{
|
||||
/* Get all api doc libraries. */
|
||||
$libs = $this->doc->getApiLibs();
|
||||
|
||||
/* Generate bread crumbs dropMenu. */
|
||||
if($libs)
|
||||
{
|
||||
if($libID == 0) $libID = key($libs);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $release);
|
||||
}
|
||||
|
||||
/* Get an api doc. */
|
||||
if($apiID > 0)
|
||||
@@ -58,15 +67,6 @@ class api extends control
|
||||
$this->view->apiList = $apiList;
|
||||
}
|
||||
|
||||
/* Get all api doc libraries. */
|
||||
$libs = $this->doc->getApiLibs();
|
||||
|
||||
/* Generate bread crumbs dropMenu. */
|
||||
if($libs)
|
||||
{
|
||||
if($libID == 0) $libID = key($libs);
|
||||
$this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $release);
|
||||
}
|
||||
$this->setMenu($libID);
|
||||
|
||||
$this->view->isRelease = $release > 0;
|
||||
@@ -671,7 +671,7 @@ class api extends control
|
||||
else
|
||||
{
|
||||
/* generate create api doc lib button */
|
||||
if(common::hasPriv('api', 'createDoc'))
|
||||
if(common::hasPriv('api', 'createLib'))
|
||||
{
|
||||
$menu .= html::a(helper::createLink('api', 'createLib'), '<i class="icon icon-plus"></i> ' . $this->lang->api->createLib, '', 'class="btn btn-secondary iframe"');
|
||||
}
|
||||
|
||||
+36
-20
@@ -302,11 +302,17 @@ try {
|
||||
},
|
||||
current: {
|
||||
handler(val) {
|
||||
// console.log(val)
|
||||
/* handle level field data. */
|
||||
const attr = [];
|
||||
val.forEach((item) => {
|
||||
if (item.sub == 1) {
|
||||
attr.push(this.handleParams(item))
|
||||
const newItem = {
|
||||
...item,
|
||||
children: []
|
||||
}
|
||||
this.handleParams(val, newItem);
|
||||
attr.push(newItem)
|
||||
}
|
||||
})
|
||||
this.$emit('change', attr)
|
||||
@@ -319,17 +325,25 @@ try {
|
||||
if (this.attr && this.attr.length > 0) {
|
||||
const attr = [];
|
||||
this.decodeParams(this.attr, attr)
|
||||
this.current = attr
|
||||
this.params[this.structType] = this.current;
|
||||
const current = [];
|
||||
attr.forEach(item => {
|
||||
current.push({
|
||||
...item,
|
||||
children: [],
|
||||
})
|
||||
})
|
||||
this.current = current.splice(0);
|
||||
this.params[this.structType] = [...this.current];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
genKey() {
|
||||
this.fieldKey++;
|
||||
if (this.current.findIndex(item => item.key == this.fieldKey) != -1) {
|
||||
this.genKey();
|
||||
let key = Date.now().toString(36)
|
||||
key += Math.random().toString(36).substr(2)
|
||||
if (this.current.findIndex(item => item.key == key) != -1) {
|
||||
return this.genKey();
|
||||
}
|
||||
return this.fieldKey
|
||||
return key
|
||||
},
|
||||
getInitField() {
|
||||
const data = {
|
||||
@@ -345,25 +359,27 @@ try {
|
||||
data.key = this.genKey()
|
||||
return data
|
||||
},
|
||||
handleParams(field) {
|
||||
this.current.forEach(item => {
|
||||
handleParams(current, field) {
|
||||
current.forEach(item => {
|
||||
if (!field.children) field.children = []
|
||||
if (item.parentKey == field.key && field.children.findIndex(i => i.key == item.key) == -1) {
|
||||
this.handleParams(item)
|
||||
field.children.push(item)
|
||||
const newField = {
|
||||
...item,
|
||||
children: [],
|
||||
}
|
||||
this.handleParams(current, newField)
|
||||
field.children.push({...newField})
|
||||
}
|
||||
})
|
||||
return field
|
||||
},
|
||||
decodeParams(data, attr) {
|
||||
if (!data) return;
|
||||
data.forEach(item => {
|
||||
const tmp = {
|
||||
...item
|
||||
}
|
||||
delete tmp.children
|
||||
attr.push(tmp)
|
||||
if (item.children) {
|
||||
attr.push({
|
||||
...item,
|
||||
children: [],
|
||||
})
|
||||
if (item.children && item.children.length> 0) {
|
||||
this.decodeParams(item.children, attr)
|
||||
}
|
||||
})
|
||||
@@ -375,6 +391,7 @@ try {
|
||||
sub = s.sub + 1
|
||||
}
|
||||
fieldKey = s.key
|
||||
// console.log('添加子字段', JSON.stringify(s), fieldKey)
|
||||
const field = {
|
||||
...this.getInitField(),
|
||||
parentKey: fieldKey,
|
||||
@@ -385,7 +402,7 @@ try {
|
||||
add(data, sub) {
|
||||
const field = this.getInitField();
|
||||
field.sub = sub;
|
||||
data.push(field);
|
||||
data.push({...field});
|
||||
},
|
||||
del(data, index) {
|
||||
if(data.length <= 1) return;
|
||||
@@ -398,7 +415,6 @@ try {
|
||||
];
|
||||
}
|
||||
this.current = this.params[this.structType];
|
||||
console.log(this.current)
|
||||
},
|
||||
getPadding(sub) {
|
||||
var padding = 0;
|
||||
|
||||
@@ -41,6 +41,7 @@ var app = new Vue({
|
||||
},
|
||||
methods: {
|
||||
changeAttr(val) {
|
||||
// console.log('更新之前', JSON.stringify(val))
|
||||
this.body = val;
|
||||
},
|
||||
changeType(val) {
|
||||
|
||||
@@ -58,6 +58,7 @@ var app = new Vue({
|
||||
},
|
||||
methods: {
|
||||
changeAttr(val) {
|
||||
// console.log('新的值', JSON.stringify(val))
|
||||
this.body = val
|
||||
},
|
||||
changeType(val) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div id='mainContent' class='main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->api->createLib;?></h2>
|
||||
<h2><?php echo $lang->api->editLib;?></h2>
|
||||
</div>
|
||||
<form class='load-indicator main-form form-ajax' id="apiForm" method='post' enctype='multipart/form-data'>
|
||||
<table class='table table-form'>
|
||||
|
||||
@@ -69,7 +69,8 @@ class docModel extends model
|
||||
if($type == 'all' or $type == 'includeDeleted')
|
||||
{
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)
|
||||
->beginIF($type == 'all')->where('deleted')->eq(0)->fi()
|
||||
->where('type')->ne('api')
|
||||
->beginIF($type == 'all')->andWhere('deleted')->eq(0)->fi()
|
||||
->orderBy('id_desc')
|
||||
->query();
|
||||
}
|
||||
@@ -77,7 +78,8 @@ class docModel extends model
|
||||
{
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF($type)->andWhere('type')->eq($type)->fi()
|
||||
->beginIF($type and $type != 'api')->andWhere('type')->eq($type)->fi()
|
||||
->andWhere('type')->ne('api')
|
||||
->orderBy('`order`, id desc')->query();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<?php echo $lib->type != 'book' ? $lang->doc->editLib : $lang->doc->editBook;?>
|
||||
</h2>
|
||||
</div>
|
||||
<form method='post' target="hiddenwin">
|
||||
<form method='post' class='load-indicator main-form form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<?php if(!empty($lib->product)):?>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user