details.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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('CX-EQ-YLSJL-008', 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. console.log(res.fixCode)
  161. _arr[index].equipmentList = res
  162. }
  163. })
  164. this.List = _arr
  165. this.$forceUpdate()
  166. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  167. _arr = this.List
  168. _arr.forEach((e, index) => {
  169. if (e.workOrderId == id) {
  170. _arr[index].modelList = res
  171. }
  172. })
  173. this.List = _arr
  174. this.$forceUpdate()
  175. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  176. _arr = this.List
  177. _arr.forEach((e, index) => {
  178. if (e.workOrderId == id) {
  179. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  180. }
  181. })
  182. this.List = _arr
  183. this.$forceUpdate()
  184. }
  185. })
  186. },
  187. // 全部扫一扫
  188. handlScanCode() {
  189. // CX-EQ-YLSJL-008 设备
  190. // M001 M002 模具
  191. // S310000552731 物料
  192. // this.scanItAllData('M001')
  193. // return false
  194. let _this = this
  195. uni.scanCode({
  196. success: function(res) {
  197. _this.scanItAllData(res.result)
  198. }
  199. })
  200. },
  201. scanItAllData(result) {
  202. scanLedger(result).then(res => {
  203. let _arr = []
  204. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  205. _arr = this.List
  206. _arr.forEach((e, index) => {
  207. res['extInfo'].fixCode = res.fixCode
  208. e.equipmentList = res
  209. })
  210. this.List = _arr
  211. this.$forceUpdate()
  212. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  213. _arr = this.List
  214. _arr.forEach((e, index) => {
  215. e.modelList = res
  216. })
  217. this.List = _arr
  218. this.$forceUpdate()
  219. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  220. _arr = this.List
  221. _arr.forEach((e, index) => {
  222. e.instanceList = e.instanceList.concat(res)
  223. })
  224. this.List = _arr
  225. this.$forceUpdate()
  226. }
  227. })
  228. },
  229. handAdd(id, list) {
  230. const storageKey = Date.now() + "";
  231. uni.setStorageSync(storageKey, list || []);
  232. uni.navigateTo({
  233. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed`
  234. })
  235. },
  236. },
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. .content-box {
  241. height: 100vh;
  242. overflow: hidden;
  243. display: flex;
  244. flex-direction: column;
  245. }
  246. .list_box {
  247. flex: 1;
  248. overflow: hidden;
  249. padding: 4rpx 0;
  250. .u-list {
  251. height: 100% !important;
  252. }
  253. .card_box {
  254. padding: 16rpx 24rpx;
  255. }
  256. }
  257. .bottom-wrapper {
  258. .btn_box {
  259. width: 750rpx;
  260. height: 88rpx;
  261. line-height: 88rpx;
  262. background: $theme-color;
  263. text-align: center;
  264. font-size: 36rpx;
  265. font-style: normal;
  266. font-weight: 400;
  267. color: #fff;
  268. }
  269. }
  270. .operate_box {
  271. padding: 10rpx 160rpx;
  272. /deep/ .u-button {
  273. width: 160rpx;
  274. }
  275. }
  276. </style>