index.vue 12 KB

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