【更新】更新前端机构、职位、角色、用户 选择器的内部逻辑

pull/109/MERGE
小诺 2 years ago committed by 俞宝山
parent ac84f7376a
commit 6156b0755e

@ -27,12 +27,12 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item name="searchKey"> <a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入机构名"></a-input> <a-input v-model:value="searchFormState.searchKey" placeholder="请输入机构名" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-button type="primary" class="primarySele" @click="loadData(searchFormState)"> </a-button> <a-button type="primary" class="primarySele" @click="loadData()"> </a-button>
<a-button class="snowy-buttom-left" @click="() => searchFormRef.resetFields()"> 重置 </a-button> <a-button class="snowy-buttom-left" @click="() => reset()"> 重置 </a-button>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
@ -134,7 +134,7 @@
// ref // ref
const selectedTable = ref() const selectedTable = ref()
const tableRecordNum = ref() const tableRecordNum = ref()
let searchFormState = reactive({}) const searchFormState = ref({})
const searchFormRef = ref() const searchFormRef = ref()
const cardLoading = ref(true) const cardLoading = ref(true)
// treeNode title,key,children // treeNode title,key,children
@ -184,14 +184,11 @@
} }
// //
const loadData = () => { const loadData = () => {
orgSelectorPlusApi.orgSelector(props.pageUrl, searchFormState).then((res) => { orgSelectorPlusApi.orgSelector(props.pageUrl, searchFormState.value).then((res) => {
// //
tableRecordNum.value = res.length tableRecordNum.value = res.length
tableData.value = res tableData.value = res
// loadCheckedKey()
if (JSON.stringify(searchFormState) === '{}') {
loadCheckedKey()
}
}) })
} }
// //
@ -254,9 +251,9 @@
// //
const treeSelect = (selectedKeys) => { const treeSelect = (selectedKeys) => {
if (selectedKeys.length > 0) { if (selectedKeys.length > 0) {
searchFormState.orgId = selectedKeys.toString() searchFormState.value.orgId = selectedKeys.toString()
} else { } else {
delete searchFormState.orgId delete searchFormState.value.orgId
} }
loadData() loadData()
} }
@ -279,8 +276,15 @@
} }
handleClose() handleClose()
} }
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => { const handleClose = () => {
searchFormState = reactive({}) searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
visible = false visible = false
} }

@ -27,12 +27,12 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item name="searchKey"> <a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入职位名"></a-input> <a-input v-model:value="searchFormState.searchKey" placeholder="请输入职位名" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-button type="primary" class="primarySele" @click="loadData(searchFormState)"> </a-button> <a-button type="primary" class="primarySele" @click="loadData()"> </a-button>
<a-button class="snowy-buttom-left" @click="() => searchFormRef.resetFields()"> 重置 </a-button> <a-button class="snowy-buttom-left" @click="() => reset()"> 重置 </a-button>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
@ -134,7 +134,7 @@
// ref // ref
const selectedTable = ref() const selectedTable = ref()
const tableRecordNum = ref() const tableRecordNum = ref()
let searchFormState = reactive({}) const searchFormState = ref({})
const searchFormRef = ref() const searchFormRef = ref()
const cardLoading = ref(true) const cardLoading = ref(true)
// treeNode title,key,children // treeNode title,key,children
@ -184,14 +184,11 @@
} }
// //
const loadData = () => { const loadData = () => {
posSelectorPlusApi.posSelector(props.pageUrl, searchFormState).then((res) => { posSelectorPlusApi.posSelector(props.pageUrl, searchFormState.value).then((res) => {
// //
tableRecordNum.value = res.length tableRecordNum.value = res.length
tableData.value = res tableData.value = res
// loadCheckedKey()
if (JSON.stringify(searchFormState) === '{}') {
loadCheckedKey()
}
}) })
} }
// //
@ -254,9 +251,9 @@
// //
const treeSelect = (selectedKeys) => { const treeSelect = (selectedKeys) => {
if (selectedKeys.length > 0) { if (selectedKeys.length > 0) {
searchFormState.orgId = selectedKeys.toString() searchFormState.value.orgId = selectedKeys.toString()
} else { } else {
delete searchFormState.orgId delete searchFormState.value.orgId
} }
loadData() loadData()
} }
@ -279,8 +276,15 @@
} }
handleClose() handleClose()
} }
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => { const handleClose = () => {
searchFormState = reactive({}) searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
visible = false visible = false
} }

@ -27,12 +27,12 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item name="searchKey"> <a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入角色名"></a-input> <a-input v-model:value="searchFormState.searchKey" placeholder="请输入角色名" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-button type="primary" class="primarySele" @click="loadData(searchFormState)"> </a-button> <a-button type="primary" class="primarySele" @click="loadData()"> </a-button>
<a-button class="snowy-buttom-left" @click="() => searchFormRef.resetFields()"> 重置 </a-button> <a-button class="snowy-buttom-left" @click="() => reset()"> 重置 </a-button>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
@ -134,7 +134,7 @@
// ref // ref
const selectedTable = ref() const selectedTable = ref()
const tableRecordNum = ref() const tableRecordNum = ref()
let searchFormState = reactive({}) const searchFormState = ref({})
const searchFormRef = ref() const searchFormRef = ref()
const cardLoading = ref(true) const cardLoading = ref(true)
// treeNode title,key,children // treeNode title,key,children
@ -229,16 +229,13 @@
const loadData = () => { const loadData = () => {
// //
if (!roleGlobal) { if (!roleGlobal) {
searchFormState.category = 'ORG' searchFormState.value.category = 'ORG'
} }
roleSelectorPlusApi.roleSelector(props.pageUrl, searchFormState).then((res) => { roleSelectorPlusApi.roleSelector(props.pageUrl, searchFormState.value).then((res) => {
// //
tableRecordNum.value = res.length tableRecordNum.value = res.length
tableData.value = res tableData.value = res
// loadCheckedKey()
if (JSON.stringify(searchFormState) === '{}') {
loadCheckedKey()
}
}) })
} }
// //
@ -302,15 +299,15 @@
const treeSelect = (selectedKeys) => { const treeSelect = (selectedKeys) => {
if (selectedKeys.length > 0) { if (selectedKeys.length > 0) {
if (selectedKeys[0] === 'GLOBAL') { if (selectedKeys[0] === 'GLOBAL') {
searchFormState.category = selectedKeys[0] searchFormState.value.category = selectedKeys[0]
delete searchFormState.orgId delete searchFormState.value.orgId
} else { } else {
searchFormState.orgId = selectedKeys.toString() searchFormState.value.orgId = selectedKeys.toString()
delete searchFormState.category delete searchFormState.value.category
} }
} else { } else {
delete searchFormState.category delete searchFormState.value.category
delete searchFormState.orgId delete searchFormState.value.orgId
} }
loadData() loadData()
} }
@ -332,8 +329,15 @@
} }
handleClose() handleClose()
} }
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => { const handleClose = () => {
searchFormState = reactive({}) searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
visible = false visible = false
} }

@ -27,12 +27,12 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item name="searchKey"> <a-form-item name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入用户名"></a-input> <a-input v-model:value="searchFormState.searchKey" placeholder="请输入用户名" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-button type="primary" class="primarySele" @click="loadData(searchFormState)"> </a-button> <a-button type="primary" class="primarySele" @click="loadData()"> </a-button>
<a-button class="snowy-buttom-left" @click="() => searchFormRef.resetFields()"> 重置 </a-button> <a-button class="snowy-buttom-left" @click="reset()"> </a-button>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
@ -134,7 +134,7 @@
// ref // ref
const selectedTable = ref() const selectedTable = ref()
const tableRecordNum = ref() const tableRecordNum = ref()
let searchFormState = reactive({}) const searchFormState = ref({})
const searchFormRef = ref() const searchFormRef = ref()
const cardLoading = ref(true) const cardLoading = ref(true)
// treeNode title,key,children // treeNode title,key,children
@ -184,14 +184,11 @@
} }
// //
const loadData = () => { const loadData = () => {
userSelectorPlusApi.userSelector(props.pageUrl, searchFormState).then((res) => { userSelectorPlusApi.userSelector(props.pageUrl, searchFormState.value).then((res) => {
// //
tableRecordNum.value = res.length tableRecordNum.value = res.length
tableData.value = res tableData.value = res
// loadCheckedKey()
if (JSON.stringify(searchFormState) === '{}') {
loadCheckedKey()
}
}) })
} }
// //
@ -254,9 +251,9 @@
// //
const treeSelect = (selectedKeys) => { const treeSelect = (selectedKeys) => {
if (selectedKeys.length > 0) { if (selectedKeys.length > 0) {
searchFormState.orgId = selectedKeys.toString() searchFormState.value.orgId = selectedKeys.toString()
} else { } else {
delete searchFormState.orgId delete searchFormState.value.orgId
} }
loadData() loadData()
} }
@ -279,8 +276,15 @@
} }
handleClose() handleClose()
} }
//
const reset = () => {
delete searchFormState.value.searchKey
loadData()
}
const handleClose = () => { const handleClose = () => {
searchFormState = reactive({}) searchFormState.value = {}
tableRecordNum.value = 0
tableData.value = []
visible = false visible = false
} }

Loading…
Cancel
Save