batchorder-list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view>
  3. <!-- 导航 -->
  4. <view class="nav-base bg-white">
  5. <block v-for="(item, index) in nav_status_list" :key="index">
  6. <view v-if="nav_status_index == index" class="item fl tc cr-main" :data-index="index" @tap="nav_event">{{item.name}}</view>
  7. <view v-else class="item fl tc" :data-index="index" @tap="nav_event">{{item.name}}</view>
  8. </block>
  9. </view>
  10. <!-- 数据列表 -->
  11. <scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav" @scrolltolower="scroll_lower" lower-threshold="60">
  12. <view v-if="data_list.length > 0" class="padding-horizontal-main padding-top-main">
  13. <view v-for="(item, index) in data_list" :key="index" class="list-item padding-horizontal-main padding-top-main border-radius-main bg-white oh spacing-mb">
  14. <view class="item-base oh br-b padding-bottom-main">
  15. <text class="fl cr-base">{{item.add_time}}</text>
  16. <text class="fr cr-red">{{item.status_name}}<text v-if="(item.is_under_line_text || null) != null">({{item.is_under_line_text}})</text></text>
  17. </view>
  18. <view class="br-b padding-vertical-main">
  19. <view class="cr-base">{{item.name}}</view>
  20. <view v-if="(item.describe || null) != null" class="cr-grey margin-top-xs">{{item.describe}}</view>
  21. </view>
  22. <block v-if="(item.detail_data || null) != null && item.detail_data.length > 0">
  23. <view v-for="(detail, di) in item.detail_data" :key="di" class="br-b-dashed oh padding-vertical-main">
  24. <block v-for="(fv,fi) in content_list">
  25. <view class="single-text margin-top-xs">
  26. <text class="cr-gray margin-right-xl">{{fv.name}}</text>
  27. <text class="cr-base">{{detail[fv.field]}}</text>
  28. <text v-if="(fv.unit || null) != null" class="cr-gray">{{fv.unit}}</text>
  29. </view>
  30. </block>
  31. </view>
  32. </block>
  33. </view>
  34. </view>
  35. <view v-else>
  36. <!-- 提示信息 -->
  37. <component-no-data :propStatus="data_list_loding_status"></component-no-data>
  38. </view>
  39. <!-- 结尾 -->
  40. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  41. </scroll-view>
  42. </view>
  43. </template>
  44. <script>
  45. const app = getApp();
  46. import componentNoData from "../../../../components/no-data/no-data";
  47. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  48. export default {
  49. data() {
  50. return {
  51. data_list: [],
  52. data_total: 0,
  53. data_page_total: 0,
  54. data_page: 1,
  55. data_list_loding_status: 1,
  56. data_bottom_line_status: false,
  57. params: null,
  58. nav_status_list: [
  59. { name: "全部", value: "-1" },
  60. { name: "待生效", value: "0" },
  61. { name: "进行中", value: "1" },
  62. { name: "已完成", value: "2" },
  63. { name: "已关闭", value: "3" },
  64. ],
  65. nav_status_index: 0,
  66. content_list: [
  67. {name: "描述", field: "describe"},
  68. {name: "备注", field: "note"},
  69. {name: "时间", field: "upd_time"},
  70. {name: "状态", field: "status_name"}
  71. ]
  72. };
  73. },
  74. components: {
  75. componentNoData,
  76. componentBottomLine
  77. },
  78. props: {},
  79. onLoad(params) {
  80. // 是否指定状态
  81. var nav_status_index = 0;
  82. if ((params.status || null) != null) {
  83. for (var i in this.nav_status_list) {
  84. if (this.nav_status_list[i]['value'] == params.status) {
  85. nav_status_index = i;
  86. break;
  87. }
  88. }
  89. }
  90. this.setData({
  91. params: params,
  92. nav_status_index: nav_status_index
  93. });
  94. // 数据加载
  95. this.init();
  96. },
  97. onShow() {
  98. // 分享菜单处理
  99. app.globalData.page_share_handle();
  100. },
  101. // 下拉刷新
  102. onPullDownRefresh() {
  103. this.setData({
  104. data_page: 1
  105. });
  106. this.get_data_list(1);
  107. },
  108. methods: {
  109. // 获取数据
  110. init() {
  111. var user = app.globalData.get_user_info(this, 'init');
  112. if (user != false) {
  113. // 用户未绑定用户则转到登录页面
  114. if (app.globalData.user_is_need_login(user)) {
  115. uni.redirectTo({
  116. url: "/pages/login/login?event_callback=init"
  117. });
  118. return false;
  119. } else {
  120. // 获取数据
  121. this.get_data_list();
  122. }
  123. } else {
  124. this.setData({
  125. data_list_loding_status: 0,
  126. data_bottom_line_status: false
  127. });
  128. }
  129. },
  130. // 获取数据
  131. get_data_list(is_mandatory) {
  132. // 分页是否还有数据
  133. if ((is_mandatory || 0) == 0) {
  134. if (this.data_bottom_line_status == true) {
  135. uni.stopPullDownRefresh();
  136. return false;
  137. }
  138. }
  139. // 加载loding
  140. uni.showLoading({
  141. title: '加载中...'
  142. });
  143. this.setData({
  144. data_list_loding_status: 1
  145. });
  146. // 参数
  147. var status = (this.nav_status_list[this.nav_status_index] || null) == null ? -1 : this.nav_status_list[this.nav_status_index]['value'];
  148. // 获取数据
  149. uni.request({
  150. url: app.globalData.get_request_url("index", "batchorder", "realstore"),
  151. method: 'POST',
  152. data: {
  153. page: this.data_page,
  154. status: status,
  155. oid: this.params.oid || 0
  156. },
  157. dataType: 'json',
  158. success: res => {
  159. uni.hideLoading();
  160. uni.stopPullDownRefresh();
  161. if (res.data.code == 0) {
  162. if (res.data.data.data.length > 0) {
  163. if (this.data_page <= 1) {
  164. var temp_data_list = res.data.data.data;
  165. } else {
  166. var temp_data_list = this.data_list || [];
  167. var temp_data = res.data.data.data;
  168. for (var i in temp_data) {
  169. temp_data_list.push(temp_data[i]);
  170. }
  171. }
  172. this.setData({
  173. data_list: temp_data_list,
  174. data_total: res.data.data.total,
  175. data_page_total: res.data.data.page_total,
  176. data_list_loding_status: 3,
  177. data_page: this.data_page + 1
  178. });
  179. // 是否还有数据
  180. this.setData({
  181. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  182. });
  183. } else {
  184. this.setData({
  185. data_list_loding_status: 0,
  186. data_list: [],
  187. data_bottom_line_status: false
  188. });
  189. }
  190. } else {
  191. this.setData({
  192. data_list_loding_status: 0
  193. });
  194. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  195. app.globalData.showToast(res.data.msg);
  196. }
  197. }
  198. },
  199. fail: () => {
  200. uni.hideLoading();
  201. uni.stopPullDownRefresh();
  202. this.setData({
  203. data_list_loding_status: 2,
  204. load_status: 1
  205. });
  206. app.globalData.showToast('服务器请求出错');
  207. }
  208. });
  209. },
  210. // 滚动加载
  211. scroll_lower(e) {
  212. this.get_data_list();
  213. },
  214. // 导航事件
  215. nav_event(e) {
  216. this.setData({
  217. nav_status_index: e.currentTarget.dataset.index || 0,
  218. data_page: 1
  219. });
  220. // 重新拉取数据
  221. this.get_data_list(1);
  222. }
  223. }
  224. };
  225. </script>
  226. <style>
  227. @import './batchorder-list.css';
  228. </style>