index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <!-- 入库报工 报工列表 -->
  3. <div>
  4. <div class="top_fixed">
  5. <el-button type="primary" size="mini" @click="save">一键报工</el-button>
  6. </div>
  7. <div class="warehousing_box">
  8. <div v-for="(item, index) in List" :key="index" class="card_box">
  9. <div class="title_box rx-bc">
  10. <div class="name">工单信息</div>
  11. </div>
  12. <workOrderBom :item="item" v-if="item"></workOrderBom>
  13. <!-- 报工时间 -->
  14. <div>
  15. <div class="title_box rx-bc">
  16. <div class="name">报工时间</div>
  17. </div>
  18. <el-date-picker v-model="item.workReportInfo.executorTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
  19. placeholder="选择日期">
  20. </el-date-picker>
  21. </div>
  22. <div v-if="
  23. clientEnvironmentId == 3 &&
  24. item.toWarehouseList &&
  25. item.toWarehouseList.length > 0
  26. ">
  27. <div style="margin-top: 6px">
  28. <el-select v-model="item.warehouseId" filterable clearable placeholder="请选择仓库" size="mini"
  29. class="content_num">
  30. <el-option v-for="item in warehouseList" :key="item.id" :value="item.id" :label="item.name"></el-option>
  31. </el-select>
  32. </div>
  33. <div v-for="(it, idx) in item.toWarehouseList" :key="idx">
  34. <packingTgBom :list="it.extInfo.pickOutInList" :isWarehousing="true" :item="it"></packingTgBom>
  35. </div>
  36. </div>
  37. <!-- 单独报工 -->
  38. <div v-else-if="item.currentTaskDiagram.type == 4 || (item.currentTaskDiagram.type == 5 && item.singleReport == 1)">
  39. <div v-if="
  40. item.toWarehouseList &&
  41. item.toWarehouseList.length > 0
  42. ">
  43. <div style="margin-top: 6px">
  44. <el-select v-model="item.warehouseId" filterable clearable placeholder="请选择仓库" size="mini"
  45. class="content_num">
  46. <el-option v-for="item in warehouseList" :key="item.id" :value="item.id" :label="item.name"></el-option>
  47. </el-select>
  48. </div>
  49. <div v-for="(it, idx) in item.toWarehouseList" :key="idx">
  50. <packingTgBom :list="it.extInfo.pickOutInList" :singleReport="item.singleReport" :item="item"
  51. :equipmentList="item.equipmentList" :isWarehousing="true"></packingTgBom>
  52. </div>
  53. </div>
  54. </div>
  55. <!-- {{ item.currentTaskDiagram.type }} {{ item.singleReport }}
  56. {{ clientEnvironmentId != 2 && item && item.currentTaskDiagram.type == 5 && clientEnvironmentId != 3 && item.singleReport == 1 }} -->
  57. <div
  58. v-if="clientEnvironmentId != 2 && item && item.currentTaskDiagram.type == 5 && clientEnvironmentId != 3 && item.singleReport !== 1">
  59. <div style="margin-top: 6px">
  60. <el-select v-model="item.warehouseId" filterable clearable placeholder="请选择仓库" size="mini"
  61. class="content_num">
  62. <el-option v-for="item in warehouseList" :key="item.id" :value="item.id" :label="item.name"></el-option>
  63. </el-select>
  64. </div>
  65. <!-- 批量报工 -->
  66. <div class="list_box" v-for="(d, index) in item.toWarehouseList" :key="index">
  67. <div class="time" style="margin-bottom: 10rpx;">打包时间: {{ d.createTime }}</div>
  68. <packagingGroupingTwx ref="packagingGroupingRef" :objData="d.extInfo" :workOrderId="item.workOrderId"
  69. :taskId="item.currentTaskDiagram.taskId">
  70. </packagingGroupingTwx>
  71. </div>
  72. </div>
  73. <div>
  74. <jobDdBom :item='item' ref='jobRef' :notFormed='item.notFormedList' :warehouseList="warehouseList"></jobDdBom>
  75. </div>
  76. <!-- item.currentTaskDiagram.type == 4 ? item.pickOutInList : item.semiProductList -->
  77. <!-- <div v-else>
  78. <el-empty :image-size="30" description="暂无数据"></el-empty>
  79. </div> -->
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import workOrderBom from '../feeding/components/workOrderBom.vue';
  86. import packingTgBom from '../jobBooking/components/packingTgBom.vue';
  87. import semiProductJobBomQT from "../jobBooking/components/semiProductJobBomQT.vue"
  88. import packagingGroupingTwx from "../jobBooking/components/packagingGroupingTwx.vue";
  89. import { getWarehouseList } from '@/api/produce/index.js';
  90. import { listByIdsReport } from '@/api/produce/job';
  91. import { listPcToWarehouseTG, listPCToWarehouse } from '@/api/produce/workOrder';
  92. import { jobSave } from '@/api/produce/workOrder';
  93. import jobDdBom from './components/jobDdBom.vue';
  94. export default {
  95. components: {
  96. workOrderBom,
  97. semiProductJobBomQT,
  98. packagingGroupingTwx,
  99. packingTgBom,
  100. jobDdBom
  101. },
  102. props: {
  103. workListIds: {
  104. type: Array,
  105. default() {
  106. return [];
  107. }
  108. }
  109. },
  110. data() {
  111. return {
  112. isLoad: false,
  113. List: [],
  114. idsList: [],
  115. warehouseList: []
  116. };
  117. },
  118. computed: {
  119. taskObj() {
  120. return this.$store.state.user.taskObj;
  121. },
  122. clientEnvironmentId() {
  123. return this.$store.state.user.info.clientEnvironmentId;
  124. }
  125. },
  126. watch: {
  127. workListIds: {
  128. handler(val) {
  129. this.getList(val);
  130. },
  131. deep: true,
  132. immediate: true
  133. }
  134. },
  135. created() {
  136. this.getWarehouseListFn();
  137. },
  138. methods: {
  139. getList(ids) {
  140. this.idsList = ids || [];
  141. let param = {
  142. ids: ids,
  143. taskId: this.taskObj.id,
  144. type: 0
  145. };
  146. this.isLoad = false;
  147. listByIdsReport(param)
  148. .then((res) => {
  149. this.List = res.map((obj) => {
  150. obj.workReportInfo = {
  151. formingNum: null,
  152. formingWeight: null,
  153. formedNum: null,
  154. formedWeight: null,
  155. taskId: this.taskObj.id,
  156. executorTime: null
  157. };
  158. return {
  159. ...obj
  160. };
  161. });
  162. })
  163. .finally(() => {
  164. this.isLoad = true;
  165. if (this.clientEnvironmentId == 3) {
  166. this.getTgWarehouse();
  167. } else {
  168. this.getQtWarehouse();
  169. }
  170. });
  171. },
  172. getTgWarehouse() {
  173. const param = {
  174. workOrderIds: this.idsList,
  175. taskId: this.taskObj.id
  176. };
  177. listPcToWarehouseTG(param).then((res) => {
  178. // 创建一个映射,以便快速查找
  179. const workOrderMap = new Map(res.map((it) => [it.workOrderId, it]));
  180. // 更新List中的每个项目
  181. // this.List.forEach((item,index) => {
  182. // if (workOrderMap.has(item.workOrderId)) {
  183. // // 直接从映射中获取数据,避免嵌套循环
  184. // this.$set(item, 'toWarehouseList', [
  185. // JSON.parse(JSON.stringify(workOrderMap.get(item.workOrderId)))
  186. // ]);
  187. // } else {
  188. // this.$set(item, 'toWarehouseList', []);
  189. // }
  190. // });
  191. this.List.forEach((item,index) => {
  192. let arr=[]
  193. res.map(titem=>{
  194. if(item.workOrderId==titem.workOrderId){
  195. arr.push(titem)
  196. }
  197. this.$set(item, 'toWarehouseList', arr);
  198. })
  199. })
  200. });
  201. },
  202. getQtWarehouse() {
  203. const param = {
  204. workOrderIds: this.idsList,
  205. taskId: this.taskObj.id
  206. };
  207. console.log(123456);
  208. listPCToWarehouse(param).then((res) => {
  209. // 创建一个映射,以便快速查找
  210. const workOrderMap = new Map(res.map((it) => [it.workOrderId, it]));
  211. console.log(workOrderMap, '99');
  212. // 更新List中的每个项目
  213. // this.List.map((item) => {
  214. // if (workOrderMap.has(item.workOrderId)) {
  215. // console.log(1);
  216. // // 直接从映射中获取数据,避免嵌套循环
  217. // this.$set(item, 'toWarehouseList', [
  218. // JSON.parse(JSON.stringify(workOrderMap.get(item.workOrderId)))
  219. // ]);
  220. // } else {
  221. // this.$set(item, 'toWarehouseList', []);
  222. // }
  223. // });
  224. this.List.forEach((item,index) => {
  225. let arr=[]
  226. res.map(titem=>{
  227. if(item.workOrderId==titem.workOrderId){
  228. arr.push(titem)
  229. }
  230. this.$set(item, 'toWarehouseList', arr);
  231. })
  232. })
  233. console.log(this.List, '6666666666');
  234. });
  235. },
  236. getWarehouseListFn() {
  237. getWarehouseList().then((res) => {
  238. this.warehouseList = res.data;
  239. });
  240. },
  241. save() {
  242. if(this.clientEnvironmentId==21){
  243. jobSave(this.List).then((res) => {
  244. console.log(res);
  245. this.$message.success('入库成功');
  246. this.getList(this.idsList);
  247. });
  248. }else{
  249. let _arr = [];
  250. _arr = this.List.filter((item) => {
  251. return item.toWarehouseList.length > 0;
  252. });
  253. let bol = true;
  254. bol = _arr.every((e, i) => {
  255. return e.warehouseId;
  256. });
  257. if (!bol) {
  258. this.$message.warning(`仓库不能为空`);
  259. return false;
  260. }
  261. let _arr2 = JSON.parse(JSON.stringify(_arr));
  262. _arr2.map((m) => {
  263. m.storageInfo = {
  264. warehouseId: m.warehouseId,
  265. toWarehouseList: m.toWarehouseList,
  266. inWarehouseSpecType: 2
  267. };
  268. delete m.warehouseId
  269. delete m.toWarehouseList
  270. return {
  271. ...m
  272. };
  273. });
  274. jobSave(_arr2).then((res) => {
  275. console.log(res);
  276. this.$message.success('入库成功');
  277. this.getList(this.idsList);
  278. });
  279. }
  280. }
  281. }
  282. };
  283. </script>
  284. <style scoped lang="scss">
  285. .top_fixed {
  286. width: 100%;
  287. height: 40px;
  288. background: #fff;
  289. display: flex;
  290. align-items: center;
  291. justify-content: flex-end;
  292. }
  293. .title_box {
  294. .name {
  295. font-size: 14px;
  296. font-style: normal;
  297. font-weight: 400;
  298. color: #157a2c;
  299. padding-left: 5px;
  300. position: relative;
  301. &:before {
  302. position: absolute;
  303. content: '';
  304. left: 0px;
  305. top: 0px;
  306. bottom: 0px;
  307. width: 2px;
  308. height: 14px;
  309. background: #157a2c;
  310. margin: auto;
  311. }
  312. }
  313. }
  314. .warehousing_box {
  315. margin-top: 6px;
  316. width: 100%;
  317. height: calc(100vh - 70px - 50px - 80px - 60px);
  318. overflow-y: scroll;
  319. overflow-x: hidden;
  320. }
  321. .card_box {
  322. background: #fff;
  323. padding: 8px;
  324. border-radius: 2px;
  325. }
  326. .content_num {
  327. --input-background-color: #f0f8f2;
  328. }
  329. </style>