dialog-lot.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <dialog-base class="dialog-body" ref="baseDialog" title="添加新批次">
  3. <view class="prompt">
  4. <text>请选择工序、批次后再确认</text>
  5. </view>
  6. <uni-section title="请选择当前工序" type="square">
  7. <uni-data-select v-model="selectedProcess" :localdata="processList" :clear="false"
  8. @change="handleProcessChange"></uni-data-select>
  9. </uni-section>
  10. <view :class="{'list-container':true, 'selected':isSelected(item)}" @click="handleSelection(item,index)"
  11. v-for="(item, index) in form" :key="item.id">
  12. <view class="list-title"><text class="label">批次号:{{item.lotCode}}</text></view>
  13. <view class="list-container-item uni-row">
  14. <text class="label">产品描述</text>
  15. <text class="label value">{{item['productDescription']}}</text>
  16. </view>
  17. <view class="list-container-item uni-row">
  18. <text class="label">关联箱号</text>
  19. <text class="label value">{{item['carrierName']}}</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['prodNum']}}</text>
  24. </view>
  25. <view class="list-container-item uni-row">
  26. <text class="label">上道工序</text>
  27. <text class="label value">{{item['process'].processAlias}}</text>
  28. </view>
  29. </view>
  30. <view class="add-btn-container uni-row">
  31. <button type="primary" class="btn" @click="handleConfirm">确认</button>
  32. </view>
  33. </dialog-base>
  34. </template>
  35. <script setup>
  36. import {
  37. ref,
  38. getCurrentInstance
  39. } from 'vue'
  40. import {
  41. getProcessList
  42. } from '@/api/business/deptProcess.js'
  43. import { store } from '@/store/index.js'
  44. const baseDialog = ref(null)
  45. const selectedButton = ref(null)
  46. const form = ref({})
  47. const emit = defineEmits(['submit'])
  48. const selection = ref([])
  49. const selectedProcess = ref(null)
  50. const processList = ref([])
  51. const open = (data) => {
  52. // console.log(dialog.value)
  53. form.value = data;
  54. baseDialog.value.open();
  55. getProcesses();
  56. }
  57. const close = () => {
  58. baseDialog.value.close()
  59. }
  60. defineExpose({
  61. open
  62. })
  63. function getProcesses() {
  64. getProcessList({
  65. deptId: store.curDeptDetails.deptId,
  66. }).then(res => {
  67. if (res.code == 200) {
  68. //过滤出工序交集
  69. let filteredData = res.data.filter((item1) =>
  70. store.planDetails.processSequence.some((item2) => item2.processCode === item1.processCode)
  71. );
  72. for (let i = 0; i < filteredData.length; i++) {
  73. processList.value[i] = {
  74. text: filteredData[i].processAlias,
  75. value: filteredData[i].processId
  76. }
  77. }
  78. // selectedProcess.value = filteredData[0].processId;
  79. }
  80. })
  81. }
  82. function handleProcessChange(){
  83. }
  84. function handleConfirm() {
  85. // 添加选择的工序
  86. for (let i = 0; i < selection.value.length; i++) {
  87. selection.value[i].daywork.processId = selectedProcess.value;
  88. }
  89. // 执行确认
  90. if(selectedProcess.value && selection.value.length > 0){
  91. close();
  92. emit('submit', selection.value);
  93. uni.$emit('dayworkItemUpdate');
  94. }else {
  95. uni.showToast({
  96. icon: 'none',
  97. title: '请选择工序、批次后再确认'
  98. })
  99. }
  100. }
  101. function isSelected(item) {
  102. return selection.value.includes(item);
  103. }
  104. function handleSelection(item, index) {
  105. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  106. if (buttonIndex > -1) {
  107. selection.value.splice(buttonIndex, 1); // 取消选中
  108. } else {
  109. selection.value.push(item); // 选中
  110. }
  111. console.log(selection.value, "selection");
  112. }
  113. </script>
  114. <style lang="scss">
  115. .selected {
  116. border: 2px solid #1684fc;
  117. }
  118. .dialog-body {
  119. overflow: auto;
  120. .list-title {
  121. margin: 20rpx 0 20rpx 0;
  122. .label {
  123. font-size: 32rpx;
  124. font-weight: bold;
  125. }
  126. }
  127. .prompt {
  128. color: red;
  129. margin: 8rpx auto 0;
  130. }
  131. .list-container {
  132. width: 100%;
  133. display: flex;
  134. align-items: flex-start;
  135. // padding: 0 4rpx;
  136. margin: 10rpx 0;
  137. border-radius: 6rpx;
  138. overflow: auto;
  139. .list-container-item {
  140. width: 100%;
  141. border: 1px solid #999999;
  142. border-bottom: none;
  143. padding: 12rpx 8rpx;
  144. box-sizing: border-box;
  145. .label {
  146. font-size: 28rpx;
  147. color: gray;
  148. width: 144rpx;
  149. &.value {
  150. flex: 1;
  151. }
  152. }
  153. }
  154. }
  155. .add-btn-container {
  156. margin-top: 32rpx;
  157. .btn {
  158. flex: 1;
  159. }
  160. }
  161. }
  162. .selectedProcess {
  163. width: 88%;
  164. margin: 20rpx auto 40rpx;
  165. }
  166. </style>