index.vue 13 KB

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