parric.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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="brandIndex == i ? 'active' : ''" v-for="(v,i) in brand" :key="i"
  15. @click="change(v,i,1)">
  16. {{v}}
  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="geneIndex == i ? 'active' : ''" v-for="(v,i) in gene" :key="i"
  26. @click="change(v,i,2)">
  27. {{v == -1 ? '全部' : v == 0 ? '转基因' : v== 1 ? '非转基因' : '其他'}}
  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="levelIndex == i ? 'active' : ''" v-for="(v,i) in level" :key="i"
  37. @click="change(v,i,3)">
  38. {{v}}
  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="capacityIndex == i ? 'active' : ''" v-for="(v,i) in capacity" :key="i"
  48. @click="change(v,i,4)">
  49. {{v}}
  50. </view>
  51. </view>
  52. </view>
  53. <view class="btn">
  54. <view class="" @click="reset()">
  55. 重置
  56. </view>
  57. <view class="" @click="confirm()">
  58. 确定
  59. </view>
  60. </view>
  61. </view>
  62. </uni-drawer>
  63. </view>
  64. <view class="main">
  65. <view class="hint" v-if="wu">
  66. 暂无数据
  67. </view>
  68. <view class="tab" v-for="(v, i) in chartData" :key="i">
  69. <view class="th">
  70. <view class="">
  71. {{v.name}}
  72. </view>
  73. <view class="">
  74. {{v.sendBox}}箱/{{v.sendTotal}}瓶
  75. </view>
  76. </view>
  77. <view class="th">
  78. <view class="">
  79. {{v.sendId}}
  80. </view>
  81. <view class="">
  82. {{getTime(v.sendTime)}}
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="bom">
  88. 合计: {{sendBox}}箱/{{sendTotal}}瓶
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import {productSearch,product} from '../../api/dealer.js'
  94. export default {
  95. data() {
  96. return {
  97. wu: false,
  98. sendBox: 0,
  99. sendTotal: 0,
  100. showRight: false,
  101. showLeft: false,
  102. id:'',
  103. BeginSingle: '',
  104. FinishSingle: '',
  105. chartData: '',
  106. brandIndex: 0,
  107. capacityIndex: 0,
  108. geneIndex: 0,
  109. levelIndex: 0,
  110. warehouseIndex: 0,
  111. brand: [],
  112. capacity: [],
  113. gene: [],
  114. level: [],
  115. warehouse: [],
  116. brandName: '',
  117. capacityName: '',
  118. geneName: '',
  119. levelName: '',
  120. warehouseName: '',
  121. date:''
  122. };
  123. },
  124. onLoad(options) {
  125. this.date = options.date
  126. this.name = options.name
  127. this.dealerName = options.dealerName
  128. if (this.name) {
  129. uni.setNavigationBarTitle({
  130. title: this.dealerName + '—' +this.name
  131. });
  132. }
  133. this.getData()
  134. },
  135. mounted() {
  136. this.getScreen()
  137. },
  138. methods: {
  139. async getData() {
  140. uni.showLoading({
  141. title: '加载中'
  142. });
  143. const res = await product({
  144. name: this.dealerName,
  145. month: this.date,
  146. typeName: this.name,
  147. brand: this.brandName,
  148. gene: this.gene,
  149. level: this.levelName,
  150. capacity: this.capacityName,
  151. accessToken: uni.getStorageSync('tokenInfo'),
  152. account: uni.getStorageSync('account')
  153. })
  154. uni.hideLoading();
  155. this.chartData = res.data.list
  156. if(this.chartData === 0){
  157. this.wu = true
  158. }
  159. let that = this
  160. res.data.list.forEach(v=>{
  161. that.sendBox += v.sendBox
  162. that.sendTotal += v.sendTotal
  163. })
  164. },
  165. async getScreen() {
  166. const res = await productSearch({
  167. name: this.dealerName,
  168. month: this.date,
  169. typeName: this.name,
  170. accessToken: uni.getStorageSync('tokenInfo'),
  171. account: uni.getStorageSync('account')
  172. })
  173. this.brand = res.data.data.brand
  174. this.brand.unshift("全部品牌")
  175. this.level = res.data.data.level
  176. this.level.unshift("全部等级")
  177. this.capacity = res.data.data.capacity
  178. this.capacity.unshift("全部容量")
  179. this.gene = res.data.data.gene
  180. this.gene.unshift(-1)
  181. },
  182. // 打开窗口
  183. showDrawer(e) {
  184. this.$refs.showRight.open()
  185. },
  186. // 关闭窗口
  187. closeDrawer(e) {
  188. this.$refs.showRight.close()
  189. },
  190. // 点击
  191. change(v, i, num) {
  192. if (num === 1) {
  193. this.brandIndex = i
  194. if (i == 0) {
  195. this.brandName = ''
  196. } else {
  197. this.brandName = v
  198. }
  199. } else if (num === 2) {
  200. this.geneIndex = i
  201. if (i == 0) {
  202. this.geneName = ''
  203. } else {
  204. this.geneName = v
  205. }
  206. } else if (num === 3) {
  207. this.levelIndex = i
  208. if (i == 0) {
  209. this.levelName = ''
  210. } else {
  211. this.levelName = v
  212. }
  213. } else if (num === 4) {
  214. this.capacityIndex = i
  215. if (i == 0) {
  216. this.capacityName = ''
  217. } else {
  218. this.capacityName = v
  219. }
  220. }
  221. },
  222. // 筛选重置
  223. reset() {
  224. this.brandIndex = 0
  225. this.capacityIndex = 0
  226. this.geneIndex = 0
  227. this.levelIndex = 0
  228. this.warehouseIndex = 0
  229. this.brandName = ''
  230. this.capacityName = ''
  231. this.geneName = ''
  232. this.levelName = ''
  233. this.warehouseName = ''
  234. },
  235. // 筛选确定
  236. confirm() {
  237. this.getData()
  238. this.closeDrawer()
  239. },
  240. // 获取时间
  241. getTime(time = new Date()) {
  242. let date = new Date(time);
  243. let year = date.getFullYear();
  244. let month = date.getMonth() + 1;
  245. let day = date.getDate();
  246. let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
  247. let minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()
  248. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  249. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  250. let timer = year + '-' + month + '-' + day + ' ' + hour + ':'+ minute;
  251. return timer;
  252. },
  253. }
  254. }
  255. </script>
  256. <style lang="scss">
  257. .particulars {
  258. height: 100%;
  259. display: flex;
  260. flex-direction: column;
  261. justify-content: space-between;
  262. .top {
  263. height: 100rpx;
  264. line-height: 100rpx;
  265. text-align: right;
  266. background-color: #e40315;
  267. .text {
  268. padding: 30rpx;
  269. color: #fff;
  270. }
  271. .close {
  272. height: 100%;
  273. display: flex;
  274. flex-direction: column;
  275. justify-content: space-between;
  276. .par {
  277. text-align: left;
  278. padding: 20rpx;
  279. .th {
  280. display: flex;
  281. flex-wrap: wrap;
  282. .td {
  283. background-color: #eff3f6;
  284. height: 50rpx;
  285. line-height: 50rpx;
  286. padding: 0 20rpx;
  287. border-radius: 4px;
  288. margin: 0 10rpx 10rpx 0;
  289. }
  290. .active {
  291. background-color: #e40315;
  292. color: #fff;
  293. }
  294. }
  295. }
  296. .btn {
  297. height: 80rpx;
  298. padding: 10rpx;
  299. display: flex;
  300. margin-bottom: 20rpx;
  301. view {
  302. height: 100%;
  303. flex: 1;
  304. background-color: #e40315;
  305. border-right: 2rpx solid #fff;
  306. text-align: center;
  307. color: #fff;
  308. line-height: 80rpx;
  309. }
  310. }
  311. }
  312. }
  313. .main {
  314. flex: 1;
  315. overflow-y: scroll;
  316. padding: 0 20rpx;
  317. .hint{
  318. text-align: center;
  319. }
  320. .tab {
  321. padding: 15rpx 0;
  322. border-bottom: 1rpx solid #e3e3e3;
  323. &>view:nth-child(2) {
  324. margin: 10rpx 0;
  325. }
  326. .th {
  327. display: flex;
  328. justify-content: space-between;
  329. }
  330. .td {
  331. color: #818181;
  332. }
  333. }
  334. }
  335. .bom {
  336. height: 120rpx;
  337. border-top: 10rpx solid #f1f1f1;
  338. text-align: center;
  339. line-height: 120rpx;
  340. color: #e40315;
  341. font-size: 26rpx;
  342. }
  343. }
  344. </style>