index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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" :cats="teamCats"></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. teamCats:uni.getStorageSync('teamCat')||[]
  102. }
  103. },
  104. onShow() {
  105. this.getData()
  106. this.init();
  107. },
  108. methods: {
  109. changeTab({currentIndex}){
  110. if (this.tabIdx !== currentIndex) {
  111. this.tabIdx = currentIndex
  112. this.getData()
  113. }
  114. },
  115. getData(){
  116. teamApi.getByListInfo({teamType:this.tabIdx+1}).then((res)=>{
  117. this.teamItems=res.data
  118. for(let i=0;i<res.data.length;i++){
  119. // #ifdef MP
  120. this.$nextTick(() => {
  121. this.$refs[`collapse-${i+1}`][0]&&this.$refs[`collapse-${i+1}`][0].resize()
  122. })
  123. // #endif
  124. }
  125. })
  126. },
  127. handleTeam(type,item){
  128. this.$refs.team.show(type,item)
  129. },
  130. handleMember(type,item){
  131. const self=this;
  132. if(type==='del'){
  133. uni.showModal({
  134. title: '提示',
  135. content: '是否确定删除',
  136. success: function (res) {
  137. if (res.confirm) {
  138. teamApi.deleteMemberById(item.teamId,item.memberId).then(()=>{
  139. uni.showToast({
  140. title:'删除成功!',
  141. icon:'none'
  142. })
  143. self.getData()
  144. })
  145. }
  146. }
  147. });
  148. }else{
  149. this.$refs.member.show(type,item)
  150. }
  151. },
  152. callPhone(phoneNumber) {
  153. if(!phoneNumber)return
  154. wx.makePhoneCall({
  155. phoneNumber
  156. })
  157. },
  158. init(){
  159. if(!uni.getStorageSync('teamCat')){
  160. teamApi.getCatByList().then((res)=>{
  161. uni.setStorageSync('teamCat',res.data)
  162. this.teamCats=res.data
  163. })
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .page-wrap{
  171. padding:0 20rpx;
  172. .pageTabs{
  173. background-color: #fff;
  174. }
  175. .pageMain{
  176. margin-top: 20rpx;
  177. background-color: #f5f5f5;
  178. padding-bottom: 50rpx;
  179. .teamhead{
  180. background-color: #fff;
  181. display: flex;
  182. justify-content: space-between;
  183. align-items: center;
  184. .teamName{
  185. font-weight: 600;
  186. font-size: 36rpx;
  187. color: #333;
  188. }
  189. .handle-bt{
  190. padding: 20rpx 30rpx;
  191. font-size: 28rpx;
  192. color: #409eff;
  193. line-height: 1;
  194. flex-shrink: 0;
  195. }
  196. }
  197. .teamDuty{
  198. padding: 20rpx;
  199. line-height: 1.2;
  200. background-color: #f5f5f5;
  201. }
  202. .addbt{
  203. width: 100rpx;
  204. height: 100rpx;
  205. border-radius: 50%;
  206. color: #fff;
  207. background-color: rgba(64,158,255,0.7);
  208. box-shadow:0 0 10rpx rgba(0,0,0,0.4);
  209. position: fixed;
  210. right: 10rpx;
  211. bottom: 20%;
  212. z-index: 99;
  213. text-align: center;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. .word{
  218. width: 80rpx;
  219. height: 80rpx;
  220. border-radius: 50%;
  221. margin: 5rpx auto;
  222. font-size: 28rpx;
  223. letter-spacing: 2px;
  224. }
  225. }
  226. .item-container{
  227. margin-top: 20rpx;
  228. padding-bottom: 50rpx;
  229. .item{
  230. &{
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. }
  235. .avatar {
  236. flex-shrink: 0;
  237. width: 60rpx;
  238. height: 60rpx;
  239. overflow: hidden;
  240. border-radius: 50%;
  241. background-color: #ddd;
  242. image{
  243. width: 60rpx;
  244. height: 60rpx;
  245. }
  246. }
  247. .info{
  248. flex: 1;
  249. padding:0 14rpx;
  250. .icon,.icon image{
  251. display: block;
  252. width: 30rpx;
  253. height: 30rpx;
  254. flex-shrink: 0;
  255. }
  256. .user,.phone{
  257. display: flex;
  258. align-items: center;
  259. .name,.phoneNumber{
  260. color: #999;
  261. font-size: 12px;
  262. font-weight: normal;
  263. line-height: 1;
  264. }
  265. }
  266. .user{
  267. padding: 10rpx 0;
  268. .userinfo{
  269. display: flex;
  270. align-items: center;
  271. }
  272. }
  273. .posbox{
  274. display: flex;
  275. justify-content: flex-end;
  276. }
  277. .bottom {
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. }
  282. }
  283. }
  284. .slot-button{
  285. width: 260rpx;
  286. height: 100%;
  287. display: flex;
  288. flex-direction: row;
  289. justify-content: center;
  290. align-items: center;
  291. color: #fff;
  292. .bt{
  293. width: 50%;
  294. height: 100%;
  295. font-size: 30rpx;
  296. box-sizing: border-box;
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. &.edit{
  301. background-color:#007aff;
  302. }
  303. &.del{
  304. background-color:#F56C6C;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. </style>