dialog-outsourceLot.vue 7.1 KB

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