sopLogsList.vue 6.1 KB

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