particulars.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view class="particulars">
  3. <view class="top">
  4. <text class="text" @click="showDrawer()">
  5. 筛选
  6. </text>
  7. <uni-drawer ref="showRight" mode="right" :width="340">
  8. <view class="close">
  9. <view class="par">
  10. <text class="tad">
  11. 仓库
  12. </text>
  13. <view class="th">
  14. <view class="td" :class="warehouseIndex == i ? 'active' : ''" v-for="(v,i) in warehouse"
  15. :key="i" @click="change(v,i,0)">
  16. {{v.name}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="par">
  21. <text class="tad">
  22. 品牌
  23. </text>
  24. <view class="th">
  25. <view class="td" :class="brandIndex == i ? 'active' : ''" v-for="(v,i) in brand" :key="i"
  26. @click="change(v,i,1)">
  27. {{v}}
  28. </view>
  29. </view>
  30. </view>
  31. <view class="par">
  32. <text class="tad">
  33. 是否转基因
  34. </text>
  35. <view class="th">
  36. <view class="td" :class="geneIndex == i ? 'active' : ''" v-for="(v,i) in gene" :key="i"
  37. @click="change(v,i,2)">
  38. {{v == -1 ? '全部' : v == 0 ? '转基因' : v== 1 ? '非转基因' : '其他'}}
  39. </view>
  40. </view>
  41. </view>
  42. <view class="par">
  43. <text class="tad">
  44. 等级
  45. </text>
  46. <view class="th">
  47. <view class="td" :class="levelIndex == i ? 'active' : ''" v-for="(v,i) in level" :key="i"
  48. @click="change(v,i,3)">
  49. {{v}}
  50. </view>
  51. </view>
  52. </view>
  53. <view class="par">
  54. <text class="tad">
  55. 容量
  56. </text>
  57. <view class="th">
  58. <view class="td" :class="capacityIndex == i ? 'active' : ''" v-for="(v,i) in capacity"
  59. :key="i" @click="change(v,i,4)">
  60. {{v}}
  61. </view>
  62. </view>
  63. </view>
  64. <view class="btn">
  65. <view class="" @click="reset()">
  66. 重置
  67. </view>
  68. <view class="" @click="confirm()">
  69. 确定
  70. </view>
  71. </view>
  72. </view>
  73. </uni-drawer>
  74. </view>
  75. <scroll-view scroll-y="true" class="main" @scrolltolower="more()">
  76. <view class="hint" v-if="wu">
  77. 暂无数据
  78. </view>
  79. <view class="tab" v-for="(v, i) in chartData" :key="i">
  80. <view class="th">
  81. <view class="">
  82. {{v.fullName}}
  83. </view>
  84. <view class="">
  85. 操作人: {{v.name}}
  86. </view>
  87. </view>
  88. <view class="th">
  89. <view class="">
  90. {{v.comeGo}}
  91. </view>
  92. <view class="">
  93. {{v.Num}}箱
  94. </view>
  95. </view>
  96. <view class="td">
  97. {{getTime(v.opTime)}}
  98. </view>
  99. </view>
  100. <uni-load-more :status="status" :content-text="contentText" />
  101. </scroll-view>
  102. <view class="bom">
  103. 合计: {{num}}箱
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. recordDetail,
  110. stockSearch
  111. } from '../../api/statistics.js'
  112. export default {
  113. data() {
  114. return {
  115. status: 'more',
  116. wu: false,
  117. showRight: false,
  118. showLeft: false,
  119. list: '',
  120. id: '',
  121. num: 0,
  122. BeginSingle: '',
  123. FinishSingle: '',
  124. chartData: '',
  125. brandIndex: 0,
  126. capacityIndex: 0,
  127. geneIndex: 0,
  128. levelIndex: 0,
  129. warehouseIndex: 0,
  130. brand: [],
  131. capacity: [],
  132. gene: [],
  133. level: [],
  134. warehouse: [],
  135. brandName: '',
  136. capacityName: '',
  137. geneName: '',
  138. levelName: '',
  139. warehouseName: '',
  140. page: 1,
  141. contentText: {
  142. contentdown: '上拉加载更多',
  143. contentrefresh: '加载中',
  144. contentnomore: '没有更多'
  145. },
  146. };
  147. },
  148. onLoad(options) {
  149. this.id = options.id
  150. this.name = options.name
  151. this.BeginSingle = options.startTime
  152. this.FinishSingle = options.endTime
  153. this.num = options.sum
  154. if (this.name) {
  155. uni.setNavigationBarTitle({
  156. title: this.name
  157. });
  158. }
  159. this.getData()
  160. },
  161. created() {},
  162. mounted() {
  163. this.getScreen()
  164. },
  165. methods: {
  166. async getData() {
  167. uni.showLoading({
  168. title: '加载中'
  169. });
  170. const res = await recordDetail({
  171. startTime: this.BeginSingle, // 开始时间
  172. endTime: this.FinishSingle, // 结束时间
  173. type: this.id,
  174. typeName: this.name,
  175. brand: this.brandName, // 品牌
  176. gene: this.geneName, // 转基因
  177. level: this.levelName, // 等级
  178. capacity: this.capacityName, // 容量
  179. warehouse: this.warehouseName, //仓库
  180. accessToken: uni.getStorageSync('tokenInfo'),
  181. account: uni.getStorageSync('account')
  182. })
  183. uni.hideLoading();
  184. this.list = res.data.list
  185. if(this.list.length === 0){
  186. this.wu = true
  187. }
  188. this.chartData = this.pagination(1, 20, this.list);
  189. },
  190. // 上拉加载更多
  191. more() {
  192. this.status = 'loading'
  193. this.page++;
  194. this.chartData =[...this.chartData, ...this.pagination(this.page, 20, this.list)]
  195. if (this.chartData.length===this.list.length){
  196. this.status = "noMore"
  197. }
  198. },
  199. // 数组分页
  200. pagination(pageNo, pageSize, array) {
  201. let offset = (pageNo - 1) * pageSize;
  202. return (offset + pageSize >= array.length) ? array.slice(offset, array.length) : array.slice(offset,
  203. offset + pageSize);
  204. },
  205. async getScreen() {
  206. const res = await stockSearch({})
  207. this.warehouse = res.data.data.warehouse
  208. this.warehouse.unshift({
  209. name: "全部仓库",
  210. code: 'ck00'
  211. })
  212. this.brand = res.data.data.brand
  213. this.brand.unshift("全部品牌")
  214. this.level = res.data.data.level
  215. this.level.unshift("全部等级")
  216. this.capacity = res.data.data.capacity
  217. this.capacity.unshift("全部容量")
  218. this.gene = res.data.data.gene
  219. this.gene.unshift(-1)
  220. },
  221. // 打开窗口
  222. showDrawer(e) {
  223. this.$refs.showRight.open()
  224. },
  225. // 关闭窗口
  226. closeDrawer(e) {
  227. this.$refs.showRight.close()
  228. },
  229. // 点击
  230. change(v, i, num) {
  231. if (num === 0) {
  232. this.warehouseIndex = i
  233. if (i == 0) {
  234. this.warehouseName = ''
  235. } else {
  236. this.warehouseName = v.name
  237. }
  238. } else if (num === 1) {
  239. this.brandIndex = i
  240. if (i == 0) {
  241. this.brandName = ''
  242. } else {
  243. this.brandName = v
  244. }
  245. } else if (num === 2) {
  246. this.geneIndex = i
  247. if (i == 0) {
  248. this.geneName = ''
  249. } else {
  250. this.geneName = v
  251. }
  252. } else if (num === 3) {
  253. this.levelIndex = i
  254. if (i == 0) {
  255. this.levelName = ''
  256. } else {
  257. this.levelName = v
  258. }
  259. } else if (num === 4) {
  260. this.capacityIndex = i
  261. if (i == 0) {
  262. this.capacityName = ''
  263. } else {
  264. this.capacityName = v
  265. }
  266. }
  267. },
  268. // 筛选重置
  269. reset() {
  270. this.brandIndex = 0
  271. this.capacityIndex = 0
  272. this.geneIndex = 0
  273. this.levelIndex = 0
  274. this.warehouseIndex = 0
  275. this.brandName = ''
  276. this.capacityName = ''
  277. this.geneName = ''
  278. this.levelName = ''
  279. this.warehouseName = ''
  280. },
  281. // 筛选确定
  282. confirm() {
  283. this.getData()
  284. this.closeDrawer()
  285. },
  286. // 获取时间
  287. getTime(time = new Date()) {
  288. let date = new Date(time);
  289. let year = date.getFullYear();
  290. let month = date.getMonth() + 1;
  291. let day = date.getDate();
  292. let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
  293. let minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()
  294. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  295. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  296. let timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute;
  297. return timer;
  298. },
  299. }
  300. }
  301. </script>
  302. <style lang="scss">
  303. .particulars {
  304. height: 100%;
  305. display: flex;
  306. flex-direction: column;
  307. justify-content: space-between;
  308. .top {
  309. height: 100rpx;
  310. line-height: 100rpx;
  311. text-align: right;
  312. background-color: #e40315;
  313. .text {
  314. padding: 30rpx;
  315. color: #fff;
  316. }
  317. .close {
  318. height: 100%;
  319. display: flex;
  320. flex-direction: column;
  321. justify-content: space-between;
  322. .par {
  323. text-align: left;
  324. padding: 20rpx;
  325. .th {
  326. display: flex;
  327. flex-wrap: wrap;
  328. .td {
  329. background-color: #eff3f6;
  330. height: 50rpx;
  331. line-height: 50rpx;
  332. padding: 0 20rpx;
  333. border-radius: 4px;
  334. margin: 0 10rpx 10rpx 0;
  335. }
  336. .active {
  337. background-color: #e40315;
  338. color: #fff;
  339. }
  340. }
  341. }
  342. .btn {
  343. height: 80rpx;
  344. padding: 10rpx;
  345. display: flex;
  346. margin-bottom: 20rpx;
  347. view {
  348. height: 100%;
  349. flex: 1;
  350. background-color: #e40315;
  351. border-right: 2rpx solid #fff;
  352. text-align: center;
  353. color: #fff;
  354. line-height: 80rpx;
  355. }
  356. }
  357. }
  358. }
  359. .main {
  360. height: calc(100% - 230rpx);
  361. padding: 0 20rpx;
  362. box-sizing: border-box;
  363. .hint {
  364. text-align: center;
  365. }
  366. .tab {
  367. padding: 15rpx 0;
  368. border-bottom: 1rpx solid #e3e3e3;
  369. &>view:nth-child(2) {
  370. margin: 10rpx 0;
  371. }
  372. .th {
  373. display: flex;
  374. justify-content: space-between;
  375. }
  376. .td {
  377. color: #818181;
  378. }
  379. }
  380. }
  381. .bom {
  382. height: 120rpx;
  383. border-top: 10rpx solid #f1f1f1;
  384. text-align: center;
  385. line-height: 120rpx;
  386. color: #e40315;
  387. font-size: 26rpx;
  388. }
  389. }
  390. </style>