details.vue 9.1 KB

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