sopLosList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="content">
  3. <view class="top-box">
  4. <view class="tabs">
  5. <u-tabs
  6. :scrollable="false"
  7. :list="tabs"
  8. lineColor="#115296"
  9. @change="tagChange">
  10. </u-tabs>
  11. </view>
  12. </view>
  13. <mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  14. <view class="sop-list">
  15. <view class="sop-item" v-for="(item) in dataList" @click.stop="openDetails(item)" >
  16. <view class="name-box">
  17. <view class="name">{{item.externalUserName}}</view>
  18. </view>
  19. <view class="desc-box">
  20. <view class="label">发送时间:</view>
  21. <view class="value">{{item.sendTime}}</view>
  22. </view>
  23. <view class="desc-box">
  24. <view class="label">所属销售:</view>
  25. <view class="value">{{item.userName}}</view>
  26. </view>
  27. </view>
  28. </view>
  29. </mescroll-body>
  30. <view class="footer-btns">
  31. <u-button :disabled="!sendFlag" type="success" wid @click="sendMsg()" text="启动群发"></u-button>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  37. import {updateQwSopLogs,getQwSopLogsList} from '@/api/qw.js'
  38. export default {
  39. mixins: [MescrollMixin], // 使用mixin
  40. data() {
  41. return {
  42. sendFlag:true,
  43. hasNextPage:false,
  44. totalCount:0,
  45. sopId:null,
  46. status:3,
  47. tabs:[
  48. {
  49. id:3,
  50. name:'待发送'
  51. },
  52. {
  53. id:1,
  54. name:'发送成功'
  55. },
  56. {
  57. id:0,
  58. name:'发送失败'
  59. }
  60. ],
  61. mescroll:null,
  62. downOption: {
  63. auto:false//不要自动加载
  64. },
  65. upOption: {
  66. onScroll:false,
  67. use: true, // 是否启用上拉加载; 默认true
  68. page: {
  69. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  70. size: 10 // 每页数据的数量,默认10
  71. },
  72. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  73. textNoMore:"已经到底了",
  74. empty: {
  75. icon:'/static/images/empty.png',
  76. tip: '暂无数据'
  77. }
  78. },
  79. dataList: []
  80. }
  81. },
  82. onLoad(option) {
  83. this.sopId=option.sopId;
  84. var that=this;
  85. uni.$on('sendSop', (item) => {
  86. console.log(JSON.parse(item.data))
  87. var data=JSON.parse(item.data);
  88. var param={
  89. sendStatus:1,
  90. id: data.id,
  91. receivingStatus: data.receivingStatus,
  92. remark:item.remark
  93. };
  94. updateQwSopLogs(param).then(res => {
  95. });
  96. that.sendMsgOp();
  97. })
  98. },
  99. onShow() {
  100. },
  101. methods: {
  102. sendMsgOp(){
  103. if(this.sendFlag){
  104. return;
  105. }
  106. //循环发送 先获取一条,更新一条这样发送
  107. this.mescroll.resetUpScroll()
  108. var userId=uni.getStorageSync('companyUserId') ;
  109. var that=this;
  110. setTimeout(function(){
  111. if(that.dataList.length>0){
  112. var data={cmd:"sendSop", data:that.dataList[0],userId:"p-"+userId};
  113. uni.$emit('sendMsg',data);
  114. }
  115. else{
  116. that.sendFlag=true;
  117. uni.showToast({
  118. icon:'none',
  119. title: "已完成",
  120. });
  121. }
  122. },5000);
  123. },
  124. sendMsg(){
  125. if(!this.sendFlag){
  126. uni.showToast({
  127. icon:'none',
  128. title: "运行中...",
  129. });
  130. return;
  131. }
  132. var that=this;
  133. uni.showModal({
  134. title:"提示",
  135. content:"确认启动自动发送吗?",
  136. showCancel:true,
  137. cancelText:'取消',
  138. confirmText:'确定',
  139. success:res=>{
  140. if(res.confirm){
  141. this.sendFlag=false;
  142. that.sendMsgOp()
  143. }else{
  144. // 否则点击了取消
  145. }
  146. }
  147. })
  148. },
  149. openDetails(item){
  150. uni.setStorageSync("sop",JSON.stringify(item))
  151. uni.navigateTo({
  152. url:"sopLogsDetails"
  153. })
  154. },
  155. tagChange(item){
  156. this.status=item.id
  157. this.mescroll.resetUpScroll()
  158. },
  159. mescrollInit(mescroll) {
  160. this.mescroll = mescroll;
  161. },
  162. /*下拉刷新的回调 */
  163. downCallback(mescroll) {
  164. mescroll.resetUpScroll()
  165. },
  166. upCallback(page) {
  167. //联网加载数据
  168. var that = this;
  169. var data={
  170. sopId:this.sopId,
  171. sendStatus:this.status,
  172. pageNum: page.num,
  173. pageSize: page.size
  174. };
  175. uni.showLoading({
  176. title:"加载中..."
  177. })
  178. getQwSopLogsList(data).then(res => {
  179. uni.hideLoading()
  180. if(res.code==200){
  181. //设置列表数据
  182. if (page.num == 1) {
  183. that.dataList = res.data.list;
  184. } else {
  185. that.dataList = that.dataList.concat(res.data.list);
  186. }
  187. that.hasNextPage=res.data.hasNextPage
  188. that.mescroll.endBySize(res.data.list.length, res.data.total);
  189. }else{
  190. uni.showToast({
  191. icon:'none',
  192. title: "请求失败",
  193. });
  194. that.dataList = null;
  195. that.mescroll.endErr();
  196. }
  197. });
  198. },
  199. navTo(url){
  200. uni.navigateTo({
  201. url: url
  202. })
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. page{
  209. height: 100%;
  210. background: #f6f6f6;
  211. }
  212. </style>
  213. <style scoped lang="scss">
  214. .content{
  215. height: 100%;
  216. padding: 0rpx;
  217. .top-box{
  218. width: 100%;
  219. z-index: 10000;
  220. position: absolute;
  221. top:0rpx;
  222. left:0rpx;
  223. .tabs{
  224. height: 88rpx;
  225. background-color: #fff;
  226. width: 100%;
  227. }
  228. }
  229. .footer-btns{
  230. padding:15rpx;
  231. width: 100%;
  232. z-index: 10000;
  233. position: absolute;
  234. bottom:30rpx;
  235. left:0rpx;
  236. }
  237. .sop-list{
  238. display: flex;
  239. flex-direction: column;
  240. padding: 15rpx;
  241. .sop-item{
  242. padding: 15rpx;
  243. border-radius: 15rpx;
  244. background-color: #fff;
  245. margin-bottom: 15rpx;
  246. width: 100%;
  247. .name-box{
  248. width: 100%;
  249. display: flex;
  250. align-items: center;
  251. justify-content: flex-start;
  252. .name{
  253. flex: 1;
  254. font-size: 38rpx;
  255. color:#111;
  256. }
  257. .btns{
  258. .btn{
  259. margin-left: 10rpx;
  260. width: 40rpx;
  261. height:40rpx;
  262. }
  263. }
  264. }
  265. .desc-box{
  266. margin-top: 15rpx;
  267. width: 100%;
  268. display: flex;
  269. align-items: center;
  270. justify-content: flex-start;
  271. .label{
  272. font-size: 28rpx;
  273. color: #a8a8a8;
  274. }
  275. .value{
  276. font-size: 28rpx;
  277. color: #a8a8a8;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. </style>