index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <div>
  3. <div v-if="isShow">
  4. <div class="top_fixed">
  5. <el-button type="primary" size="mini" @click="save(2, 'all')">一键投料(报工)</el-button>
  6. <el-button type="primary" size="mini" @click="removeCacheFn('all')">清空缓存</el-button>
  7. <el-button type="primary" size="mini" @click="save(1, 'all')">缓存</el-button>
  8. </div>
  9. <div class="feed_box" v-if="isLoad">
  10. <div v-for="(item, index) in List" :key="index" class="card_box">
  11. <div class="title_box rx-bc">
  12. <div class="name">工单信息 </div>
  13. <div class="rx-bc">
  14. <el-button type="text" size="mini">出库单</el-button>
  15. <el-button type="text" size="mini" @click="openPicking(item.workOrderId, item)">手动添加</el-button>
  16. <el-button type="text" size="mini" @click="removeCacheFn(item.workOrderId)">清空缓存</el-button>
  17. <el-button type="text" size="mini" @click="save(1, index)">缓存</el-button>
  18. </div>
  19. </div>
  20. <workOrderBom :item="item"></workOrderBom>
  21. <div >
  22. <div class="title_box rx-bc">
  23. <div class="name">投料时间 </div>
  24. </div>
  25. <el-date-picker v-model="item.executorTime" type="datetime" value-format="yyyy-MM-dd HH:dd:ss"
  26. placeholder="选择日期">
  27. </el-date-picker>
  28. <!-- -->
  29. </div>
  30. <paramBom v-if="item.paramDetailList.length != 0" :list="item.paramDetailList"></paramBom>
  31. <!-- 设备信息 -->
  32. <deviceBom v-if="item.equipmentList.length != 0" :list="item.equipmentList"></deviceBom>
  33. <productsBom v-if="item.product != null && item.product != '{}'" :itemObj="item" :productsObj="item.product">
  34. </productsBom>
  35. <modelBom v-if="item.modelList.length != 0" :list="item.modelList">
  36. </modelBom>
  37. <!-- 物料清单 -->
  38. <instanceBom v-if="item.instanceList.length != 0" :list="item.instanceList"
  39. :equipmentList="item.equipmentList" :currentTaskDiagram="item.currentTaskDiagram" :workInfo="item">
  40. </instanceBom>
  41. <semiProductBom v-if="item.semiProductList.length != 0" :list="item.semiProductList"
  42. :equipmentList="item.equipmentList" :currentTaskDiagram="item.currentTaskDiagram" :workInfo="item">
  43. </semiProductBom>
  44. <!-- 周转车 -->
  45. <turnoverBom v-if="item.turnover.length != 0" :wordItem="item" :list="item.turnover" pattern="feed">
  46. </turnoverBom>
  47. <aridRegion v-if="item.aridRegionList.length != 0" :list="item.aridRegionList"></aridRegion>
  48. <palletBom v-if="item.palletList.length != 0" :list="item.palletList"></palletBom>
  49. <revolvingDiskBom v-if="item.revolvingDiskList.length != 0" :list="item.revolvingDiskList"></revolvingDiskBom>
  50. </div>
  51. </div>
  52. <pickingList isType="feed" ref="pickingListRef" @allSelection="allSelection"></pickingList>
  53. </div>
  54. <div v-else>
  55. <el-empty description="批量报工,不需要投料,直接去报工取样"></el-empty>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import { workorderList } from '@/api/produce/workOrder';
  61. import {
  62. batchSave,
  63. feedSaveCache,
  64. feedGetCache,
  65. removeCache
  66. } from '@/api/produce/feeding';
  67. import pickingList from '../picking/pickingList.vue';
  68. import workOrderBom from './components/workOrderBom.vue';
  69. import paramBom from './components/paramBom.vue';
  70. import deviceBom from './components/deviceBom.vue';
  71. import productsBom from './components/productsBom.vue';
  72. import modelBom from './components/modelBom.vue';
  73. import instanceBom from './components/instanceBom.vue';
  74. import semiProductBom from './components/semiProductBom.vue';
  75. import turnoverBom from './components/turnoverBom.vue';
  76. import aridRegion from './components/aridRegion.vue';
  77. import palletBom from './components/palletBom.vue';
  78. import revolvingDiskBom from './components/revolvingDiskBom.vue';
  79. import { deepClone } from '@/utils';
  80. export default {
  81. name: 'feeding',
  82. components: {
  83. pickingList,
  84. workOrderBom,
  85. paramBom,
  86. deviceBom,
  87. productsBom,
  88. modelBom,
  89. instanceBom,
  90. semiProductBom,
  91. turnoverBom,
  92. aridRegion,
  93. palletBom,
  94. revolvingDiskBom
  95. },
  96. props: {
  97. workListIds: {
  98. type: Array,
  99. default() {
  100. return [];
  101. }
  102. }
  103. },
  104. computed: {
  105. taskObj() {
  106. return this.$store.state.user.taskObj;
  107. },
  108. clientEnvironmentId() {
  109. return this.$store.state.user.info.clientEnvironmentId;
  110. }
  111. },
  112. watch: {
  113. workListIds: {
  114. handler(val) {
  115. this.getList(val);
  116. },
  117. deep: true,
  118. immediate: true
  119. }
  120. },
  121. data() {
  122. return {
  123. List: [],
  124. idsList: [],
  125. isLoad: false,
  126. isShow: true
  127. };
  128. },
  129. methods: {
  130. getList(ids) {
  131. this.idsList = ids || [];
  132. let param = {
  133. ids: ids,
  134. taskId: this.taskObj.id
  135. };
  136. this.isLoad = false;
  137. workorderList(param)
  138. .then((res) => {
  139. let arr = [];
  140. arr = res.map((m) => {
  141. m.workOrderId = m.id;
  142. m.paramDetailList = [];
  143. m.instanceList = []; // 物料
  144. m.equipmentList = []; // 设备
  145. m.modelList = []; // 模具
  146. m.aridRegionList = []; // 干燥区
  147. m.packingList = []; // 包装
  148. m.palletList = []; // 舟皿
  149. m.revolvingDiskList = []; // 周转盘
  150. m.semiProductList = []; //半成品
  151. if (m.pickOutInList.length > 0) {
  152. m.pickOutInList.forEach((f) => {
  153. if (f.rootCategoryLevelId == 1) {
  154. m.instanceList.push(f);
  155. } else if (f.rootCategoryLevelId == 4) {
  156. m.modelList.push(f);
  157. } else if (f.rootCategoryLevelId == 5) {
  158. m.modelList.push(f);
  159. } else if (f.rootCategoryLevelId == 11) {
  160. m.aridRegionList.push(f);
  161. } else if (f.rootCategoryLevelId == 13) {
  162. m.packingList.push(f);
  163. } else if (f.rootCategoryLevelId == 8) {
  164. m.palletList.push(f);
  165. } else if (f.rootCategoryLevelId == 26) {
  166. m.revolvingDiskList.push(f);
  167. } else if (
  168. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  169. ) {
  170. m.semiProductList.push(f);
  171. }
  172. });
  173. }
  174. // 处理字段
  175. if (m.quality == '') {
  176. m.product = '{}';
  177. }
  178. if (!Object.prototype.hasOwnProperty.call(m, 'product')) {
  179. m.product = '{}';
  180. }
  181. if (this.clientEnvironmentId == 3 && this.taskObj.type == 6 && m.singleReport == 0) {
  182. this.isShow = false;
  183. } else {
  184. this.isShow = true;
  185. }
  186. delete m.id;
  187. if (this.taskObj.id) {
  188. m.taskId = this.taskObj.id;
  189. m.taskName = this.taskObj.name;
  190. }
  191. return {
  192. ...m
  193. };
  194. });
  195. this.List = deepClone(arr);
  196. })
  197. .finally(() => {
  198. this.isLoad = true;
  199. this.getCacheFn();
  200. });
  201. this.$forceUpdate();
  202. },
  203. openPicking(id, item) {
  204. this.$refs.pickingListRef.open(id, item,'选择列表');
  205. },
  206. allSelection(id, selectList) {
  207. this.List.forEach((m) => {
  208. if (m.workOrderId == id) {
  209. let modelList = []; // 模具
  210. let instanceList = []; // 投料
  211. let aridRegionList = []; // 干燥区
  212. let equipmentList = []; // 生产设备
  213. let palletList = []; // 舟皿
  214. let revolvingDiskList = []; // 周转盘
  215. let semiProductList = []; // 半成品
  216. let turnover = []; //周转车
  217. selectList.forEach((f) => {
  218. if (f.rootCategoryLevelId == 4) {
  219. equipmentList = equipmentList.concat(f);
  220. }
  221. if (f.rootCategoryLevelId == 5) {
  222. modelList = modelList.concat(f);
  223. } else if (f.rootCategoryLevelId == 1) {
  224. instanceList = instanceList.concat(f);
  225. } else if (f.rootCategoryLevelId == 11) {
  226. aridRegionList = aridRegionList.concat(f);
  227. } else if (f.rootCategoryLevelId == 7) {
  228. turnover = turnover.concat(f);
  229. } else if (f.rootCategoryLevelId == 8) {
  230. palletList = palletList.concat(f);
  231. } else if (f.rootCategoryLevelId == 26) {
  232. revolvingDiskList = revolvingDiskList.concat(f);
  233. } else if (
  234. [23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))
  235. ) {
  236. semiProductList = semiProductList.concat(f);
  237. }
  238. });
  239. this.$set(m, 'modelList', modelList);
  240. this.$set(m, 'instanceList', instanceList);
  241. this.$set(m, 'aridRegionList', aridRegionList);
  242. this.$set(m, 'equipmentList', equipmentList);
  243. this.$set(m, 'turnover', turnover);
  244. this.$set(m, 'palletList', palletList);
  245. this.$set(m, 'revolvingDiskList', revolvingDiskList);
  246. this.$set(m, 'semiProductList', semiProductList);
  247. this.$forceUpdate();
  248. }
  249. });
  250. },
  251. getCacheFn() {
  252. let parma = {
  253. workOrderIds: this.idsList,
  254. taskId: this.taskObj.id,
  255. type: 2
  256. };
  257. feedGetCache(parma).then((res) => {
  258. if (res.length == 0) {
  259. return false;
  260. }
  261. let objList = res[0].extInfo.objList;
  262. this.List.forEach((f) => {
  263. objList.forEach((o) => {
  264. if (f.workOrderId == o.workOrderId && f.currentTaskDiagram.taskId == o.taskId) {
  265. f['instanceList'] = o.instanceList || [];
  266. f['equipmentList'] = o.equipmentList || [];
  267. f['modelList'] = o.modelList || [];
  268. f['aridRegionList'] = o.aridRegionList || [];
  269. f['packingList'] = o.packingList || [];
  270. f['palletList'] = o.palletList || [];
  271. f['revolvingDiskList'] = o.revolvingDiskList || [];
  272. f['semiProductList'] = o.semiProductList || [];
  273. this.$forceUpdate();
  274. }
  275. });
  276. });
  277. });
  278. },
  279. async save(type, index) {
  280. this.List.forEach((f) => {
  281. f.instanceList.forEach((e) => {
  282. if (Object.prototype.hasOwnProperty.call(e, 'type')) {
  283. e.extInfo['type'] = e.type;
  284. }
  285. e.extInfo['isConsumable'] = e.isConsumable;
  286. });
  287. });
  288. const isCache = await this.checkCache(type);
  289. if (!isCache) {
  290. return false;
  291. }
  292. batchSave(this.List).then((res) => {
  293. this.$message.success('投料成功');
  294. this.getList(this.idsList);
  295. });
  296. },
  297. checkCache(type, index) {
  298. return new Promise((resolve) => {
  299. if (type == 1) {
  300. feedSaveCache(this.List).then((rr) => {
  301. this.$message.success('已经缓存');
  302. });
  303. resolve(false);
  304. } else if (type == 2) {
  305. resolve(true);
  306. }
  307. });
  308. },
  309. removeCacheFn(type) {
  310. this.$confirm('是否清空缓存', '缓存')
  311. .then(() => {
  312. let parma = {
  313. workOrderIds: type == 'all' ? this.idsList : [type],
  314. taskId: this.taskObj.id,
  315. type: 2
  316. };
  317. removeCache(parma).then((res) => {
  318. this.getList(this.idsList);
  319. });
  320. })
  321. .catch(() => { });
  322. }
  323. }
  324. };
  325. </script>
  326. <style scoped lang="scss">
  327. .top_fixed {
  328. width: 100%;
  329. height: 40px;
  330. background: #fff;
  331. display: flex;
  332. align-items: center;
  333. justify-content: flex-end;
  334. }
  335. .feed_box {
  336. margin-top: 6px;
  337. width: 100%;
  338. height: calc(100vh - 70px - 50px - 80px - 60px);
  339. overflow-y: scroll;
  340. overflow-x: hidden;
  341. }
  342. .card_box {
  343. background: #fff;
  344. padding: 8px;
  345. border-radius: 2px;
  346. }
  347. </style>
  348. <style lang="scss">
  349. .mt6 {
  350. margin-top: 6px;
  351. }
  352. .title_box {
  353. padding: 5px 0;
  354. .name {
  355. font-size: 14px;
  356. font-style: normal;
  357. font-weight: 400;
  358. color: #157a2c;
  359. padding-left: 5px;
  360. position: relative;
  361. &:before {
  362. position: absolute;
  363. content: '';
  364. left: 0px;
  365. top: 0px;
  366. bottom: 0px;
  367. width: 2px;
  368. height: 14px;
  369. background: #157a2c;
  370. margin: auto;
  371. }
  372. }
  373. }
  374. .material {
  375. margin-top: 6px;
  376. .content_table {
  377. width: 100%;
  378. border: 1px solid #e3e5e5;
  379. position: relative;
  380. .item {
  381. display: flex;
  382. border-bottom: 1px solid #e3e5e5;
  383. .lable {
  384. width: 72px;
  385. text-align: center;
  386. background-color: #f7f9fa;
  387. font-size: 12px;
  388. border-right: 1px solid #e3e5e5;
  389. flex-shrink: 0;
  390. }
  391. .lable80 {
  392. width: 80px !important;
  393. font-size: 12px;
  394. }
  395. .lable90 {
  396. width: 90px !important;
  397. }
  398. .lable100 {
  399. width: 100px !important;
  400. }
  401. .ww60 {
  402. width: 60px;
  403. }
  404. .content {
  405. width: 250px;
  406. min-height: 32px;
  407. font-size: 14px;
  408. line-height: 14px;
  409. font-style: normal;
  410. font-weight: 400;
  411. padding: 9px 4px;
  412. box-sizing: border-box;
  413. word-wrap: break-word;
  414. flex-grow: 1 !important;
  415. .unit {
  416. padding: 0 2px;
  417. font-size: 12px;
  418. color: #404446;
  419. }
  420. }
  421. .content_num {
  422. display: flex;
  423. align-items: center;
  424. padding: 2px;
  425. --input-background-color: #f0f8f2;
  426. }
  427. .pd2 {
  428. padding: 2px 4px;
  429. }
  430. &:last-child {
  431. border-bottom: none;
  432. }
  433. }
  434. .ww55 {
  435. width: 55%;
  436. }
  437. .ww50 {
  438. width: 50%;
  439. }
  440. .ww45 {
  441. width: 45%;
  442. }
  443. .ww40 {
  444. width: 40%;
  445. }
  446. .ww30 {
  447. width: 30%;
  448. }
  449. .ww33 {
  450. width: 33.33%;
  451. }
  452. .ww20 {
  453. width: 20%;
  454. }
  455. .del_box {
  456. position: absolute;
  457. right: 2px;
  458. top: 2px;
  459. }
  460. .sort_index {
  461. position: absolute;
  462. left: 2px;
  463. top: 2px;
  464. width: 14px;
  465. height: 14px;
  466. line-height: 14px;
  467. text-align: center;
  468. color: #fff;
  469. font-size: 12px;
  470. border-radius: 50%;
  471. background: rgb(21, 122, 44);
  472. }
  473. }
  474. }
  475. </style>