details.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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"></uni-nav-bar>
  5. <view class="list_box">
  6. <u-list @scrolltolower="scrolltolower">
  7. <view v-for="(item,index) in List" :key="index" class="card_box">
  8. <workOrderBom :item='item' @handleScan='handleScan'></workOrderBom>
  9. <paramBom v-if='item.paramDetailList.length != 0' :list='item.paramDetailList'></paramBom>
  10. <deviceBom v-if='item.equipmentList.length != 0' :workOrderId='item.workOrderId'
  11. :list='item.equipmentList' @scanIt='scanIt'></deviceBom>
  12. <modelBom v-if='item.modelList.length != 0' :workOrderId='item.workOrderId' :list='item.modelList'
  13. @scanIt='scanIt'>
  14. </modelBom>
  15. <instanceBom v-if='item.instanceList.length != 0' :workOrderId='item.workOrderId'
  16. :list='item.instanceList'></instanceBom>
  17. <turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item' pattern='feed'
  18. @handleScan='handleScan' @handleDel='handleDel'></turnoverBom>
  19. <aridRegion v-if='item.aridRegionList.length != 0' :list='item.aridRegionList'
  20. @handleScan='handleScan'></aridRegion>
  21. <view class="operate_box rx-sc">
  22. <u-button size="small" class="u-reset-button" type="success"
  23. @click="handAdd(item.workOrderId)">手动添加</u-button>
  24. <u-button size="small" class="u-reset-button" type="success"
  25. @click="scanIt(item.workOrderId)">扫一扫</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. </view>
  34. </template>
  35. <script>
  36. import workOrderBom from './components/workOrderBom.vue'
  37. import deviceBom from './components/deviceBom.vue'
  38. import modelBom from './components/modelBom.vue'
  39. import instanceBom from './components/instanceBom.vue'
  40. import aridRegion from './components/aridRegion'
  41. import paramBom from './components/paramBom.vue'
  42. import turnoverBom from '../jobBooking/components/turnoverBom.vue'
  43. import {
  44. workorderList,
  45. getByCode,
  46. scanLedger,
  47. } from '@/api/pda/workOrder.js'
  48. import {
  49. batchSave
  50. } from '@/api/pda/feeding.js'
  51. export default {
  52. components: {
  53. workOrderBom,
  54. deviceBom,
  55. modelBom,
  56. instanceBom,
  57. aridRegion,
  58. paramBom,
  59. turnoverBom
  60. },
  61. data() {
  62. return {
  63. title: '',
  64. idsList: [],
  65. List: [],
  66. taskId: null
  67. }
  68. },
  69. onLoad(options) {
  70. this.title = options.taskName ? options.taskName + '-投料' : '投料'
  71. let queryArray = decodeURIComponent(options.arr);
  72. this.idsList = JSON.parse(queryArray);
  73. this.taskId = options.taskId
  74. this.taskName = options.taskName
  75. this.getList()
  76. },
  77. onShow() {
  78. uni.$off("setSelectList");
  79. uni.$on("setSelectList", (selectList, id) => {
  80. this.List.forEach(m => {
  81. if (m.workOrderId == id) {
  82. let modelList = [] // 模具
  83. let instanceList = [] // 投料
  84. let aridRegionList = [] // 干燥区
  85. let equipmentList = [] // 生产设备
  86. let isEquipment = m.equipmentList.length > 0 ? true : false // 判断是否有设置
  87. selectList.forEach(f => {
  88. if (f.rootCategoryLevelId == 4) {
  89. if (isEquipment) {
  90. equipmentList = m.equipmentList
  91. } else {
  92. equipmentList = equipmentList.concat(f)
  93. }
  94. }
  95. if (f.rootCategoryLevelId == 5) {
  96. modelList = modelList.concat(f)
  97. } else if (f.rootCategoryLevelId == 1) {
  98. instanceList = instanceList.concat(f)
  99. } else if (f.rootCategoryLevelId == 11) {
  100. aridRegionList = aridRegionList.concat(f)
  101. }
  102. })
  103. this.$set(m, 'modelList', modelList)
  104. this.$set(m, 'instanceList', instanceList)
  105. this.$set(m, 'aridRegionList', aridRegionList)
  106. this.$set(m, 'equipmentList', equipmentList)
  107. }
  108. })
  109. });
  110. },
  111. methods: {
  112. scrolltolower() {},
  113. save() {
  114. batchSave(this.List).then(res => {
  115. uni.navigateTo({
  116. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  117. });
  118. })
  119. },
  120. getList() {
  121. workorderList({
  122. ids: this.idsList,
  123. taskId: this.taskId
  124. }).then(res => {
  125. this.List = res.map(m => {
  126. m.workOrderId = m.id
  127. m.instanceList = [] // 物料
  128. m.equipmentList = [] // 设备
  129. m.modelList = [] // 模具
  130. m.aridRegionList = [] // 干燥区
  131. if (m.pickOutInList.length > 0) {
  132. m.pickOutInList.forEach(f => {
  133. if (f.rootCategoryLevelId == 1) {
  134. m.instanceList.push(f)
  135. } else if (f.rootCategoryLevelId == 4) {
  136. m.modelList.push(f)
  137. } else if (f.rootCategoryLevelId == 5) {
  138. m.modelList.push(f)
  139. } else if (f.rootCategoryLevelId == 11) {
  140. m.aridRegionList.push(f)
  141. }
  142. })
  143. }
  144. // 处理字段
  145. m.quality == '' ? m.quality = {} : ''
  146. delete m.id
  147. if (this.taskId) {
  148. m.taskId = this.taskId
  149. m.taskName = this.taskName
  150. }
  151. return {
  152. ...m
  153. }
  154. })
  155. })
  156. },
  157. handleScan(id, type) {
  158. console.log(id)
  159. console.log(type)
  160. // this.scanData('SCJHGD20240117002', type, id)
  161. // return false
  162. let _this = this
  163. uni.scanCode({
  164. success: function(res) {
  165. _this.scanData(res.result, type, id)
  166. }
  167. })
  168. },
  169. scanData(result, type, id) {
  170. if (type == 'wordOrder') {
  171. let isFals = this.List.some(m => m.code == result)
  172. if (isFals) {
  173. uni.showToast({
  174. title: '工单已存在',
  175. icon: 'none'
  176. })
  177. return false
  178. }
  179. getByCode(result).then(res => {
  180. let _arr = this.List
  181. _arr.forEach((e, index) => {
  182. if (e.workOrderId == id && res) {
  183. _arr[index] = res
  184. }
  185. })
  186. this.List = _arr
  187. this.$forceUpdate()
  188. })
  189. }
  190. },
  191. scanIt(id) {
  192. console.log(id)
  193. let _this = this
  194. uni.scanCode({
  195. success: function(res) {
  196. _this.scanItData(res.result, id)
  197. console.log(res.result, id)
  198. }
  199. })
  200. },
  201. scanItData(result, id) {
  202. scanLedger(result).then(res => {
  203. console.log(res)
  204. let _arr = []
  205. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  206. _arr = this.List
  207. _arr.forEach((e, index) => {
  208. if (e.workOrderId == id) {
  209. _arr[index].equipmentList = res
  210. }
  211. })
  212. this.List = _arr
  213. this.$forceUpdate()
  214. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  215. _arr = this.List
  216. _arr.forEach((e, index) => {
  217. if (e.workOrderId == id) {
  218. _arr[index].modelList = res
  219. }
  220. })
  221. this.List = _arr
  222. this.$forceUpdate()
  223. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) { // 物料
  224. _arr = this.List
  225. _arr.forEach((e, index) => {
  226. if (e.workOrderId == id) {
  227. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  228. }
  229. })
  230. this.List = _arr
  231. this.$forceUpdate()
  232. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  233. _arr = this.List
  234. _arr.forEach((e, index) => {
  235. if (e.workOrderId == id) {
  236. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  237. .aridRegionList[0].code)
  238. if (isFals) {
  239. uni.showToast({
  240. title: '干燥区已存在',
  241. icon: 'none'
  242. })
  243. return false
  244. }
  245. let _obj = res[0].aridRegionList[0]
  246. if (_obj.status == 0) {
  247. _obj['name'] = res[0].name
  248. _obj['region'] = res[0].extInfo.region
  249. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  250. .aridRegionList)
  251. } else {
  252. uni.showToast({
  253. title: '干燥区已占用',
  254. icon: 'none'
  255. })
  256. }
  257. }
  258. })
  259. this.List = _arr
  260. this.$forceUpdate()
  261. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  262. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  263. if (isFals) {
  264. uni.showToast({
  265. title: '周转车已存在',
  266. icon: 'none'
  267. })
  268. return false
  269. }
  270. }
  271. })
  272. },
  273. // 全部扫一扫
  274. handlScanCode() {
  275. let _this = this
  276. uni.scanCode({
  277. success: function(res) {
  278. _this.scanItAllData(res.result)
  279. }
  280. })
  281. },
  282. scanItAllData(result) {
  283. scanLedger(result).then(res => {
  284. let _arr = []
  285. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  286. _arr = this.List
  287. _arr.forEach((e, index) => {
  288. res['extInfo'].fixCode = res.fixCode
  289. e.equipmentList = res
  290. })
  291. this.List = _arr
  292. this.$forceUpdate()
  293. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  294. _arr = this.List
  295. _arr.forEach((e, index) => {
  296. e.modelList = res
  297. })
  298. this.List = _arr
  299. this.$forceUpdate()
  300. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  301. _arr = this.List
  302. _arr.forEach((e, index) => {
  303. e.instanceList = e.instanceList.concat(res)
  304. })
  305. this.List = _arr
  306. this.$forceUpdate()
  307. }
  308. })
  309. },
  310. handAdd(id) {
  311. const storageKey = Date.now() + "";
  312. uni.setStorageSync(storageKey, this.List || []);
  313. uni.navigateTo({
  314. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  315. })
  316. },
  317. },
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. .content-box {
  322. height: 100vh;
  323. overflow: hidden;
  324. display: flex;
  325. flex-direction: column;
  326. }
  327. .list_box {
  328. flex: 1;
  329. overflow: hidden;
  330. padding: 4rpx 0;
  331. .u-list {
  332. height: 100% !important;
  333. }
  334. .card_box {
  335. padding: 16rpx 24rpx;
  336. }
  337. }
  338. .bottom-wrapper {
  339. .btn_box {
  340. width: 750rpx;
  341. height: 88rpx;
  342. line-height: 88rpx;
  343. background: $theme-color;
  344. text-align: center;
  345. font-size: 36rpx;
  346. font-style: normal;
  347. font-weight: 400;
  348. color: #fff;
  349. }
  350. }
  351. .operate_box {
  352. padding: 10rpx 160rpx;
  353. /deep/ .u-button {
  354. width: 160rpx;
  355. }
  356. }
  357. </style>