mirror of https://github.com/veops/cmdb.git
fix attributes paginate
This commit is contained in:
parent
9105f92c82
commit
0a36330852
|
@ -14,6 +14,7 @@ from api.lib.database import CRUDModel
|
|||
|
||||
|
||||
class UserQuery(BaseQuery):
|
||||
|
||||
def authenticate(self, login, password):
|
||||
user = self.filter(db.or_(User.username == login,
|
||||
User.email == login)).first()
|
||||
|
@ -28,8 +29,8 @@ class UserQuery(BaseQuery):
|
|||
user = self.filter(User.key == key).filter(User.block == 0).first()
|
||||
if not user:
|
||||
return None, False
|
||||
if user and hashlib.sha1('%s%s%s' % (
|
||||
path, user.secret, "".join(args))).hexdigest() == secret:
|
||||
if user and hashlib.sha1('{0}{1}{2}'.format(
|
||||
path, user.secret, "".join(args)).encode("utf-8")).hexdigest() == secret:
|
||||
authenticated = True
|
||||
else:
|
||||
authenticated = False
|
||||
|
@ -79,9 +80,6 @@ class User(CRUDModel):
|
|||
wx_id = db.Column(db.String(32))
|
||||
avatar = db.Column(db.String(128))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(User, self).__init__(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return self.username
|
||||
|
||||
|
@ -99,7 +97,7 @@ class User(CRUDModel):
|
|||
return self._password
|
||||
|
||||
def _set_password(self, password):
|
||||
self._password = hashlib.md5(password).hexdigest()
|
||||
self._password = hashlib.md5(password.encode('utf-8')).hexdigest()
|
||||
|
||||
password = db.synonym("_password",
|
||||
descriptor=property(_get_password,
|
||||
|
@ -176,7 +174,7 @@ class RoleCache(object):
|
|||
@classmethod
|
||||
def get(cls, rid):
|
||||
role = None
|
||||
if isinstance(rid, (int, long)):
|
||||
if isinstance(rid, six.integer_types):
|
||||
role = cache.get("Role::rid::%s" % rid)
|
||||
if not role:
|
||||
role = db.session.query(Role).filter(Role.rid == rid).first()
|
||||
|
|
|
@ -135,7 +135,7 @@ export default {
|
|||
filterDropdown: 'filterDropdown',
|
||||
filterIcon: 'filterIcon'
|
||||
},
|
||||
onFilter: (value, record) => record.alias.toLowerCase().includes(value.toLowerCase()),
|
||||
onFilter: (value, record) => record.alias && record.alias.toLowerCase().includes(value.toLowerCase()),
|
||||
onFilterDropdownVisibleChange: (visible) => {
|
||||
if (visible) {
|
||||
setTimeout(() => {
|
||||
|
@ -154,7 +154,7 @@ export default {
|
|||
filterDropdown: 'filterDropdown',
|
||||
filterIcon: 'filterIcon'
|
||||
},
|
||||
onFilter: (value, record) => record.name.toLowerCase().includes(value.toLowerCase()),
|
||||
onFilter: (value, record) => record.name && record.name.toLowerCase().includes(value.toLowerCase()),
|
||||
onFilterDropdownVisibleChange: (visible) => {
|
||||
if (visible) {
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
:showPagination="showPagination"
|
||||
ref="table"
|
||||
size="middle"
|
||||
|
||||
>
|
||||
<div slot="filterDropdown" slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }" class="custom-filter-dropdown">
|
||||
<a-input
|
||||
|
@ -69,7 +70,15 @@
|
|||
<template>
|
||||
<a @click="handleEdit(record)">编辑</a>
|
||||
<a-divider type="vertical"/>
|
||||
<a @click="handleDelete(record)">删除</a>
|
||||
|
||||
<a-popconfirm
|
||||
title="确认删除?"
|
||||
@confirm="handleDelete(record)"
|
||||
okText="是"
|
||||
cancelText="否"
|
||||
>
|
||||
<a>删除</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</span>
|
||||
|
||||
|
@ -84,7 +93,7 @@
|
|||
placement="right"
|
||||
width="30%"
|
||||
>
|
||||
<a-form :form="form" :layout="formLayout" @submit="handleBatchUpdateSubmit">
|
||||
<a-form :form="form" :layout="formLayout" @submit="handleBatchUpdateSubmit" style="margin-bottom: 5rem">
|
||||
|
||||
<a-transfer
|
||||
:dataSource="transferData"
|
||||
|
@ -147,7 +156,7 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
form: this.$form.createForm(this),
|
||||
scroll: { x: 1300, y: 600 },
|
||||
scroll: { x: 1030, y: 600 },
|
||||
singleAttrAction: {
|
||||
btnName: '新增属性',
|
||||
drawerTitle: '新增属性',
|
||||
|
@ -335,7 +344,7 @@ export default {
|
|||
|
||||
beforeCreate () {
|
||||
},
|
||||
|
||||
inject: ['reload'],
|
||||
computed: {
|
||||
|
||||
removeTransferKeys () {
|
||||
|
@ -445,6 +454,7 @@ export default {
|
|||
},
|
||||
handleOk () {
|
||||
this.$refs.table.refresh()
|
||||
this.reload()
|
||||
},
|
||||
handleCreate () {
|
||||
this.$refs.attributeForm.handleCreate()
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
<a-icon type="setting" />
|
||||
</router-link>
|
||||
<a-icon type="edit" @click="handleEdit(item)"/>
|
||||
<a-popconfirm title="确认删除" @confirm="handleDelete(item)" okText="是" cancelText="否">
|
||||
<a-icon type="delete"/>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
<a-card-meta>
|
||||
<div slot="title" style="margin-bottom: 3px">{{ item.alias || item.name }}</div>
|
||||
|
@ -89,9 +92,13 @@
|
|||
>
|
||||
|
||||
<a-select
|
||||
showSearch
|
||||
optionFilterProp="children"
|
||||
name="unique_key"
|
||||
style="width: 200px"
|
||||
:filterOption="filterOption"
|
||||
v-decorator="['unique_key', {rules: [{required: true}], } ]"
|
||||
|
||||
>
|
||||
<a-select-option :key="item.id" :value="item.id" v-for="item in allAttributes">{{ item.alias || item.name }}</a-select-option>
|
||||
</a-select>
|
||||
|
@ -130,7 +137,7 @@
|
|||
|
||||
<script>
|
||||
|
||||
import { getCITypes, createCIType, updateCIType } from '@/api/cmdb/CIType'
|
||||
import { getCITypes, createCIType, updateCIType, deleteCIType } from '@/api/cmdb/CIType'
|
||||
import { searchAttributes } from '@/api/cmdb/CITypeAttr'
|
||||
|
||||
export default {
|
||||
|
@ -177,6 +184,12 @@ export default {
|
|||
this.getAttributes()
|
||||
},
|
||||
methods: {
|
||||
|
||||
filterOption (input, option) {
|
||||
return (
|
||||
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
)
|
||||
},
|
||||
getCITypes () {
|
||||
getCITypes().then(res => {
|
||||
this.CITypes = res.ci_types
|
||||
|
@ -185,7 +198,7 @@ export default {
|
|||
},
|
||||
|
||||
getAttributes () {
|
||||
searchAttributes().then(res => {
|
||||
searchAttributes({ page_size: 10000 }).then(res => {
|
||||
this.allAttributes = res.attributes
|
||||
})
|
||||
},
|
||||
|
@ -201,7 +214,6 @@ export default {
|
|||
this.drawerTitle = '编辑模型'
|
||||
this.drawerVisible = true
|
||||
|
||||
console.log(record)
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue({
|
||||
id: record.id,
|
||||
|
@ -213,6 +225,15 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
handleDelete (record) {
|
||||
deleteCIType(record.id)
|
||||
.then(res => {
|
||||
this.$message.success(`删除成功`)
|
||||
this.getCITypes()
|
||||
})
|
||||
.catch(err => this.requestFailed(err))
|
||||
},
|
||||
|
||||
handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
this.form.validateFields((err, values) => {
|
||||
|
|
Loading…
Reference in New Issue