| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <template>
- <view class="default_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
- <cus-header title='选择行业'></cus-header>
- <view class="data adf">
- <view class="data-left">
- <view class="data-left-item" :class="{'active':findex===index}" @click="selectFirstType(item,index)"
- v-for="(item,index) in firstList" :key="index">{{item.name}}</view>
- <view class="data-left-item" @click="handleAdd(1)">自定义</view>
- </view>
- <view class="data-right">
- <view class="data-right-item" :class="{'active':item.select}" @click="selectSecondType(item,index)"
- v-for="(item,index) in secondList" :key="index">
- {{item.name}}
- <image :src="imgBase+'icon_selected.png'" v-if="item.select"></image>
- </view>
- <view class="data-right-item" @click="handleAdd(2)" v-if="firstName">自定义</view>
- </view>
- </view>
- <view class="bottom">
- <!-- <view class="bottom-top adfac">
- <view class="bottom-top-left adfac">已选(<text>{{1}}</text>/{{3}})</view>
- <view class="bottom-top-right">
- <scroll-view class="scroll-view_H" scroll-x="true" scroll-with-animation="true" :scroll-left="scrollLeft">
- <view class="scroll-view-item_H" :id="'svih_'+index" v-for="(item,index) in selectedList" :key="index">
- <view class="cl_item">
- <text>{{item.name}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </view> -->
- <view class="bottom-top">
- 当前选择行业:<span>{{firstName}} - {{secondName}}</span>
- </view>
- <view class="bottom-btns adfacjb">
- <!-- <view class="bottom-btns-btn" @click="clear">清空条件</view> -->
- <view class="zt_btn" @click="confirm">确定</view>
- </view>
- </view>
- <view class="dialog adffc" v-if="show">
- <view class="box">
- <view class="box-top adfac">
- <view class="box-top-btn cancel" @click="show=false">取消</view>
- <view class="box-top-title">其他自定义</view>
- <view class="box-top-btn add" @click="addIndustry">添加</view>
- </view>
- <view class="box-inp">
- <u--input type="text" v-model="name" border="none" fontSize="30rpx" color="#002846" :placeholder="'请输入自定义'+(type==1?'主':'子')+'行业'" clearable></u--input>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data(){
- return {
- scrollLeft:0,
- findex:'',
- fid:'',
- fpid:'',
- firstName:'',
- secondName:'',
- sid:'',
- spid:'',
- firstList:[
- {
- name:'IT/互联网',
- children:[
- {name:'网络与信息安全'}
- ]
- }
- ],
- dataMap:new Map(),
- secondList:[],
- selectedList:[],
- show:false,
- name:'',
- type:1,
- }
- },
- onLoad() {
- this.getData()
- },
- methods:{
- getData(){
- this.$api.get('/core/industry/list').then(({data:res})=>{
- if(res.code!==0) return this.$showToast(res.msg)
- this.firstList = res.data;
- this.firstList.forEach((l,i)=>{
- this.$set(this.firstList[i],'select',false)
- this.dataMap.set(l.id,l.children)
- })
- })
- },
- selectFirstType(item,index){
- if(index!==this.findex){
- this.firstName = this.secondName = '';
- }
- this.findex = index;
- this.firstName = item.name;
- this.fid = item.id;
- this.fpid = item.pid;
- this.firstList.forEach((l,i)=>{
- this.$set(this.firstList[i],'select',i===index)
- })
- this.secondList = this.dataMap.get(item.id);
- this.secondList.forEach((l,i)=>{
- this.$set(this.secondList[i],'select',false)
- })
- },
- selectSecondType(item,index){
- this.secondName = item.name;
- this.sid = item.id;
- this.spid = item.pid;
- this.secondList.forEach((l,i)=>{
- this.$set(this.secondList[i],'select',i===index)
- })
- },
- handleAdd(type){
- this.type = type;
- this.show = true;
- },
- clear(){
- this.firstList.forEach((l,i)=>{
- this.$set(this.firstList[i],'select',false)
- })
- this.secondList.forEach((l,i)=>{
- this.$set(this.secondList[i],'select',false)
- })
- this.selectedList = [];
- },
- addIndustry(){
- if(!this.name) return this.$showToast('请输入行业名称')
- this.$api.post('/core/industry',{
- pid:this.type===1?'0':this.fid,
- name:this.name
- }).then(({data:res})=>{
- if(res.code!==0) return this.$showToast(res.msg)
- this.findex = '';
- this.fid = '';
- this.fpid = '';
- this.firstName = '';
- this.sid = '';
- this.spid = '';
- this.secondName = '';
- this.firstList = [];
- this.secondList = [];
- this.name = '';
- this.show = false;
- this.getData()
- })
- },
- confirm(){
- if(!this.secondName) return this.$showToast('请先选择行业')
- this.getOpenerEventChannel().emit('selectConfirm',{
- industryId:this.sid,
- industryName:this.secondName
- })
- uni.navigateBack()
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .default_page{
- box-sizing: border-box;
- .data{
- flex: 1;
- &-left{
- width: 274rpx;
- background: #FFFFFF;
- overflow-y: auto;
- &-item{
- padding: 18rpx 36rpx;
- position: relative;
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 26rpx;
- color: #002846;
- line-height: 37rpx;
- &.active{
- font-weight: bold;
- color: #009191;
- &::before{
- content: '';
- width: 8rpx;
- height: 64rpx;
- background: #199C9C;
- position: absolute;
- left: 0;
- top: 50%;
- margin-top: -32rpx;
- }
- }
- }
- }
- &-right{
- flex: 1;
- background: #F7F7F7;
- overflow-y: auto;
- &-item{
- padding: 30rpx 100rpx 30rpx 30rpx;
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 26rpx;
- color: #002846;
- line-height: 37rpx;
- position: relative;
- &.active{
- color: #009191;
- }
- image{
- width: 36rpx;
- height: 36rpx;
- position: absolute;
- right: 30rpx;
- top: 50%;
- margin-top: -18rpx;
- }
- }
- }
- }
-
- .bottom{
- width: 100%;
- height: 290rpx;
- background: #FFFFFF;
- padding: 36rpx 30rpx;
- box-sizing: border-box;
- &-top{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 30rpx;
- color: #667E90;
- line-height: 42rpx;
- span{
- color: #002846;
- }
- }
- &-btns{
- margin-top: 50rpx;
- &-btn{
- width: 268rpx;
- height: 88rpx;
- background: #EBF6F6;
- border-radius: 44rpx;
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 32rpx;
- color: #009191;
- line-height: 88rpx;
- text-align: center;
- }
- .zt_btn{
- // width: calc(100% - 298rpx);
- width: 100%;
- }
- }
- }
-
- .dialog{
- position: fixed;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- z-index: 1000;
- background: rgba(0, 0, 0, .4);
- .box{
- width: 100%;
- border-radius: 24rpx 24rpx 0 0;
- background: #FFFFFF;
- padding: 36rpx 36rpx 300rpx;
- box-sizing: border-box;
- position: absolute;
- bottom: 0;
- left: 0;
- &-top{
- &-btn{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 30rpx;
- line-height: 42rpx;
- width: 80rpx;
- &.cancel{
- color: #002846;
- }
- &.add{
- color: #009191;
- text-align: right;
- }
- }
- &-title{
- flex: 1;
- font-family: PingFang-SC, PingFang-SC;
- font-weight: bold;
- font-size: 36rpx;
- color: #002846;
- line-height: 50rpx;
- text-align: center;
- }
- }
- &-inp{
- margin-top: 98rpx;
- padding-bottom: 30rpx;
- border-bottom: 1rpx solid #E2E2E2;
- }
- &-textarea{
- margin-top: 30rpx;
- padding-bottom: 30rpx;
- border-bottom: 1rpx solid #E2E2E2;
- }
- }
- }
- }
- </style>
|