index.vue 12 KB

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