index.vue 11 KB

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