index.vue.btl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <%
  3. var searchCount = 0;
  4. var row = 0;
  5. %>
  6. <% for(var i = 0; i < configList.~size; i++) { %>
  7. <% if(!configList[i].needTableId && configList[i].needPage) { searchCount ++; }%>
  8. <% } %>
  9. <% if (searchCount > 0) { %>
  10. <% for(var i = 0; i < configList.~size; i++) { %>
  11. <% if(!configList[i].needTableId && configList[i].needPage) { row ++; %>
  12. <% if(row <= 1) { %>
  13. <snowy-search placeholder="请输入${configList[i].fieldRemark}" v-model="searchFormState.${configList[i].fieldNameCamelCase}" @confirm="loadData(true)" @clear="loadData(true)" :enableSenior="true" @seniorSearch="$refs.searchRef.open()"></snowy-search>
  14. <% } %>
  15. <% } %>
  16. <% } %>
  17. <search ref="searchRef" :searchFormState="searchFormState" @confirm="loadData(true)"></search>
  18. <% } %>
  19. <view class="${busName}-list">
  20. <view class="item" v-for="(item, index) in ${classNameFirstLower}Data" :key="index" :index="index" @tap="moreTapItem(item, index)">
  21. <% for(var i = 0; i < configList.~size; i++) { %>
  22. <% if(!configList[i].needTableId && configList[i].whetherTable && configList[i].fieldNameCamelCase != 'tenantId') { %>
  23. <uv-row customStyle="margin-bottom: 15rpx">
  24. <uv-col :span="1">
  25. <uv-icon size="18" name="tags-fill" color="#5677fc"></uv-icon>
  26. </uv-col>
  27. <uv-col :span="5">
  28. <view class="item-left">${configList[i].fieldRemark}</view>
  29. </uv-col>
  30. <uv-col :span="6" textAlign="right">
  31. <view class="item-right snowy-bold snowy-ellipsis"> {{ item.${configList[i].fieldNameCamelCase} }} </view>
  32. </uv-col>
  33. </uv-row>
  34. <% } %>
  35. <% } %>
  36. </view>
  37. </view>
  38. <snowy-empty :fixed="true" v-show="$xeu.isEmpty(${classNameFirstLower}Data)" />
  39. <snowy-float-btn v-if="$snowy.hasPerm('mobile${className}Add')" @click="add"></snowy-float-btn>
  40. <more ref="moreRef" @handleOk="loadData(true)"></more>
  41. </template>
  42. <script setup name="${busName}">
  43. <% if (searchCount > 0) { %>
  44. import search from './search.vue'
  45. <% } %>
  46. import { ${classNameFirstLower}Page } from '@/api/${moduleName}/${classNameFirstLower}Api'
  47. import more from './more.vue'
  48. import { onLoad, onShow, onReady, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"
  49. import { reactive, ref, getCurrentInstance } from "vue"
  50. const { proxy } = getCurrentInstance()
  51. const searchFormState = reactive({
  52. <% if (searchCount > 0) { %>
  53. <% for(var i = 0; i < configList.~size; i++) { %>
  54. <% if(!configList[i].needTableId && configList[i].needPage) { %>
  55. ${configList[i].fieldNameCamelCase}: '',
  56. <% } %>
  57. <% } %>
  58. <% } %>
  59. })
  60. const parameter = reactive({
  61. current: 1,
  62. size: 10
  63. })
  64. const ${classNameFirstLower}Data = ref([])
  65. const loadData = (isReset) => {
  66. if (isReset) {
  67. parameter.current = 1
  68. ${classNameFirstLower}Data.value = []
  69. }
  70. Object.assign(parameter, searchFormState)
  71. ${classNameFirstLower}Page(parameter).then(res => {
  72. if (uni.$xeu.isEmpty(res?.data?.records)){
  73. return
  74. }
  75. ${classNameFirstLower}Data.value = ${classNameFirstLower}Data.value.concat(res.data.records)
  76. parameter.current++
  77. }).finally(()=>{
  78. uni.stopPullDownRefresh()
  79. })
  80. }
  81. loadData(true)
  82. onShow(() => {
  83. uni.$once('formBack', (data) => {
  84. loadData(true)
  85. })
  86. })
  87. // 下拉刷新
  88. onPullDownRefresh(() => {
  89. loadData(true)
  90. })
  91. // 上拉加载
  92. onReachBottom(() => {
  93. loadData()
  94. })
  95. // 新增
  96. const add = () => {
  97. uni.navigateTo({
  98. url: '/pages/${moduleName}/${busName}/form'
  99. })
  100. }
  101. // 更多操作
  102. const moreRef = ref()
  103. const moreTapItem = (item, index) => {
  104. moreRef.value.open(item)
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .${busName}-list {}
  109. .item {
  110. background: #ffffff;
  111. margin: 20rpx 0;
  112. padding: 25rpx;
  113. box-shadow: 0 1px 2px #ccc;
  114. border-radius: 15rpx;
  115. .item-left {
  116. color: #999;
  117. font-size: 26rpx;
  118. }
  119. .item-right {
  120. font-size: 26rpx;
  121. }
  122. }
  123. .item:hover {
  124. box-shadow: 1upx 5upx 5upx #5677fc;
  125. }
  126. </style>