index.vue 6.4 KB

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