dialog-lot.vue 3.3 KB

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