You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
6.5 KiB

2 weeks ago
<template>
<view>
<!-- 弹框 -->
<uni-popup ref="share" type="share">
<view class="allcon">
<view class="xcon">
<view class="xcell" :class="cur==1?'cur':''" @click="qhclick(1)"></view>
<view class="xcell" :class="cur==2?'cur':''" @click="qhclick(2)"></view>
</view>
<view class="hcon">
<view class="htitle">
<u-search class="searchinput" v-model="searchKey" @change="searchchange" @custom="searchcustom" placeholder="请输入地址查询"
shape="square" bg-color="#EFF4F9" :clearabled="true" :show-action="showAction" input-align="left" @clear="clear"></u-search>
</view>
<view class="rclose" @tap="_cancel"></view>
</view>
<view class="selcon">
<radio-group class="checklist-group" @change="chagne">
<view class="sitem" v-for="(item,index) in clistnow" :key="index">
<view class="conright">
6 days ago
<view class="adress">
{{index+1}}
</view>
2 weeks ago
<view class="sname">
{{retType(item.departCode,2)}}
</view>
<view class="adress">
{{item.workshop}}
</view>
6 days ago
<view class="adress">
2 weeks ago
{{item.location}}
</view>
6 days ago
<view class="adress">
2 weeks ago
{{item.address}}
</view>
</view>
<view class="selbtn">
<radio :value="item.id" :checked="item.isChecked" />
</view>
</view>
</radio-group>
<view class="lineb"></view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
export default {
props: {
value: {
type: String,
default: "",
},
clist:{
type:Array,
default:[],
}
},
data() {
return {
cur:1,
clistnow:[],
clistall:[],
depts:[],
searchKey:"",
showAction:false,
};
},
watch: {
clist(list) {
console.log('监视值的改变1');
this._initTree(list);
},
deep: true, // 深度监听
immediate: true, // 初次监听即执行
},
created(){
this.getTypes();
},
methods: {
qhclick(index){
this.cur=index;
this.$forceUpdate();
this._initTree(this.clist);
},
searchchange(value) {
// 搜索框内容变化时会触发此事件value值为输入框的内容
if(value){
this.showAction=true;
this.$forceUpdate();
}
},
searchcustom(value) {
if (this.searchKey) {
this.clistall.forEach((v, i) => {
this.clistall[i].isChecked = false;
});
this.clistnow = this.clistall.filter((p) => {
//filter过滤的意思这个是过滤函数将每一项符合结果的值返回到personList
return ( p.address.indexOf(this.searchKey) !== -1 );
});
this.$forceUpdate();
}
},
clear() {
this.showAction=false;
this.clistnow=[];
this.clistall.forEach((v, i) => {
this.clistall[i].isChecked = false;
this.clistnow.push(this.clistall[i]);
});
},
_initTree(list){
this.clistall=list;
this.clistnow=[];
var user = JSON.parse(uni.getStorageSync("user"));
var bmbm = user.bmbm?user.bmbm:''; // '02'; //
this.clistall.forEach((v, i) => {
if(this.cur==1){
// 本单位
if(v.departCode==bmbm){
if(this.value == v.id){
this.clistall[i].isChecked = true;
}
else{
this.clistall[i].isChecked = false;
}
this.clistnow.push(this.clistall[i]);
}
}
else{
// 其他单位
if(v.departCode!==bmbm&&v.departCode!=='02'){
if(this.value == v.id){
this.clistall[i].isChecked = true;
}
else{
this.clistall[i].isChecked = false;
}
this.clistnow.push(this.clistall[i]);
}
}
});
// console.log(this.clistall,this.clistnow)
this.$forceUpdate();
},
chagne(e){
var rt= null;
if(e.detail.value){
this.clist.forEach(cell=>{
if(cell.id==e.detail.value){
rt=cell;
}
});
}
this.$emit("change", rt);
this._hide();
},
_show(id) {
this._initTree(this.clist);
this.$refs.share.open();
this.value=id;
this.clistnow.forEach(cell=>{
if(this.value == cell.id){
cell.isChecked=true;
}
else{
cell.isChecked=false;
}
});
this.$forceUpdate();
},
_hide() {
this.$refs.share.close();
},
_cancel() {
this._hide();
this.$emit("cancel", "");
},
getTypes() {
//获取数据字典
var commondata = uni.getStorageSync("commondata");
if(commondata){
var data = JSON.parse(commondata);
if(data){
this.depts=data.depts;
this.$forceUpdate();
}
}
},
retType(type,str) {
var rets = '';
if(str==2){
// 部门
this.depts.forEach((cell,idx)=>{
if(type==cell.departCode){
rets=cell.departName;
return;
}
});
}
if(!rets){
rets=type
}
return rets;
},
}
}
</script>
<style lang="scss" scoped>
::v-deep.uni-radio-input-checked::before{
display: none!important;
}
.allcon{
height: calc((0.8*100vh));
min-height: 300rpx;
overflow: hidden;
background-color: #FFFFFF;
}
.xcon{
display: flex;
flex-direction: row;
align-items: center;
padding: 20rpx 20rpx 0 20rpx;
.xcell{
border: 1rpx solid #ddd;
color: #949494;
margin-right: 20rpx;
padding: 10rpx 20rpx;
border-radius: 10rpx;
}
.xcell.cur{
color: #007aff;
border: 1rpx solid #007aff;
}
}
.hcon{
display: flex;
flex-direction: row;
padding: 20rpx;
.htitle{
flex:1;
justify-content: flex-start;
font-size: 32rpx;
font-weight: 600;
letter-spacing: 5rpx;
padding-right: 20rpx;
}
.rclose{
width: 70rpx;
display: flex;
justify-content: flex-start;
align-items: center;
font-size: 28rpx;
color:#949494;
}
}
.checklist-group{
width: 100%;
}
.selcon{
padding: 20rpx;
position: relative;
display: block;
overflow-y: auto;
height: calc((100vh*0.9 - 280rpx));
.lineb{
height: 50rpx;
}
.sitem {
display: flex;
flex-direction: row;
flex: 1;
background-color: #FFFFFF;
border-bottom: 1rpx solid #eeeeee;
padding: 10rpx 0;
.conright{
flex: 1;
display: flex;
flex-direction: row;
width: 100%;
justify-content:flex-start;
}
.selbtn{
width: 80rpx;
display: flex;
justify-content: center;
align-items: center;
}
.sname{
display: flex;
justify-content: flex-start;
align-items: center;
font-size: 28rpx;
font-weight: 600;
color: rgb(29, 29, 29);
padding: 10rpx 10rpx 10rpx 0;
}
.adress{
display: flex;
justify-content: flex-start;
align-items: center;
padding: 10rpx 10rpx 10rpx 10rpx;
font-size: 26rpx;
color:#949494;
}
}
}
</style>