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