TestMobileList.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content"> 测试移动表单</block>
  6. </cu-custom>
  7. <view :style="[{top:CustomBar + 'px'}]">
  8. <view class="cu-bar search">
  9. <view class="search-form bg-white round">
  10. <text class="cuIcon-search"></text>
  11. <input type="text" placeholder="搜索" v-model="curWord" confirm-type="search" @input="inputWord"></input>
  12. </view>
  13. </view>
  14. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
  15. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(row, index) in dataList" :key="index"
  16. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  17. <view class="cu-bar bg-white solid-bottom">
  18. <view class="action">
  19. <text class="cuIcon-titles text-orange "></text># {{index + 1}}
  20. </view>
  21. <view class="action">
  22. <button class="uni-button" size="mini" @click="edit(row.id)" type="primary">修改</button>
  23. <button class="uni-button" size="mini" @click="del(row.id)" type="warn">删除</button>
  24. </view>
  25. </view>
  26. <view class="cu-card dynamic no-card">
  27. <view class="cu-item shadow">
  28. <view class="cu-list menu-avatar comment solids-top">
  29. <view class="cu-item">
  30. <view class="content">
  31. <view class=" margin-top-sm text-sm">
  32. <view class="flex">
  33. <view> 姓名:</view>
  34. <view class="flex-sub">
  35. {{row.name}}
  36. </view>
  37. </view>
  38. </view>
  39. <view class=" margin-top-sm text-sm">
  40. <view class="flex">
  41. <view> 年龄:</view>
  42. <view class="flex-sub">
  43. {{row.age}}
  44. </view>
  45. </view>
  46. </view>
  47. <view class=" margin-top-sm text-sm">
  48. <view class="flex">
  49. <view> 地区:</view>
  50. <view class="flex-sub">
  51. {{ row.area && row.area.name }}
  52. </view>
  53. </view>
  54. </view>
  55. <view class=" margin-top-sm text-sm">
  56. <view class="flex">
  57. <view> 公司:</view>
  58. <view class="flex-sub">
  59. {{ row.company && row.company.name }}
  60. </view>
  61. </view>
  62. </view>
  63. <view class=" margin-top-sm text-sm">
  64. <view class="flex">
  65. <view> 部门:</view>
  66. <view class="flex-sub">
  67. {{ row.office && row.office.name }}
  68. </view>
  69. </view>
  70. </view>
  71. <view class=" margin-top-sm text-sm">
  72. <view class="flex">
  73. <view> 性别:</view>
  74. <view class="flex-sub">
  75. {{ $dictUtils.getDictLabel("sex", row.sex, '-') }}
  76. </view>
  77. </view>
  78. </view>
  79. <view class=" margin-top-sm text-sm">
  80. <view class="flex">
  81. <view> 头像:</view>
  82. <view class="flex-sub">
  83. <image :src="row.teImage"></image>
  84. </view>
  85. </view>
  86. </view>
  87. <view class=" margin-top-sm text-sm">
  88. <view class="flex">
  89. <view> 单选框:</view>
  90. <view class="flex-sub">
  91. {{ $dictUtils.getDictLabel("yes_no", row.isSingle, '-') }}
  92. </view>
  93. </view>
  94. </view>
  95. <view class=" margin-top-sm text-sm">
  96. <view class="flex">
  97. <view> 多选框:</view>
  98. <view class="flex-sub">
  99. {{row.cks.split(",").map( (item)=> { return $dictUtils.getDictLabel("form_style", item, '-')}).join(",") }}
  100. </view>
  101. </view>
  102. </view>
  103. <view class=" margin-top-sm text-sm">
  104. <view class="flex">
  105. <view> 多行文本框:</view>
  106. <view class="flex-sub">
  107. {{row.textArea}}
  108. </view>
  109. </view>
  110. </view>
  111. <view class=" margin-top-sm text-sm">
  112. <view class="flex">
  113. <view> 数字输入框:</view>
  114. <view class="flex-sub">
  115. {{row.textNumber}}
  116. </view>
  117. </view>
  118. </view>
  119. <view class=" margin-top-sm text-sm">
  120. <view class="flex">
  121. <view> 日期选择框:</view>
  122. <view class="flex-sub">
  123. {{row.teDate}}
  124. </view>
  125. </view>
  126. </view>
  127. <view class=" margin-top-sm text-sm">
  128. <view class="flex">
  129. <view> 邮箱:</view>
  130. <view class="flex-sub">
  131. {{row.email}}
  132. </view>
  133. </view>
  134. </view>
  135. <view class=" margin-top-sm text-sm">
  136. <view class="flex">
  137. <view> 手机号:</view>
  138. <view class="flex-sub">
  139. {{row.phone}}
  140. </view>
  141. </view>
  142. </view>
  143. <view class=" margin-top-sm text-sm">
  144. <view class="flex">
  145. <view> 电话:</view>
  146. <view class="flex-sub">
  147. {{row.tel}}
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. </mescroll-body>
  158. <uni-fab
  159. :pattern=" {
  160. color: '#7A7E83',
  161. backgroundColor: '#fff',
  162. selectedColor: '#007AFF',
  163. buttonColor: '#007AFF'
  164. }"
  165. horizontal="right"
  166. vertical="bottom"
  167. @fabClick="add"
  168. ></uni-fab>
  169. </view>
  170. </view>
  171. </template>
  172. <script>
  173. import uniFab from '@/components/uni-fab/uni-fab.vue';
  174. import testMobileService from '@/api/test/mobile/testMobileService'
  175. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  176. import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
  177. export default {
  178. mixins: [MescrollMixin,MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
  179. onShow(option) {
  180. this.$auth.checkLogin()
  181. },
  182. components:{
  183. uniFab
  184. },
  185. data () {
  186. return {
  187. searchForm: {},
  188. curWord:"" ,//当前搜索关键词
  189. dataList: [], // 数据列表
  190. modalName: null,
  191. tablePage: {
  192. total: 0,
  193. currentPage: 1,
  194. pageSize: 10,
  195. orders: []
  196. },
  197. loading: false
  198. }
  199. },
  200. methods: {
  201. // 新增
  202. add (){
  203. uni.navigateTo({
  204. url: '/pages/test/mobile/TestMobileForm'
  205. })
  206. },
  207. // 修改
  208. edit (id) {
  209. uni.navigateTo({
  210. url: '/pages/test/mobile/TestMobileForm?id='+id
  211. })
  212. },
  213. // 删除
  214. del (id) {
  215. uni.showModal({
  216. title: '提示',
  217. content: '您确认要删除数据吗',
  218. showCancel: true,
  219. success: (res) => {
  220. if (res.confirm) {
  221. testMobileService.delete(id).then(({data})=>{
  222. uni.showToast({
  223. title: data,
  224. icon:"success"
  225. })
  226. this.doSearch()
  227. })
  228. }
  229. }
  230. });
  231. },
  232. /*获取数据列表 */
  233. upCallback(page) {
  234. this.loading = true
  235. testMobileService.list({
  236. current: page.num,
  237. size: page.size,
  238. ...this.searchForm
  239. }).then(({data}) => {
  240. let curPageData = data.records
  241. this.mescroll.endBySize(curPageData.length, data.total);
  242. //如果是第一页需手动制空列表
  243. if(page.num == 1)
  244. this.dataList = [];
  245. //追加新数据
  246. this.dataList=this.dataList.concat(curPageData);
  247. }).catch(e=>{
  248. //联网失败, 结束加载
  249. this.mescroll.endErr();
  250. })
  251. },
  252. // 输入监听
  253. inputWord(e){
  254. // this.curWord = e.detail.value // 已使用v-model,无需再次赋值
  255. // 节流,避免输入过快多次请求
  256. this.searchTimer && clearTimeout(this.searchTimer)
  257. this.searchTimer = setTimeout(()=>{
  258. this.doSearch(this.curWord)
  259. },300)
  260. },
  261. // 搜索
  262. doSearch(word){
  263. this.curWord = word
  264. this.dataList = []; // 先清空列表,显示加载进度
  265. this.mescroll.resetUpScroll();
  266. },
  267. // ListTouch触摸开始
  268. ListTouchStart(e) {
  269. this.listTouchStart = e.touches[0].pageX
  270. },
  271. // ListTouch计算方向
  272. ListTouchMove(e) {
  273. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > -60? 'right' : 'left'
  274. },
  275. // ListTouch计算滚动
  276. ListTouchEnd(e) {
  277. if (this.listTouchDirection == 'left') {
  278. this.modalName = e.currentTarget.dataset.target
  279. } else {
  280. this.modalName = null
  281. }
  282. this.listTouchDirection = null
  283. }
  284. }
  285. }
  286. </script>
  287. <style>
  288. .ellipsis-description {
  289. font-size: 12px;
  290. line-height: $line-height-base;
  291. display: -webkit-box;/*作为弹性伸缩盒子模型显示*/
  292. -webkit-line-clamp: 1; /*显示的行数;如果要设置2行加...则设置为2*/
  293. overflow: hidden; /*超出的文本隐藏*/
  294. text-overflow: ellipsis; /* 溢出用省略号*/
  295. -webkit-box-orient: vertical;/*伸缩盒子的子元素排列:从上到下*/
  296. }
  297. .cu-bar .search-form{
  298. background-color: white;
  299. }
  300. </style>