index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <script setup>
  2. import {
  3. ref
  4. } from "vue";
  5. import {
  6. onLoad,
  7. } from "@dcloudio/uni-app";
  8. import {
  9. getPersonList,
  10. createMessage
  11. } from "@/api/work/message.js";
  12. let userNameList = ref(null);
  13. let pageForm = ref({
  14. content: null, //消息内容
  15. consumes: [], //消息接收者列表
  16. });
  17. function sendMessage() {
  18. createMessage(pageForm.value).then(res => {
  19. if (res.code === 200) {
  20. uni.showToast({
  21. title: "消息发送成功。",
  22. icon: "success",
  23. duration: 2000
  24. })
  25. uni.navigateBack({});
  26. } else {
  27. uni.showToast({
  28. title: "消息发送失败。",
  29. icon: "error",
  30. duration: 2000
  31. })
  32. }
  33. }).catch(() => {
  34. uni.showToast({
  35. title: "消息发送失败。",
  36. icon: "error",
  37. duration: 2000
  38. })
  39. });
  40. };
  41. // 选人弹窗
  42. let userChoose = ref(false);
  43. function userChooseClose() {};
  44. function userChooseOpen() {
  45. getPersonPage();
  46. };
  47. // 选人
  48. let chooseParams = ref({
  49. pageNo: 1,
  50. pageSize: 10,
  51. unitName: null,
  52. userName: null,
  53. })
  54. let personList = ref([]);
  55. let personTotal = ref(0);
  56. function getPersonPage() {
  57. getPersonList(chooseParams.value).then(res => {
  58. personList.value = res.data.list;
  59. personTotal.value = res.data.total;
  60. })
  61. }
  62. function paginationChange(e) {
  63. chooseParams.value.pageNo = e.current;
  64. getPersonPage();
  65. }
  66. let personSelectIndex = [];
  67. function personSelect(e) {
  68. personSelectIndex = e.detail.index;
  69. }
  70. // 打开弹窗
  71. function openPopup() {
  72. userChoose.value = true;
  73. }
  74. // 关闭弹窗
  75. function closePopup(type) {
  76. if (type === "confirm") {
  77. let tempArr = [];
  78. for (let i in personSelectIndex) {
  79. tempArr.push(personList.value[personSelectIndex[i]])
  80. };
  81. // 名称展示
  82. userNameList.value = tempArr.map(item => item.userName).join("、");
  83. // 筛选数据
  84. pageForm.value.consumes = tempArr.map(item => {
  85. return {
  86. userId: item.id,
  87. userName: item.userName
  88. };
  89. })
  90. }
  91. userChoose.value = false;
  92. }
  93. //清空
  94. function clear() {
  95. userNameList.value = ''
  96. pageForm.value.content = ''
  97. }
  98. </script>
  99. <template>
  100. <view class="container">
  101. <page-title rightText='清空' @rightTextClick='clear'>消息详情</page-title>
  102. <!-- <view class="clear">清空</view> -->
  103. <view class="content">
  104. <view class="card only-card">
  105. <view class="card-name" @click="openPopup()">
  106. <view class="card-name-title">
  107. <text class="card-name-description">接收人</text>
  108. </view>
  109. <view class="select-item">
  110. <view>{{userNameList}}</view>
  111. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  112. </view>
  113. </view>
  114. <view class="card-item">
  115. <view class="card-item-name">内容</view>
  116. <view class="item-textarea">
  117. <u--textarea v-model="pageForm.content" maxlength="-1" height='294rpx'></u--textarea>
  118. </view>
  119. </view>
  120. <view class="card-item">
  121. <view class="card-btn fat-btn" @click="sendMessage()">确定</view>
  122. </view>
  123. </view>
  124. </view>
  125. <u-popup :show="userChoose" @open="userChooseOpen" @close="userChooseClose" mode="center">
  126. <view class="user-choose">
  127. <view class="user-choose-title">
  128. <view class="uesr-choose-icon hide"></view>
  129. 人员筛选
  130. <view class="uesr-choose-icon" @click="closePopup('close')"></view>
  131. </view>
  132. <view class="search-item">
  133. <view class="search-item-name">单位</view>
  134. <input class="search-item-content" v-model="chooseParams.unitName" @blur="getPersonPage()"
  135. placeholder='请输入单位名称' placeholder-style="color: #D8D8D8;font-size:28rpx" />
  136. </view>
  137. <view class="search-item">
  138. <view class="search-item-name">用户姓名</view>
  139. <input class="search-item-content" v-model="chooseParams.userName" @blur="getPersonPage()"
  140. placeholder='请输入用户名称' placeholder-style="color: #D8D8D8;font-size:28rpx" />
  141. </view>
  142. <view class="search-item">
  143. <scroll-view class="swiper-item-content" scroll-y>
  144. <uni-table type="selection" emptyText="暂无更多数据" @selection-change="personSelect">
  145. <!-- 表头行 -->
  146. <uni-tr>
  147. <uni-th align="center">用户</uni-th>
  148. <uni-th align="center">单位</uni-th>
  149. <uni-th align="center">科室</uni-th>
  150. <uni-th align="center">手机号</uni-th>
  151. </uni-tr>
  152. <!-- 表格数据行 -->
  153. <uni-tr v-for="(item,index) in personList" :key="index">
  154. <uni-td align="center">{{item.userName}}</uni-td>
  155. <uni-td align="center">{{item.unitName}}</uni-td>
  156. <uni-td align="center">{{item.departName}}</uni-td>
  157. <uni-td align="center">{{item.tel}}</uni-td>
  158. </uni-tr>
  159. </uni-table>
  160. </scroll-view>
  161. </view>
  162. <uni-pagination title="标题文字" show-icon="true" :total="personTotal" :current="chooseParams.pageNo"
  163. @change="paginationChange"></uni-pagination>
  164. <view class="search-btn" @click="closePopup('confirm')">确定</view>
  165. </view>
  166. </u-popup>
  167. </view>
  168. </template>
  169. <style lang="scss" scoped>
  170. .clear {
  171. position: absolute;
  172. top: 90px;
  173. right: 4%;
  174. display: flex;
  175. font-size: 40rpx;
  176. font-weight: 500;
  177. color: #FFF;
  178. }
  179. .content {
  180. position: absolute;
  181. top: 5%;
  182. left: 0;
  183. width: 100%;
  184. height: 95%;
  185. padding: 100rpx 4% 0;
  186. box-sizing: border-box;
  187. // border-radius: 40rpx 40rpx 0 0;
  188. background-color: #fff;
  189. }
  190. .select-item {
  191. display: flex;
  192. align-items: center;
  193. font-size: 32rpx;
  194. color: #343437;
  195. }
  196. .item-textarea {
  197. width: 100%;
  198. min-height: 294rpx;
  199. padding: 20rpx;
  200. border: 2rpx solid #D0D9E7;
  201. border-radius: 20rpx;
  202. }
  203. .user-choose {
  204. width: 666rpx;
  205. min-height: 688rpx;
  206. padding: 30rpx 28rpx;
  207. .user-choose-title {
  208. display: flex;
  209. justify-content: space-between;
  210. width: 100%;
  211. margin-bottom: 54rpx;
  212. font-weight: 500;
  213. color: #3D3D3D;
  214. font-size: 32rpx;
  215. .uesr-choose-icon {
  216. width: 44rpx;
  217. height: 44rpx;
  218. background: url("@/static/message-close.svg");
  219. background-size: 100% 100%;
  220. }
  221. .hide {
  222. background: none;
  223. }
  224. }
  225. .search-item {
  226. display: flex;
  227. justify-content: space-between;
  228. align-items: flex-start;
  229. width: 606rpx;
  230. min-height: 88rpx;
  231. padding: 26rpx 30rpx;
  232. margin-bottom: 32rpx;
  233. font-size: 28rpx;
  234. border-radius: 20rpx;
  235. border: 2rpx solid #D0D9E7;
  236. .search-item-name {
  237. min-width: 128rpx;
  238. color: #939AA5;
  239. }
  240. .search-item-content {
  241. color: #3D3D3D;
  242. text-align: right;
  243. }
  244. .swiper-item-content {
  245. height: 286rpx;
  246. }
  247. }
  248. .search-btn {
  249. width: 606rpx;
  250. height: 64rpx;
  251. margin-top: 50rpx;
  252. line-height: 64rpx;
  253. text-align: center;
  254. color: #FFFFFF;
  255. font-size: 28rpx;
  256. background: #1869F6;
  257. border-radius: 16rpx;
  258. }
  259. }
  260. ::v-deep .u-popup__content {
  261. border-radius: 28rpx !important;
  262. }
  263. </style>