turnoverBom.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name">周转车</view>
  5. </view>
  6. <view class="turnover-item" v-for="(item, index) in newList" :key="item.id || item.instanceId || item.code || index">
  7. <view class="title_box rx-bc" v-if='!isDetails'>
  8. <view class="left rx-ss" >
  9. <uni-icons @click="getDelete(index)" custom-prefix="iconfont" type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
  10. <view class="des" @click="handContract(index)">{{ isExpanded(index) ? '收缩' : '展开'}}</view>
  11. </view>
  12. <view class="btn_box rx-bc" @click="handleScan(index)" v-if="pattern == 'job'">
  13. <image class="scan" src="@/static/pda/ScanIt.svg"></image>
  14. 更换周转车
  15. </view>
  16. </view>
  17. <view class="content_table">
  18. <view class="item rx-sc">
  19. <view class="rx ww50 ">
  20. <view class="lable ww80 rx-cc ">编码</view>
  21. <view class="content rx-sc">
  22. <view>{{item.code}}</view>
  23. </view>
  24. </view>
  25. <view class="rx ww50">
  26. <view class="lable rx-cc ww80">名称</view>
  27. <view class="content rx-sc">
  28. <view>{{item.name}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="item rx-sc">
  33. <view class="rx ww50 ">
  34. <view class="lable ww80 rx-cc ">编号</view>
  35. <view class="content rx-sc">
  36. <view>{{item.codeNumber}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="content_table2">
  42. <view class="head row rx-sc">
  43. <view class="item ww10">货位</view>
  44. <view class="item ww35">工单编号</view>
  45. <view class="item ww35">产品编码</view>
  46. <view class="item ww20">数量(PCS)</view>
  47. </view>
  48. <view class="table">
  49. <view class="z_list">
  50. <view v-for="(it, idx) in item.extInfo.positionList" :key='idx'>
  51. <view class="tr row rx-sc" v-if="shouldShowPosition(item, it, idx, index)">
  52. <view class="item ww10">{{it.code}}</view>
  53. <view class="item ww35" :class="{'color157': getWorkOrderCode(item, it, idx) === wordItem.code}">
  54. {{ getWorkOrderCode(item, it, idx) }}
  55. </view>
  56. <view class="item ww35" :class="{'color157': getCategoryCode(item, it, idx) === wordItem.productCode}">
  57. {{ getCategoryCode(item, it, idx) }}
  58. </view>
  59. <view class="item ww20 " :class="{'content_num' : (pattern == 'job') }" v-if='!isDetails'>
  60. <!-- // it.workOrderCode!==itemValue.code 就是工单编号和 周转车编号相同就可以修改 it.isOccupy===0 是-->
  61. <input class="uni-input" v-if="canEditQuantity(item, it, idx)" @input="quantInt(index, idx, it)"
  62. :class="{'content_num_box': getCategoryCode(item, it, idx) !== wordItem.productCode}"
  63. v-model="it.quantity" type="digit"
  64. :disabled="pattern != 'job' || isDisabled(it)"></input>
  65. <text v-else>{{it.quantity}}</text>
  66. </view>
  67. <view class="item ww20" v-if='isDetails'>
  68. {{ it.quantity }}
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. props: {
  81. itemValue:{
  82. type: Object,
  83. default: () => {}
  84. },
  85. list: {
  86. type: Array,
  87. default: () => []
  88. },
  89. wordItem: {
  90. type: Object,
  91. default: () => {}
  92. },
  93. pattern: {
  94. type: String,
  95. default: ''
  96. },
  97. isDetails: {
  98. type: Boolean,
  99. default: false
  100. }
  101. },
  102. watch: {
  103. list: {
  104. immediate: true,
  105. deep: true,
  106. handler(newVal) {
  107. this.newList = newVal
  108. }
  109. }
  110. },
  111. data() {
  112. return {
  113. recycleQuantity: '',
  114. newList: [],
  115. totalCount: 0,
  116. expandedIndexes: []
  117. }
  118. },
  119. methods: {
  120. isExpanded(index) {
  121. return this.expandedIndexes.includes(index)
  122. },
  123. isAvailablePosition(it) {
  124. return !it.workOrderCode && Number(it.isOccupy || 0) === 0 && Number(it.isFull || 0) !== 1
  125. },
  126. getDefaultPositionIndex(item) {
  127. const positionList = item && item.extInfo && Array.isArray(item.extInfo.positionList)
  128. ? item.extInfo.positionList
  129. : []
  130. return positionList.findIndex(it => this.isAvailablePosition(it))
  131. },
  132. hasCurrentWorkOrder(item) {
  133. const positionList = item && item.extInfo && Array.isArray(item.extInfo.positionList)
  134. ? item.extInfo.positionList
  135. : []
  136. return positionList.some(it => it.workOrderCode === this.wordItem.code)
  137. },
  138. isDefaultPosition(item, it, idx) {
  139. return !this.hasCurrentWorkOrder(item) && this.isAvailablePosition(it) && this.getDefaultPositionIndex(item) === idx
  140. },
  141. shouldShowPosition(item, it, idx, turnoverIndex) {
  142. return this.isExpanded(turnoverIndex) || !!it.workOrderCode || this.isDefaultPosition(item, it, idx)
  143. },
  144. getWorkOrderCode(item, it, idx) {
  145. return it.workOrderCode || (this.isDefaultPosition(item, it, idx) ? this.wordItem.code : '')
  146. },
  147. getCategoryCode(item, it, idx) {
  148. return it.categoryCode || (this.isDefaultPosition(item, it, idx) ? this.wordItem.productCode : '')
  149. },
  150. canEditQuantity(item, it, idx) {
  151. return it.isFull == 0 || it.workOrderCode === this.wordItem.code || this.isDefaultPosition(item, it, idx)
  152. },
  153. //条件判断
  154. isDisabled(it) {
  155. if(it.workOrderCode === this.itemValue.code){
  156. return false
  157. }else{
  158. if(Number(it.isOccupy || 0) !== 0){
  159. return true
  160. }else{
  161. return false
  162. }
  163. }
  164. },
  165. quantInt(index, idx, it) {
  166. if (it.quantity >= 1) {
  167. this.$set(this.newList[index].extInfo.positionList[idx], 'workOrderCode', this.wordItem.code)
  168. this.$set(this.newList[index].extInfo.positionList[idx], 'categoryCode', this.wordItem.productCode)
  169. const maxQuantity = Number(this.itemValue.product && this.itemValue.product[0]
  170. ? this.itemValue.product[0].feedQuantity
  171. : 0)
  172. const currentTotal = this.getCurrentTotal(index, idx)
  173. if(maxQuantity > 0 && currentTotal > maxQuantity) {
  174. this.$set(this.newList[index].extInfo.positionList[idx], 'quantity', 0)
  175. this.$set(this.newList[index].extInfo.positionList[idx], 'workOrderCode', '')
  176. this.$set(this.newList[index].extInfo.positionList[idx], 'categoryCode', '')
  177. return uni.showToast({
  178. icon: 'none',
  179. title: `超出投料数量`
  180. })
  181. }
  182. } else {
  183. this.$set(this.newList[index].extInfo.positionList[idx], 'workOrderCode', '')
  184. this.$set(this.newList[index].extInfo.positionList[idx], 'categoryCode', '')
  185. this.$set(this.newList[index].extInfo.positionList[idx], 'quantity', 0)
  186. this.$set(this.newList[index].extInfo.positionList[idx], 'isOccupy', 0)
  187. }
  188. this.totalCount = 0
  189. this.newList.forEach(f => {
  190. f.extInfo.positionList.forEach(o => {
  191. if (o.workOrderCode == this.wordItem.code && (!Object.prototype.hasOwnProperty
  192. .call(o, 'isOccupy') || (o.isOccupy == 0 && o.quantity > 0))) {
  193. this.totalCount = Number(this.totalCount) + Number(o.quantity)
  194. }
  195. })
  196. })
  197. uni.showToast({
  198. icon: 'none',
  199. title: `已经放${this.totalCount}`
  200. })
  201. this.$emit('formedNumFn', this.totalCount)
  202. },
  203. getCurrentTotal(excludeTurnoverIndex, excludePositionIndex) {
  204. return this.newList.reduce((total, turnover, turnoverIndex) => {
  205. const positionList = turnover && turnover.extInfo && Array.isArray(turnover.extInfo.positionList)
  206. ? turnover.extInfo.positionList
  207. : []
  208. return positionList.reduce((positionTotal, position, positionIndex) => {
  209. if (turnoverIndex === excludeTurnoverIndex && positionIndex === excludePositionIndex) {
  210. return positionTotal + Number(position.quantity || 0)
  211. }
  212. return position.workOrderCode === this.wordItem.code
  213. ? positionTotal + Number(position.quantity || 0)
  214. : positionTotal
  215. }, total)
  216. }, 0)
  217. },
  218. handleScan(index) {
  219. this.$emit('handleScan', index, 'turnover')
  220. },
  221. getDelete(index) {
  222. this.list.splice(index, 1)
  223. this.expandedIndexes = this.expandedIndexes
  224. .filter(itemIndex => itemIndex !== index)
  225. .map(itemIndex => itemIndex > index ? itemIndex - 1 : itemIndex)
  226. },
  227. scrolltolower() {},
  228. handContract(index) {
  229. const expandedIndex = this.expandedIndexes.indexOf(index)
  230. if (expandedIndex === -1) {
  231. this.expandedIndexes.push(index)
  232. } else {
  233. this.expandedIndexes.splice(expandedIndex, 1)
  234. }
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. .title_box {
  241. margin-top: 20rpx;
  242. .name {
  243. font-size: 28rpx;
  244. font-style: normal;
  245. font-weight: 400;
  246. color: $theme-color;
  247. padding-left: 20rpx;
  248. position: relative;
  249. &:before {
  250. position: absolute;
  251. content: '';
  252. left: 0rpx;
  253. top: 0rpx;
  254. bottom: 0rpx;
  255. width: 4rpx;
  256. height: 28rpx;
  257. background: $theme-color;
  258. margin: auto;
  259. }
  260. }
  261. .des{
  262. font-size: 28rpx;
  263. font-style: normal;
  264. font-weight: 400;
  265. color: $theme-color;
  266. margin-left: 38rpx;
  267. }
  268. .left {
  269. width: 140rpx;
  270. }
  271. .btn_box {
  272. padding: 0 18rpx;
  273. height: 60rpx;
  274. background: $theme-color;
  275. font-size: 26rpx;
  276. font-style: normal;
  277. font-weight: 400;
  278. font-size: 24rpx;
  279. color: #fff;
  280. border-radius: 4rpx;
  281. .scan {
  282. width: 34rpx;
  283. height: 34rpx;
  284. margin-right: 12rpx;
  285. }
  286. }
  287. }
  288. .content_table {
  289. margin-top: 8rpx;
  290. width: 100%;
  291. border: 2rpx solid $border-color;
  292. .item {
  293. display: flex;
  294. border-bottom: 2rpx solid $border-color;
  295. .lable {
  296. width: 132rpx;
  297. text-align: center;
  298. background-color: #F7F9FA;
  299. font-size: 26rpx;
  300. border-right: 2rpx solid $border-color;
  301. flex-shrink: 0;
  302. }
  303. .ww80 {
  304. width: 80rpx;
  305. }
  306. .ww50 {
  307. width: 50%;
  308. }
  309. .content {
  310. width: 518rpx;
  311. min-height: 64rpx;
  312. font-size: 28rpx;
  313. line-height: 28rpx;
  314. font-style: normal;
  315. font-weight: 400;
  316. padding: 2rpx 8rpx;
  317. box-sizing: border-box;
  318. word-wrap: break-word;
  319. flex-grow: 1 !important;
  320. font-size: 24rpx;
  321. }
  322. &:last-child {
  323. border-bottom: none;
  324. }
  325. }
  326. }
  327. .content_table2 {
  328. width: 100%;
  329. .row {
  330. width: 100%;
  331. .item {
  332. color: #404446;
  333. font-size: 28rpx;
  334. padding-left: 12rpx;
  335. }
  336. .color157 {
  337. color: $theme-color;
  338. }
  339. .ww20 {
  340. width: 20%;
  341. }
  342. .ww35 {
  343. width: 35%;
  344. }
  345. .ww10 {
  346. width: 10%;
  347. }
  348. }
  349. .head {
  350. height: 64rpx;
  351. background: #F7F9FA;
  352. border-top: 2rpx solid #E3E5E5;
  353. border-left: 2rpx solid #E3E5E5;
  354. .item {
  355. height: 64rpx;
  356. line-height: 64rpx;
  357. border-right: 2rpx solid #E3E5E5;
  358. box-sizing: border-box;
  359. }
  360. }
  361. .tr {
  362. border-top: 2rpx solid #E3E5E5;
  363. border-left: 2rpx solid #E3E5E5;
  364. .item {
  365. font-size: 24rpx;
  366. min-height: 64rpx;
  367. display: flex;
  368. align-items: center;
  369. border-right: 2rpx solid #E3E5E5;
  370. box-sizing: border-box;
  371. white-space: normal;
  372. word-break: break-all;
  373. }
  374. &:last-child {
  375. border-bottom: 2rpx solid #E3E5E5;
  376. }
  377. }
  378. }
  379. .content_num {
  380. display: flex;
  381. align-items: center;
  382. padding: 0 4rpx;
  383. /deep/ .uni-input-input {
  384. border: 2rpx solid #F0F8F2;
  385. background: #F0F8F2;
  386. color: $theme-color;
  387. }
  388. }
  389. .content_num_box {
  390. /deep/ .uni-input-input {
  391. border: 2rpx solid #F0F8F2;
  392. background: #fafafa;
  393. color:#222;
  394. }
  395. }
  396. .z_list {
  397. height: auto;
  398. }
  399. </style>