123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <template>
- <view class="container">
- <uni-popup ref="popup" type="bottom" :maskClick="true">
- <view class="content">
- <text class="contentTitle">新增访查对象</text>
- <input class="input" type="text" focus="true" v-model="visiterInfo" placeholder-class="placeholder" placeholder="请填写访查对象信息" />
- <view class="bottomBtnGroup">
- <view class="cancel" @click="cancelAdd">取消</view>
- <view class="comfirm" @click="commitAdd">确定</view>
- </view>
- </view>
- </uni-popup>
- <view class="pageTitle">
- <text class="pageTitleLeft">访查对象</text>
- <text class="pageTitleRight" @click="manageHandle">{{edit?'完成':'管理'}}</text>
- </view>
- <view class="listWrap">
- <view class="list" v-for="(item,index) in investigationUsers" :key="index" @click="selectPersonHandle({...item,index})">
- <text class="name">{{item.investigationUserName}}</text>
- <view v-if="item.investigationStatus==1||item.investigationStatus==2" :class="[item.investigationStatus==1||item.investigationStatus==2?item.investigationStatus==1?'status done':'status checking':'status']">{{item.investigationStatus==1?'已完成':'进行中'}}</view>
- <text v-if="!edit&¤t.investigationUserName ==item.investigationUserName " class="checked">当前选中</text>
- <text v-if="edit" class="delBtn" @click="delInvestigationUser(item,index)">删除</text>
- </view>
- </view>
- <view class="bottom" @click="addVisiter">
- + 新增访查对象
- <!-- <image src="" mode=""></image> -->
- </view>
- </view>
- </template>
- <script>
- import {mapState} from 'vuex';
- export default {
- data() {
- return {
- // status:1,
- edit:false,//是否编辑状态
- visiterInfo:'',
- current:null,//当前选中对象
- index:null,//当前选中的对象在列表中的下标
- };
- },
- computed:{
- ...mapState({
- investigationUsers:state=>state.checkMainPoints.investigationUsers,
- currentSelectedInvestigationUser:state=>state.checkMainPoints.currentSelectedInvestigationUser,
- }),
- },
- watch:{
- currentSelectedInvestigationUser:function (newVal,oldVal){
- const index = this.investigationUsers.findIndex(item=>item.investigationUserName == newVal.investigationUserName);
- this.current = newVal;
- this.index = index;
- },
- },
- onLoad({checkId,situationType,deptId}) {
- this.checkId = Number(checkId);
- this.situationType = situationType;
- this.deptId = deptId;
- this.current = this.currentSelectedInvestigationUser;
- const index = this.investigationUsers.findIndex(item=>item.investigationUserName == this.current.investigationUserName);
- if(index>=0){
- this.index = index;
- }else {
- this.index = 0
- }
- },
- onUnload(){
- console.log('页面卸载');
- this.$store.commit('checkMainPoints/comChangeState',{key:'currentSelectedInvestigationUser',data:this.current})
- },
- methods:{
- manageHandle(){
- if(!this.edit){
- this.edit = true;
- }else {
- this.edit = false;
- }
- },
- addVisiter(){
- this.$refs.popup.open();
- },
- cancelAdd(){
- this.$refs.popup.close();
- this.visiterInfo ='';
- },
- //添加受访者
- commitAdd(){
- this.$store.dispatch({
- type: 'selectVisitPerson/commActions',
- key: 'addInvestigationUser',
- data:{
- checkId:this.checkId,
- investigationUser:this.visiterInfo,
- deptId:Number(this.deptId)
- }
- }).then(data=>{
- if(data){
- uni.showModal({
- title: '提示',
- content: '添加成功,是否立即返回?',
- success:(res)=>{
- if (res.confirm) {
- this.cancelAdd();
- uni.navigateBack({
- delta: 1
- });
- this.reloadData(true);
- }
- if (res.cancel) {
- this.cancelAdd();
- this.reloadData();
- }
- }
- });
- }
- })
- },
- //删除受访者
- /**
- * @param {Object} item
- * @param {Number} index
- */
- delInvestigationUser(item,index){
- const {investigationUserName} = item;
- this.$store.dispatch({
- type: 'selectVisitPerson/commActions',
- key: 'delInvestigationUser',
- data:{checkId:this.checkId,investigationUser:investigationUserName}
- }).then(data=>{
- // console.log(index,this.index);
- if(index==this.index){
- //当删除的是当前选中的对象
- const prevInvestigationUser = this.index>0?this.investigationUsers[this.index-1]:{investigationUserName:'',investigationStatus:''};
- this.current = prevInvestigationUser;
- }
- this.reloadData();
- });
- },
- //操作后重新获取数据
- /**
- * @param {Boolean} bool 判断是否直接将最新添加设置当前选中
- */
- reloadData(bool){
- this.$store.dispatch({
- type: 'checkMainPoints/commActions',
- key: 'getInvestigationUsers',
- data:{checkId:this.checkId,situationType:this.situationType,deptId:this.deptId}
- }).then(data=>{
- this.$store.commit('checkMainPoints/comChangeState',{key:'investigationUsers',data:data});
-
- if(bool){
- this.$store.commit('checkMainPoints/comChangeState',{key:'currentSelectedInvestigationUser',data:data[data.length-1]})
- }
- //还未设置默认受访对象时
- if(!this.currentSelectedInvestigationUser||!this.currentSelectedInvestigationUser.investigationUserName){
- this.$store.commit('checkMainPoints/comChangeState',{key:'currentSelectedInvestigationUser',data:data[0]})
- }
-
- });
- },
- selectPersonHandle(item){
- this.current = item;
- this.index = item.index;
- }
- }
- }
- </script>
- <style lang="less">
- .container {
- .content {
- position: relative;
- height:45vh;
- padding: 0 40rpx;
- padding-top: 35rpx;
- border-radius: 25rpx 25rpx 0px 0px;
- background-color: #FFFFFF;
- .contentTitle {
- font-size: 30rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #292C33;
- }
- .input {
- color:#292C33;
- height: 87.5rpx;
- margin-top: 35rpx;
- border-bottom: 0.62rpx solid #DADEE6;
- }
- .placeholder {
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #A1A7B3;
- }
- .bottomBtnGroup {
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- display: flex;
- flex-direction: row;
- .cancel {
- flex: 1;
- height:75rpx;
- text-align: center;
- line-height: 75rpx;
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #3377FF;
- border-top:0.62rpx solid #DADEE6;
- }
- .comfirm {
- flex: 1;
- height:75rpx;
- text-align: center;
- line-height: 75rpx;
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #FFFFFF;
- background-color:#3377FF;
- }
- }
- }
- .pageTitle {
- display: flex;
- width: 100%;
- flex-direction: row;
- justify-content:space-between;
- box-sizing: border-box;
- padding: 0 25rpx;
- padding-top:25rpx;
- padding-bottom:15rpx;
- .pageTitleLeft {
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #666F80;
- }
- .pageTitleRight {
- font-size: 20rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #3377FF;
- }
- }
- .listWrap {
- padding-left: 25rpx;
- margin-bottom: 15rpx;
- background-color: #FFFFFF;
- .list {
- position: relative;
- display: flex;
- height: 87.5rpx;
- flex-direction: row;
- justify-content: flex-start;
- align-items: center;
- border-bottom: 1px solid #DADEE6;
- .checked {
- position: absolute;
- top:32.5rpx;
- right: 25rpx;
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #7A8599;
- }
- .delBtn {
- position: absolute;
- top:32.5rpx;
- right: 25rpx;
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #FF3355;
- }
- .name {
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #292C33;
- }
- .status {
- width: 75rpx;
- height: 31.25rpx;
- border-radius: 5rpx;
- font-size: 17.5rpx;
- font-family: SourceHanSansCN-Medium, SourceHanSansCN;
- font-weight: 500;
- text-align: center;
- line-height: 31.25rpx;
- margin-left: 15rpx;
- &.done {
- color: #29CC96;
- background-color: rgba(41, 204, 150,0.1);
- }
-
- &.checking {
- color: #FFAA00;
- background:rgba(255, 204, 102,0.1);
- }
- }
-
- &:last-child {
- border: none;
- }
- }
- }
- .bottom {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 75rpx;
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #3377FF;
- background: #FFFFFF;
- }
- }
- </style>
|