index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="page-wrap">
  3. <view class="pageTabs">
  4. <uni-segmented-control :current="tabIdx" :values="tabs" style-type="text" active-color="#007aff" @clickItem="changeTab" />
  5. </view>
  6. <view class="pageMain">
  7. <uni-card v-for="(team,index) in teamItems" :key="team.teamId" margin="10px 0" padding="0">
  8. <template v-slot:title>
  9. <view class="teamhead">
  10. <view class="teamName">
  11. <text>{{team.teamName}}</text>
  12. </view>
  13. <view class="handle-bt" @click="handleTeam('edit',team)">
  14. <text>编辑</text>
  15. </view>
  16. <view class="addbt" @click="handleTeam('add',team.teamType)">
  17. <view class="word">添加队伍</view>
  18. </view>
  19. </view>
  20. </template>
  21. <uni-collapse value="0" :ref="`collapse-${index+1}`" accordion>
  22. <uni-collapse-item :title="team.teamName">
  23. <view class="teamDuty">
  24. <text>{{team.teamDuty}}</text>
  25. </view>
  26. </uni-collapse-item>
  27. </uni-collapse>
  28. <view class="item-container">
  29. <view class="teamhead">
  30. <view class="item-select">
  31. <text>成员列表</text>
  32. </view>
  33. <view class="handle-bt" @click="handleMember('add',team.teamId)">
  34. <text>新增</text>
  35. </view>
  36. </view>
  37. <uni-swipe-action class="item-action-box">
  38. <uni-card padding="10px 0" margin="5px 0" v-for="item in team.memberList" :key="item.memberId">
  39. <uni-swipe-action-item class="item-action" :auto-close="true" >
  40. <template v-slot:right>
  41. <view class="slot-button">
  42. <view class="bt edit" @click="handleMember('edit',item)"><text class="slot-button-text">编辑</text></view>
  43. <view class="bt del" @click="handleMember('del',item)"><text class="slot-button-text">删除</text></view>
  44. </view>
  45. </template>
  46. <view class="item">
  47. <view class="avatar">
  48. <image :src="item.memberAvatar" v-if="item.memberAvatar"></image>
  49. <image class="icon" src="/static/images/avatar.png" v-else></image>
  50. </view>
  51. <view class="info">
  52. <view class="top">
  53. <view class="posName">
  54. <text>{{item.memberPosition}}</text>
  55. </view>
  56. <view class="posbox">
  57. <view class="tag">
  58. <uni-tag :inverted="true" :text="item.ifCpc===1?'党员':'不是党员'"
  59. :type="item.ifCpc===1?'primary':'success'"></uni-tag>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="bottom">
  64. <view class="user">
  65. <div class="userinfo">
  66. <uni-icons type="person-filled" size="24" :color="item.memberSex===1?'#666666':'#ffc0cb'"></uni-icons>
  67. <view class="name">{{item.memberName}}</view>
  68. </div>
  69. </view>
  70. <view class="phone" @click="callPhone(item.memberPhone)">
  71. <image class="icon" src="/static/images/phone.png"></image>
  72. <view class="phoneNumber">{{item.memberPhone||'未填写'}}</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </uni-swipe-action-item>
  78. </uni-card>
  79. </uni-swipe-action>
  80. </view>
  81. </uni-card>
  82. </view>
  83. <MemberForm ref="member" @success="getData"></MemberForm>
  84. <TeamForm ref="team" @success="getData"></TeamForm>
  85. </view>
  86. </template>
  87. <script>
  88. import teamApi from '@/api/team.js'
  89. import TeamForm from './components/TeamForm.vue'
  90. import MemberForm from './components/MemberForm.vue'
  91. export default {
  92. components:{
  93. TeamForm,
  94. MemberForm
  95. },
  96. data() {
  97. return {
  98. tabIdx:0,
  99. tabs:['专业救援队伍','行业救援队伍','综合抢险队伍'],
  100. teamItems:[]
  101. }
  102. },
  103. onShow() {
  104. this.getData()
  105. this.init();
  106. },
  107. methods: {
  108. changeTab({currentIndex}){
  109. if (this.tabIdx !== currentIndex) {
  110. this.tabIdx = currentIndex
  111. this.getData()
  112. }
  113. },
  114. getData(){
  115. teamApi.getByListInfo({teamType:this.tabIdx+1}).then((res)=>{
  116. this.teamItems=res.data
  117. for(let i=0;i<res.data.length;i++){
  118. // #ifdef MP
  119. this.$nextTick(() => {
  120. this.$refs[`collapse-${i+1}`][0]&&this.$refs[`collapse-${i+1}`][0].resize()
  121. })
  122. // #endif
  123. }
  124. })
  125. },
  126. handleTeam(type,item){
  127. this.$refs.team.show(type,item)
  128. },
  129. handleMember(type,item){
  130. const self=this;
  131. if(type==='del'){
  132. uni.showModal({
  133. title: '提示',
  134. content: '是否确定删除',
  135. success: function (res) {
  136. if (res.confirm) {
  137. teamApi.deleteMemberById(item.teamId,item.memberId).then(()=>{
  138. uni.showToast({
  139. title:'删除成功!',
  140. icon:'none'
  141. })
  142. self.getData()
  143. })
  144. }
  145. }
  146. });
  147. }else{
  148. this.$refs.member.show(type,item)
  149. }
  150. },
  151. callPhone(phoneNumber) {
  152. if(!phoneNumber)return
  153. wx.makePhoneCall({
  154. phoneNumber
  155. })
  156. },
  157. init(){
  158. if(!uni.getStorageSync('teamCat')){
  159. teamApi.getCatByList().then((res)=>{
  160. uni.setStorageSync('teamCat',res.data)
  161. })
  162. }
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .page-wrap{
  169. padding:0 20rpx;
  170. .pageTabs{
  171. background-color: #fff;
  172. }
  173. .pageMain{
  174. margin-top: 20rpx;
  175. background-color: #f5f5f5;
  176. padding-bottom: 50rpx;
  177. .teamhead{
  178. background-color: #fff;
  179. display: flex;
  180. justify-content: space-between;
  181. align-items: center;
  182. .teamName{
  183. font-weight: 600;
  184. font-size: 36rpx;
  185. color: #333;
  186. }
  187. .handle-bt{
  188. padding: 20rpx 30rpx;
  189. font-size: 28rpx;
  190. color: #409eff;
  191. line-height: 1;
  192. flex-shrink: 0;
  193. }
  194. }
  195. .teamDuty{
  196. padding: 20rpx;
  197. line-height: 1.2;
  198. background-color: #f5f5f5;
  199. }
  200. .addbt{
  201. width: 100rpx;
  202. height: 100rpx;
  203. border-radius: 50%;
  204. color: #fff;
  205. background-color: rgba(64,158,255,0.7);
  206. box-shadow:0 0 10rpx rgba(0,0,0,0.4);
  207. position: fixed;
  208. right: 10rpx;
  209. bottom: 20%;
  210. z-index: 99;
  211. text-align: center;
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. .word{
  216. width: 80rpx;
  217. height: 80rpx;
  218. border-radius: 50%;
  219. margin: 5rpx auto;
  220. font-size: 28rpx;
  221. letter-spacing: 2px;
  222. }
  223. }
  224. .item-container{
  225. margin-top: 20rpx;
  226. padding-bottom: 50rpx;
  227. .item{
  228. &{
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. }
  233. .avatar {
  234. flex-shrink: 0;
  235. width: 60rpx;
  236. height: 60rpx;
  237. overflow: hidden;
  238. border-radius: 50%;
  239. background-color: #ddd;
  240. image{
  241. width: 60rpx;
  242. height: 60rpx;
  243. }
  244. }
  245. .info{
  246. flex: 1;
  247. padding:0 14rpx;
  248. .icon,.icon image{
  249. display: block;
  250. width: 30rpx;
  251. height: 30rpx;
  252. flex-shrink: 0;
  253. }
  254. .user,.phone{
  255. display: flex;
  256. align-items: center;
  257. .name,.phoneNumber{
  258. color: #999;
  259. font-size: 12px;
  260. font-weight: normal;
  261. line-height: 1;
  262. }
  263. }
  264. .user{
  265. padding: 10rpx 0;
  266. .userinfo{
  267. display: flex;
  268. align-items: center;
  269. }
  270. }
  271. .posbox{
  272. display: flex;
  273. justify-content: flex-end;
  274. }
  275. .bottom {
  276. display: flex;
  277. justify-content: space-between;
  278. align-items: center;
  279. }
  280. }
  281. }
  282. .slot-button{
  283. width: 260rpx;
  284. height: 100%;
  285. display: flex;
  286. flex-direction: row;
  287. justify-content: center;
  288. align-items: center;
  289. color: #fff;
  290. .bt{
  291. width: 50%;
  292. height: 100%;
  293. font-size: 30rpx;
  294. box-sizing: border-box;
  295. display: flex;
  296. justify-content: center;
  297. align-items: center;
  298. &.edit{
  299. background-color:#007aff;
  300. }
  301. &.del{
  302. background-color:#F56C6C;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. </style>