dialog-lot.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <dialog-base class="dialog-body" ref="baseDialog" title="添加新批次">
  3. <view class="prompt">
  4. <text>请选择批次再确认</text>
  5. </view>
  6. <view :class="{'list-container':true, 'selected':isSelected(item)}" @click="handleSelection(item,index)"
  7. v-for="(item, index) in form" :key="item.id">
  8. <view class="list-title"><text class="label">批次号:{{item.lotCode}}</text></view>
  9. <view class="list-container-item uni-row">
  10. <text class="label">产品描述</text>
  11. <text class="label value">{{item['productDescription']}}</text>
  12. </view>
  13. <view class="list-container-item uni-row">
  14. <text class="label">关联箱号</text>
  15. <text class="label value">{{item['carrierName']}}</text>
  16. </view>
  17. <view class="list-container-item uni-row">
  18. <text class="label">当前工序</text>
  19. <text class="label value">{{item['daywork'].currentProcess.processAlias}}</text>
  20. </view>
  21. <view class="list-container-item uni-row" style="border-bottom: 1px solid #999999;">
  22. <text class="label">投产数量</text>
  23. <text class="label value">{{item['qualifiedQuantity']}}</text>
  24. </view>
  25. </view>
  26. <view class="add-btn-container uni-row">
  27. <button type="primary" class="btn" @click="handleConfirm" :disabled="flag">确认</button>
  28. </view>
  29. </dialog-base>
  30. </template>
  31. <script setup>
  32. import {
  33. ref,
  34. getCurrentInstance
  35. } from 'vue'
  36. const baseDialog = ref(null)
  37. const selectedButton = ref(null)
  38. const form = ref({})
  39. const emit = defineEmits(['submit'])
  40. const selection = ref([])
  41. const flag = ref(true)
  42. const open = (data) => {
  43. // console.log(dialog.value)
  44. form.value = data
  45. baseDialog.value.open()
  46. }
  47. const close = () => {
  48. baseDialog.value.close()
  49. }
  50. defineExpose({
  51. open
  52. })
  53. function handleScanCode() {
  54. uni.scanCode({
  55. onlyFromCamera: true,
  56. success: function(res) {}
  57. });
  58. }
  59. function handleConfirm() {
  60. close();
  61. emit('submit', selection.value);
  62. uni.$emit('dayworkItemUpdate');
  63. }
  64. function isSelected(item) {
  65. return selection.value.includes(item);
  66. }
  67. function handleSelection(item, index) {
  68. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  69. if (buttonIndex > -1) {
  70. selection.value.splice(buttonIndex, 1); // 取消选中
  71. } else {
  72. selection.value.push(item); // 选中
  73. }
  74. console.log(selection.value, "selection");
  75. flag.value = selection.value.length > 0 ? false : true;
  76. }
  77. </script>
  78. <style lang="scss">
  79. .selected {
  80. border: 2px solid #1684fc;
  81. }
  82. .dialog-body {
  83. overflow: auto;
  84. .list-title {
  85. margin: 20rpx 0 20rpx 0;
  86. .label {
  87. font-size: 32rpx;
  88. font-weight: bold;
  89. }
  90. }
  91. .prompt{
  92. color: #999;
  93. margin: 8rpx auto 0;
  94. }
  95. .list-container {
  96. width: 100%;
  97. display: flex;
  98. align-items: flex-start;
  99. // padding: 0 4rpx;
  100. margin: 10rpx 0;
  101. border-radius: 6rpx;
  102. overflow: auto;
  103. .list-container-item {
  104. width: 100%;
  105. border: 1px solid #999999;
  106. border-bottom: none;
  107. padding: 12rpx 8rpx;
  108. box-sizing: border-box;
  109. .label {
  110. font-size: 28rpx;
  111. color: gray;
  112. width: 144rpx;
  113. &.value {
  114. flex: 1;
  115. }
  116. }
  117. }
  118. }
  119. .add-btn-container {
  120. margin-top: 32rpx;
  121. .btn {
  122. flex: 1;
  123. }
  124. }
  125. }
  126. </style>