dialog-lot.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. selection.value = [];
  56. getProcesses();
  57. }
  58. const close = () => {
  59. baseDialog.value.close()
  60. }
  61. defineExpose({
  62. open
  63. })
  64. function getProcesses() {
  65. getProcessList({
  66. deptId: store.curDeptDetails.deptId,
  67. }).then(res => {
  68. if (res.code == 200) {
  69. //过滤出工序交集
  70. let filteredData = store.planDetails.processSequence.filter((item1) =>
  71. res.data.some((item2) => item2.processCode === item1.processCode)
  72. );
  73. for (let i = 0; i < filteredData.length; i++) {
  74. processList.value[i] = {
  75. text: filteredData[i].processAlias,
  76. value: filteredData[i].id
  77. }
  78. }
  79. // selectedProcess.value = filteredData[0].processId;
  80. }
  81. })
  82. }
  83. function handleProcessChange(){
  84. }
  85. function handleConfirm() {
  86. // 添加选择的工序
  87. for (let i = 0; i < selection.value.length; i++) {
  88. selection.value[i].daywork.processId = selectedProcess.value;
  89. }
  90. console.log(selection.value)
  91. // 执行确认
  92. if(selectedProcess.value && selection.value.length > 0){
  93. close();
  94. emit('submit', selection.value);
  95. uni.$emit('dayworkItemUpdate');
  96. }else {
  97. uni.showToast({
  98. icon: 'none',
  99. title: '请选择工序、批次后再确认'
  100. })
  101. }
  102. }
  103. function isSelected(item) {
  104. return selection.value.includes(item);
  105. }
  106. function handleSelection(item, index) {
  107. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  108. if (buttonIndex > -1) {
  109. selection.value.splice(buttonIndex, 1); // 取消选中
  110. } else {
  111. selection.value.push(item); // 选中
  112. }
  113. console.log(selection.value, "selection");
  114. }
  115. </script>
  116. <style lang="scss">
  117. .selected {
  118. border: 2px solid #1684fc;
  119. }
  120. .dialog-body {
  121. overflow: auto;
  122. .list-title {
  123. margin: 20rpx 0 20rpx 0;
  124. .label {
  125. font-size: 32rpx;
  126. font-weight: bold;
  127. }
  128. }
  129. .prompt {
  130. color: red;
  131. margin: 8rpx auto 0;
  132. }
  133. .list-container {
  134. width: 100%;
  135. display: flex;
  136. align-items: flex-start;
  137. // padding: 0 4rpx;
  138. margin: 10rpx 0;
  139. border-radius: 6rpx;
  140. overflow: auto;
  141. .list-container-item {
  142. width: 100%;
  143. border: 1px solid #999999;
  144. border-bottom: none;
  145. padding: 12rpx 8rpx;
  146. box-sizing: border-box;
  147. .label {
  148. font-size: 28rpx;
  149. color: gray;
  150. width: 144rpx;
  151. &.value {
  152. flex: 1;
  153. }
  154. }
  155. }
  156. }
  157. .add-btn-container {
  158. margin-top: 32rpx;
  159. .btn {
  160. flex: 1;
  161. }
  162. }
  163. }
  164. .selectedProcess {
  165. width: 88%;
  166. margin: 20rpx auto 40rpx;
  167. }
  168. </style>