dialog-lot.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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">
  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" style="word-wrap: break-word;">{{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. isAmend:form.value[0].daywork.isAmend,
  82. technologicalProcessId:form.value[0].technologicalProcessId
  83. })]).then(([res, response]) => {
  84. if (res.code == 200) {
  85. //过滤工序列表将上道序及之前的工序去掉, 然后过滤出工序交集
  86. // let curProcessSequence = [...store.planDetails.processSequence];
  87. let curProcessSequence = response.data
  88. // 这里根据前一序当前工序 过滤工序列表。
  89. // 假设单批单改部分修改后 需要做其他修改
  90. /* // 20240408 前毛宇辰版本
  91. for (let i = 0; i < curProcessSequence.length; i++) {
  92. if (curProcessSequence[i].id == form.value[0].processId) {
  93. curProcessSequence.splice(0,i + 1);
  94. console.log(curProcessSequence)
  95. break;
  96. }
  97. }
  98. */
  99. /* 20240408后版本 */
  100. // 过滤前序
  101. curProcessSequence = curProcessSequence.filter(v => (v.processStepNumber > form.value[0]
  102. .technologicalProcessDetail.processStepNumber))
  103. /* 20240408 修改完成 */
  104. console.log(curProcessSequence)
  105. let filteredData = curProcessSequence.filter((item1) =>
  106. res.data.some((item2) => item2.processCode === item1.processCode)
  107. );
  108. console.log(filteredData)
  109. for (let i = 0; i < filteredData.length; i++) {
  110. processList.value[i] = {
  111. text: filteredData[i].processAlias,
  112. value: filteredData[i].technologicalProcessDetailId ? filteredData[i]
  113. .technologicalProcessDetailId : filteredData[i].id,
  114. processId: filteredData[i].processId,
  115. processStepNumber: filteredData[i].processStepNumber
  116. }
  117. }
  118. console.log(processList.value)
  119. selectedProcess.value = filteredData[0].value;
  120. console.log(selectedProcess.value)
  121. }
  122. // console.log(selectedProcess.value)
  123. })
  124. }
  125. function handleProcessChange() {
  126. console.log(selectedProcess.value)
  127. }
  128. function handleConfirm() {
  129. // 添加选择的工序
  130. for (let i = 0; i < selection.value.length; i++) {
  131. selection.value[i].daywork.technologicalProcessDetailId = selectedProcess.value;
  132. selection.value[i].daywork.processStepNumber = processList.value.find(v => v.value === selectedProcess.value)
  133. ?.processStepNumber;
  134. selection.value[i].daywork.processId = processList.value.findIndex(v => v.value === selectedProcess.value) >=
  135. 0 ? processList.value.find(v => v.value === selectedProcess.value).processId : null
  136. console.log(processList.value.findIndex(v => v.value === selectedProcess.value) >= 0 ? processList.value.find(
  137. v => v.value === selectedProcess.value).processId : null)
  138. }
  139. console.log(selection.value)
  140. //执行确认
  141. var msg = ""
  142. if (selectedProcess.value && selection.value.length > 0) {
  143. //判断选择的批次里是否有废品回用的
  144. for (let i = 0; i < selection.value.length; i++) {
  145. if (selection.value[i].daywork.isWaste == 0) {
  146. msg += selection.value[i].lotCode + ","
  147. }
  148. }
  149. if (msg === "") {
  150. uni.showToast({
  151. icon: 'none',
  152. title: msg + "已被废弃"
  153. })
  154. } else {
  155. close();
  156. emit('submit', selection.value);
  157. uni.$emit('dayworkItemUpdate');
  158. }
  159. } else {
  160. uni.showToast({
  161. icon: 'none',
  162. title: '请选择工序、批次后再确认'
  163. })
  164. }
  165. }
  166. function isSelected(item) {
  167. return selection.value.includes(item);
  168. }
  169. function handleSelection(item, index) {
  170. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  171. if (buttonIndex > -1) {
  172. selection.value.splice(buttonIndex, 1); // 取消选中
  173. } else {
  174. selection.value.push(item); // 选中
  175. }
  176. console.log(selection.value, "selection");
  177. }
  178. </script>
  179. <style lang="scss">
  180. .selected {
  181. border: 3rpx solid #1684fc;
  182. border-radius: 8rpx;
  183. }
  184. .dialog-body {
  185. overflow: auto;
  186. .list-title {
  187. margin: 10rpx 0 20rpx 0;
  188. .label {
  189. font-size: 32rpx;
  190. font-weight: bold;
  191. }
  192. }
  193. .prompt {
  194. color: red;
  195. margin: 8rpx auto 0;
  196. }
  197. .list-container {
  198. width: 94%;
  199. display: flex;
  200. align-items: flex-start;
  201. margin: 10rpx auto;
  202. padding: 8px 2% 16px 2%;
  203. border-radius: 8rpx;
  204. .list-container-item {
  205. width: 100%;
  206. border-bottom: 1px solid #e1e1e1;
  207. border-left: 1px solid #e1e1e1;
  208. border-right: 1px solid #e1e1e1;
  209. padding: 12rpx 8rpx;
  210. box-sizing: border-box;
  211. .label {
  212. font-size: 28rpx;
  213. color: gray;
  214. width: 140rpx;
  215. &.value {
  216. flex: 1;
  217. }
  218. }
  219. }
  220. }
  221. .add-btn-container {
  222. margin-top: 32rpx;
  223. .btn {
  224. flex: 1;
  225. }
  226. }
  227. }
  228. .selectedProcess {
  229. width: 88%;
  230. margin: 20rpx auto 40rpx;
  231. }
  232. </style>