dialog-lot.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. getExamine
  51. } from '@/api/business/dayworkItemExamine.js'
  52. import {
  53. store
  54. } from '@/store/index.js'
  55. const baseDialog = ref(null)
  56. const selectedButton = ref(null)
  57. const form = ref([])
  58. const emit = defineEmits(['submit'])
  59. const selection = ref([])
  60. const selectedProcess = ref({})
  61. const processList = ref([])
  62. const open = (data) => {
  63. console.log(data)
  64. form.value = data;
  65. baseDialog.value.open();
  66. selection.value = [];
  67. selectedProcess.value = {};
  68. processList.value = [];
  69. getProcesses();
  70. }
  71. const close = () => {
  72. baseDialog.value.close()
  73. }
  74. defineExpose({
  75. open
  76. })
  77. function getProcesses() {
  78. Promise.all([getProcessList({
  79. deptId: store.curDeptDetails.deptId,
  80. dayworkId:form.value.dayworkId
  81. }), getProcessListByLot({
  82. id: form.value[0].daywork.lotId,
  83. isWasteRecycling: form.value[0].daywork.isWasteRecycling,
  84. isAmend:form.value[0].daywork.isAmend,
  85. technologicalProcessId:form.value[0].technologicalProcessId
  86. })]).then(([res, response]) => {
  87. if (res.code == 200) {
  88. //过滤工序列表将上道序及之前的工序去掉, 然后过滤出工序交集
  89. // let curProcessSequence = [...store.planDetails.processSequence];
  90. let curProcessSequence = response.data
  91. // 这里根据前一序当前工序 过滤工序列表。
  92. // 假设单批单改部分修改后 需要做其他修改
  93. /* // 20240408 前毛宇辰版本
  94. for (let i = 0; i < curProcessSequence.length; i++) {
  95. if (curProcessSequence[i].id == form.value[0].processId) {
  96. curProcessSequence.splice(0,i + 1);
  97. console.log(curProcessSequence)
  98. break;
  99. }
  100. }
  101. */
  102. /* 20240408后版本 */
  103. // 过滤前序
  104. curProcessSequence = curProcessSequence.filter(v => (v.processStepNumber > form.value[0]
  105. .technologicalProcessDetail.processStepNumber))
  106. /* 20240408 修改完成 */
  107. console.log(curProcessSequence)
  108. let filteredData = curProcessSequence.filter((item1) =>
  109. res.data.some((item2) => item2.processCode === item1.processCode)
  110. );
  111. console.log(filteredData)
  112. for (let i = 0; i < filteredData.length; i++) {
  113. processList.value[i] = {
  114. text: filteredData[i].processAlias,
  115. value: filteredData[i].technologicalProcessDetailId ? filteredData[i]
  116. .technologicalProcessDetailId : filteredData[i].id,
  117. processId: filteredData[i].processId,
  118. processStepNumber: filteredData[i].processStepNumber
  119. }
  120. }
  121. console.log(processList.value)
  122. selectedProcess.value = filteredData[0].value;
  123. console.log(selectedProcess.value)
  124. }
  125. // console.log(selectedProcess.value)
  126. })
  127. }
  128. function handleProcessChange() {
  129. console.log(selectedProcess.value)
  130. }
  131. function handleConfirm() {
  132. // 添加选择的工序
  133. for (let i = 0; i < selection.value.length; i++) {
  134. selection.value[i].daywork.technologicalProcessDetailId = selectedProcess.value;
  135. selection.value[i].daywork.processStepNumber = processList.value.find(v => v.value === selectedProcess.value)
  136. ?.processStepNumber;
  137. selection.value[i].daywork.processId = processList.value.findIndex(v => v.value === selectedProcess.value) >=
  138. 0 ? processList.value.find(v => v.value === selectedProcess.value).processId : null
  139. console.log(processList.value.findIndex(v => v.value === selectedProcess.value) >= 0 ? processList.value.find(
  140. v => v.value === selectedProcess.value).processId : null)
  141. }
  142. console.log(selection.value)
  143. //执行确认
  144. var msg = ""
  145. if (selectedProcess.value && selection.value.length > 0) {
  146. //判断选择的批次里是否有废品回用的
  147. for (let i = 0; i < selection.value.length; i++) {
  148. if (selection.value[i].daywork.isWaste == 0) {
  149. msg += selection.value[i].lotCode + ","
  150. }
  151. }
  152. if (msg === "") {
  153. uni.showToast({
  154. icon: 'none',
  155. title: msg + "已被废弃"
  156. })
  157. } else {
  158. //判断选择最后一道序的时候是否审核通过
  159. let dayworkIds = []
  160. for (let i = 0; i < selection.value.length; i++) {
  161. if(selection.value[i].daywork.processStepNumber == selection.value[i].processSequence[selection.value[i].processSequence.length -1].processStepNumber) {
  162. dayworkIds.push(selection.value[i].dayworkId)
  163. }
  164. }
  165. if(dayworkIds.length>0) {
  166. getExamine({dayworkIds: dayworkIds})
  167. .then(res => {
  168. console.log(res.code);
  169. if (res.code === 200) {
  170. //处理成功情况
  171. close();
  172. emit('submit', selection.value);
  173. uni.$emit('dayworkItemUpdate');
  174. } else {
  175. uni.showModal({
  176. title: '提示',
  177. content: res.msg,
  178. });
  179. }
  180. })
  181. }else{
  182. close();
  183. emit('submit', selection.value);
  184. uni.$emit('dayworkItemUpdate');
  185. }
  186. // console.log(selection.value)
  187. }
  188. } else {
  189. uni.showToast({
  190. icon: 'none',
  191. title: '请选择工序、批次后再确认'
  192. })
  193. }
  194. }
  195. function isSelected(item) {
  196. return selection.value.includes(item);
  197. }
  198. function handleSelection(item, index) {
  199. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  200. if (buttonIndex > -1) {
  201. selection.value.splice(buttonIndex, 1); // 取消选中
  202. } else {
  203. selection.value.push(item); // 选中
  204. }
  205. console.log(selection.value, "selection");
  206. }
  207. </script>
  208. <style lang="scss">
  209. .selected {
  210. border: 3rpx solid #1684fc;
  211. border-radius: 8rpx;
  212. }
  213. .dialog-body {
  214. overflow: auto;
  215. .list-title {
  216. margin: 10rpx 0 20rpx 0;
  217. .label {
  218. font-size: 32rpx;
  219. font-weight: bold;
  220. }
  221. }
  222. .prompt {
  223. color: red;
  224. margin: 8rpx auto 0;
  225. }
  226. .list-container {
  227. width: 94%;
  228. display: flex;
  229. align-items: flex-start;
  230. margin: 10rpx auto;
  231. padding: 8px 2% 16px 2%;
  232. border-radius: 8rpx;
  233. .list-container-item {
  234. width: 100%;
  235. border-bottom: 1px solid #e1e1e1;
  236. border-left: 1px solid #e1e1e1;
  237. border-right: 1px solid #e1e1e1;
  238. padding: 12rpx 8rpx;
  239. box-sizing: border-box;
  240. .label {
  241. font-size: 28rpx;
  242. color: gray;
  243. width: 140rpx;
  244. &.value {
  245. flex: 1;
  246. }
  247. }
  248. }
  249. }
  250. .add-btn-container {
  251. margin-top: 32rpx;
  252. .btn {
  253. flex: 1;
  254. }
  255. }
  256. }
  257. .selectedProcess {
  258. width: 88%;
  259. margin: 20rpx auto 40rpx;
  260. }
  261. </style>