sampleBom.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name">取样</view>
  5. </view>
  6. <view class="material ">
  7. <view class="content_table">
  8. <view class="item">
  9. <view class="lable rx-cc">工序名称</view>
  10. <view class="content">
  11. {{item.diagramLast.taskTypeName}}
  12. </view>
  13. </view>
  14. <view class="item rx-sc">
  15. <view class="rx ww55 ">
  16. <view class="lable rx-cc">数量</view>
  17. <view class="content rx-sc">
  18. <view>{{item.formedNum}}</view>
  19. <view class="unit">{{item.unit}}</view>
  20. </view>
  21. </view>
  22. <view class="rx ww45">
  23. <view class="lable rx-cc ww80">重量</view>
  24. <view class="content content_num">
  25. <view>{{item.formedWeight}}</view>
  26. <view class="unit">{{item.weightUnit}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="item">
  31. <view class="lable rx-cc">取样数量</view>
  32. <view class="content content_num rx-sc">
  33. <view style='width: 300rpx;'>{{ item.sampleNum }}</view>
  34. <view class="unit">{{item.unit}}</view>
  35. <view class="penalize" v-if='!isDetails' @click="penalize">处置
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="content_table2" v-if="item.sampleList.length > 0">
  41. <view class="head row rx-sc">
  42. <view class="item ww15">货位</view>
  43. <view class="item ww30">类型</view>
  44. <view class="item ww45">处置</view>
  45. <view class="item ww15">操作</view>
  46. </view>
  47. <view class="table">
  48. <view v-for="(it, index) in item.sampleList" :key='index'>
  49. <view class="tr row rx-sc ">
  50. <view class="item ww15 content_num">
  51. {{ it.code }}
  52. </view>
  53. <view class="item ww30 content_num">
  54. <zxz-uni-data-select v-model="it.selectType" :localdata="rangeList"
  55. :disabled="isDetails" @change="hendleReuseNum"></zxz-uni-data-select>
  56. </view>
  57. <view class="item ww45 content_num">
  58. <zxz-uni-data-select :localdata="warehouseList" :disabled="isDetails"
  59. v-if='it.selectType == 2' v-model="it.warehouseId" dataValue='id' dataKey="name"
  60. filterable format='{name}'></zxz-uni-data-select>
  61. </view>
  62. <view class="item ww15">
  63. <view class="left rx-ss" @click="getDelete(index)">
  64. <uni-icons custom-prefix="iconfont" v-if="!isDetails" type="icon-shanchu" size="20"
  65. color="#fa3534"></uni-icons>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="tr row rx-sc wrap" style="margin-bottom: 30rpx;">
  70. <view class="item ww25 content_num cx-cc" v-for="(p, i) in it.paramList" :key="index + i">
  71. <view class="name">{{p.name}}</view>
  72. <input v-model="p.value" style="width: 168rpx ;"></input>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="title_box rx-bc" v-if="isDetails">
  80. <view class="name">报工</view>
  81. </view>
  82. <view class="material " v-if="isDetails">
  83. <view class="content_table">
  84. <view class="item">
  85. <view class="lable rx-cc">合格数量</view>
  86. <view class="content content_num">
  87. <input class="uni-input" v-model="workReportInfo.formedNum" type='digit'></input>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <u-popup :show="show" mode='center' v-if='show' :closeOnClickOverlay='false'>
  93. <view class="popup_box">
  94. <uni-data-select v-model="selectType" :localdata="rangeList"></uni-data-select>
  95. <view class="operate_box rx-sc">
  96. <u-button size="small" class="u-reset-button" @click="cancel">取消</u-button>
  97. <u-button size="small" class="u-reset-button" type="success" @click="save">确定</u-button>
  98. </view>
  99. </view>
  100. </u-popup>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. getWarehouseList,
  106. } from '@/api/pda/workOrder.js'
  107. export default {
  108. components: {
  109. },
  110. props: {
  111. item: {
  112. type: Object,
  113. default: () => {}
  114. },
  115. workReportInfo: {
  116. type: Object,
  117. default: () => {}
  118. },
  119. isDetails: {
  120. type: Boolean,
  121. default: false
  122. },
  123. turnoverList: {
  124. type: Array,
  125. default: () => []
  126. },
  127. paramList: {
  128. type: Array,
  129. default: () => []
  130. }
  131. },
  132. watch: {
  133. turnoverList: {
  134. immediate: true,
  135. deep: true,
  136. handler(newVal) {
  137. this.turnoverCount = 0
  138. newVal.forEach(f => {
  139. if (f.extInfo && f.extInfo.positionList && f.extInfo.positionList.length > 0) {
  140. f.extInfo.positionList.forEach(o => {
  141. if (Object.prototype.hasOwnProperty.call(o, 'sampleNum')) {
  142. this.turnoverCount = this.turnoverCount + Number(o.sampleNum)
  143. this.$set(this.item, 'sampleNum', this.turnoverCount)
  144. }
  145. })
  146. }
  147. this.mergedArray = []
  148. if (f.extInfo && f.extInfo.positionList && f.extInfo.positionList.length > 0) {
  149. f.extInfo.positionList.forEach(obj => {
  150. if (Object.prototype.hasOwnProperty.call(obj, 'sampleNum') && obj
  151. .sampleNum > 1) {
  152. for (let i = 0; i < obj.sampleNum; i++) {
  153. // 创建对象的副本,以避免引用相同的对象
  154. const objCopy = {
  155. ...obj,
  156. paramList: JSON.parse(JSON.stringify(this.paramList))
  157. };
  158. // 可以选择删除 num 属性,如果不需要在最终结果中保留它
  159. delete objCopy.sampleNum;
  160. this.mergedArray.push(objCopy);
  161. }
  162. } else if (obj.sampleNum == 1) {
  163. // 如果 sampleNum 等于 1,直接推入数组(可以选择删除 sampleNum 属性)
  164. const objCopy = {
  165. ...obj,
  166. paramList: JSON.parse(JSON.stringify(this.paramList))
  167. };
  168. this.mergedArray.push(objCopy);
  169. }
  170. // 如果 num 小于 1,则不执行任何操作(根据需求调整)
  171. });
  172. }
  173. console.log(this.mergedArray)
  174. })
  175. }
  176. }
  177. },
  178. data() {
  179. return {
  180. warehouseList: [],
  181. show: false,
  182. selectType: null,
  183. rangeList: [{
  184. value: 1,
  185. text: "回用"
  186. },
  187. {
  188. value: 2,
  189. text: "入库"
  190. },
  191. {
  192. value: 3,
  193. text: "损耗"
  194. }
  195. ],
  196. turnoverCount: 0,
  197. mergedArray: []
  198. }
  199. },
  200. created() {
  201. this.getWarehouseListFn()
  202. },
  203. methods: {
  204. getWarehouseListFn() {
  205. getWarehouseList().then(res => {
  206. this.warehouseList = res
  207. })
  208. },
  209. cancel() {
  210. this.selectType = null
  211. this.show = false
  212. },
  213. penalize() {
  214. if (Number(this.item.sampleNum <= 0)) {
  215. uni.showToast({
  216. icon: 'none',
  217. title: '取样数量要大于0, 请先选择周转车'
  218. })
  219. return false
  220. }
  221. this.item.sampleList = JSON.parse(JSON.stringify(this.mergedArray))
  222. this.$forceUpdate()
  223. },
  224. getDelete(idx) {
  225. this.item.sampleList.splice(idx, 1)
  226. },
  227. hendleReuseNum() {
  228. let count = 0
  229. if (this.item.sampleList.length > 0) {
  230. this.item.sampleList.forEach(f => {
  231. if (Object.prototype.hasOwnProperty.call(f, 'selectType') && f.selectType == 1) {
  232. count = count + 1
  233. }
  234. })
  235. }
  236. if (count > 0) {
  237. this.$set(this.item, 'reuseNum', count)
  238. this.$emit('showReuseTurnover', true)
  239. this.$forceUpdate()
  240. }
  241. },
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .title_box {
  247. margin-top: 28rpx;
  248. .name {
  249. font-size: 28rpx;
  250. font-style: normal;
  251. font-weight: 400;
  252. color: $theme-color;
  253. padding-left: 20rpx;
  254. position: relative;
  255. &:before {
  256. position: absolute;
  257. content: '';
  258. left: 0rpx;
  259. top: 0rpx;
  260. bottom: 0rpx;
  261. width: 4rpx;
  262. height: 28rpx;
  263. background: $theme-color;
  264. margin: auto;
  265. }
  266. }
  267. .btn_box {
  268. padding: 0 18rpx;
  269. height: 60rpx;
  270. background: $theme-color;
  271. font-size: 26rpx;
  272. font-style: normal;
  273. font-weight: 400;
  274. font-size: 24rpx;
  275. color: #fff;
  276. border-radius: 4rpx;
  277. .scan {
  278. width: 34rpx;
  279. height: 34rpx;
  280. margin-right: 12rpx;
  281. }
  282. }
  283. }
  284. .material {
  285. margin-top: 10rpx;
  286. .content_table {
  287. width: 100%;
  288. border: 2rpx solid $border-color;
  289. .item {
  290. display: flex;
  291. border-bottom: 2rpx solid $border-color;
  292. .lable {
  293. width: 156rpx;
  294. text-align: center;
  295. background-color: #F7F9FA;
  296. font-size: 26rpx;
  297. border-right: 2rpx solid $border-color;
  298. flex-shrink: 0;
  299. }
  300. .lable150 {
  301. width: 156rpx !important;
  302. font-size: 24rpx;
  303. }
  304. .ww80 {
  305. width: 80rpx;
  306. }
  307. .content {
  308. width: 518rpx;
  309. min-height: 64rpx;
  310. font-size: 28rpx;
  311. line-height: 28rpx;
  312. font-style: normal;
  313. font-weight: 400;
  314. padding: 18rpx 8rpx;
  315. box-sizing: border-box;
  316. word-wrap: break-word;
  317. flex-grow: 1 !important;
  318. .unit {
  319. padding: 0 4rpx;
  320. font-size: 24rpx;
  321. color: #404446;
  322. }
  323. .penalize {
  324. width: 200rpx;
  325. line-height: 60rpx;
  326. background: $theme-color;
  327. font-size: 24rpx;
  328. text-align: center;
  329. color: #fff;
  330. }
  331. }
  332. .pd4 {
  333. padding: 4rpx 8rpx;
  334. }
  335. &:last-child {
  336. border-bottom: none;
  337. }
  338. }
  339. .ww55 {
  340. width: 55%;
  341. }
  342. .ww45 {
  343. width: 45%;
  344. }
  345. }
  346. .content_table2 {
  347. width: 100%;
  348. margin-top: 8rpx;
  349. .wrap {
  350. flex-wrap: wrap;
  351. }
  352. .row {
  353. width: 100%;
  354. .item {
  355. padding: 8rpx 0;
  356. color: #404446;
  357. font-size: 28rpx;
  358. padding-left: 12rpx;
  359. }
  360. .left {
  361. width: 40rpx;
  362. }
  363. .ww25 {
  364. width: 25%;
  365. }
  366. .ww30 {
  367. width: 30%;
  368. }
  369. .ww20 {
  370. width: 20%;
  371. }
  372. .ww35 {
  373. width: 35%;
  374. }
  375. .ww45 {
  376. width: 45%;
  377. }
  378. .ww55 {
  379. width: 55%;
  380. }
  381. .ww15 {
  382. width: 15%;
  383. }
  384. .turnover_btn {
  385. color: $theme-color;
  386. font-size: 24rpx;
  387. padding-left: 12rpx;
  388. }
  389. }
  390. .head {
  391. height: 64rpx;
  392. background: #F7F9FA;
  393. border-top: 2rpx solid #E3E5E5;
  394. border-left: 2rpx solid #E3E5E5;
  395. .item {
  396. height: 64rpx;
  397. line-height: 64rpx;
  398. border-right: 2rpx solid #E3E5E5;
  399. box-sizing: border-box;
  400. }
  401. }
  402. .tr {
  403. border-top: 2rpx solid #E3E5E5;
  404. border-left: 2rpx solid #E3E5E5;
  405. .item {
  406. font-size: 24rpx;
  407. min-height: 78rpx;
  408. display: flex;
  409. align-items: center;
  410. border-right: 2rpx solid #E3E5E5;
  411. box-sizing: border-box;
  412. white-space: normal;
  413. word-break: break-all;
  414. }
  415. &:last-child {
  416. border-bottom: 2rpx solid #E3E5E5;
  417. }
  418. }
  419. }
  420. }
  421. .content_num {
  422. display: flex;
  423. align-items: center;
  424. padding: 0 4rpx;
  425. box-sizing: border-box;
  426. /deep/ .uni-input-input {
  427. border: 2rpx solid #F0F8F2;
  428. min-width: 100rpx;
  429. background: #F0F8F2;
  430. color: $theme-color;
  431. box-sizing: border-box;
  432. }
  433. }
  434. </style>