details.vue 7.0 KB

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