szh_zidingyibiaoti
张同海 2 years ago
parent a8f34350b2
commit 448ec0a1b1

@ -7,11 +7,7 @@
<a-form layout="inline" :form="form">
<a-row :gutter="48">
<a-col :md="5" :sm="24" :style="{ paddingRight: 0 }">
<a-form-item
label="API接口"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
>
<a-form-item label="API接口" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select
style="width: 100%"
show-search
@ -26,11 +22,7 @@
</a-form-item>
</a-col>
<a-col :md="5" :sm="24" :style="{ paddingRight: 0 }">
<a-form-item
label="租户"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
>
<a-form-item label="租户" :labelCol="labelCol" :wrapperCol="wrapperCol">
<!-- <a-input
placeholder="请输入租户名称"
v-decorator="[
@ -42,10 +34,7 @@
<a-select
show-search
placeholder="请选择租户"
v-decorator="[
'TenantName',
{ rules: [{ required: false, message: '请输入租户名称' }] },
]"
v-decorator="['TenantName', { rules: [{ required: false, message: '请输入租户名称' }] }]"
:default-active-first-option="false"
:show-arrow="false"
:filter-option="filterOption"
@ -58,11 +47,7 @@
</a-form-item>
</a-col>
<a-col :md="5" :sm="24" :style="{ paddingRight: 0 }">
<a-form-item
label="用户姓名"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
>
<a-form-item label="用户姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
<!-- <a-input
placeholder="请输入用户姓名"
v-decorator="[
@ -73,9 +58,7 @@
<auto-complete
:allowClear="true"
class="customer-input"
v-decorator="[
'UserName'
]"
v-decorator="['UserName']"
:data-source="userListArr"
:dropdown-match-select-width="false"
:dropdown-style="{ width: '200px' }"
@ -85,11 +68,7 @@
</a-form-item>
</a-col>
<a-col :md="4" :sm="24" :style="{ paddingRight: 0 }">
<a-form-item
label="是否禁用"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
>
<a-form-item label="是否禁用" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select
default-value="2"
style="width: 100%"
@ -139,14 +118,32 @@
</template>
<template #operate="{ row }">
<vxe-button type="text" class="disable-btn" @click="editColumns(row)"></vxe-button>
<a-popconfirm title="确认删除?" ok-text="" cancel-text="" @confirm="removeColumns(row)" @cancel="cancel">
<a-popconfirm
title="确认删除?"
ok-text="是"
cancel-text="否"
@confirm="removeColumns(row)"
@cancel="cancel"
>
<vxe-button type="text" class="disable-btn active">删除</vxe-button>
</a-popconfirm>
<a-popconfirm :title="`是否${row.isDisable? '启用' : '禁用'}`" ok-text="" cancel-text="" @confirm="setDisableFun(row)" @cancel="cancel">
<a-popconfirm
:title="`是否${row.isDisable ? '启用' : '禁用'}`"
ok-text="是"
cancel-text="否"
@confirm="setDisableFun(row)"
@cancel="cancel"
>
<span v-if="row.isDisable" class="disable-btn"></span>
<span v-else class="disable-btn active">禁用</span>
</a-popconfirm>
<a-popconfirm title="确认重置秘钥?" ok-text="" cancel-text="" @confirm="secretResetFun(row)" @cancel="cancel">
<a-popconfirm
title="确认重置秘钥?"
ok-text="是"
cancel-text="否"
@confirm="secretResetFun(row)"
@cancel="cancel"
>
<vxe-button class="disable-btn active" type="text">重置秘钥</vxe-button>
</a-popconfirm>
</template>
@ -158,7 +155,7 @@
<add-form ref="addForm" :formData="addFormData" :type="addFormType" :index="addFromIndex" @ok="handleOk" />
</div>
</template>
<script>
<script>
import { XCard } from '@/components'
import initData from './modules/initData'
import columnSetting from '@/components/tableColumnSetting'
@ -213,10 +210,10 @@ export default {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 50, 100, 200, 500],
pageSizes: [10, 20, 50, 100, 200, 500]
},
columns: JSON.parse(JSON.stringify(initData.columns)),
data: [],
data: []
},
addFormData: {},
addFormType: 'add',
@ -227,24 +224,23 @@ export default {
}
},
computed: {
userListArr() {
if (this.userList) {
const arr = []
this.userList.map((item, index) => {
if (!arr.includes(item.name)) {
arr.push(item.name)
}
})
return arr
} else {
return []
}
userListArr() {
if (this.userList) {
const arr = []
this.userList.map((item, index) => {
if (!arr.includes(item.name)) {
arr.push(item.name)
}
})
return arr
} else {
return []
}
},
}
},
created() {
this.getList()
this.apiInterface = this.$options.filters['dictData']('api_interface')
console.log('apiInterface', this.apiInterface)
SysTenantPage({ pageNo: 1, pageSize: 9999, name: '' }).then(res => {
this.TenantData = res.data.rows
})
@ -256,15 +252,14 @@ export default {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 50, 100, 200, 500],
pageSizes: [10, 20, 50, 100, 200, 500]
}
this.gridOptions.data = []
this.getList(queryParam)
},
handlePageChange({ currentPage, pageSize }) {
console.log(currentPage, pageSize)
const {
form: { validateFields },
form: { validateFields }
} = this
validateFields((err, values) => {
if (!err) {
@ -276,12 +271,10 @@ export default {
},
getList(queryParam = {}) {
const { currentPage, pageSize } = this.gridOptions.pagerConfig
console.log('查询内容', queryParam)
let IsDisable = null
if (Object.keys(queryParam).length > 0 && queryParam.IsDisable && queryParam.IsDisable !== 2) {
IsDisable = Boolean(queryParam.IsDisable)
}
console.log('IsDisable = ', IsDisable)
GetApiPage({
ApiCode: queryParam.ApiCode,
ApiName: queryParam.ApiName,
@ -291,17 +284,17 @@ export default {
pageNo: currentPage,
pageSize: pageSize
})
.then((res) => {
.then(res => {
const _data = res.data.rows.map((item, index) => {
item.row_id = (currentPage - 1) * pageSize + index
return item
})
this.$set(this.gridOptions.pagerConfig, 'total', res.data.totalCount)
this.$set(this.gridOptions.pagerConfig, 'total', res.data.totalRows)
this.$set(this.gridOptions, 'data', JSON.parse(JSON.stringify(_data)))
this.$set(this.gridOptions, 'loading', false)
this.$forceUpdate()
})
.catch((err) => {
.catch(err => {
console.log(err)
})
},
@ -310,11 +303,10 @@ export default {
this.addFormId = data.id
this.addFromIndex = data.row_id
GetApiDetail({
id: this.addFormId,
}).then((res) => {
id: this.addFormId
}).then(res => {
if (res.success) {
this.addFormData = res.data
console.log(this.addFormData)
this.$refs.addForm.add()
} else {
this.$message.error(res.message)
@ -324,11 +316,11 @@ export default {
removeColumns(data) {
DeleteApi({
id: data.id
}).then((res) => {
}).then(res => {
if (res.success) {
this.$message.success('删除成功')
const {
form: { validateFields },
form: { validateFields }
} = this
validateFields((err, values) => {
if (!err) {
@ -359,19 +351,17 @@ export default {
this.$forceUpdate()
},
confirmRemove(e) {
console.log(e)
const select = this.$refs.xGrid.getCheckboxRecords()
const pkIdArr = select.map((item, index) => {
return Number(item.id)
})
console.log(pkIdArr)
DeleteApi({
Ids: pkIdArr,
}).then((res) => {
Ids: pkIdArr
}).then(res => {
if (res.success) {
this.$message.success('删除成功')
const {
form: { validateFields },
form: { validateFields }
} = this
validateFields((err, values) => {
if (!err) {
@ -384,12 +374,11 @@ export default {
})
},
cancelRemove(e) {
console.log(e)
this.$message.error('取消操作')
},
handleOk(data) {
SaveApi(data)
.then((res) => {
.then(res => {
this.$refs.addForm.$data.confirmLoading = false
if (res.success) {
this.$message.success('保存成功')
@ -406,13 +395,13 @@ export default {
this.$message.error(res.message)
}
})
.catch((err) => {
.catch(err => {
console.log(err)
})
},
tableRefresh() {
const {
form: { validateFields },
form: { validateFields }
} = this
validateFields((err, values) => {
if (!err) {
@ -426,40 +415,39 @@ export default {
},
tableHeaderEdit() {},
setDisableFun(data) {
console.log('是否禁用: ', data.id, data.isDisable, data)
DisableApi({
id: data.id,
disable: !data.isDisable
})
.then((res) => {
if (res.success) {
const tip = !data.isDisable ? '已禁用' : '已启用'
this.$message.success(tip)
this.gridOptions.data[data.row_id].isDisable = !data.isDisable
this.$forceUpdate()
} else {
this.$message.error(res.message)
}
})
.catch((err) => {
console.log(err)
})
.then(res => {
if (res.success) {
const tip = !data.isDisable ? '已禁用' : '已启用'
this.$message.success(tip)
this.gridOptions.data[data.row_id].isDisable = !data.isDisable
this.$forceUpdate()
} else {
this.$message.error(res.message)
}
})
.catch(err => {
console.log(err)
})
},
secretResetFun (data) {
secretResetFun(data) {
ResetApi({
id: data.id
})
.then((res) => {
if (res.success) {
this.$message.success('秘钥已重置')
this.$forceUpdate()
} else {
this.$message.error(res.message)
}
})
.catch((err) => {
console.log(err)
})
.then(res => {
if (res.success) {
this.$message.success('秘钥已重置')
this.$forceUpdate()
} else {
this.$message.error(res.message)
}
})
.catch(err => {
console.log(err)
})
},
cancel() {},
filterOption(input, option) {
@ -494,22 +482,22 @@ export default {
// },
userChange(value) {
this.getUserList(value)
},
}
}
}
</script>
<style lang="less" scoped>
.disable-btn{
.disable-btn {
font-size: 12px;
color: @primary-color;
margin-left: 10px;
cursor: pointer;
&.active{
&.active {
color: #999;
}
}
.disable-radio{
display:flex;
.disable-radio {
display: flex;
width: 100%;
margin-top: 7px;
}

Loading…
Cancel
Save