index.vue 13 KB

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