< Modalv-model = " modal1" title = " 项目药品上下架维护" width = " 1020" :mask-closable = " false" @on-ok = " addOk()" > < Col span = " 36" > < Selectfilterable @on-change = " onChangeProject" placeholder = " 请先选择药店" > < Optionv-for = " (item, index) in dictCodesList" :value = " item" :key = " index" > {{ item.pharmacyName }}</ Option> </ Select> </ Col> < transfer:titles = " titles" filterable :operations = " [' 下架' , ' 上架' ]" :list- style =" listStyle " :data = " data_" :target-keys = " targetKeys1" @on-change = " handleChange" > </ transfer> </ Modal>
dictCodesList: [ ] , projectSelect: "" , modal1: false , titles: [ "项目未上架列表" , "项目已上架列表" ] , listStyle: { width: "440px" , height: "400px" , marginTop: "20px" , } , data_: this . getMockData ( ) , targetKeys1: this . getTargetKeys ( ) , mainDataPharmacyListt: [ ] , originalPharmacyList: [ ] , onChangeProject ( projectSelect) { this . projectSelect = projectSelect. pharmacyId; this . yaopinlists ( ) ; } , open ( ) { this . modal1 = true ; this . mainDataPharmacyList ( ) ; } , addOk ( ) { this . $Modal. confirm ( { title: "确认执行上下架?" , content: "执行上下架" , onOk: ( ) => { console. log ( "左边" , this . originalPharmacyList, "右边" , this . mainDataPharmacySelect) ; let id = this . $route. query. id || Number ( localStorage. getItem ( "id" ) ) ; let data = { newCommodityIdList: this . mainDataPharmacySelect, pharmacyId: this . projectSelect, projectId: id, } ; new Promise ( ( resolve, reject) => { PeopelManagement. yaopinDownShelves ( data) . then ( ( response) => { this . $Message. success ( "添加成功!" ) ; this . mainDataPharmacyList ( ) ; this . financeQueryList ( ) ; } ) . catch ( ( error) => { reject ( error) ; } ) ; } ) ; } , } ) ; } , getMockData ( ) { this . mockData = [ ] ; if ( this . mainDataPharmacyListt != undefined) { for ( let i = 0 ; i < this . mainDataPharmacyListt. length; i++ ) { this . mockData. push ( { key: this . mainDataPharmacyListt[ i] . commodityId, label: this . mainDataPharmacyListt[ i] . commodityName + `<span style="float:right;">` + this . mainDataPharmacyListt[ i] . commoditySpec + `</span>` , falg: this . mainDataPharmacyListt[ i] . falg, } ) ; } } return this . mockData; } , getTargetKeys ( ) { return this . getMockData ( ) . filter ( ( item) => item. falg == true ) . map ( ( item) => item. key) ; } , handleChange ( newTargetKeys, direction, moveKeys) { if ( this . mainDataPharmacyListt != undefined) { let originalEle = [ ] ; let targetEle = [ ] ; function arr_dive ( aArr, bArr) { if ( bArr. length == 0 ) { return aArr; } var diff = [ ] ; var str = bArr. join ( """" ) ; for ( var e in aArr) { if ( str. indexOf ( aArr[ e] ) == - 1 ) { diff. push ( aArr[ e] ) ; } } return diff; } this . data_ = this . getMockData ( ) ; console. log ( "555555555555555" , this . getMockData ( ) ) ; for ( let i = 0 ; i < this . data_. length; i++ ) { originalEle. push ( this . data_[ i] . label) ; if ( this . data_[ i] . key == moveKeys) { console. log ( "移动元素:" , this . data_[ i] . label) ; } for ( var j = 0 ; j < newTargetKeys. length; j++ ) { if ( this . data_[ i] . key == newTargetKeys[ j] ) { targetEle. push ( this . data_[ i] . label) ; } } } originalEle = arr_dive ( originalEle, targetEle) ; console. log ( "源列表元素:" , originalEle) ; console. log ( "目标列表元素:" , targetEle) ; this . targetKeys1 = newTargetKeys; this . mainDataPharmacySelect = this . targetKeys1; } } , yaopinlists ( ) { let id = this . $route. query. id || Number ( localStorage. getItem ( "id" ) ) ; new Promise ( ( resolve, reject) => { PeopelManagement. yaopinquerytest ( JSON . stringify ( id) , this . projectSelect) . then ( ( response) => { this . mainDataPharmacyListt = response. result; console. log ( "主数据" , this . mainDataPharmacyListt) ; this . mainDataPharmacyListt. forEach ( ( element) => { if ( element. falg == true ) { this . originalPharmacyList. push ( element. commodityId) ; } } ) ; this . getMockData ( ) ; this . getTargetKeys ( ) ; this . handleChange ( this . getTargetKeys ( ) ) ; } ) . catch ( ( error) => { console. log ( error) ; reject ( "error" ) ; } ) ; } ) ; } , mainDataPharmacyList ( ) { let id = this . $route. query. id || Number ( localStorage. getItem ( "id" ) ) ; new Promise ( ( resolve, reject) => { PeopelManagement. queryList ( JSON . stringify ( id) ) . then ( ( response) => { this . dictCodesList = response. result; console. log ( "主数据" , this . dictCodesList) ; } ) . catch ( ( error) => { console. log ( error) ; reject ( "error" ) ; } ) ; } ) ; } ,