index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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'
  20. pattern='job' @handleScan='handleScan'>
  21. </turnoverBom>
  22. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  23. :remainingTime='remainingTime' @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. let equipmentList = [] // 生产设备
  124. let isEquipment = this.objData.equipmentList.length > 0 ? true : false // 判断是否有设置
  125. selectList.forEach(f => {
  126. if (f.rootCategoryLevelId == 4) { // 生产设备
  127. if (isEquipment) {
  128. equipmentList = this.objData.equipmentList
  129. } else {
  130. equipmentList = equipmentList.concat(f)
  131. }
  132. }
  133. if (f.rootCategoryLevelId == 7) { // 周转车
  134. turnover = turnover.concat(f)
  135. }
  136. })
  137. this.$set(this.objData, 'equipmentList', equipmentList)
  138. this.$set(this.objData, 'turnover', turnover)
  139. this.$forceUpdate()
  140. });
  141. },
  142. methods: {
  143. // 相机扫码
  144. HandlScanCode() {
  145. // CX-EQ-YLSJL-008 设备
  146. // M001 M002 模具
  147. // 周转车 w0300000003140004
  148. // this.scanItAllData('M002')
  149. // return false
  150. let _this = this
  151. uni.scanCode({
  152. success: function(res) {
  153. _this.scanItAllData(res.result)
  154. }
  155. })
  156. },
  157. scanItAllData(result) {
  158. scanLedger(result).then(res => {
  159. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  160. if (this.objData.equipmentList.length == 0) {
  161. this.objData.equipmentList = res
  162. this.$forceUpdate()
  163. } else {
  164. if (this.objData.equipmentList[0].instanceId != res[0].instanceId) {
  165. uni.showToast({
  166. title: '设备不匹配',
  167. icon: 'none'
  168. })
  169. } else {
  170. uni.showToast({
  171. title: '设备匹配成功',
  172. icon: 'none'
  173. })
  174. }
  175. }
  176. }
  177. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  178. if (this.objData.modelList.length == 0) {
  179. this.objData.modelList = res
  180. this.$forceUpdate()
  181. } else {
  182. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  183. uni.showToast({
  184. title: '模具不匹配',
  185. icon: 'none'
  186. })
  187. } else {
  188. uni.showToast({
  189. title: '设备匹配成功',
  190. icon: 'none'
  191. })
  192. }
  193. }
  194. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  195. let isFals = this.objData.turnover.some(m => m.code == result)
  196. if (isFals) {
  197. uni.showToast({
  198. title: '周转车已存在',
  199. icon: 'none'
  200. })
  201. return false
  202. }
  203. this.objData.turnover.push(res[0])
  204. this.$forceUpdate()
  205. }
  206. })
  207. },
  208. handleScan(id, type) {
  209. let _this = this
  210. uni.scanCode({
  211. success: function(res) {
  212. _this.scanData(res.result, type, id)
  213. }
  214. })
  215. },
  216. scanData(result, type, id) {
  217. if (type == 'wordOrder') {
  218. getByCodeReport(result, this.taskId).then(res => {
  219. this.objData = res
  220. if (!this.objData.hasOwnProperty('turnover')) {
  221. this.objData['turnover'] = []
  222. }
  223. if (!this.objData.hasOwnProperty('aridRegionList')) {
  224. this.objData['aridRegionList'] = []
  225. }
  226. })
  227. } else if (type == 'turnover') {
  228. let isFals = this.objData.turnover.some(m => m.code == result)
  229. if (isFals) {
  230. uni.showToast({
  231. title: '周转车已存在',
  232. icon: 'none'
  233. })
  234. return false
  235. }
  236. getByCodeReport(result, this.taskId).then(res => {
  237. this.objData.turnover[id] = res
  238. })
  239. }
  240. },
  241. getList() {
  242. getByIdReport(this.id, this.taskId).then(res => {
  243. this.objData = res
  244. if (!this.objData.hasOwnProperty('turnover')) {
  245. this.objData['turnover'] = []
  246. }
  247. if (!this.objData.hasOwnProperty('aridRegionList')) {
  248. this.objData['aridRegionList'] = []
  249. }
  250. this.objData.palletList = [{
  251. categoryLevelId: '',
  252. categoryLevelName: '',
  253. categoryId: '',
  254. rootCategoryLevelId: '',
  255. code: '',
  256. name: '',
  257. specification: '',
  258. brandNum: '',
  259. modelType: '',
  260. quantity: '',
  261. unit: ''
  262. }]
  263. this.objData.workReportInfo = {
  264. formingNum: null,
  265. formingWeight: null,
  266. formedNum: null,
  267. formedWeight: null,
  268. taskId: this.taskId
  269. }
  270. this.objData.notFormedList = [{
  271. notFormedNum: null,
  272. notFormedWeight: null,
  273. weightUnit: res.weightUnit,
  274. unit: res.unit,
  275. warehouseId: null, // 处置 仓库id
  276. }]
  277. this.objData.workReportInfo.formingNum = res.formingNum
  278. this.objData.workReportInfo.formingWeight = res.formingWeight
  279. this.objData.workReportInfo.unit = res.unit
  280. this.objData.workReportInfo.weightUnit = res.weightUnit
  281. this.objData.workReportInfo.workOrderId = res.workOrderId
  282. this.paramDetailList = []
  283. this.paramDetailList = res.paramDetailList.map(m => {
  284. if (m.extInfo.textType == 5) {
  285. this.remainingTime = m.extInfo.remainingTime
  286. }
  287. return {
  288. ...m.extInfo
  289. }
  290. })
  291. })
  292. },
  293. scrolltolower() {},
  294. handAdd() {
  295. const storageKey = Date.now() + "";
  296. uni.setStorageSync(storageKey, this.objData || {});
  297. uni.navigateTo({
  298. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  299. })
  300. },
  301. penalize(index) {
  302. if (index || index == 0) {
  303. this.penalizeIndex = index
  304. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  305. } else {
  306. this.penalizeIndex = null
  307. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  308. }
  309. this.$forceUpdate()
  310. if (this.warehouseList.length == 0) {
  311. getWarehouseList().then(res => {
  312. this.warehouseList = res
  313. this.searchShow = true
  314. })
  315. } else {
  316. this.searchShow = true
  317. }
  318. },
  319. inputChange(e) {
  320. console.log(e)
  321. },
  322. searchCancel() {
  323. this.searchShow = false
  324. },
  325. popupOk() {
  326. if (this.penalizeIndex == null) {
  327. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  328. } else {
  329. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  330. }
  331. this.$forceUpdate()
  332. this.searchShow = false
  333. },
  334. save() {
  335. console.log(this.objData)
  336. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  337. uni.showToast({
  338. title: '请输入合格品数量',
  339. icon: 'none'
  340. })
  341. return false
  342. }
  343. // if (!this.objData.workReportInfo['formedWeight'] && this.objData.workReportInfo['formedWeight'] != 0) {
  344. // uni.showToast({
  345. // title: '请输入合格品重量',
  346. // icon: 'none'
  347. // })
  348. // return false
  349. // }
  350. if (this.objData.notFormedList[0].notFormedNum > 0 && !this.objData.notFormedList[0].warehouseId) {
  351. uni.showToast({
  352. title: '请点击不合格品处置,选择仓库',
  353. icon: 'none'
  354. })
  355. return false
  356. }
  357. if (this.objData.productRecycleList.length > 0) {
  358. let bol
  359. bol = this.objData.productRecycleList.every(e => {
  360. return e.recycleQuantity >= 0 && e.warehouseId
  361. })
  362. if (!bol) {
  363. uni.showToast({
  364. title: '请选择副产品回收处置',
  365. icon: 'none'
  366. })
  367. return false
  368. }
  369. }
  370. jobSave(this.objData).then(res => {
  371. if (res) {
  372. uni.navigateBack()
  373. }
  374. })
  375. }
  376. }
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. .content-box {
  381. height: 100vh;
  382. overflow: hidden;
  383. display: flex;
  384. flex-direction: column;
  385. }
  386. .list_box {
  387. flex: 1;
  388. overflow: hidden;
  389. padding: 4rpx 0;
  390. .u-list {
  391. height: 100% !important;
  392. }
  393. .card_box {
  394. padding: 16rpx 24rpx;
  395. }
  396. }
  397. .bottom-wrapper {
  398. .btn_box {
  399. width: 750rpx;
  400. height: 88rpx;
  401. line-height: 88rpx;
  402. background: $theme-color;
  403. text-align: center;
  404. font-size: 36rpx;
  405. font-style: normal;
  406. font-weight: 400;
  407. color: #fff;
  408. }
  409. }
  410. .operate_box {
  411. padding: 10rpx 160rpx;
  412. /deep/ .u-button {
  413. width: 160rpx;
  414. }
  415. }
  416. .search_list {
  417. min-height: 500rpx;
  418. padding: 0 32rpx;
  419. }
  420. </style>