details.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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. // CX-EQ-YLSJL-008 设备
  194. // M001 M002 模具
  195. // S310000552731 物料
  196. // 干燥区
  197. // w0300000003140004 周转车
  198. // this.scanItData('w0300000003140004', id)
  199. // return false
  200. let _this = this
  201. uni.scanCode({
  202. success: function(res) {
  203. _this.scanItData(res.result, id)
  204. console.log(res.result, id)
  205. }
  206. })
  207. },
  208. scanItData(result, id) {
  209. scanLedger(result).then(res => {
  210. console.log(res)
  211. let _arr = []
  212. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  213. _arr = this.List
  214. _arr.forEach((e, index) => {
  215. if (e.workOrderId == id) {
  216. _arr[index].equipmentList = res
  217. }
  218. })
  219. this.List = _arr
  220. this.$forceUpdate()
  221. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  222. _arr = this.List
  223. _arr.forEach((e, index) => {
  224. if (e.workOrderId == id) {
  225. _arr[index].modelList = res
  226. }
  227. })
  228. this.List = _arr
  229. this.$forceUpdate()
  230. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) { // 物料
  231. _arr = this.List
  232. _arr.forEach((e, index) => {
  233. if (e.workOrderId == id) {
  234. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  235. }
  236. })
  237. this.List = _arr
  238. this.$forceUpdate()
  239. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  240. _arr = this.List
  241. _arr.forEach((e, index) => {
  242. if (e.workOrderId == id) {
  243. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  244. .aridRegionList[0].code)
  245. if (isFals) {
  246. uni.showToast({
  247. title: '干燥区已存在',
  248. icon: 'none'
  249. })
  250. return false
  251. }
  252. let _obj = res[0].aridRegionList[0]
  253. if (_obj.status == 0) {
  254. _obj['name'] = res[0].name
  255. _obj['region'] = res[0].extInfo.region
  256. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  257. .aridRegionList)
  258. } else {
  259. uni.showToast({
  260. title: '干燥区已占用',
  261. icon: 'none'
  262. })
  263. }
  264. }
  265. })
  266. this.List = _arr
  267. this.$forceUpdate()
  268. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  269. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  270. if (isFals) {
  271. uni.showToast({
  272. title: '周转车已存在',
  273. icon: 'none'
  274. })
  275. return false
  276. }
  277. }
  278. })
  279. },
  280. // 全部扫一扫
  281. handlScanCode() {
  282. // CX-EQ-YLSJL-008 设备
  283. // M001 M002 模具
  284. // S310000552731 物料
  285. // w0300000003140004 周转车
  286. // this.scanItAllData('w0300000003140004')
  287. // return false
  288. let _this = this
  289. uni.scanCode({
  290. success: function(res) {
  291. _this.scanItAllData(res.result)
  292. }
  293. })
  294. },
  295. scanItAllData(result) {
  296. scanLedger(result).then(res => {
  297. let _arr = []
  298. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  299. _arr = this.List
  300. _arr.forEach((e, index) => {
  301. res['extInfo'].fixCode = res.fixCode
  302. e.equipmentList = res
  303. })
  304. this.List = _arr
  305. this.$forceUpdate()
  306. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  307. _arr = this.List
  308. _arr.forEach((e, index) => {
  309. e.modelList = res
  310. })
  311. this.List = _arr
  312. this.$forceUpdate()
  313. } else if (res.length >= 1 && ['1'].includes(res[0].rootCategoryLevelId)) {
  314. _arr = this.List
  315. _arr.forEach((e, index) => {
  316. e.instanceList = e.instanceList.concat(res)
  317. })
  318. this.List = _arr
  319. this.$forceUpdate()
  320. }
  321. })
  322. },
  323. handAdd(id) {
  324. const storageKey = Date.now() + "";
  325. uni.setStorageSync(storageKey, this.List || []);
  326. uni.navigateTo({
  327. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  328. })
  329. },
  330. },
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. .content-box {
  335. height: 100vh;
  336. overflow: hidden;
  337. display: flex;
  338. flex-direction: column;
  339. }
  340. .list_box {
  341. flex: 1;
  342. overflow: hidden;
  343. padding: 4rpx 0;
  344. .u-list {
  345. height: 100% !important;
  346. }
  347. .card_box {
  348. padding: 16rpx 24rpx;
  349. }
  350. }
  351. .bottom-wrapper {
  352. .btn_box {
  353. width: 750rpx;
  354. height: 88rpx;
  355. line-height: 88rpx;
  356. background: $theme-color;
  357. text-align: center;
  358. font-size: 36rpx;
  359. font-style: normal;
  360. font-weight: 400;
  361. color: #fff;
  362. }
  363. }
  364. .operate_box {
  365. padding: 10rpx 160rpx;
  366. /deep/ .u-button {
  367. width: 160rpx;
  368. }
  369. }
  370. </style>