index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <!-- <Water></Water> -->
  3. <view class="nav" :style="{ paddingTop: statusBarHeight + 'px' }">
  4. <text class="nav-back" :style="{ top: statusBarHeight + 'px' }" @click="onBack"></text>
  5. <view class="nav-title">{{ title }}</view>
  6. </view>
  7. <view class="page">
  8. <view class="list-container" :style="{ paddingTop: statusBarHeight + 60 + 'px' }">
  9. <view v-for="(prd, i) in products" :key="'prd-' + i">
  10. <view class="section-title">感冒灵</view>
  11. <view class="card product-card">
  12. <view class="customer-row" v-for="(c, j) in prd.customers" :key="'cust-' + j">
  13. <text class="customer-label">上游客户:</text>
  14. <text class="customer-name" @click.stop="toggleCustomer(i, j)">{{
  15. c.name
  16. }}</text>
  17. <text class="expand-tag" @click.stop="toggleCustomer(i, j)">{{
  18. c.expanded ? "收起" : "展开"
  19. }}</text>
  20. </view>
  21. <view class="table-card" v-for="(c, j) in prd.customers" :key="'tbl-' + j" v-show="c.expanded">
  22. <scroll-view scroll-x="true" class="table-scroll">
  23. <view class="blk-table">
  24. <view class="blk-header">
  25. <view class="th col-region">货源片区</view>
  26. <view class="th col-qty">数量</view>
  27. <view class="th col-batch">批号</view>
  28. <view class="th col-sample">监管码样本(抽样)</view>
  29. <view class="th col-terminal">终端到达数量</view>
  30. </view>
  31. <view class="blk-body">
  32. <view class="blk-row" v-for="(row, idx) in c.details" :key="'row-' + idx">
  33. <view class="td col-region">{{ row.region }}</view>
  34. <view class="td col-qty">{{ row.quantity }}</view>
  35. <view class="td col-batch">{{ row.batchNo }}</view>
  36. <view class="td col-sample">{{ row.sample }}</view>
  37. <view class="td col-terminal">{{ row.arrivalQty }}</view>
  38. </view>
  39. <view v-if="!c.details || c.details.length === 0" class="empty-row">暂无数据</view>
  40. </view>
  41. </view>
  42. </scroll-view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import Water from "@/components/water/water.vue";
  51. export default {
  52. components: {
  53. Water,
  54. },
  55. data() {
  56. return {
  57. statusBarHeight: 20,
  58. title: "黑名单详情",
  59. products: [],
  60. };
  61. },
  62. onLoad(options) {
  63. const info = uni.getSystemInfoSync();
  64. this.statusBarHeight = info.statusBarHeight || 20;
  65. const name =
  66. options && options.name ? decodeURIComponent(options.name) : "";
  67. this.title = name || "黑名单详情";
  68. this.products = this.generateMockProducts(name || "感冒灵");
  69. },
  70. methods: {
  71. onBack() {
  72. try {
  73. uni.navigateBack();
  74. } catch (e) { }
  75. },
  76. toggleCustomer(i, j) {
  77. const expanded = this.products[i].customers[j].expanded;
  78. this.products[i].customers.forEach((c) => (c.expanded = false));
  79. this.$set(this.products[i].customers[j], "expanded", !expanded);
  80. },
  81. generateMockProducts(drugName) {
  82. const makeDetails = (n = 3) =>
  83. Array.from({ length: n }).map((_, idx) => ({
  84. region: ["广东", "江苏", "四川", "山东"][idx % 4],
  85. quantity: 100 + idx * 20,
  86. batchNo: `B${String(202400 + idx)}`,
  87. sample: `抽样${10 + idx}枚`,
  88. arrivalQty: 90 + idx * 15,
  89. }));
  90. return [
  91. {
  92. name: drugName,
  93. customers: [
  94. { name: "公司A", expanded: false, details: makeDetails(3) },
  95. { name: "公司B", expanded: false, details: makeDetails(2) },
  96. ],
  97. },
  98. {
  99. name: drugName,
  100. customers: [
  101. { name: "公司A", expanded: true, details: makeDetails(4) },
  102. { name: "公司C", expanded: false, details: makeDetails(3) },
  103. ],
  104. },
  105. ];
  106. },
  107. },
  108. };
  109. </script>
  110. <style scoped>
  111. .nav {
  112. position: fixed;
  113. top: 0;
  114. left: 0;
  115. right: 0;
  116. height: 44px;
  117. background-color: #2c69ff;
  118. display: flex;
  119. align-items: center;
  120. justify-content: center;
  121. z-index: 10;
  122. }
  123. .nav-title {
  124. font-size: 36rpx;
  125. color: #fff;
  126. font-weight: 700;
  127. }
  128. .nav-back {
  129. position: absolute;
  130. left: 40rpx;
  131. top: 12rpx;
  132. width: 20rpx;
  133. height: 20rpx;
  134. color: #fff;
  135. border-left: 3rpx solid #fff;
  136. border-bottom: 3rpx solid #fff;
  137. transform: rotate(45deg) translateY(56rpx);
  138. margin-left: 40rpx;
  139. margin-top: -6rpx;
  140. }
  141. .page {
  142. min-height: 100vh;
  143. background: #f3f6f9;
  144. }
  145. .section-title {
  146. position: relative;
  147. font-size: 30rpx;
  148. font-weight: bold;
  149. color: #2c69ff;
  150. margin-left: 24rpx;
  151. }
  152. .section-title::after {
  153. content: "";
  154. position: absolute;
  155. left: -20rpx;
  156. bottom: 11rpx;
  157. width: 8rpx;
  158. height: 50%;
  159. background: #2c69ff;
  160. border-radius: 10px;
  161. }
  162. .list-container {
  163. padding: 0 24rpx 24rpx;
  164. box-sizing: border-box;
  165. }
  166. .card {
  167. margin: 24rpx;
  168. background: #fff;
  169. border-radius: 16rpx;
  170. font-size: 30rpx;
  171. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  172. }
  173. .product-card {
  174. padding: 24rpx;
  175. }
  176. .product-title {
  177. font-size: 32rpx;
  178. font-weight: bold;
  179. color: #333;
  180. margin-bottom: 16rpx;
  181. }
  182. .customer-row {
  183. display: flex;
  184. align-items: center;
  185. padding: 12rpx 0;
  186. border-bottom: 1rpx solid #f0f0f0;
  187. }
  188. .customer-row:last-child {
  189. border-bottom: none;
  190. }
  191. .customer-label {
  192. font-size: 28rpx;
  193. color: #666;
  194. margin-right: 10rpx;
  195. }
  196. .customer-name {
  197. font-size: 28rpx;
  198. color: #2c69ff;
  199. }
  200. .expand-tag {
  201. margin-left: auto;
  202. font-size: 26rpx;
  203. color: #2c69ff;
  204. }
  205. .table-card {
  206. padding: 0;
  207. overflow: hidden;
  208. margin-top: 16rpx;
  209. }
  210. .table-scroll {
  211. width: 100%;
  212. }
  213. .blk-table {
  214. min-width: 1060rpx;
  215. border-top: 1rpx solid #eee;
  216. border-left: 1rpx solid #eee;
  217. }
  218. .blk-header {
  219. display: flex;
  220. background: #f5f7fa;
  221. font-size: 26rpx;
  222. font-weight: bold;
  223. color: #333;
  224. }
  225. .blk-body {
  226. font-size: 26rpx;
  227. color: #666;
  228. }
  229. .blk-row {
  230. display: flex;
  231. border-bottom: 1rpx solid #eee;
  232. }
  233. .th,
  234. .td {
  235. padding: 16rpx 10rpx;
  236. border-right: 1rpx solid #eee;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. text-align: center;
  241. word-break: break-all;
  242. box-sizing: border-box;
  243. flex-shrink: 0;
  244. }
  245. .th {
  246. border-bottom: 1rpx solid #eee;
  247. }
  248. .empty-row {
  249. padding: 30rpx;
  250. text-align: center;
  251. color: #999;
  252. }
  253. .col-region {
  254. width: 200rpx;
  255. }
  256. .col-qty {
  257. width: 140rpx;
  258. }
  259. .col-batch {
  260. width: 200rpx;
  261. }
  262. .col-sample {
  263. width: 300rpx;
  264. }
  265. .col-terminal {
  266. width: 220rpx;
  267. }
  268. </style>