personList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="page_body">
  3. <!-- 头部 -->
  4. <nav-bar height="220" :title="pageTitle" :onlyTitle="false" :showHeadSearchInput="false" :showFilterPicker="false" :showTabs="false" :showTabBtns="false" rightWidth="0rpx" @GoBack="GoBack">
  5. <template #tabs_bottom_content>
  6. <!-- 搜索框单独一行 -->
  7. <view class="nav_head row_search_box">
  8. <uni-easyinput class="search_box" v-model="state.searchWord" trim="all" :styles="state.searchInputStyles"
  9. :placeholderStyle="state.searchInputPlaceholderStyle" placeholder="请输入关键字搜索" @input="HandleSearchInput">
  10. <template #left>
  11. <image src="@/static/image/overview/search.png" class="search_icon"></image>
  12. </template>
  13. </uni-easyinput>
  14. </view>
  15. </template>
  16. </nav-bar>
  17. <view class="person_list">
  18. <view class="list_item" v-for="(item,index) in state.listData" :key="item.id">
  19. <view class="item_name">{{item.label}}</view>
  20. <view :class="['btn_del',{'disabled':item.disabled}]" @click="handleDel(item.disabled,index,item.id,item.targetName)">删除</view>
  21. </view>
  22. </view>
  23. <!-- 删除确认框 -->
  24. <popupDialog ref="popupDelDialogRef" :showFootBorder="true" :content="state.popupDelDialog.content" @DialogConfirm="DialogDelConfirm" />
  25. </view>
  26. </template>
  27. <script setup>
  28. import navBar from '@/components/navBar.vue';
  29. import uniEasyinput from '@/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue';
  30. import {onLoad} from '@dcloudio/uni-app';
  31. import {reactive,ref,onUnmounted, computed} from 'vue';
  32. import popupDialog from '@/components/popupDialog.vue';
  33. const state = reactive({
  34. listData:[],
  35. allListData:[],
  36. popupDelDialog:{//删除确认框
  37. content:'',
  38. index:'',
  39. id:'',
  40. targetName:''
  41. }
  42. });
  43. const targetType = ref('');//采集对象 1-按部门,2-按学科,3-按年级,4-按权限,5-按学生
  44. const popupDelDialogRef = ref('');
  45. onLoad((option) => {
  46. const taskTargetsTreeData = uni.getStorageSync('taskTargetsTreeData');
  47. targetType.value = taskTargetsTreeData.targetType;
  48. const listData = taskTargetsTreeData?.taskTargets || [];
  49. state.listData = listData;
  50. state.allListData = listData;
  51. })
  52. const pageTitle = computed(() => {
  53. const num = state.allListData?.length || 0;
  54. if(targetType.value == 1){
  55. return `按部门 已选${num}人`
  56. }else if(targetType.value == 2){
  57. return `按学科 已选${num}人`
  58. }else if(targetType.value == 3){
  59. return `按年级 已选${num}人`
  60. }else if(targetType.value == 4){
  61. return `按权限 已选${num}人`
  62. }else{
  63. return ''
  64. }
  65. });
  66. // onUnmounted(()=>{
  67. // uni.removeStorageSync('taskTargetsTreeData');//移除缓存
  68. // })
  69. //搜索
  70. const HandleSearchInput = (e) => {
  71. const searchWord = (e || '').trim();
  72. if (!searchWord) {
  73. state.listData = [...state.allListData]; // 清空恢复全量
  74. return;
  75. }
  76. state.listData = state.allListData.filter(item=>item.label.indexOf(searchWord) > -1)
  77. }
  78. //删除
  79. const handleDel = (disabled,index,id,targetName) => {
  80. if(disabled){
  81. return false
  82. }
  83. state.popupDelDialog.index = index;
  84. state.popupDelDialog.id = id;
  85. state.popupDelDialog.targetName = targetName;
  86. state.popupDelDialog.content = `确定要删除【${targetName}】吗?`;
  87. popupDelDialogRef.value.OpenDialog();
  88. }
  89. const DialogDelConfirm = () => {
  90. state.listData.splice(state.popupDelDialog.index,1);
  91. const key = state.allListData.findIndex(item=>item.id==state.popupDelDialog.id);
  92. if (key !== -1) {
  93. state.allListData.splice(key, 1);
  94. }
  95. uni.setStorageSync('taskTargetsTreeData',{
  96. targetType:Number(targetType.value),
  97. taskTargets:state.allListData,//已选中
  98. });
  99. }
  100. //返回
  101. const GoBack = () => {
  102. uni.navigateBack({
  103. delta: 1
  104. });
  105. }
  106. </script>
  107. <style scoped lang="scss">
  108. .page_body{
  109. display: flex;
  110. flex-direction: column;
  111. height: 100%;
  112. min-width: auto;
  113. .row_search_box{
  114. height: 96rpx;
  115. align-items: flex-start;
  116. }
  117. .person_list{
  118. display: flex;
  119. flex-direction: column;
  120. width: 100%;
  121. padding: 0 24rpx;
  122. box-sizing: border-box;
  123. flex:1;
  124. overflow: auto;
  125. align-items: flex-start;
  126. .list_item{
  127. display: flex;
  128. width: 100%;
  129. justify-content: space-between;
  130. padding: 24rpx 0;
  131. border-bottom: 2rpx solid #F3F3F3;
  132. .item_name{
  133. font-weight: 400;
  134. font-size: 28rpx;
  135. color: #666666;
  136. flex:1;
  137. white-space: nowrap;
  138. overflow: hidden;
  139. text-overflow: ellipsis;
  140. }
  141. .btn_del{
  142. font-weight: 400;
  143. font-size: 28rpx;
  144. color: #F56C6C;
  145. &.disabled{
  146. color: #C0C4CC;
  147. }
  148. }
  149. }
  150. }
  151. }
  152. </style>