index.vue 13 KB

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