Skip to content

Commit 340a7b9

Browse files
committed
feat: 支持公共素材文件
1 parent 1a20239 commit 340a7b9

File tree

10 files changed

+95
-19
lines changed

10 files changed

+95
-19
lines changed

public/asset/entry/basic.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/asset/entry/dataFileManager.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modstart/modstart/asset/entry/basic.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modstart/modstart/asset/entry/dataFileManager.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modstart/modstart/resources/asset/src/svue/components/DataSelector.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@
6969
<div class="action">
7070
<a v-if="permission['Delete']"
7171
href="javascript:;" :title="L('Delete')"
72-
:class="{active:listChecked.length>0}"
72+
:class="{active:activeFileOperate}"
7373
@click="doFileDelete">
7474
<i class="iconfont icon-trash"></i>
7575
{{ L('Delete') }}
7676
</a>
7777
<a v-if="permission['Add/Edit']"
7878
href="javascript:;" :title="L('Edit')"
79-
:class="{active:listChecked.length>0}"
79+
:class="{active:activeFileOperate}"
8080
@click="doFileEdit">
8181
<i class="iconfont icon-sign"></i>
8282
{{ L('Edit') }}
@@ -284,20 +284,22 @@ export default {
284284
watch: {
285285
categoryFilter(val) {
286286
this.$refs.$categoryTreeAll.filter(val)
287-
}
287+
},
288288
},
289289
computed: {
290290
apiUrl() {
291291
return this.url + '/' + this.category
292292
},
293293
listChecked() {
294-
return this.records.filter(o => o.checked
295-
)
294+
return this.records.filter(o => o.checked)
296295
},
297296
listCheckedIds() {
298297
return this.listChecked.map(o => o.id
299298
)
300-
}
299+
},
300+
activeFileOperate() {
301+
return this.listChecked.length > 0 && this.listChecked.filter(f => f.id > 0).length === this.listChecked.length
302+
},
301303
},
302304
mounted() {
303305
if ('flat' === this.mode) {
@@ -340,6 +342,9 @@ export default {
340342
Dialog.tipError(this.L('Select %d item(s) at most', this.max))
341343
},
342344
doFileEdit() {
345+
if (!this.activeFileOperate) {
346+
return
347+
}
343348
this.fileEdit.categoryId = this.currentCategoryId
344349
this.fileVisible = true
345350
},
@@ -362,13 +367,12 @@ export default {
362367
})
363368
},
364369
doFileDelete() {
365-
const ids = this.listCheckedIds;
366-
if (ids.length === 0) {
370+
if (!this.activeFileOperate || !this.listCheckedIds.length) {
367371
return;
368372
}
369373
Dialog.confirm(this.L('Confirm Delete ?'), () => {
370374
Dialog.loadingOn()
371-
this.$api.post(this.apiUrl, JsonUtil.extend({id: ids.join(',')}, {action: 'fileDelete'}), res => {
375+
this.$api.post(this.apiUrl, JsonUtil.extend({id: this.listCheckedIds.join(',')}, {action: 'fileDelete'}), res => {
372376
Dialog.loadingOff()
373377
Dialog.tipSuccess(this.L('Delete Success'))
374378
this.doList(1)

vendor/modstart/modstart/src/Core/Util/CRUDUtil.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212

1313
class CRUDUtil
1414
{
15-
public static function copyId()
15+
public static function copyId($defaultValue = null)
1616
{
1717
$input = InputPackage::buildFromInput();
18-
return $input->getInteger('_copyId');
18+
return $input->getInteger('_copyId', $defaultValue);
19+
}
20+
21+
public static function scope($defaultValue = null)
22+
{
23+
$input = InputPackage::buildFromInput();
24+
return $input->getTrimString('_scope', $defaultValue);
1925
}
2026

2127
public static function id()

vendor/modstart/modstart/src/Data/FileManager.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Illuminate\Support\Facades\DB;
88
use Illuminate\Support\Facades\Input;
9+
use Illuminate\Support\Str;
910
use ModStart\Core\Assets\AssetsUtil;
1011
use ModStart\Core\Dao\ModelUtil;
1112
use ModStart\Core\Exception\BizException;
@@ -18,6 +19,7 @@
1819
use ModStart\Core\Util\TreeUtil;
1920
use ModStart\Data\Event\DataUploadedEvent;
2021
use ModStart\Data\Event\DataUploadingEvent;
22+
use ModStart\Data\Support\FileManagerProvider;
2123
use Symfony\Component\HttpFoundation\File\UploadedFile;
2224

2325
class FileManager
@@ -296,7 +298,21 @@ private static function listExecute(InputPackage $input, $category, $uploadTable
296298
{
297299
$page = $input->getPage();
298300
$pageSize = $input->getPageSize(null, null, null, 24);
299-
$categoryId = $input->getInteger('categoryId');
301+
$categoryId = $input->getTrimString('categoryId');
302+
if (Str::startsWith($categoryId, ':')) {
303+
$pcs = explode(':', $categoryId);
304+
BizException::throwsIf('Unsupported category id', count($pcs) < 2);
305+
$provider = FileManagerProvider::getByName($pcs[1]);
306+
BizException::throwsIfEmpty('provider not found', $provider);
307+
$categoryId = (isset($pcs[2]) ? trim($pcs[2]) : null);
308+
return $provider->listExecute($category, $categoryId, [
309+
'uploadTable' => $uploadTable,
310+
'uploadCategoryTable' => $uploadCategoryTable,
311+
'userId' => $userId,
312+
'option' => $option,
313+
]);
314+
}
315+
$categoryId = intval($categoryId);
300316
$option = [];
301317
$option['order'] = ['id', 'desc'];
302318
$option['where'] = ['userId' => $userId, 'category' => $category];
@@ -405,6 +421,17 @@ private static function categoryExecute(InputPackage $input, $category, $uploadT
405421
'id' => -1,
406422
]
407423
];
424+
foreach (FileManagerProvider::listAll() as $provider) {
425+
$categoryTree = $provider->getCategoryTree($category, [
426+
'uploadTable' => $uploadTable,
427+
'uploadCategoryTable' => $uploadCategoryTable,
428+
'userId' => $userId,
429+
'option' => $option,
430+
]);
431+
if (!empty($categoryTree)) {
432+
$categoryTreeAll[] = $categoryTree;
433+
}
434+
}
408435
$categoryListParent = TreeUtil::treeToListWithIndent($categoryTreeParent, 'id', 'name');
409436
$categoryListAll = TreeUtil::treeToListWithIndent($categoryTreeAll, 'id', 'name');
410437
return Response::jsonSuccessData([
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
4+
namespace ModStart\Data\Support;
5+
6+
7+
abstract class AbstractFileManager
8+
{
9+
abstract public function name();
10+
11+
abstract public function title();
12+
13+
public function getCategoryTree($category, $param = [])
14+
{
15+
return null;
16+
}
17+
18+
public function listExecute($category, $categoryId, $param = [])
19+
{
20+
return null;
21+
}
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
4+
namespace ModStart\Data\Support;
5+
6+
7+
use ModStart\Core\Provider\ProviderTrait;
8+
9+
/**
10+
* @method static AbstractFileManager[] listAll();
11+
*/
12+
class FileManagerProvider
13+
{
14+
use ProviderTrait;
15+
16+
private static $list = [];
17+
}

vendor/modstart/modstart/src/Repository/Filter/HasScopeFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ trait HasScopeFilter
1818
/**
1919
* Set the scope filter.
2020
*
21-
* @param string $name
22-
* @param string $title
23-
* @param Closure $callback function(ScopeFilter $filter){ $filter->where('userId','1'); }
21+
* @param $name string
22+
* @param $title string
23+
* @param $callback \Closure function(ScopeFilter $filter){ $filter->where('userId','1'); }
2424
* @return $this
2525
*/
2626
public function scopeFilter($name, $title, \Closure $callback = null)

0 commit comments

Comments
 (0)