管理后台存储选择页面展示

v1.0.0
youngS 4 years ago
parent ef5d434c40
commit e25046df93
  1. 2
      fir_admin/src/views/login/index.vue
  2. 4
      fir_admin/src/views/storage/Detail.vue
  3. 15
      fir_admin/src/views/storage/list.vue
  4. 125
      fir_admin/src/views/userinfos/UserDetail.vue
  5. 2
      fir_ser/admin/views/storage.py
  6. 13
      fir_ser/api/utils/baseutils.py
  7. 8
      fir_ser/api/utils/serializer.py

@ -113,7 +113,7 @@ export default {
this.$router.push({ path: this.redirect || '/' })
this.loading = false
}).catch((err) => {
this.loading = false;
this.loading = false
console.log(err)
})
} else {

@ -107,8 +107,9 @@
</el-col>
</el-row>
</el-form>
<el-link v-if="postForm.id === postForm.used_id" type="danger" :underline="false">存储使用中无法修改存储相关配置请悉知</el-link>
<el-col :span="9" style="float: right">
<el-button v-if="!is_edit" type="primary" @click="is_edit=true">修改</el-button>
<el-button v-if="!is_edit" type="primary" :disabled="postForm.id === postForm.used_id" @click="is_edit=true">修改</el-button>
<div v-else>
<el-button type="primary" @click="is_edit=false">取消</el-button>
<el-button type="primary" @click="updateData">保存修改</el-button>
@ -135,6 +136,7 @@ const defaultForm = {
download_auth_type: undefined,
cnd_auth_key: undefined,
updated_time: undefined,
used_id: undefined,
download_auth_type_choices: []
}

@ -62,12 +62,10 @@
<el-tag :type="scope.row.storage_type | certStatusFilter">{{ scope.row| certLableFilter }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" prop="created_time" label="创建时间" width="120">
<el-table-column class-name="status-col" label="存储状态" width="95" align="center">
<template slot-scope="scope">
<i class="el-icon-time" />
<el-tooltip :content="scope.row.created_time">
<span>{{ scope.row.created_time|formatTime }}</span>
</el-tooltip>
<el-tag v-if="scope.row.id === scope.row.used_id" type="success">已启用</el-tag>
<el-tag v-else type="info">未启用</el-tag>
</template>
</el-table-column>
<el-table-column align="center" prop="created_time" label="更新时间" width="120">
@ -169,7 +167,8 @@ export default {
access_key: undefined,
storage_type: undefined,
domain_name: undefined,
user_id: undefined
user_id: undefined,
used_id: undefined
},
sortOptions,
storage_choices: []
@ -177,6 +176,10 @@ export default {
},
created() {
this.fetchData()
},mounted() {
if (this.$route.query.user_id) {
this.listQuery.user_id = this.$route.query.user_id
}
},
methods: {
handleFilter() {

@ -50,23 +50,7 @@
</el-col>
</el-row>
</el-form-item>
<el-form-item label="实名认证">
<el-row :gutter="12">
<el-col :span="16">
<el-select v-model="postForm.certification" class="filter-item" placeholder="Please select" :disabled="postForm.certification === -1">
<el-option v-for="item in postForm.certification_status_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<router-link v-if="postForm.certification_id" :to="{name: 'user_authentication_info_edit',params:{id:postForm.certification_id.id}}">
<el-button type="primary">
审核认证信息
</el-button>
</router-link>
</el-col>
<el-col v-if="postForm.certification === -1" span="16">
<el-link :underline="false"> 用户需要先提交认证信息才可以进行认证修改</el-link>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="手机" prop="mobile">
<el-row :gutter="12">
<el-col :span="16">
@ -126,12 +110,12 @@
</el-col>
</el-row>
</el-form-item>
<el-form-item label="私有存储">
<el-form-item label="超级签名">
<el-row :gutter="12">
<el-col :span="16">
<el-tooltip :content="postForm.storage_active|statusFilter" placement="top">
<el-tooltip :content="postForm.supersign_active|statusFilter" placement="top">
<el-switch
v-model="postForm.storage_active"
v-model="postForm.supersign_active"
active-color="#13ce66"
inactive-color="#ff4949"
:active-value="true"
@ -141,49 +125,60 @@
</el-col>
</el-row>
</el-form-item>
<!-- <el-form-item v-if="postForm.storage_active===true" label="私有存储">-->
<!-- <el-row :gutter="12">-->
<!-- <el-col :span="16">-->
<!-- <el-select v-model="postForm.use_storage_id" filterable :placeholder="selectlabel" @change="select_storage">-->
<!-- <el-option-group-->
<!-- v-for="storage_group in fstorage_lists"-->
<!-- :key="storage_group.group_name"-->
<!-- :label="storage_group.group_name">-->
<!-- <el-option-->
<!-- v-for="storage in storage_group.storages"-->
<!-- :key="storage.id"-->
<!-- :label="storage.name"-->
<!-- :value="storage.id">-->
<!-- </el-option>-->
<!-- </el-option-group>-->
<!-- </el-select>-->
<!-- <el-button v-if="use_storage_id!==org_storage_id" style="margin-left: 10px" round type="info"-->
<!-- icon="el-icon-thumb"-->
<!-- @click="change_storage_info">-->
<!-- 迁移数据并保存-->
<!-- </el-button>-->
<!-- <el-select v-model="postForm.storage" class="filter-item" placeholder="Please select">-->
<!-- <el-option v-for="item in postForm.storage_choices" :key="item.id" :label="item.name" :value="item.id" />-->
<!-- </el-select>-->
<!-- </el-col>-->
<!-- </el-row>-->
<!-- </el-form-item>-->
<el-form-item label="超级签名">
<el-form-item label="存储权限">
<el-row :gutter="12">
<el-col :span="16">
<el-tooltip :content="postForm.supersign_active|statusFilter" placement="top">
<el-col :span="3">
<el-tooltip :content="postForm.storage_active|statusFilter" placement="top">
<el-switch
v-model="postForm.supersign_active"
v-model="postForm.storage_active"
active-color="#13ce66"
inactive-color="#ff4949"
:active-value="true"
:inactive-value="false"
/>
</el-tooltip>
</el-col>
<el-col :span="6">
<el-select v-model="postForm.storage" filterable>
<el-option-group
v-for="storage_group in storage_selection"
:key="storage_group.id"
:label="storage_group.name"
>
<el-option
v-for="storage in storage_group.storage_info"
:key="storage.id"
:label="storage.name"
:value="storage.id"
/>
</el-option-group>
</el-select>
</el-col>
<el-col :span="6">
<router-link :to="{name: 'storage_info_list',query:{user_id:postForm.id}}">
<el-button type="primary" style="margin-left: 20px">
查看私有存储信息
</el-button>
</router-link>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="实名认证">
<el-row :gutter="12">
<el-col :span="16">
<el-select v-model="postForm.certification" class="filter-item" placeholder="Please select" :disabled="postForm.certification === -1">
<el-option v-for="item in postForm.certification_status_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<router-link v-if="postForm.certification_id" :to="{name: 'user_authentication_info_edit',params:{id:postForm.certification_id.id}}">
<el-button type="primary">
审核认证信息
</el-button>
</router-link>
</el-col>
<el-col v-if="postForm.certification === -1" :span="16">
<el-link :underline="false" type="danger"> 用户需要先提交认证信息才可以进行认证修改</el-link>
</el-col>
</el-row>
</el-form-item>
@ -234,6 +229,7 @@
<script>
import { validURL } from '@/utils/validate'
import { getUserInfos, updateUserInfo } from '@/api/user'
import { getStorageInfo } from '@/api/storage'
import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown'
const defaultForm = {
@ -250,14 +246,15 @@ const defaultForm = {
domain_name: undefined,
download_times: undefined,
is_active: undefined,
head_img: '',
head_img: undefined,
memo: undefined,
date_joined: undefined,
storage_active: undefined,
storage: undefined,
supersign_active: undefined,
role_choices: [],
gender_choices: [],
storage_choices: [],
storage_choices: []
}
export default {
@ -322,7 +319,8 @@ export default {
source_uri: [{ validator: validateSourceUri, trigger: 'blur' }]
},
is_edit: false,
certification_status_choices: []
certification_status_choices: [],
storage_selection: []
}
},
computed: {
@ -334,11 +332,24 @@ export default {
}
},
methods: {
fetchStorageData(user_id) {
getStorageInfo({ user_id: user_id }).then(response => {
if (response.storage_selection) {
this.storage_selection = response.storage_selection
}
}).catch(err => {
console.log(err)
})
},
fetchData(id) {
getUserInfos({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
if (!this.postForm.storage) {
this.postForm.storage = -1
}
this.certification_status_choices = this.postForm.certification_status_choices
this.fetchStorageData(this.postForm.id)
}
}).catch(err => {
console.log(err)

@ -21,6 +21,7 @@ from api.utils.storage.caches import login_auth_failed
import logging
from api.utils.throttle import VisitRegister1Throttle, VisitRegister2Throttle
from rest_framework.pagination import PageNumberPagination
from api.utils.baseutils import format_storage_selection
logger = logging.getLogger(__name__)
@ -46,6 +47,7 @@ class StorageInfoView(APIView):
view=self)
serializer = AdminStorageSerializer(page_serializer, many=True)
res.data = serializer.data
res.storage_selection = format_storage_selection(serializer.data,serializer.data[0].get('storage_choices'))
res.total = obj_list.count()
return Response(res.dict)

@ -88,3 +88,16 @@ def get_dict_from_filter_fields(filter_fields, data):
if f_value:
filter_data[filed] = f_value
return filter_data
def format_storage_selection(storage_info_list, storage_choice_list):
storage_info_list.append({'id': -1, 'storage_type': 3, 'name': '默认存储'})
for storage_choice in storage_choice_list:
storage_choice['storage_info'] = []
for storage_info in storage_info_list:
if storage_info.get('storage_type') == storage_choice.get('id',):
storage_choice['storage_info'].append({'name': storage_info.get('name', ''), 'id': storage_info.get('id', '')})
for storage_choice in storage_choice_list:
if not storage_choice['storage_info']:
storage_choice_list.remove(storage_choice)
return storage_choice_list

@ -7,7 +7,6 @@ from api.utils.storage.storage import Storage
from api.utils.utils import get_developer_udided, get_choices_dict, get_choices_name_from_key
from api.utils.storage.caches import get_user_free_download_times, get_user_cert_auth_status
import os, json, logging
logger = logging.getLogger(__file__)
token_obj = DownloadToken()
@ -365,7 +364,12 @@ class AdminStorageSerializer(StorageSerializer):
storage_choices = serializers.SerializerMethodField()
def get_storage_choices(self, obj):
return get_choices_dict(obj.storage_choices)
return get_choices_dict(obj.storage_choices[1:])
used_id = serializers.SerializerMethodField()
def get_used_id(self, obj):
return obj.user_id_id
class DeveloperSerializer(serializers.ModelSerializer):

Loading…
Cancel
Save