code-item.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="bg-#fff b-radius-16 pd-24 mb-16 p-rtv b-radius">
  3. <!-- 状态标签 -->
  4. <view class="d-flex a-c j-ed" style="position: absolute; right: 0; top: 0">
  5. <view class="bg-#FAECE9 c-#F74C30 f-w-5 pd-10 pt-4 pb-4 f-s-20" style="border-radius: 0 16rpx 0 16rpx" v-if="item.status === '0'">追溯码生成中...</view>
  6. <view class="bg-#EBF6EE c-primary f-w-5 pd-10 pt-4 pb-4 f-s-20" style="border-radius: 0 16rpx 0 16rpx" v-else-if="item.downloadFlag === '0' && item.status !== '0'">未下载</view>
  7. <view class="bg-#E8F0F7 c-#2289E0 f-w-5 pd-10 pt-4 pb-4 f-s-20" style="border-radius: 0 16rpx 0 16rpx" v-else-if="item.downloadFlag === '1' && item.status !== '0'">已下载</view>
  8. </view>
  9. <!-- 主要内容 -->
  10. <view class="" @click="handleItemClick">
  11. <view class="d-flex a-c pb-10">
  12. <span class="f-s-28 c-#666">生成批号:</span>
  13. <span class="f-s-28 c-#333 f-w-500">{{ item.batchSn || '-' }}</span>
  14. </view>
  15. <view class="d-flex pb-10">
  16. <span class="f-s-28 c-#666">码段:</span>
  17. <span class="f-s-28 c-#333 f-w-500 flex1">{{ formatCodeRange }}</span>
  18. <up-icon v-if="showButtons" name="arrow-right" size="26rpx" color="#999"></up-icon>
  19. </view>
  20. <view class="d-flex a-c pb-10">
  21. <view class="w-50%">
  22. <span class="f-s-28 c-#666">生成数量:</span>
  23. <span class="f-s-28 c-#333 f-w-500">{{ item.sumCount }}个</span>
  24. </view>
  25. <view class="w-50%">
  26. <span class="f-s-28 c-#666">剩余数量:</span>
  27. <span class="f-s-28 c-#333 f-w-500">{{ getRemainingCount }}个</span>
  28. </view>
  29. </view>
  30. <view class="d-flex a-c pb-10">
  31. <span class="f-s-28 c-#666">备注:</span>
  32. <span class="f-s-28 c-#333 f-w-500">{{ item.remark || '-' }}</span>
  33. </view>
  34. <view class="d-flex a-c pb-20" style="flex-wrap: nowrap; border-bottom: 1rpx solid #f7f7f7">
  35. <view class="flex1 ov-hd d-flex a-c" style="min-width: 0">
  36. <span class="f-s-24 c-#666 w-s-no">操作人:</span>
  37. <span class="f-s-24 c-#999 f-w-500 ov-hd w-s-no tx-ov" style="display: inline-block">{{ item?.createByName }}</span>
  38. </view>
  39. <view class="ml-20" style="flex-shrink: 0">
  40. <span class="f-s-24 c-#666 w-s-no">生成时间:</span>
  41. <span class="f-s-24 c-#999 f-w-500" style="white-space: nowrap">{{ parseTime(item?.createTime) }}</span>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 底部按钮 -->
  46. <view class="d-flex a-c j-ed mt-24" v-if="showButtons">
  47. <!-- 追溯码生成中状态 -->
  48. <template v-if="item.status === '0'">
  49. <up-button type="primary" customStyle="height: 64rpx; font-size: 28rpx; border-radius: 8rpx; background-color: #37A954; color: #fff;width: 160rpx;" @click="handleRefresh"> 刷新 </up-button>
  50. </template>
  51. <!-- 未下载状态 -->
  52. <view class="d-flex j-ed a-c" v-else-if="item.downloadFlag === '0' && item.status !== '0'">
  53. <!-- <up-button class="mr-16"
  54. customStyle="height: 64rpx; font-size: 28rpx; border-radius: 8rpx; background-color: #18BECA; color: #fff; width: 200rpx;"
  55. @click="handleFindAgent">
  56. 找人代制作
  57. </up-button> -->
  58. <up-button type="primary" customStyle="height: 64rpx; font-size: 28rpx; border-radius: 8rpx; background-color: #37A954; color: #fff; width: 160rpx;" @click="handleDownload"> 下载 </up-button>
  59. </view>
  60. <!-- 已下载状态 -->
  61. <view v-else-if="item.downloadFlag === '1' && item.status !== '0'" class="d-flex j-ed a-c">
  62. <!-- <up-button class="mr-16"
  63. customStyle="height: 64rpx; font-size: 28rpx; border-radius: 8rpx; background-color: #2289E0; color: #fff;"
  64. @click="handleViewOrder">
  65. 查看代做订单
  66. </up-button> -->
  67. <up-button customStyle="height: 64rpx; font-size: 28rpx; border-radius: 8rpx; background-color: #91C747; color: #fff;" @click="handleReDownload"> 重新下载 </up-button>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script setup lang="ts">
  73. import { parseTime } from '@/utils/ruoyi';
  74. const props = withDefaults(
  75. defineProps<{
  76. item: any;
  77. showButtons?: boolean;
  78. }>(),
  79. {
  80. item: () => ({}),
  81. showButtons: true,
  82. },
  83. );
  84. const emit = defineEmits<{
  85. refresh: [id: number];
  86. download: [item: any];
  87. findAgent: [item: any];
  88. viewOrder: [item: any];
  89. reDownload: [item: any];
  90. itemClick: [item: any];
  91. }>();
  92. // 格式化码段范围
  93. const formatCodeRange = computed(() => {
  94. const start = props.item.startSn || 0;
  95. const end = props.item.endSn || 0;
  96. const prefix = props.item.prefix || '';
  97. if (start && end) {
  98. return `${prefix}${start} 至 ${prefix}${end}`;
  99. }
  100. return '-';
  101. });
  102. // 计算剩余数量
  103. const getRemainingCount = computed(() => {
  104. const sum = props.item.sumCount || 0;
  105. const use = props.item.useCount || 0;
  106. const voidCount = props.item.voidCount || 0;
  107. return sum - use - voidCount;
  108. });
  109. // 格式化时间
  110. // 处理刷新按钮点击
  111. const handleRefresh = () => {
  112. if (props.item.id) {
  113. emit('refresh', props.item.id);
  114. }
  115. };
  116. // 处理下载按钮点击
  117. const handleDownload = () => {
  118. emit('download', props.item);
  119. };
  120. // 处理找人代制作按钮点击
  121. const handleFindAgent = () => {
  122. emit('findAgent', props.item);
  123. };
  124. // 处理查看代做订单按钮点击
  125. const handleViewOrder = () => {
  126. emit('viewOrder', props.item);
  127. };
  128. // 处理重新下载按钮点击
  129. const handleReDownload = () => {
  130. emit('reDownload', props.item);
  131. };
  132. // 处理 item 点击
  133. const handleItemClick = () => {
  134. // 跳转到码详情页面
  135. uni.$u.route({
  136. type: 'navigateTo',
  137. url: '/plant/code/code-detail-list/index',
  138. params: { id: props.item.id },
  139. });
  140. emit('itemClick', props.item);
  141. };
  142. // 监听 item 变化,内部可以修改数据
  143. watch(
  144. () => props.item,
  145. (newVal) => {
  146. // 可以在这里处理 item 变化后的逻辑
  147. console.log('item 变化:', newVal);
  148. },
  149. { deep: true },
  150. );
  151. </script>
  152. <style scoped lang="scss"></style>