productItem.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="bgcolor productItem">
  3. <div class="navBarTOP">
  4. <van-nav-bar class="navBar" title="产品列表" left-arrow @click-left="onClickLeft">
  5. <template #right>
  6. <span style="color: #0057ba" @click="placeOrderFn"> 去下单 </span>
  7. </template>
  8. </van-nav-bar>
  9. </div>
  10. <div class="lineGrey"></div>
  11. <div class="lineGrey"></div>
  12. <div class="lineGrey"></div>
  13. <div class="lineGrey"></div>
  14. <div class="lineGrey"></div>
  15. <div class="container" style="width: 100%; margin: 0 auto">
  16. <van-tabs class="myTab" type="card" v-model="tabVal" color="#0057ba" @change="tabChange">
  17. <van-tab :title="timeData + '下单SKU'" name="0"></van-tab>
  18. <van-tab title="建议下单SKU" name="1"></van-tab>
  19. </van-tabs>
  20. <div class="tips" v-if="tabVal == '1'">
  21. <p style="font-weight: bold; font-size: 16px">建议下单规则:</p>
  22. <p>①计算该店所在销售部同店型门店:滚动3个月DIS/OMS下单的TOP产品</p>
  23. <p>②已售品项 VS TOP产品,输出未下单产品TOP50如下</p>
  24. </div>
  25. <div
  26. v-for="item in list"
  27. v-if="list.length"
  28. style="display: flex; flex-direction: column; align-items: center">
  29. <p
  30. style="
  31. font-weight: bold;
  32. font-size: 16px;
  33. text-align: center;
  34. background: #d6eaff;
  35. margin: 0;
  36. padding: 10px 0;
  37. width: 94%;
  38. ">
  39. &nbsp;&nbsp;&nbsp;{{ item.m01Name }}
  40. </p>
  41. <el-table class="table-headermd1" :data="item.productDetailList" border>
  42. <el-table-column label="物料名称" prop="productName" align="center" />
  43. <el-table-column label="规格" prop="productSku" align="center" width="120px" />
  44. </el-table>
  45. </div>
  46. <van-empty v-if="list.length == 0" />
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import { getItemList } from '@/api';
  52. import { getOrderUrlByStoreId } from '@/api/inventory';
  53. export default {
  54. data() {
  55. return {
  56. list: [],
  57. tabVal: '0',
  58. detail: null,
  59. timeData: '',
  60. };
  61. },
  62. activated() {
  63. this.getMonth();
  64. this.getMyInventoryList();
  65. },
  66. methods: {
  67. getMonth() {
  68. // 获取当前日期
  69. var currentDate = new Date();
  70. // 获取当前月份
  71. var currentMonth = currentDate.getMonth();
  72. // 获取当前年份
  73. // var currentYear = currentDate.getFullYear();
  74. var previousMonthDate1 = new Date();
  75. if (currentDate.getDate() == 1) {
  76. previousMonthDate1.setMonth(currentMonth - 1);
  77. } else {
  78. }
  79. var previousMonth1 = previousMonthDate1.getMonth();
  80. var previousYear1 = previousMonthDate1.getFullYear();
  81. // 计算前三个月的年份和月份
  82. var previousMonthDate = new Date();
  83. if (currentDate.getDate() == 1) {
  84. previousMonthDate.setMonth(currentMonth - 3);
  85. } else {
  86. previousMonthDate.setMonth(currentMonth - 2);
  87. }
  88. 1;
  89. var previousMonth = previousMonthDate.getMonth();
  90. var previousYear = previousMonthDate.getFullYear();
  91. //前三个月
  92. if (previousYear1 == previousYear) {
  93. var formattedPreviousMonth1 = previousYear1 + '-' + (previousMonth1 + 1);
  94. // 格式化年份和月份
  95. var formattedPreviousMonth = previousYear + '-' + (previousMonth + 1);
  96. this.timeData =
  97. formattedPreviousMonth.split('-')[1] + '-' + formattedPreviousMonth1.split('-')[1] + '月';
  98. } else {
  99. var formattedPreviousMonth1 = previousYear1 + '年' + (previousMonth1 + 1) + '月';
  100. // .toString().padStart(2, '0');
  101. // 格式化年份和月份
  102. var formattedPreviousMonth = previousYear + '年' + (previousMonth + 1) + '月';
  103. this.timeData = formattedPreviousMonth + '-' + formattedPreviousMonth1;
  104. }
  105. },
  106. tabChange(name) {
  107. this.tabVal = name;
  108. this.setListData();
  109. // this.getMyInventoryList();
  110. },
  111. onSelect(action) {
  112. this.$router.push({
  113. path: '/material',
  114. query: {
  115. tabVal: action,
  116. },
  117. });
  118. },
  119. getMyInventoryList() {
  120. let loading1 = this.$toast.loading({
  121. duration: 0,
  122. message: '加载中...',
  123. forbidClick: true,
  124. });
  125. getItemList({ storeCode: this.$route.query.storeCode }).then((res) => {
  126. loading1.clear();
  127. if (res.code == 200) {
  128. this.loading = false;
  129. this.detail = res.data;
  130. this.setListData();
  131. } else {
  132. this.$toast.fail(res.msg);
  133. }
  134. });
  135. },
  136. setListData() {
  137. this.list = this.tabVal == '0' ? this.detail.threeMonthItemList : this.detail.adviceItemList;
  138. },
  139. placeOrderFn() {
  140. let loading1 = this.$toast.loading({
  141. duration: 0,
  142. message: '加载中...',
  143. forbidClick: true,
  144. });
  145. getOrderUrlByStoreId({
  146. storeId: this.$route.query.id,
  147. from: this.$route.query.from || '',
  148. }).then((res) => {
  149. loading1.clear();
  150. if (res.code == 200 && res.data) {
  151. window.location.href = res.data;
  152. } else {
  153. this.Toast({
  154. message: res.msg,
  155. duration: 5000,
  156. });
  157. }
  158. });
  159. },
  160. onClickLeft() {
  161. this.$router.go(-1);
  162. },
  163. },
  164. };
  165. </script>
  166. <style lang="scss">
  167. .productItem {
  168. .container {
  169. background-color: #fff;
  170. padding-bottom: 30px;
  171. .myTab {
  172. margin-bottom: 10px;
  173. .van-tabs__nav--card {
  174. margin: 0 !important;
  175. border-left: 0;
  176. border-right: 0;
  177. }
  178. .van-tabs__wrap,
  179. .van-tabs__nav--card {
  180. height: 39px;
  181. }
  182. .van-tab {
  183. line-height: 40px;
  184. }
  185. }
  186. .myList {
  187. .van-cell {
  188. padding: 0;
  189. &:after {
  190. border-bottom: none;
  191. }
  192. }
  193. }
  194. .tips {
  195. width: 94% !important;
  196. margin: 0 auto;
  197. padding-bottom: 10px;
  198. p {
  199. line-height: 25px;
  200. margin: 0;
  201. }
  202. }
  203. }
  204. }
  205. </style>
  206. <style lang="scss">
  207. .productItem {
  208. .table-headermd1 {
  209. font-size: 16px;
  210. text-align: center;
  211. position: initial;
  212. width: 94% !important;
  213. margin: 0 auto;
  214. }
  215. .table-headermd1 .el-table__header,
  216. .table-headermd1 .el-table__body {
  217. width: 100% !important;
  218. }
  219. // .table-headermd1 col {
  220. // width: 5.8rem;
  221. // }
  222. .table-headermd1 col:nth-child(2),
  223. .table-headermd1 col:nth-child(4),
  224. // .table-headermd1 col:nth-child(3) {
  225. // width: 5rem;
  226. // }
  227. .table-headermd1 .van-cell {
  228. padding: 0 4px;
  229. height: 100%;
  230. }
  231. .table-headermd1 th.el-table__cell > .cell {
  232. padding: 0 4px;
  233. }
  234. .table-headermd1 th.el-table__cell {
  235. background-color: #f3f9ff;
  236. color: #000;
  237. }
  238. .table-headermd1 .el-table__cell {
  239. padding: 4px 0;
  240. }
  241. .el-table__body {
  242. .cell {
  243. font-size: 14px;
  244. }
  245. }
  246. }
  247. </style>