dialog-lot.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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" style="border-top: 1px solid #e1e1e1;border-radius: 8rpx 8rpx 0 0;">
  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">
  22. <text class="label">投产数量</text>
  23. <text class="label value">{{item['daywork'].temporaryProcessQualifiedNum}}</text>
  24. </view>
  25. <view class="list-container-item uni-row" style="border-radius: 0 0 8rpx 8rpx;">
  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. getProcessListByLot
  42. } from "@/api/business/lot.js"
  43. import {
  44. getProcessList
  45. } from '@/api/business/deptProcess.js'
  46. import {
  47. store
  48. } from '@/store/index.js'
  49. const baseDialog = ref(null)
  50. const selectedButton = ref(null)
  51. const form = ref([])
  52. const emit = defineEmits(['submit'])
  53. const selection = ref([])
  54. const selectedProcess = ref({})
  55. const processList = ref([])
  56. const open = (data) => {
  57. console.log(data)
  58. form.value = data;
  59. baseDialog.value.open();
  60. selection.value = [];
  61. selectedProcess.value = {};
  62. processList.value = [];
  63. getProcesses();
  64. }
  65. const close = () => {
  66. baseDialog.value.close()
  67. }
  68. defineExpose({
  69. open
  70. })
  71. function getProcesses() {
  72. Promise.all([getProcessList({
  73. deptId: store.curDeptDetails.deptId,
  74. dayworkId:form.value.dayworkId
  75. }), getProcessListByLot({
  76. id: form.value[0].daywork.lotId,
  77. isWasteRecycling:form.value[0].daywork.isWasteRecycling
  78. })
  79. ]).then(([res, response]) =>{
  80. if (res.code == 200) {
  81. //过滤工序列表将上道序及之前的工序去掉, 然后过滤出工序交集
  82. // let curProcessSequence = [...store.planDetails.processSequence];
  83. let curProcessSequence = response.data
  84. // 这里根据前一序当前工序 过滤工序列表。
  85. // 假设单批单改部分修改后 需要做其他修改
  86. /* // 20240408 前毛宇辰版本
  87. for (let i = 0; i < curProcessSequence.length; i++) {
  88. if (curProcessSequence[i].id == form.value[0].processId) {
  89. curProcessSequence.splice(0,i + 1);
  90. console.log(curProcessSequence)
  91. break;
  92. }
  93. }
  94. */
  95. /* 20240408后版本 */
  96. // 过滤前序
  97. curProcessSequence = curProcessSequence.filter(v => (v.processStepNumber > form.value[0].technologicalProcessDetail.processStepNumber))
  98. /* 20240408 修改完成 */
  99. console.log(curProcessSequence)
  100. let filteredData = curProcessSequence.filter((item1) =>
  101. res.data.some((item2) => item2.processCode === item1.processCode)
  102. );
  103. console.log(filteredData)
  104. for (let i = 0; i < filteredData.length; i++) {
  105. processList.value[i] = {
  106. text: filteredData[i].processAlias,
  107. value: filteredData[i].technologicalProcessDetailId?filteredData[i].technologicalProcessDetailI:filteredData[i].id,
  108. processId: filteredData[i].processId,
  109. processStepNumber:filteredData[i].processStepNumber
  110. }
  111. }
  112. console.log(processList.value)
  113. selectedProcess.value = filteredData[0].value;
  114. console.log(selectedProcess.value)
  115. }
  116. // console.log(selectedProcess.value)
  117. })
  118. }
  119. function handleProcessChange() {
  120. console.log(selectedProcess.value)
  121. }
  122. function handleConfirm() {
  123. // 添加选择的工序
  124. for (let i = 0; i < selection.value.length; i++) {
  125. selection.value[i].daywork.technologicalProcessDetailId = selectedProcess.value;
  126. selection.value[i].daywork.processStepNumber = processList.value.find(v => v.value === selectedProcess.value)?.processStepNumber;
  127. selection.value[i].daywork.processId = processList.value.findIndex(v => v.value === selectedProcess.value) >= 0 ? processList.value.find(v => v.value === selectedProcess.value).processId : null
  128. console.log(processList.value.findIndex(v => v.value === selectedProcess.value) >= 0 ? processList.value.find(v => v.value === selectedProcess.value).processId : null)
  129. }
  130. console.log(selection.value)
  131. //执行确认
  132. if (selectedProcess.value && selection.value.length > 0) {
  133. close();
  134. emit('submit', selection.value);
  135. uni.$emit('dayworkItemUpdate');
  136. } else {
  137. uni.showToast({
  138. icon: 'none',
  139. title: '请选择工序、批次后再确认'
  140. })
  141. }
  142. }
  143. function isSelected(item) {
  144. return selection.value.includes(item);
  145. }
  146. function handleSelection(item, index) {
  147. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  148. if (buttonIndex > -1) {
  149. selection.value.splice(buttonIndex, 1); // 取消选中
  150. } else {
  151. selection.value.push(item); // 选中
  152. }
  153. console.log(selection.value, "selection");
  154. }
  155. </script>
  156. <style lang="scss">
  157. .selected {
  158. border: 3rpx solid #1684fc;
  159. border-radius: 8rpx;
  160. }
  161. .dialog-body {
  162. overflow: auto;
  163. .list-title {
  164. margin: 10rpx 0 20rpx 0;
  165. .label {
  166. font-size: 32rpx;
  167. font-weight: bold;
  168. }
  169. }
  170. .prompt {
  171. color: red;
  172. margin: 8rpx auto 0;
  173. }
  174. .list-container {
  175. width: 96%;
  176. display: flex;
  177. align-items: flex-start;
  178. margin: 10rpx auto;
  179. padding: 2%;
  180. border-radius: 8rpx;
  181. overflow: auto;
  182. .list-container-item {
  183. width: 100%;
  184. border-bottom: 1px solid #e1e1e1;
  185. border-left: 1px solid #e1e1e1;
  186. border-right: 1px solid #e1e1e1;
  187. padding: 12rpx 8rpx;
  188. box-sizing: border-box;
  189. .label {
  190. font-size: 28rpx;
  191. color: gray;
  192. width: 144rpx;
  193. &.value {
  194. flex: 1;
  195. }
  196. }
  197. }
  198. }
  199. .add-btn-container {
  200. margin-top: 32rpx;
  201. .btn {
  202. flex: 1;
  203. }
  204. }
  205. }
  206. .selectedProcess {
  207. width: 88%;
  208. margin: 20rpx auto 40rpx;
  209. }
  210. </style>