index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
  4. color="#000" @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode">
  5. </uni-nav-bar>
  6. <view class="list_box">
  7. <u-list @scrolltolower="scrolltolower">
  8. <view class="card_box">
  9. <workOrderBom :item='objData' v-if='objData' @handleScan='handleScan'></workOrderBom>
  10. <paramBom v-if='paramDetailList.length != 0' :list='paramDetailList'></paramBom>
  11. <deviceBom v-if='objData.equipmentList.length != 0' :list='objData.equipmentList'></deviceBom>
  12. <modelBom v-if='objData.modelList.length != 0' :list='objData.modelList' pattern='job'
  13. ref='modelRef'>
  14. </modelBom>
  15. <jobBom :item='objData' :palletList='objData.palletList' :notFormed='objData.notFormedList'
  16. @penalize='penalize' @modeNum='modeNum'></jobBom>
  17. <oneJobBom v-if='objData.instanceList && objData.instanceList.length != 0' :item='objData'
  18. :list='objData.instanceList'>
  19. </oneJobBom>
  20. <byProductBom v-if='objData.productRecycleList.length != 0 ' :list='objData.productRecycleList'
  21. @penalize='penalize'>
  22. </byProductBom>
  23. <turnoverBom v-if='objData.turnover.length != 0' :list='objData.turnover' :wordItem='objData'
  24. pattern='job' @handleScan='handleScan'>
  25. </turnoverBom>
  26. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  27. :remainingTime='remainingTime' @handleScan='handleScan' :isType='true'></aridRegion>
  28. <packingBom :taskId='taskId' :workOrderId='id' :objData='objData' ref="packRef"
  29. v-if='taskType == 4 && objData'></packingBom>
  30. <view class="operate_box rx-sc">
  31. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  32. </view>
  33. </view>
  34. </u-list>
  35. </view>
  36. <view class="bottom-wrapper">
  37. <view class="btn_box" @click="save">一键报工</view>
  38. </view>
  39. <SearchPopup mode="bottom" v-if='searchShow'>
  40. <template v-slot:list>
  41. <view class="search_list">
  42. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  43. <u-form-item label="仓库:" class="required-form" borderBottom prop="warehouseId">
  44. <zxz-uni-data-select :localdata="warehouseList" v-model="formData.warehouseId"
  45. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  46. </u-form-item>
  47. </u-form>
  48. </view>
  49. </template>
  50. <template v-slot:operate>
  51. <view class="operate_box rx-bc">
  52. <u-button size="small" class="u-reset-button" @click="searchCancel">
  53. 取消
  54. </u-button>
  55. <u-button type="success" size="small" class="u-reset-button" @click="popupOk">
  56. 确定
  57. </u-button>
  58. </view>
  59. </template>
  60. </SearchPopup>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. getByIdReport,
  66. getByCodeReport,
  67. jobSave
  68. } from '@/api/pda/jobBooking.js'
  69. import {
  70. scanLedger,
  71. getWarehouseList,
  72. } from '@/api/pda/workOrder.js'
  73. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  74. import deviceBom from '../../feeding/components/deviceBom.vue'
  75. import modelBom from '../../feeding/components/modelBom.vue'
  76. import jobBom from '../components/jobBom.vue'
  77. import oneJobBom from '../components/oneJobBom.vue'
  78. import byProductBom from '../components/byProductBom'
  79. import turnoverBom from '../components/turnoverBom.vue'
  80. import aridRegion from '../../feeding/components/aridRegion.vue'
  81. import paramBom from '../../feeding/components/paramBom.vue'
  82. import packingBom from '../components/packingBom.vue'
  83. import SearchPopup from '../../components/searchPopup.vue'
  84. export default {
  85. components: {
  86. workOrderBom,
  87. deviceBom,
  88. modelBom,
  89. jobBom,
  90. oneJobBom,
  91. byProductBom,
  92. turnoverBom,
  93. aridRegion,
  94. paramBom,
  95. packingBom,
  96. SearchPopup
  97. },
  98. data() {
  99. return {
  100. title: '',
  101. taskType: 1,
  102. objData: {
  103. equipmentList: [],
  104. modelList: [],
  105. turnover: [],
  106. productRecycleList: [],
  107. aridRegionList: [],
  108. palletList: [],
  109. workReportInfo: {},
  110. notFormedList: [], // 报工-不合格
  111. },
  112. searchShow: false,
  113. warehouseList: [],
  114. formData: {
  115. warehouseId: ''
  116. },
  117. penalizeIndex: null,
  118. paramDetailList: [],
  119. remainingTime: 0,
  120. id: null,
  121. taskId: null,
  122. }
  123. },
  124. onLoad(options) {
  125. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  126. this.taskType = options.taskType
  127. this.id = options.id
  128. this.taskId = options.taskId
  129. this.getList()
  130. },
  131. onShow() {
  132. uni.$off("setSelectList");
  133. uni.$on("setSelectList", (selectList, id) => {
  134. let turnover = []
  135. let equipmentList = [] // 生产设备
  136. let isEquipment = this.objData.equipmentList.length > 0 ? true : false // 判断是否有设置
  137. selectList.forEach(f => {
  138. if (f.rootCategoryLevelId == 4) { // 生产设备
  139. if (isEquipment) {
  140. equipmentList = this.objData.equipmentList
  141. } else {
  142. equipmentList = equipmentList.concat(f)
  143. }
  144. }
  145. if (f.rootCategoryLevelId == 7) { // 周转车
  146. turnover = turnover.concat(f)
  147. }
  148. })
  149. this.$set(this.objData, 'equipmentList', equipmentList)
  150. this.$set(this.objData, 'turnover', turnover)
  151. this.$forceUpdate()
  152. });
  153. },
  154. methods: {
  155. // 相机扫码
  156. HandlScanCode() {
  157. let _this = this
  158. uni.scanCode({
  159. success: function(res) {
  160. _this.scanItAllData(res.result)
  161. }
  162. })
  163. },
  164. scanItAllData(result) {
  165. scanLedger(result).then(res => {
  166. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  167. if (this.objData.equipmentList.length == 0) {
  168. this.objData.equipmentList = res
  169. this.$forceUpdate()
  170. } else {
  171. if (this.objData.equipmentList[0].instanceId != res[0].instanceId) {
  172. uni.showToast({
  173. title: '设备不匹配',
  174. icon: 'none'
  175. })
  176. } else {
  177. uni.showToast({
  178. title: '设备匹配成功',
  179. icon: 'none'
  180. })
  181. }
  182. }
  183. }
  184. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  185. if (this.objData.modelList.length == 0) {
  186. this.objData.modelList = res
  187. this.$forceUpdate()
  188. } else {
  189. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  190. uni.showToast({
  191. title: '模具不匹配',
  192. icon: 'none'
  193. })
  194. } else {
  195. uni.showToast({
  196. title: '设备匹配成功',
  197. icon: 'none'
  198. })
  199. }
  200. }
  201. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  202. let isFals = this.objData.turnover.some(m => m.code == result)
  203. if (isFals) {
  204. uni.showToast({
  205. title: '周转车已存在',
  206. icon: 'none'
  207. })
  208. return false
  209. }
  210. this.objData.turnover.push(res[0])
  211. this.$forceUpdate()
  212. }
  213. })
  214. },
  215. handleScan(id, type) {
  216. let _this = this
  217. uni.scanCode({
  218. success: function(res) {
  219. _this.scanData(res.result, type, id)
  220. }
  221. })
  222. },
  223. scanData(result, type, id) {
  224. if (type == 'wordOrder') {
  225. getByCodeReport(result, this.taskId).then(res => {
  226. this.objData = res
  227. if (!this.objData.hasOwnProperty('turnover')) {
  228. this.objData['turnover'] = []
  229. }
  230. if (!this.objData.hasOwnProperty('aridRegionList')) {
  231. this.objData['aridRegionList'] = []
  232. }
  233. })
  234. } else if (type == 'turnover') {
  235. let isFals = this.objData.turnover.some(m => m.code == result)
  236. if (isFals) {
  237. uni.showToast({
  238. title: '周转车已存在',
  239. icon: 'none'
  240. })
  241. return false
  242. }
  243. getByCodeReport(result, this.taskId).then(res => {
  244. this.objData.turnover[id] = res
  245. })
  246. }
  247. },
  248. getList() {
  249. getByIdReport(this.id, this.taskId).then(res => {
  250. this.objData = res
  251. if (!this.objData.hasOwnProperty('turnover')) {
  252. this.objData['turnover'] = []
  253. }
  254. if (!this.objData.hasOwnProperty('aridRegionList')) {
  255. this.objData['aridRegionList'] = []
  256. }
  257. if (!this.objData.hasOwnProperty('instanceList')) {
  258. this.objData['instanceList'] = []
  259. }
  260. this.taskType = res.currentTaskDiagram.type
  261. this.objData.palletList = [{
  262. categoryLevelId: '',
  263. categoryLevelName: '',
  264. categoryId: '',
  265. rootCategoryLevelId: '',
  266. code: '',
  267. name: '',
  268. specification: '',
  269. brandNum: '',
  270. modelType: '',
  271. quantity: '',
  272. unit: ''
  273. }]
  274. this.objData.workReportInfo = {
  275. formingNum: null,
  276. formingWeight: null,
  277. formedNum: null,
  278. formedWeight: null,
  279. taskId: this.taskId
  280. }
  281. this.objData.notFormedList = [{
  282. notFormedNum: null,
  283. notFormedWeight: null,
  284. weightUnit: res.weightUnit,
  285. unit: res.unit,
  286. warehouseId: null, // 处置 仓库id
  287. }]
  288. if (this.objData.instanceList.length > 0) { // 预制体报工
  289. this.objData.workReportInfo.formedNum = this.objData.instanceList.length
  290. }
  291. this.objData.workReportInfo.formingNum = res.formingNum
  292. this.objData.workReportInfo.formingWeight = res.formingWeight
  293. this.objData.workReportInfo.unit = res.unit
  294. this.objData.workReportInfo.weightUnit = res.weightUnit
  295. this.objData.workReportInfo.workOrderId = res.workOrderId
  296. this.paramDetailList = []
  297. this.paramDetailList = res.paramDetailList.map(m => {
  298. if (m.extInfo.textType == 5) {
  299. this.remainingTime = m.extInfo.remainingTime
  300. }
  301. return {
  302. ...m.extInfo
  303. }
  304. })
  305. })
  306. },
  307. scrolltolower() {},
  308. handAdd() {
  309. const storageKey = Date.now() + "";
  310. uni.setStorageSync(storageKey, this.objData || {});
  311. uni.navigateTo({
  312. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  313. })
  314. },
  315. penalize(index) {
  316. if (index || index == 0) {
  317. this.penalizeIndex = index
  318. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  319. } else {
  320. this.penalizeIndex = null
  321. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  322. }
  323. this.$forceUpdate()
  324. if (this.warehouseList.length == 0) {
  325. getWarehouseList().then(res => {
  326. this.warehouseList = res
  327. this.searchShow = true
  328. })
  329. } else {
  330. this.searchShow = true
  331. }
  332. },
  333. inputChange(e) {
  334. console.log(e)
  335. },
  336. searchCancel() {
  337. this.searchShow = false
  338. },
  339. popupOk() {
  340. if (this.penalizeIndex == null) {
  341. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  342. } else {
  343. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  344. }
  345. this.$forceUpdate()
  346. this.searchShow = false
  347. },
  348. modeNum(num) {
  349. if (this.objData.modelList.length == 0) {
  350. return false
  351. }
  352. this.$refs.modelRef.setNum(num)
  353. },
  354. save() {
  355. uni.showLoading({
  356. title: '加载中'
  357. });
  358. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  359. uni.showToast({
  360. title: '请输入合格品数量',
  361. icon: 'none'
  362. })
  363. return false
  364. }
  365. // if (!this.objData.workReportInfo['formedWeight'] && this.objData.workReportInfo['formedWeight'] != 0) {
  366. // uni.showToast({
  367. // title: '请输入合格品重量',
  368. // icon: 'none'
  369. // })
  370. // return false
  371. // }
  372. if (this.objData.notFormedList[0].notFormedNum > 0 && !this.objData.notFormedList[0].warehouseId) {
  373. uni.showToast({
  374. title: '请点击不合格品处置,选择仓库',
  375. icon: 'none'
  376. })
  377. return false
  378. }
  379. if (this.objData.productRecycleList.length > 0) {
  380. let bol
  381. bol = this.objData.productRecycleList.every(e => {
  382. return e.recycleQuantity >= 0 && e.warehouseId
  383. })
  384. if (!bol) {
  385. uni.showToast({
  386. title: '请选择副产品回收处置',
  387. icon: 'none'
  388. })
  389. return false
  390. }
  391. }
  392. // 预制体
  393. if (this.objData.instanceList.length > 0) {
  394. let bol
  395. let _i
  396. bol = this.objData.instanceList.every((e, i) => {
  397. _i = i + 1
  398. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId
  399. })
  400. if (!bol) {
  401. uni.showToast({
  402. title: `请完善第${_i}处置方式`,
  403. icon: 'none'
  404. })
  405. return false
  406. }
  407. }
  408. // 包装
  409. if (this.taskType == 4) {
  410. let packInfo = this.$refs.packRef.getData()
  411. this.objData.packInfo = packInfo
  412. this.objData.taskType = this.taskType
  413. if (packInfo.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this.objData
  414. .notFormedList[0].notFormedNum)) {
  415. uni.showToast({
  416. title: `合格品数量加不合格品数量不等于包装总数`,
  417. icon: 'none'
  418. })
  419. return false
  420. }
  421. }
  422. if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask 判断是否首工序
  423. if (this.objData.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this
  424. .objData.notFormedList[0].notFormedNum)) {
  425. uni.showToast({
  426. title: `合格品数量加不合格品数量不等于上道工序数量`,
  427. icon: 'none'
  428. })
  429. return false
  430. }
  431. }
  432. jobSave(this.objData).then(res => {
  433. uni.hideLoading();
  434. uni.navigateBack()
  435. }).finally(() => {
  436. setTimeout(function() {
  437. uni.hideLoading();
  438. }, 3000);
  439. })
  440. }
  441. }
  442. }
  443. </script>
  444. <style lang="scss" scoped>
  445. .content-box {
  446. height: 100vh;
  447. overflow: hidden;
  448. display: flex;
  449. flex-direction: column;
  450. }
  451. .list_box {
  452. flex: 1;
  453. overflow: hidden;
  454. padding: 4rpx 0;
  455. .u-list {
  456. height: 100% !important;
  457. }
  458. .card_box {
  459. padding: 16rpx 24rpx;
  460. }
  461. }
  462. .bottom-wrapper {
  463. .btn_box {
  464. width: 750rpx;
  465. height: 88rpx;
  466. line-height: 88rpx;
  467. background: $theme-color;
  468. text-align: center;
  469. font-size: 36rpx;
  470. font-style: normal;
  471. font-weight: 400;
  472. color: #fff;
  473. }
  474. }
  475. .operate_box {
  476. padding: 10rpx 160rpx;
  477. /deep/ .u-button {
  478. width: 160rpx;
  479. }
  480. }
  481. .search_list {
  482. min-height: 500rpx;
  483. padding: 0 32rpx;
  484. }
  485. </style>