dialog-lot.vue 6.6 KB

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