4848 </div >
4949 </el-option >
5050 <el-option v-if =" attrs.paginate && loadMore && options.length" :value =" undefined" >
51- <div @click.stop =' paginateData($event )' >
51+ <div @click.stop =' remoteMethod(null,"next" )' >
5252 <i class =" el-icon-loading" ></i >
5353 <span >加载更多</span >
5454 </div >
@@ -85,6 +85,9 @@ export default {
8585 return _ .pick (this .form_data , this .attrs .depend );
8686 }
8787 },
88+ mounted () {
89+ this .setLable ()
90+ },
8891 methods: {
8992 onChange (value ) {
9093 let resValue = value
@@ -96,31 +99,39 @@ export default {
9699 }
97100 this .$emit (" change" , resValue);
98101 },
99- remoteMethod (query ) {
100- this .query = query
101- this .meta .page = 1
102- this .$http
103- .get (this .attrs .remoteUrl , { params: { ... this .meta , query: query, depend: this .depend , extUrlParams: this .extUrlParams } })
104- .then (res => {
105- this .options = res .data ;
106- this .meta .page ++
107- this .loadMore = true
108- });
109- },
110- paginateData (event ) {
102+ remoteMethod (query ,next = null ) {
103+ if (! next) {
104+ this .options = []
105+ this .query = query
106+ this .meta .page = 1
107+ }
111108 this .$http
112109 .get (this .attrs .remoteUrl , { params: { ... this .meta , query: this .query , depend: this .depend , extUrlParams: this .extUrlParams } })
113110 .then (res => {
114- if (res .data .length ) {
115- this .options .push (... res .data )
111+ const total = res .data .total || res .meta .total
112+ const data = res .data .data || res .data
113+ if (data .length ) {
114+ this .options .push (... data)
116115 }
117- if (this .meta . page < res . meta . to ){
118- this .meta .page = res . meta . to
116+ if (this .options . length < total ){
117+ this .meta .page ++
119118 this .loadMore = true
120119 }else {
121120 this .loadMore = false
122121 }
123- })
122+ });
123+ },
124+ setLable (){
125+ const label = this .attrs .label
126+ if (label && this .form_data [label .key ]) {
127+ const options = label .value || {value: " value" ,label: " label" }
128+ this .options = [_ .transform (options, (result , value , key ) => {
129+ const tempValue = _ .values (_ .pick (this .form_data [label .key ], value)).join (' -' )
130+ // 数字校验
131+ result[key] = (parseFloat (tempValue).toString () == " NaN" )? tempValue: parseFloat (tempValue)
132+ }, {})]
133+ this .loadMore = false
134+ }
124135 }
125136 }
126137};
0 commit comments