index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="uni-column container" >
  3. <scroll-view class="scroll-container" scroll-y>
  4. <view v-for="(item, index) in listData" :key="index" :class="{'list-item':true,'selected':isSelected(item)}"
  5. @click="handleSelection(item,index)">
  6. <view class="title-container uni-row">
  7. <view class="title uni-row">
  8. <text class="label">{{ item['door'] }}</text>
  9. <text class="label code">{{ item['process'] }}</text>
  10. <text class="label code" style="margin-left: 16rpx;">→</text>
  11. <text class="label code" style="margin-left: 16rpx;">{{ item['car'] }}</text>
  12. </view>
  13. <view class="right-info uni-row">
  14. <view class="uni-row"><text class="label right" @click="handleDeleteTurnover(item)">删除</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="item-info uni-row"> <text class="label ">产品描述</text>
  19. <text class="label right" style="color: #000000;">{{ item['description'] }}</text>
  20. </view>
  21. <view class="item-info uni-row"> <text class="label">批次</text>
  22. <text class="label right ">{{ item['batch'] }}</text>
  23. </view>
  24. <view class="item-info uni-row">
  25. <text class="label">箱数</text>
  26. <text class="label right">{{ item['cases'] }}</text>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">箱号</text>
  30. <text class="label right">{{ item['caseNumber']}}</text>
  31. </view>
  32. </view>
  33. </scroll-view>
  34. <view class="bottom uni-row">
  35. <button class="bottom-btn left-btn ">继续扫码</button>
  36. <button class="bottom-btn right-btn" @click="handleStartTurnover(null)">确认周转</button>
  37. </view>
  38. <dialog-turnoverTask ref="turnoverTaskDialog" />
  39. </view>
  40. </template>
  41. <script setup>
  42. import {
  43. ref
  44. } from 'vue'
  45. import {
  46. onLoad,
  47. onReady
  48. } from '@dcloudio/uni-app'
  49. onLoad((option) => {
  50. listData.value = JSON.parse(option.turnoverList);
  51. })
  52. const active = ref(false)
  53. const selection = ref([])
  54. const turnoverTaskDialog = ref(null)
  55. const listData = ref([
  56. //{
  57. // door: "A门",
  58. // process: "粗磨",
  59. // car: "NC车",
  60. // description: "万博_039561419_15*110.1",
  61. // batch: "DC23727410070",
  62. // cases: 5,
  63. // caseNumber: "X12522、X55222、X15522、J5211、J5211"
  64. // },
  65. // {
  66. // door: "A门",
  67. // process: "粗磨",
  68. // car: "NC车",
  69. // description: "万博_039561419_15*110.1",
  70. // batch: "DC23727410070",
  71. // cases: 5,
  72. // caseNumber: "X12522、X55222、X15522、J5211、J5211"
  73. // },
  74. // {
  75. // door: "A门",
  76. // process: "粗磨",
  77. // car: "NC车",
  78. // description: "万博_039561419_15*110.1",
  79. // batch: "DC23727410070",
  80. // cases: 5,
  81. // caseNumber: "X12522、X55222、X15522、J5211、J5211"
  82. // },
  83. // {
  84. // door: "A门",
  85. // process: "粗磨",
  86. // car: "NC车",
  87. // description: "万博_039561419_15*110.1",
  88. // batch: "DC23727410070",
  89. // cases: 5,
  90. // caseNumber: "X12522、X55222、X15522、J5211、J5211"
  91. // },
  92. // {
  93. // door: "A门",
  94. // process: "粗磨",
  95. // car: "NC车",
  96. // description: "万博_039561419_15*110.1",
  97. // batch: "DC23727410070",
  98. // cases: 5,
  99. // caseNumber: "X12522、X55222、X15522、J5211、J5211"
  100. // }
  101. ])
  102. const handleStartTurnover = () => {
  103. if(selection.value.length >0) {
  104. turnoverTaskDialog.value.open(selection.value)
  105. }
  106. else {
  107. uni.showToast({
  108. title: '未选中周转内容',
  109. icon:'error',
  110. duration: 1000//1后消失
  111. });
  112. }
  113. // 调用子组件中的方法
  114. }
  115. const isSelected = (item) => {
  116. return selection.value.includes(item);
  117. }
  118. const handleSelection = (item, index) => {
  119. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  120. if (buttonIndex > -1) {
  121. selection.value.splice(buttonIndex, 1); // 取消选中
  122. } else {
  123. selection.value.push(item); // 选中
  124. }
  125. console.log(selection.value, "selection");
  126. }
  127. function handleDeleteTurnover(item) {
  128. uni.showModal({
  129. title: '提示', // 标题
  130. content: '是否删除此条周转', // 提示内容
  131. cancelText: "取消", // 取消按钮的文字
  132. confirmText: "确认", // 确认按钮的文字
  133. //点击确定之后执行的代码
  134. success(res) {
  135. if (res.confirm) {
  136. const checkIndex = listData.value.findIndex(selectedItem => selectedItem === item);
  137. if (checkIndex > -1) {
  138. listData.value.splice(checkIndex, 1);
  139. }
  140. }
  141. }
  142. });
  143. }
  144. </script>
  145. <style lang="scss">
  146. .container {
  147. height: 100%;
  148. background-color: #f5f5f5;
  149. }
  150. .scroll-container {
  151. position: absolute;
  152. top: 24rpx;
  153. right: 0;
  154. bottom: 160rpx;
  155. left: 0;
  156. }
  157. .selected {
  158. border: 1px solid #1684fc;
  159. }
  160. .list-item {
  161. background-color: #fff;
  162. position: relative;
  163. padding: 16rpx;
  164. padding-bottom: 24rpx;
  165. margin: 0 24rpx;
  166. margin-bottom: 24rpx;
  167. border-radius: 8rpx;
  168. .title-container {
  169. justify-content: space-between;
  170. margin-top: 8rpx;
  171. margin-bottom: 16rpx;
  172. .title {
  173. height: 48rpx;
  174. align-items: center;
  175. .label {
  176. color: #1684fc;
  177. font-size: 32rpx;
  178. font-weight: bold;
  179. &.code {
  180. color: #000000;
  181. margin-left: 32rpx;
  182. }
  183. }
  184. }
  185. }
  186. .item-info {
  187. margin-bottom: 16rpx;
  188. .label {
  189. font-size: 28rpx;
  190. width: 152rpx;
  191. color: #808080;
  192. &.right {
  193. flex: 1;
  194. color: #808080;
  195. }
  196. }
  197. }
  198. .right-info {
  199. justify-content: flex-end;
  200. margin-top: 2rpx;
  201. .label {
  202. font-size: 28rpx;
  203. color: #ff0000;
  204. }
  205. }
  206. }
  207. .bottom {
  208. position: absolute;
  209. right: 0;
  210. bottom: 0;
  211. left: 0;
  212. height: 100rpx;
  213. padding: 16rpx 24rpx;
  214. align-items: center;
  215. background-color: #FFFFFF;
  216. justify-content: space-between;
  217. .bottom-btn {
  218. flex: 1;
  219. font-size: 28rpx;
  220. color: #FFFFFF;
  221. &.left-btn {
  222. background-color: #1684fc;
  223. }
  224. &.right-btn {
  225. background-color: rgb(255, 121, 1);
  226. margin-left: 24rpx;
  227. }
  228. }
  229. }
  230. </style>