details.vue 7.5 KB

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