TestMobileList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view>
  3. <!--查询只能指定一个字段,请自行指定,生成时并未生成,以xxx代替-->
  4. <u-search :show-action="false" v-model="searchForm.xxx" @change="inputWord" margin="20rpx 50rpx"></u-search>
  5. <u-swipe-action>
  6. <view
  7. v-for="(row, index) in dataList"
  8. :key="index">
  9. <u-swipe-action-item @click="del(row.id)" :key="row.id" :threshold="60" duration="500"
  10. :options="options">
  11. <u-cell-group>
  12. <u-cell @click="edit(row.id)">
  13. <view slot="title" class="content">
  14. <view class="text-bold text-grey">
  15. <view class="ellipsis-description">
  16. 姓名:{{row.name}}
  17. </view>
  18. </view>
  19. <view class="text-bold text-grey">
  20. <view class="ellipsis-description">
  21. 年龄:{{row.age}}
  22. </view>
  23. </view>
  24. <view class="text-bold text-grey">
  25. <view class="ellipsis-description">
  26. 地区:{{row.area}}
  27. </view>
  28. </view>
  29. <view class="text-bold text-grey">
  30. <view class="ellipsis-description">
  31. 公司:{{ row.company && row.company.name }}
  32. </view>
  33. </view>
  34. <view class="text-bold text-grey">
  35. <view class="ellipsis-description">
  36. 部门:{{ row.office && row.office.name }}
  37. </view>
  38. </view>
  39. <view class="text-bold text-grey">
  40. <view class="ellipsis-description">
  41. 性别:{{ $dictUtils.getDictLabel("sex", row.sex, '-') }}
  42. </view>
  43. </view>
  44. <view class="text-bold text-grey">
  45. <view class="ellipsis-description">
  46. 头像:<view class="cu-avatar lg margin-left-sm" :style="{backgroundImage: 'url(' + row.teImage + ')' }"></view>
  47. </view>
  48. </view>
  49. <view class="text-bold text-grey">
  50. <view class="ellipsis-description">
  51. 单选框:{{ $dictUtils.getDictLabel("yes_no", row.isSingle, '-') }}
  52. </view>
  53. </view>
  54. <view class="text-bold text-grey">
  55. <view class="ellipsis-description">
  56. 多选框:{{row.cks.split(",").map( (item)=> { return $dictUtils.getDictLabel("interface_type", item, '-')}).join(",") }}
  57. </view>
  58. </view>
  59. <view class="text-bold text-grey">
  60. <view class="ellipsis-description">
  61. 多行文本框:{{row.textArea}}
  62. </view>
  63. </view>
  64. <view class="text-bold text-grey">
  65. <view class="ellipsis-description">
  66. 数字输入框:{{row.textNumber}}
  67. </view>
  68. </view>
  69. <view class="text-bold text-grey">
  70. <view class="ellipsis-description">
  71. 日期选择框:{{row.teDate}}
  72. </view>
  73. </view>
  74. <view class="text-bold text-grey">
  75. <view class="ellipsis-description">
  76. 邮箱:{{row.email}}
  77. </view>
  78. </view>
  79. <view class="text-bold text-grey">
  80. <view class="ellipsis-description">
  81. 手机号:{{row.phone}}
  82. </view>
  83. </view>
  84. <view class="text-bold text-grey">
  85. <view class="ellipsis-description">
  86. 电话:{{row.tel}}
  87. </view>
  88. </view>
  89. </view>
  90. </u-cell>
  91. </u-cell-group>
  92. </u-swipe-action-item>
  93. </view>
  94. </u-swipe-action>
  95. <uni-fab
  96. horizontal="right"
  97. vertical="bottom"
  98. @fabClick="add"
  99. ></uni-fab>
  100. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  101. <u-gap height="20" bgColor="#fff"></u-gap>
  102. </view>
  103. </template>
  104. <script>
  105. import testMobileService from '@/api/test/mobile/testMobileService'
  106. export default {
  107. data () {
  108. return {
  109. status: 'loadmore',
  110. searchForm: {
  111. name: ''
  112. },
  113. dataList: [],
  114. tablePage: {
  115. pages: 0,
  116. currentPage: 0,
  117. pageSize: 10,
  118. orders: [{ column: "a.create_time", asc: false }]
  119. },
  120. loading: false,
  121. options: [ {
  122. text: '删除',
  123. style: {
  124. backgroundColor: '#f56c6c'
  125. }
  126. }]
  127. }
  128. },
  129. onLoad() {
  130. this.loadmore()
  131. },
  132. methods: {
  133. // 新增
  134. add (){
  135. uni.navigateTo({
  136. url: '/pages/test/mobile/TestMobileForm'
  137. })
  138. },
  139. // 修改
  140. edit (id) {
  141. uni.navigateTo({
  142. url: '/pages/test/mobile/TestMobileForm?id='+id
  143. })
  144. },
  145. // 删除
  146. del (id) {
  147. uni.showModal({
  148. title: '提示',
  149. content: '您确认要删除数据吗',
  150. showCancel: true,
  151. success: (res) => {
  152. if (res.confirm) {
  153. testMobileService.delete(id).then((data)=>{
  154. uni.showToast({
  155. title: data,
  156. icon:"success"
  157. })
  158. this.doSearch()
  159. })
  160. }
  161. }
  162. });
  163. },
  164. // 输入监听
  165. inputWord(e){
  166. this.searchTimer && clearTimeout(this.searchTimer)
  167. this.searchTimer = setTimeout(()=>{
  168. this.doSearch()
  169. },300)
  170. },
  171. // 搜索
  172. doSearch(){
  173. this.dataList = [];
  174. this.tablePage.currentPage = 0;
  175. this.tablePage.pageSize = 10;
  176. this.tablePage.pages = 0;
  177. this.loadmore()
  178. },
  179. onReachBottom() {
  180. this.loadmore()
  181. },
  182. /*获取数据列表 */
  183. loadmore() {
  184. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  185. this.status = 'nomore';
  186. return;
  187. }
  188. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  189. //联网加载数据
  190. this.status = 'loading';
  191. testMobileService.list({
  192. 'current': this.tablePage.currentPage,
  193. 'size': this.tablePage.pageSize,
  194. 'orders': this.tablePage.orders,
  195. ...this.searchForm
  196. }).then((data) => {
  197. //追加新数据
  198. this.dataList=this.dataList.concat(data.records);
  199. this.tablePage.pages = data.pages;
  200. if(this.tablePage.pages <= this.tablePage.currentPage){
  201. this.status = 'nomore'
  202. } else {
  203. this.status = 'loadmore'
  204. }
  205. })
  206. }
  207. }
  208. }
  209. </script>