mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 05:12:49 +00:00
perf: 新增文件打包下载权限设置
This commit is contained in:
parent
e5c3cf6adb
commit
9c4ff466a4
@ -1014,6 +1014,28 @@ class FileController extends AbstractController
|
||||
}
|
||||
|
||||
$user = User::auth();
|
||||
if ($user->isTemp()) {
|
||||
return Base::retError('无法打包下载');
|
||||
}
|
||||
$setting = Base::setting('fileSetting');
|
||||
switch ($setting['permission_pack_type']) {
|
||||
case 'admin':
|
||||
if (!$user->isAdmin()) {
|
||||
return Base::retError('此功能仅管理员可用');
|
||||
}
|
||||
break;
|
||||
case 'appointAllow':
|
||||
if (!in_array($user->userid, $setting['permission_pack_userids'])) {
|
||||
return Base::retError('此功能仅指定用户可用');
|
||||
}
|
||||
break;
|
||||
case 'appointProhibit':
|
||||
if (in_array($user->userid, $setting['permission_pack_userids'])) {
|
||||
return Base::retError('此功能已禁止使用');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$ids = Request::input('ids');
|
||||
$fileName = Request::input('name');
|
||||
$fileName = preg_replace("/[\/\\\:\*\?\"\<\>\|]/", "", $fileName);
|
||||
|
||||
@ -605,6 +605,46 @@ class SystemController extends AbstractController
|
||||
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/system/setting/file 07. 文件设置(限管理员)
|
||||
*
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup system
|
||||
* @apiName setting__file
|
||||
*
|
||||
* @apiParam {String} type
|
||||
* - get: 获取(默认)
|
||||
* - save: 保存设置(参数:['permission_pack_type', 'permission_pack_userids'])
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function setting__file()
|
||||
{
|
||||
User::auth('admin');
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$all = Base::newTrim(Request::input());
|
||||
foreach ($all as $key => $value) {
|
||||
if (!in_array($key, [
|
||||
'permission_pack_type',
|
||||
'permission_pack_userids'
|
||||
])) {
|
||||
unset($all[$key]);
|
||||
}
|
||||
}
|
||||
$setting = Base::setting('fileSetting', Base::newTrim($all));
|
||||
} else {
|
||||
$setting = Base::setting('fileSetting');
|
||||
}
|
||||
//
|
||||
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/system/demo 08. 获取演示帐号
|
||||
*
|
||||
|
||||
@ -43,8 +43,14 @@ class Setting extends AbstractModel
|
||||
return $value;
|
||||
}
|
||||
$value = Base::json2array($value);
|
||||
if ($this->name === 'system') {
|
||||
$value['system_alias'] = $value['system_alias'] ?: env('APP_NAME');
|
||||
switch ($this->name) {
|
||||
case 'system':
|
||||
$value['system_alias'] = $value['system_alias'] ?: env('APP_NAME');
|
||||
break;
|
||||
case 'fileSetting':
|
||||
$value['permission_pack_type'] = $value['permission_pack_type'] ?: 'all';
|
||||
$value['permission_pack_userids'] = is_array($value['permission_pack_userids']) ? $value['permission_pack_userids'] : [];
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div class="setting-component-item">
|
||||
<Form
|
||||
ref="formData"
|
||||
:model="formData"
|
||||
:rules="ruleData"
|
||||
v-bind="formOptions"
|
||||
@submit.native.prevent>
|
||||
<div class="block-setting-box">
|
||||
<h3>{{$L('权限设置')}}</h3>
|
||||
<div class="form-box">
|
||||
<FormItem :label="$L('打包权限')" prop="permission_pack_type">
|
||||
<RadioGroup v-model="formData.permission_pack_type">
|
||||
<Radio label="all">{{ $L('允许所有人') }}</Radio>
|
||||
<Radio label="admin">{{ $L('仅限管理员') }}</Radio>
|
||||
<Radio label="appointAllow">{{ $L('指定允许') }}</Radio>
|
||||
<Radio label="appointProhibit">{{ $L('指定禁止') }}</Radio>
|
||||
</RadioGroup>
|
||||
<div v-if="formData.permission_pack_type === 'all'" class="form-tip">{{$L('允许系统所有人员使用文件打包下载功能')}}</div>
|
||||
<div v-else-if="formData.permission_pack_type === 'admin'" class="form-tip">{{$L('仅限管理员使用文件打包下载功能')}}</div>
|
||||
<div v-else-if="formData.permission_pack_type === 'appointAllow'" class="form-tip">{{$L('指定允许的人员使用文件打包下载功能')}}</div>
|
||||
<div v-else-if="formData.permission_pack_type === 'appointProhibit'" class="form-tip">{{$L('指定禁止的人员使用文件打包下载功能')}}</div>
|
||||
</FormItem>
|
||||
<FormItem v-if="['appointAllow', 'appointProhibit'].includes(formData.permission_pack_type)" :label="$L('指定人员')" prop="permission_pack_userid">
|
||||
<UserSelect v-model="formData.permission_pack_userid" :multiple-max="200" avatar-name show-disable :title="$L('请选择指定人员')"/>
|
||||
<div class="form-tip">{{$L('指定人员最多可选择200人')}}</div>
|
||||
</FormItem>
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
<div class="setting-footer">
|
||||
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{ $L('提交') }}</Button>
|
||||
<Button :loading="loadIng > 0" @click="resetForm" style="margin-left: 8px">{{ $L('重置') }}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapState} from "vuex";
|
||||
import UserSelect from "../../../../components/UserSelect.vue";
|
||||
|
||||
export default {
|
||||
name: "SystemFileSetting",
|
||||
components: {UserSelect},
|
||||
data() {
|
||||
return {
|
||||
loadIng: 0,
|
||||
formData: {
|
||||
|
||||
},
|
||||
ruleData: {},
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.systemSetting();
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['formOptions']),
|
||||
},
|
||||
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.$refs.formData.validate((valid) => {
|
||||
if (valid) {
|
||||
this.systemSetting(true);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
resetForm() {
|
||||
this.formData = $A.cloneJSON(this.formDatum_bak);
|
||||
},
|
||||
|
||||
systemSetting(save) {
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'system/setting/file?type=' + (save ? 'save' : 'all'),
|
||||
data: this.formData,
|
||||
}).then(({data}) => {
|
||||
if (save) {
|
||||
$A.messageSuccess('修改成功');
|
||||
}
|
||||
this.formData = data;
|
||||
this.formDatum_bak = $A.cloneJSON(this.formData);
|
||||
}).catch(({msg}) => {
|
||||
if (save) {
|
||||
$A.modalError(msg);
|
||||
}
|
||||
}).finally(_ => {
|
||||
this.loadIng--;
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -41,6 +41,7 @@
|
||||
<li>{{$L('禁止发起会话。')}}</li>
|
||||
<li>{{$L('禁止创建群聊。')}}</li>
|
||||
<li>{{$L('禁止拨打电话。')}}</li>
|
||||
<li>{{$L('禁止打包下载文件。')}}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</FormItem>
|
||||
|
||||
@ -10,6 +10,9 @@
|
||||
<TabPane :label="$L('项目模板')" name="columnTemplate">
|
||||
<SystemColumnTemplate/>
|
||||
</TabPane>
|
||||
<TabPane :label="$L('文件设置')" name="fileSetting">
|
||||
<SystemFileSetting/>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
</template>
|
||||
@ -18,9 +21,10 @@
|
||||
import SystemSetting from "./components/SystemSetting";
|
||||
import SystemTaskPriority from "./components/SystemTaskPriority";
|
||||
import SystemColumnTemplate from "./components/SystemColumnTemplate";
|
||||
import SystemFileSetting from "./components/SystemFileSetting";
|
||||
|
||||
export default {
|
||||
components: {SystemColumnTemplate, SystemTaskPriority, SystemSetting},
|
||||
components: {SystemColumnTemplate, SystemTaskPriority, SystemSetting, SystemFileSetting},
|
||||
data() {
|
||||
return {
|
||||
tabAction: 'setting',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user