Skip to content

Commit

Permalink
feat: end
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberty-liu committed May 19, 2023
1 parent 37374cc commit 8cfe674
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/views/filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const handleLang = (val) => {
:isFetchOptions="!isShowValidateState"
:isShowValidateState="!isShowValidateState"
:options="defaultOptions"
:getOptions="isShowValidateState ? getOptions : ''"
:getOptions="isShowValidateState ? getOptions : undefined"
:getConditions="getConditions"
:type="state.type"
ref="ERfilterRef"/>
Expand Down
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{
"name": "everright-filter",
"version": "0.0.20",
"version": "0.0.22",
"files": [
"dist"
],
"license": "SEE LICENSE IN LICENSE",
"keywords": [
"everright",
"everright-filter"
],
"type": "module",
"main": "dist/Everright-filter.umd.cjs",
"module": "dist/Everright-filter.js",
"style": "dist/style.css",
"main": "./dist/Everright-filter.umd.cjs",
"module": "./dist/Everright-filter.js",
"style": "./dist/style.css",
"exports": {
".": {
"import": "./dist/Everright-filter.js",
"require": "./dist/Everright-filter.umd.cjs"
},
"./dist/style.css": "./dist/style.css"
},
"scripts": {
"dev:server": "nodemon server --watch server",
"dev": "vite --host 0.0.0.0 --port 5174",
Expand Down
11 changes: 8 additions & 3 deletions packages/filter/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ const {
ruleRef
})
const addRule = () => {
state.rules.push(...utils.generateItems(1))
if (ER.props.canAddRule() !== false) {
state.rules.push(...utils.generateItems(1))
}
}
defineExpose({
getData,
setData,
addRule
addRule () {
state.rules.push(...utils.generateItems(1))
},
state
})
const operatorHeight = ref('auto')
const callback = (mutationsList) => {
Expand Down Expand Up @@ -115,7 +120,7 @@ const itemLabel = computed(() => {
/>
</TransitionGroup>
<el-button
v-if="ER.state.isShowAdd"
v-if="isInConstraint ? true : ER.isShowAdd.value"
:class="[ns.e('add')]"
@click="addRule"
link
Expand Down
4 changes: 4 additions & 0 deletions packages/filter/components/Trigger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const handleChange = (val) => {
defineExpose({
ref: element
})
const filterMethod = (node, keyword) => {
return node.text.toLowerCase().includes(keyword.toLowerCase())
}
</script>
<template>
<el-cascader
Expand All @@ -39,6 +42,7 @@ defineExpose({
:checkStrictly="true"
:model-value="modelValue"
filterable
:filter-method="filterMethod"
@change="handleChange"
:props="{
emitPath: false
Expand Down
25 changes: 19 additions & 6 deletions packages/filter/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,24 @@ const props = defineProps({
default: 'zh-cn'
},
getOptions: {
type: [Function, String]
type: Function
},
getConditions: {
type: [Function, String]
type: Function
},
getProps: {
type: [Function, String]
type: Function
},
getPropValues: {
type: [Function, String]
type: Function
},
canAddRule: {
type: Function,
default: () => {}
},
ruleLimit: {
type: Number,
default: -1
}
})
const {
Expand Down Expand Up @@ -108,12 +116,17 @@ const fireEvent = (type, data) => {
})
}
}
const isShowAdd = computed(() => {
// console.log(_.flatten(_.get(itemRef, 'value', []).map(e => e.state.rules)).length)
return state.isShowAdd && props.ruleLimit === -1 ? true : _.flatten(_.get(itemRef, 'value', []).map(e => e.state.rules)).length < props.ruleLimit
})
provide('Everright', {
state,
api,
readied,
props,
fireEvent
fireEvent,
isShowAdd
})
const flatNodes = (nodes) => {
return nodes.reduce((res, node) => {
Expand Down Expand Up @@ -244,7 +257,7 @@ const addGroupLabel = computed(() => {
</Item>
</TransitionGroup>
<el-button
v-if="state.isShowAdd"
v-if="isShowAdd"
:class="[ns.e('add')]"
@click="addItem"
link
Expand Down
4 changes: 4 additions & 0 deletions packages/filter/types/Cascader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ const componentProps = computed(() => {
}
return _.merge(result, _.get(props, 'params.customProps', {}))
})
const filterMethod = (node, keyword) => {
return node.text.toLowerCase().includes(keyword.toLowerCase())
}
</script>
<template>
<div
v-loading="state.loading">
<el-cascader
:filter-method="filterMethod"
v-model="state.value0" :options="state.options"
v-if="state.isChanged"
collapseTagsTooltip
Expand Down
1 change: 1 addition & 0 deletions packages/filter/types/Region.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ defineExpose({
v-if="state.isChanged"
v-model="state.value0"
:multiple="isMultiple"
:selectType="props.params.selectType"
clearable
:placeholder="t('er.public.select')"
ref="erRegin"/>
Expand Down
8 changes: 6 additions & 2 deletions packages/region/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ const props = defineProps({
},
modelValue: {
type: Array
},
selectType: {
type: Number,
default: 3
}
})
const emit = defineEmits(['update:modelValue', 'change'])
let inputInitialHeight = 0
const pressDeleteCount = 0
const region = new Region(areaList, {
isFilter: true,
selectType: 3
isFilter: false,
selectType: props.selectType
})
const tooltipRef = ref()
const tagWrapper = ref()
Expand Down
1 change: 1 addition & 0 deletions server/routes/Filter/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default (req, res) => {
operatorKey: 'Gender',
value: 'Region',
multiple: false
// selectType: 1 default 3
},
{
label: '文本',
Expand Down

0 comments on commit 8cfe674

Please sign in to comment.