diff --git a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/input.spec.js b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/input.spec.js index efbfa38..25e30b8 100644 --- a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/input.spec.js +++ b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/input.spec.js @@ -411,7 +411,7 @@ context('input', () => { }); }); - it.only('autocomplete', () => { + it('autocomplete', () => { cy.server(); cy.route({ method: 'GET', diff --git a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/select.spec.js b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/select.spec.js index 91c872b..18c8f10 100644 --- a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/select.spec.js +++ b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/select.spec.js @@ -363,6 +363,25 @@ context('select', () => { }; }).as('list'); + cy.route(() => { + return { + method: 'GET', + url: '/list1**', + response: { + data: [ + { + value: '1', + label: 'daniel' + }, + { + value: '2', + label: 'sarah' + } + ] + } + }; + }).as('list1'); + let formSchema = { type: 'object', properties: { @@ -403,6 +422,22 @@ context('select', () => { } } } + }, + // filter > select > clear > select + name3: { + type: 'string', + ui: { + widget: 'select', + widgetConfig: { + filterable: true, + filterLocal: false, + enumSourceRemote: { + remoteUrl: '/list1', + itemTemplate: '{{item.id}} : {{item.name}}', + resField: 'data' + } + } + } } } }; @@ -458,6 +493,41 @@ context('select', () => { expect(xhr.url.search('status=1&keyword=d')).to.be.greaterThan(0); expect(callCount).to.be.equal(3); }); + + cy.get('@body') + .find('li:contains("daniel"):visible') + .click() + cy.get('input') + .eq(0) + .should('have.value', 'daniel'); + }); + + cy.get('label') + .contains('name3') + .parent() + .within(() => { + cy.wait('@list1'); + cy.get('input') + .eq(0) + .click(); + + cy.get('@body') + .find('li:contains("daniel"):visible:last') + .click() + cy.get('input') + .eq(0) + .should('have.value', 'daniel'); + + cy.get('input') + .eq(0) + .click().clear(); + + cy.get('@body') + .find('li:contains("sarah"):visible:last') + .click() + cy.get('input') + .eq(0) + .should('have.value', 'sarah'); }); // common.submitForm(); @@ -542,7 +612,7 @@ context('select', () => { .find('li:contains("sarah")') .find(':not(:hidden)') .click(); - cy.get('input') + cy.get('input') .eq(0) .should('have.value', 'sarah'); diff --git a/packages/ncform-theme-elementui/src/components/control-comps/input.vue b/packages/ncform-theme-elementui/src/components/control-comps/input.vue index 2a88fa0..434b2e6 100755 --- a/packages/ncform-theme-elementui/src/components/control-comps/input.vue +++ b/packages/ncform-theme-elementui/src/components/control-comps/input.vue @@ -416,7 +416,7 @@ export default { // 下面是远程数据源的处理 const options = { url: autoCpl.enumSourceRemote.remoteUrl, - params: _get(this.mergeConfig, "autocomplete.enumSourceRemote.otherParams", {}) + params: _cloneDeep(_get(this.mergeConfig, "autocomplete.enumSourceRemote.otherParams", {})) }; if (autoCpl.enumSourceRemote.paramName) options.params[autoCpl.enumSourceRemote.paramName] = queryString; diff --git a/packages/ncform-theme-elementui/src/components/control-comps/select.vue b/packages/ncform-theme-elementui/src/components/control-comps/select.vue index 3be9ae6..150bb33 100755 --- a/packages/ncform-theme-elementui/src/components/control-comps/select.vue +++ b/packages/ncform-theme-elementui/src/components/control-comps/select.vue @@ -108,9 +108,10 @@ export default { const options = { url: this.mergeConfig.enumSourceRemote.remoteUrl, - params: _get(this.mergeConfig, "enumSourceRemote.otherParams", {}) + params: _cloneDeep(_get(this.mergeConfig, "enumSourceRemote.otherParams", {})) }; - options.params[this.mergeConfig.enumSourceRemote.paramName] = query; + if (this.mergeConfig.enumSourceRemote.paramName) + options.params[this.mergeConfig.enumSourceRemote.paramName] = query; this.$http(options).then(res => { this.$data.options = this.mergeConfig.enumSourceRemote.resField ? _get(res.data, this.mergeConfig.enumSourceRemote.resField)