extraction-order.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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 :class="'item fl tc cr-gray ' + (nav_status_index == index ? 'cr-main' : '')" :data-index="index" @tap="nav_event">{{item.name}}</view>
  7. </block>
  8. </view>
  9. <movable-area class="wh-auto ht-auto">
  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="data-list padding-horizontal-main padding-top-main">
  13. <view v-for="(item, index) in data_list" :key="index" class="item padding-main border-radius-main oh bg-white spacing-mb">
  14. <view class="base oh br-b padding-bottom-main">
  15. <text class="cr-base">{{item.add_time}}</text>
  16. <text class="cr-main fr">{{item.status_name}}</text>
  17. </view>
  18. <view class="content margin-top">
  19. <block v-for="(fv,fi) in content_list">
  20. <view class="single-text margin-top-xs">
  21. <text class="cr-gray margin-right-xl">{{fv.name}}</text>
  22. <text class="cr-base">{{item[fv.field]}}</text>
  23. <text v-if="(fv.unit || null) != null" class="cr-gray">{{fv.unit}}</text>
  24. </view>
  25. </block>
  26. </view>
  27. <view v-if="item.status == 0" class="item-operation tr br-t-dashed padding-top-main margin-top-main">
  28. <button class="round bg-white br cr-base" type="default" size="mini" hover-class="none" :data-index="index" :data-oid="item.order_id" :data-uid="item.order_user_id" @tap="list_submit_take_event">取货</button>
  29. </view>
  30. </view>
  31. </view>
  32. <view v-else>
  33. <!-- 提示信息 -->
  34. <component-no-data :propStatus="data_list_loding_status"></component-no-data>
  35. </view>
  36. <!-- 结尾 -->
  37. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  38. </scroll-view>
  39. <!-- 拖拽按钮 -->
  40. <movable-view class="search-drag tc circle" direction="all" @tap="drag_event">
  41. <icon type="search" size="20"></icon>
  42. </movable-view>
  43. </movable-area>
  44. <!-- 取货 popup -->
  45. <component-popup :propShow="is_show_take_popup" propPosition="bottom" @onclose="take_popup_event_close">
  46. <view class="form-container bg-base padding-horizontal-main padding-top-main padding-bottom-xs">
  47. <view class="form-gorup tc bg-white margin-top-lg">
  48. <view class="form-gorup-title">取货码</view>
  49. <input type="number" :value="extraction_code" placeholder-class="cr-grey" class="cr-base" placeholder="请输入取货码" maxlength="4" @input="extraction_code_input_event">
  50. </view>
  51. <view class="form-gorup form-gorup-submit">
  52. <button class="bg-main br-main cr-white round text-size" type="default" hover-class="none" :disabled="form_submit_disabled_status" @tap="form_submit_take_event">确认</button>
  53. </view>
  54. </view>
  55. </component-popup>
  56. <!-- 搜索 popup -->
  57. <component-popup :propShow="is_show_search_popup" propPosition="bottom" @onclose="search_popup_event_close">
  58. <view class="form-container bg-base padding-horizontal-main padding-top-main padding-bottom-xs">
  59. <view class="form-gorup tc bg-white margin-top-lg">
  60. <view class="form-gorup-title">搜索条件</view>
  61. <input type="number" :value="search_keywords_value" placeholder-class="cr-grey" class="cr-base" placeholder="订单号/取货码" @input="search_input_keywords_event">
  62. </view>
  63. <view class="form-gorup form-gorup-submit">
  64. <button class="bg-main-pair br-main-pair cr-white round text-size" type="default" hover-class="none" :disabled="form_submit_disabled_status" @tap="search_submit_event">搜索</button>
  65. </view>
  66. </view>
  67. </component-popup>
  68. </view>
  69. </template>
  70. <script>
  71. const app = getApp();
  72. import componentPopup from "../../../../components/popup/popup";
  73. import componentNoData from "../../../../components/no-data/no-data";
  74. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  75. export default {
  76. data() {
  77. return {
  78. data_list: [],
  79. data_total: 0,
  80. data_page_total: 0,
  81. data_page: 1,
  82. data_list_loding_status: 1,
  83. data_bottom_line_status: false,
  84. params: null,
  85. nav_status_list: [
  86. { name: "全部", value: "-1" },
  87. { name: "待处理", value: "0" },
  88. { name: "已处理", value: "1" }
  89. ],
  90. nav_status_index: 0,
  91. is_show_take_popup: false,
  92. extraction_value: null,
  93. extraction_code: '',
  94. form_submit_disabled_status: false,
  95. is_show_search_popup: false,
  96. search_keywords_value: '',
  97. content_list: [
  98. {name: "订单号", field: "order_no"},
  99. {name: "支付金额", field: "pay_price", unit: "元"}
  100. ]
  101. };
  102. },
  103. components: {
  104. componentPopup,
  105. componentNoData,
  106. componentBottomLine
  107. },
  108. props: {},
  109. onLoad(params) {
  110. // 是否指定状态
  111. var nav_status_index = 0;
  112. if (params.status != undefined) {
  113. for (var i in this.nav_status_list) {
  114. if (this.nav_status_list[i]['value'] == params.status) {
  115. nav_status_index = i;
  116. break;
  117. }
  118. }
  119. }
  120. this.setData({
  121. params: params,
  122. nav_status_index: nav_status_index
  123. });
  124. this.init();
  125. },
  126. onShow() {
  127. // 分享菜单处理
  128. app.globalData.page_share_handle();
  129. },
  130. // 下拉刷新
  131. onPullDownRefresh() {
  132. this.setData({
  133. data_page: 1
  134. });
  135. this.get_data_list(1);
  136. },
  137. methods: {
  138. init() {
  139. var user = app.globalData.get_user_info(this, 'init');
  140. if (user != false) {
  141. // 用户未绑定用户则转到登录页面
  142. if (app.globalData.user_is_need_login(user)) {
  143. uni.redirectTo({
  144. url: "/pages/login/login?event_callback=init"
  145. });
  146. return false;
  147. } else {
  148. // 获取数据
  149. this.get_data_list();
  150. }
  151. } else {
  152. this.setData({
  153. data_list_loding_status: 0,
  154. data_bottom_line_status: false
  155. });
  156. }
  157. },
  158. // 获取数据
  159. get_data_list(is_mandatory) {
  160. // 分页是否还有数据
  161. if ((is_mandatory || 0) == 0) {
  162. if (this.data_bottom_line_status == true) {
  163. uni.stopPullDownRefresh();
  164. return false;
  165. }
  166. }
  167. // 加载loding
  168. uni.showLoading({
  169. title: '加载中...'
  170. });
  171. this.setData({
  172. data_list_loding_status: 1
  173. });
  174. // 参数
  175. var status = (this.nav_status_list[this.nav_status_index] || null) == null ? -1 : this.nav_status_list[this.nav_status_index]['value'];
  176. // 获取数据
  177. uni.request({
  178. url: app.globalData.get_request_url("order", "extraction", "distribution"),
  179. method: 'POST',
  180. data: {
  181. page: this.data_page,
  182. status: status || 0,
  183. keywords: this.search_keywords_value || ''
  184. },
  185. dataType: 'json',
  186. success: res => {
  187. uni.hideLoading();
  188. uni.stopPullDownRefresh();
  189. if (res.data.code == 0) {
  190. if (res.data.data.data.length > 0) {
  191. if (this.data_page <= 1) {
  192. var temp_data_list = res.data.data.data;
  193. } else {
  194. var temp_data_list = this.data_list || [];
  195. var temp_data = res.data.data.data;
  196. for (var i in temp_data) {
  197. temp_data_list.push(temp_data[i]);
  198. }
  199. }
  200. this.setData({
  201. data_list: temp_data_list,
  202. data_total: res.data.data.total,
  203. data_page_total: res.data.data.page_total,
  204. data_list_loding_status: 3,
  205. data_page: this.data_page + 1
  206. });
  207. // 是否还有数据
  208. this.setData({
  209. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  210. });
  211. } else {
  212. this.setData({
  213. data_list_loding_status: 0,
  214. data_list: [],
  215. data_bottom_line_status: false
  216. });
  217. }
  218. } else {
  219. this.setData({
  220. data_list_loding_status: 0
  221. });
  222. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  223. app.globalData.showToast(res.data.msg);
  224. }
  225. }
  226. },
  227. fail: () => {
  228. uni.hideLoading();
  229. uni.stopPullDownRefresh();
  230. this.setData({
  231. data_list_loding_status: 2
  232. });
  233. app.globalData.showToast('服务器请求出错');
  234. }
  235. });
  236. },
  237. // 滚动加载
  238. scroll_lower(e) {
  239. this.get_data_list();
  240. },
  241. // 导航事件
  242. nav_event(e) {
  243. this.setData({
  244. nav_status_index: e.currentTarget.dataset.index || 0,
  245. data_page: 1
  246. });
  247. this.get_data_list(1);
  248. },
  249. // 取件码弹层-开启
  250. list_submit_take_event(e) {
  251. this.setData({
  252. is_show_take_popup: true,
  253. extraction_code: '',
  254. extraction_value: {
  255. index: e.currentTarget.dataset.index,
  256. oid: e.currentTarget.dataset.oid,
  257. uid: e.currentTarget.dataset.uid
  258. }
  259. });
  260. },
  261. // 取件码弹层-关闭
  262. take_popup_event_close() {
  263. this.setData({
  264. is_show_take_popup: false
  265. });
  266. },
  267. // 取件码输入事件
  268. extraction_code_input_event(e) {
  269. this.setData({
  270. extraction_code: e.detail.value || ''
  271. });
  272. },
  273. // 取件提交
  274. form_submit_take_event(e) {
  275. // 参数
  276. if ((this.extraction_code || null) == null) {
  277. app.globalData.showToast('请输入取件码');
  278. return false;
  279. }
  280. if ((this.extraction_value || null) == null) {
  281. app.globalData.showToast('操作数据有误');
  282. return false;
  283. }
  284. // 提交表单
  285. var data = {
  286. id: this.extraction_value.oid,
  287. user_id: this.extraction_value.uid,
  288. extraction_code: this.extraction_code
  289. };
  290. this.setData({
  291. form_submit_disabled_status: true
  292. });
  293. uni.showLoading({
  294. title: '处理中...'
  295. });
  296. uni.request({
  297. url: app.globalData.get_request_url("take", "extraction", "distribution"),
  298. method: 'POST',
  299. data: data,
  300. dataType: 'json',
  301. success: res => {
  302. this.setData({
  303. form_submit_disabled_status: false
  304. });
  305. uni.hideLoading();
  306. if (res.data.code == 0) {
  307. var temp_data_list = this.data_list;
  308. var index = this.extraction_value.index;
  309. temp_data_list[index]['status'] = 1;
  310. temp_data_list[index]['status_name'] = '已处理';
  311. this.setData({
  312. is_show_take_popup: false,
  313. data_list: temp_data_list
  314. });
  315. app.globalData.showToast(res.data.msg, 'success');
  316. } else {
  317. app.globalData.showToast(res.data.msg);
  318. }
  319. },
  320. fail: () => {
  321. this.setData({
  322. form_submit_disabled_status: false
  323. });
  324. uni.hideLoading();
  325. app.globalData.showToast('服务器请求出错');
  326. }
  327. });
  328. },
  329. // 搜索弹层-开启
  330. drag_event(e) {
  331. this.setData({
  332. is_show_search_popup: true
  333. });
  334. },
  335. // 搜索弹层-关闭
  336. search_popup_event_close() {
  337. this.setData({
  338. is_show_search_popup: false
  339. });
  340. },
  341. // 搜索关键字输入事件
  342. search_input_keywords_event(e) {
  343. this.setData({
  344. search_keywords_value: e.detail.value || ''
  345. });
  346. },
  347. // 搜索确认事件
  348. search_submit_event(e) {
  349. this.setData({
  350. is_show_search_popup: false,
  351. data_page: 1
  352. });
  353. this.get_data_list(1);
  354. }
  355. }
  356. };
  357. </script>
  358. <style>
  359. @import './extraction-order.css';
  360. </style>