index.vue 12 KB

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