report.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="报工"
  8. @clickLeft="back"
  9. >
  10. </uni-nav-bar>
  11. <uni-section title="设备信息">
  12. <view class="device">
  13. <view class="divice-top">
  14. <view class="top-name">设备</view>
  15. <view class="content">{{currentDivice.name}}</view>
  16. <view class="choose" @click="chooseAsset">选择</view>
  17. </view>
  18. <view class="divice-number">
  19. <view>生产数量<span>{{countInfo.standardTotalNum}} PCS</span></view>
  20. <view>生产重量<span>{{countInfo.standardTotalWeight}} KG</span></view>
  21. <view>已投料<span>{{countInfo.feedMaterielWeight}} KG</span></view>
  22. </view>
  23. <view class="divice-btm">
  24. <view class="btm-mold">
  25. <view class="mold-name">模具编码</view>
  26. <view class="content">{{currentMold.name}}</view>
  27. <view class="choose" @click="chooseMold">选择</view>
  28. </view>
  29. <view class="btm-mold">
  30. <view class="mold-name">冲压次数</view>
  31. <uni-easyinput class="modle-input" placeholder="请输入" trim="all" v-model="punchingNum"></uni-easyinput>
  32. <view>次</view>
  33. </view>
  34. </view>
  35. </view>
  36. </uni-section>
  37. <uni-section title="工单信息">
  38. <view class="device order-msg">
  39. <uni-table border stripe>
  40. <uni-tr>
  41. <uni-td align="center" class="label">工单号:</uni-td>
  42. <uni-td>{{orderInfo.code}}</uni-td>
  43. <uni-td align="center" class="label">产品编码:</uni-td>
  44. <uni-td> {{orderInfo.productCode}} </br> {{orderInfo.productName}} </uni-td>
  45. </uni-tr>
  46. <uni-tr>
  47. <uni-td align="center" class="label">牌号/型号:</uni-td>
  48. <uni-td> {{orderInfo.brandNo}} / {{orderInfo.model}} </uni-td>
  49. <uni-td align="center" class="label">生产数量:</uni-td>
  50. <uni-td> {{orderInfo.formingNum}} PCS</br> {{orderInfo.formingWeight}} KG </uni-td>
  51. </uni-tr>
  52. </uni-table>
  53. </view>
  54. </uni-section>
  55. <uni-section title="物料信息">
  56. <view class="device">
  57. <view class="device-line">
  58. <view class="line-title">物料名称</view>
  59. <view class="line-content">
  60. <view class="content">{{currentMaterial.categoryName}}</view>
  61. <view class="choose" @click="chooseMaterial">选择</view>
  62. </view>
  63. </view>
  64. <view class="device-line">
  65. <view class="line-title">物料编码</view>
  66. <view class="line-content">{{currentMaterial.categoryCode}}</view>
  67. </view>
  68. <view class="device-line">
  69. <view class="line-title">库存地点</view>
  70. <view class="line-content">
  71. <view class="content">{{currentLoaction.warehouse}}</view>
  72. <view class="choose" @click="chooseLocation">选择</view>
  73. </view>
  74. </view>
  75. <view class="device-line">
  76. <view class="line-title">批次号</view>
  77. <view class="line-content">
  78. <uni-data-select
  79. @change="batchChange"
  80. :localdata="batchList"
  81. v-model="currentMaterial.batchNo"></uni-data-select>
  82. </view>
  83. </view>
  84. <view class="device-line">
  85. <view class="line-title">库存</view>
  86. <view class="line-content">
  87. {{investmentNum}}KG
  88. </view>
  89. </view>
  90. <view class="device-line">
  91. <view class="line-title">实际投入</view>
  92. <view class="line-content">
  93. <!-- <view class="content-input"> -->
  94. <uni-easyinput trim="all" placeholder="请输入" v-model="currentMaterial.totalWeight"></uni-easyinput>
  95. <view>KG</view>
  96. <!-- </view> -->
  97. <!-- <div class="line-right">
  98. <u-button class="right-minus" @click="reduceNum" :disabled="investmentNum<2">-</u-button>
  99. <u-button class="right-add" @click="addNum">+</u-button>
  100. </div> -->
  101. </view>
  102. </view>
  103. </view>
  104. </uni-section>
  105. <uni-section title="周转车信息">
  106. <view class="device">
  107. <view class="car-row" v-for="(item, index) in carList">
  108. <view class="car-col">
  109. <text>周转车编码:</text>{{ item.code }}
  110. <view class="del" @click="handleDelete(index)">删除</view>
  111. </view>
  112. <!-- <view class="car-col">
  113. <text>产品数量:</text><uni-easyinput v-model="item.standardNum" placeholder="请输入" ></uni-easyinput>
  114. </view> -->
  115. <view class="car-col">
  116. <text>合格品数量(PCS):</text><uni-easyinput trim="all" type="number" placeholder="请输入" v-model="item.standardNum"></uni-easyinput>
  117. </view>
  118. <view class="car-col">
  119. <text>合格品重量(KG):</text><uni-easyinput disableColor="#ffffff" trim="all" :disabled="true" :value="(item.standardWeight =
  120. item.standardNum === ''
  121. ? ''
  122. : multiply(
  123. item.standardNum,
  124. orderInfo.productUnitWeight || 1
  125. ))"></uni-easyinput>
  126. </view>
  127. </view>
  128. <!-- <uni-table border stripe>
  129. <uni-tr>
  130. <uni-th align="center">周转车编码</uni-th>
  131. <uni-th align="center">产品数量</uni-th>
  132. <uni-th align="center">操作</uni-th>
  133. </uni-tr>
  134. <uni-tr v-for="(item, index) in carList">
  135. <uni-td>{{ item.code }}</uni-td>
  136. <uni-td>
  137. <uni-easyinput v-model="item.standardNum" placeholder="请输入" ></uni-easyinput>
  138. </uni-td>
  139. <uni-td>
  140. <view class="del" @click="handleDelete(index)">删除</view>
  141. </uni-td>
  142. </uni-tr>
  143. </uni-table> -->
  144. <view class="addcar" @click="chooseCar">+</view>
  145. </view>
  146. </uni-section>
  147. <uni-section title="处置信息">
  148. <view class="device handlebox">
  149. <!-- <view class="device-line">
  150. <view class="line-title">合格数量(PCS)</view>
  151. <view class="line-content">
  152. <uni-easyinput trim="all" type="number" placeholder="请输入" v-model="workReport.productInfo.standardNum"></uni-easyinput>
  153. </view>
  154. </view>
  155. <view class="device-line">
  156. <view class="line-title">合格重量(KG)</view>
  157. <view class="line-content">
  158. <uni-easyinput trim="all" type="number" :disabled="true" :value="(workReport.productInfo.standardWeight =
  159. workReport.productInfo.standardNum === ''
  160. ? ''
  161. : multiply(
  162. workReport.productInfo.standardNum,
  163. orderInfo.productUnitWeight || 1
  164. ))"></uni-easyinput>
  165. </view>
  166. </view> -->
  167. <view class="device-line">
  168. <view class="line-title">不合格数量(PCS)</view>
  169. <view class="line-content">
  170. <uni-easyinput trim="all" placeholder="请输入" type="number" v-model="workReport.productInfo.noStandardNum"></uni-easyinput>
  171. <view class="handle" @click="handle(1)">处置</view>
  172. </view>
  173. </view>
  174. <view class="device-line">
  175. <view class="line-title">不合格品重量(KG)</view>
  176. <view class="line-content">
  177. <uni-easyinput trim="all" type="number" disableColor="#ffffff" :disabled="true" :value="(workReport.productInfo.noStandardWeight =
  178. workReport.productInfo.noStandardNum === ''
  179. ? ''
  180. : multiply(
  181. workReport.productInfo.noStandardNum,
  182. orderInfo.productUnitWeight || 1
  183. ))"></uni-easyinput>
  184. </view>
  185. </view>
  186. <view class="device-line">
  187. <view class="line-title">副产品(KG)</view>
  188. <view class="line-content">
  189. <uni-easyinput trim="all" type="number" placeholder="请输入" v-model="workReport.productInfo.byProductWeight"></uni-easyinput>
  190. <view class="handle" @click="handle(2)">处置</view>
  191. </view>
  192. </view>
  193. </view>
  194. </uni-section>
  195. <view class="bottom" @click="report">完成报工</view>
  196. <locationPopu ref="locationRef" @checkLocation="comfirmLocation"></locationPopu>
  197. <assetPopu ref="assetRef" :taskId="taskId" @comfirmChoose="comfirmAsset"></assetPopu>
  198. <moldPopu ref="moldRef" @chooseMold="comfirmMold"></moldPopu>
  199. <materialPopu ref="materialRef"
  200. :taskId="taskId"
  201. :versionId="orderInfo.produceVersionId"
  202. @chooseMaterial="comfirmMaterial"
  203. ></materialPopu>
  204. <carPopu ref="carRef" @confirm="carConfirm"></carPopu>
  205. <HandlePop ref="handlePopRef" @confirm="handleConfirm" />
  206. </view>
  207. </template>
  208. <script>
  209. import locationPopu from '../components/locationPopu.vue'
  210. import assetPopu from '../components/assetPopu.vue'
  211. import moldPopu from '../components/moldPopu.vue'
  212. import materialPopu from '../components/materialPopu.vue'
  213. import carPopu from '../components/carPopu.vue'
  214. import HandlePop from "../components/HandlePop.vue";
  215. import dayjs from 'dayjs'
  216. import { getOrderById , getCount , getTaskListById , getBatchNumber } from '@/api/production/extrusion.js'
  217. import { workReport } from '@/api/production/execute'
  218. import { multiply } from '@/utils/math';
  219. export default {
  220. components: {
  221. HandlePop,
  222. locationPopu,
  223. assetPopu,
  224. moldPopu,
  225. materialPopu,
  226. carPopu
  227. },
  228. data () {
  229. return {
  230. // categoryMsg: {
  231. // batchNo: '',
  232. // number: '',
  233. // position: '',
  234. // totalWeight: '',
  235. // brandNum: '',
  236. // sourceCategoryId: '',
  237. // rootCategoryLevelId: '1',
  238. // name: '',
  239. // code: ''
  240. // },
  241. multiply,
  242. workReport: {
  243. qualityItem: '',
  244. workOrderId: '',
  245. qualityStandard: '',
  246. executorId: '',
  247. taskSort: '1',
  248. taskCode: "",
  249. taskName: "",
  250. executorJobNum: '',
  251. executeTime: dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'),
  252. remark: '',
  253. productInfo: {
  254. standardNum: '',
  255. byProductWeight: '',
  256. standardWeight: '',
  257. noStandardNum: '',
  258. noStandardWeight: ''
  259. }
  260. },
  261. punchingNum:'',
  262. diviceName:'',
  263. investmentNum:'',
  264. orderInfo:{},
  265. batchList: [],
  266. carList: [],
  267. id:'',
  268. countInfo:{},
  269. taskId:'',
  270. currentDivice:{},
  271. currentMold:{},
  272. currentLoaction:{},
  273. disposeOrderList:{},
  274. currentMaterial:{},
  275. batchNum:''
  276. }
  277. },
  278. onLoad ({ id , taskCode }) {
  279. if(id){
  280. this.id = id
  281. this.workReport.workOrderId = id
  282. }
  283. if(taskCode){
  284. this.workReport.taskCode = taskCode
  285. }
  286. this.getOrderInfo(id)
  287. this.getCountNumber()
  288. const userInfo = uni.getStorageSync('userInfo')
  289. this.workReport.executorId = userInfo?.userId;
  290. this.workReport.executorJobNum = userInfo?.jobNumber;
  291. },
  292. methods: {
  293. async carConfirm(list) {
  294. const obj = this.carList.map((i) => i.id);
  295. for (const p of list) {
  296. console.log(list, p);
  297. if (!obj.includes(p.id)) {
  298. obj.push(p.id);
  299. this.carList.push(p);
  300. }
  301. }
  302. },
  303. handleDelete(index) {
  304. const _this = this;
  305. uni.showModal({
  306. title: `确定删除当前周转车`,
  307. content: "",
  308. confirmText: "确认",
  309. success: function (res) {
  310. if (res.confirm) {
  311. _this.carList.splice(index, 1);
  312. }
  313. },
  314. });
  315. },
  316. chooseMaterial(){
  317. this.$refs.materialRef.open()
  318. },
  319. chooseAsset(){
  320. this.$refs.assetRef.open(this.currentDivice)
  321. },
  322. chooseMold(){
  323. this.$refs.moldRef.open()
  324. },
  325. chooseLocation(){
  326. this.$refs.locationRef.open()
  327. },
  328. chooseCar(){
  329. this.$refs.carRef.open()
  330. },
  331. handle(disposeType) {
  332. this.$refs.handlePopRef.open(disposeType);
  333. },
  334. handleConfirm(data) {
  335. data.workOrderCode = this.orderInfo.code
  336. data.workOrderId = this.id
  337. this.disposeOrderList = data
  338. },
  339. async report(){
  340. this.currentMaterial.position = this.currentLoaction.warehouseId
  341. this.currentMaterial.rootCategoryLevelId = '1',
  342. this.currentMaterial.sourceCategoryId = this.currentMaterial.id
  343. // this.currentMaterial.totalWeight = this.investmentNum
  344. const _this = this;
  345. uni.showModal({
  346. title: `是否提交报工?`,
  347. content: "",
  348. confirmText: "确认",
  349. success: async function (res) {
  350. if (res.confirm) {
  351. try {
  352. let standardNum = 0
  353. let standardWeight = 0
  354. _this.carList.map(item => {
  355. standardNum+=item.standardNum
  356. standardWeight+=item.standardWeight
  357. })
  358. _this.workReport.productInfo.standardNum = standardNum
  359. _this.workReport.productInfo.standardWeight = standardWeight
  360. await workReport({
  361. checkState: 1,
  362. isSapReportState: 1,
  363. workReport: _this.workReport,
  364. workReportCategoryList: [_this.currentMaterial],
  365. disposeOrderList: _this.disposeOrderList.workOrderId ? [_this.disposeOrderList] : [],
  366. workReportDeviceList: _this.carList.map(item => ({
  367. ...item,
  368. rootCategoryLevelId: 7,
  369. sourceInstanceId: item.id,
  370. }))
  371. })
  372. uni.showToast({
  373. title: "报工成功!",
  374. });
  375. setTimeout(() => {
  376. uni.navigateBack({
  377. delta: 1,
  378. });
  379. }, 1500);
  380. } catch (error) {
  381. uni.showToast({
  382. title: error,
  383. icon: "none",
  384. });
  385. }
  386. }
  387. },
  388. });
  389. },
  390. async getOrderInfo(id){
  391. const data = await getOrderById(id)
  392. this.orderInfo = data
  393. if(data.produceVersionId){
  394. const res = await getTaskListById(data.produceVersionId)
  395. if(res.length){
  396. this.taskId = res[0].id
  397. }
  398. }
  399. },
  400. async getCountNumber(){
  401. const params = {
  402. taskCode:this.workReport.taskCode,
  403. workOrderId:this.id
  404. }
  405. const data = await getCount(params)
  406. this.countInfo = data
  407. },
  408. comfirmAsset(currentData){
  409. this.currentDivice = currentData
  410. },
  411. comfirmMold(currentData){
  412. this.currentMold = currentData
  413. },
  414. comfirmLocation(currentData){
  415. this.currentLoaction = currentData
  416. this.getBatch()
  417. },
  418. comfirmMaterial(currentData){
  419. this.currentMaterial = currentData
  420. this.currentMaterial.code = currentData.categoryCode
  421. this.currentMaterial.name = currentData.categoryName
  422. // this.currentMaterial.id = currentData.categoryId
  423. this.getBatch()
  424. },
  425. getBatch(){
  426. if(this.currentLoaction.warehouseId&&this.currentMaterial.categoryCode){
  427. const params = {
  428. position:this.currentLoaction.warehouseId,
  429. categoryCode:this.currentMaterial.categoryCode,
  430. factoryCode:this.orderInfo.werks
  431. }
  432. getBatchNumber(params).then(res=>{
  433. this.batchList = res.map(item => ({
  434. ...item,
  435. value: item.batchNum,
  436. text: item.batchNum
  437. }))
  438. })
  439. }
  440. },
  441. batchChange(e){
  442. console.log(e);
  443. const obj = this.batchList.find(i => i.value === e)
  444. if(obj){
  445. this.investmentNum = obj.storageNum
  446. }
  447. },
  448. addNum(){
  449. this.investmentNum = Number(this.investmentNum)+1
  450. },
  451. reduceNum(){
  452. this.investmentNum = Number(this.investmentNum)-1
  453. }
  454. }
  455. }
  456. </script>
  457. <style lang="scss" scoped>
  458. .device{
  459. width: 100%;
  460. .car-row{
  461. border-bottom: 1rpx solid #ccc;
  462. margin-bottom: 30rpx;
  463. .car-col{
  464. display: flex;
  465. justify-content: space-between;
  466. align-items: center;
  467. padding:10rpx 20rpx;
  468. text{
  469. margin-right: 20rpx;
  470. }
  471. }
  472. }
  473. &.order-msg{
  474. .uni-table-td{
  475. font-size: 28rpx !important;
  476. padding: 8rpx 0rpx;
  477. &.label{
  478. font-weight: bold;
  479. }
  480. }
  481. }
  482. .divice-top{
  483. width: 96%;
  484. height: 60rpx;
  485. margin: 10rpx auto;
  486. display: flex;
  487. align-items: center;
  488. justify-content: flex-start;
  489. }
  490. .divice-number{
  491. display: flex;
  492. align-items: center;
  493. justify-content: space-around;
  494. margin: 20rpx 0;
  495. span{
  496. margin-left: 10rpx;
  497. }
  498. view:last-child span{
  499. color: rgba(112, 182, 3, 1);
  500. }
  501. }
  502. .divice-btm{
  503. width: 96%;
  504. margin: 0 auto;
  505. .btm-mold{
  506. display: flex;
  507. align-items: center;
  508. justify-content: flex-start;
  509. width: 60%;
  510. margin-bottom: 20rpx;
  511. .uni-easyinput,
  512. .content{
  513. width: 35%;
  514. margin: 0 20rpx;
  515. }
  516. }
  517. .btm-mold.btm-last{
  518. width: 40%;
  519. .modle-input{
  520. margin: 0 10rpx;
  521. }
  522. }
  523. }
  524. .device-line{
  525. display: flex;
  526. align-items: center;
  527. width: 100%;
  528. border-bottom: 1rpx solid #ccc;
  529. // margin-bottom: 20rpx;
  530. height: 80rpx;
  531. .line-title{
  532. width: 40%;
  533. text-indent: 30rpx;
  534. }
  535. .line-content{
  536. display: flex;
  537. align-items: center;
  538. justify-content: space-between;
  539. width: 70%;
  540. margin-right: 20rpx;
  541. .content{
  542. width: 70%;
  543. margin: 0 20rpx 0 0;
  544. }
  545. .content-input{
  546. display: flex;
  547. align-items: center;
  548. justify-content: flex-start;
  549. width: 40%;
  550. view{
  551. margin-left: 10rpx;
  552. }
  553. }
  554. .line-right{
  555. display: flex;
  556. align-items: center;
  557. justify-content: flex-end;
  558. .right-minus{
  559. width: 80rpx;
  560. height: 51rpx;
  561. text-align: center;
  562. line-height: 51rpx;
  563. color: #fff;
  564. background: #F59A23;
  565. }
  566. .right-add{
  567. width: 80rpx;
  568. height: 51rpx;
  569. text-align: center;
  570. line-height: 51rpx;
  571. color: #fff;
  572. background: #70B603;
  573. margin-left: 10rpx;
  574. }
  575. .right-choose.u-button--info{
  576. border-color:#70B603;
  577. color: #70B603;
  578. }
  579. }
  580. }
  581. }
  582. .addcar{
  583. width: 100%;
  584. display: flex;
  585. align-items: center;
  586. justify-content: center;
  587. font-size: 120rpx;
  588. color: #ccc;
  589. font-weight: bold;
  590. line-height: 80rpx;
  591. }
  592. .content{
  593. width: 40%;
  594. border: 1rpx solid #ccc;
  595. border-radius: 8rpx;
  596. line-height: 60rpx;
  597. height: 60rpx;
  598. margin: 0 20rpx;
  599. text-indent: 12rpx;
  600. }
  601. .choose{
  602. background: rgba(112, 182, 3, 1);
  603. color: #fff;
  604. padding: 10rpx 20rpx;
  605. border-radius: 8rpx;
  606. }
  607. .del{
  608. background: rgba(236, 128, 141, 1);
  609. color: #fff;
  610. padding: 10rpx 20rpx;
  611. border-radius: 8rpx;
  612. }
  613. .handle{
  614. background: rgba(112, 182, 3, 1);
  615. color: #fff;
  616. padding: 10rpx 20rpx;
  617. border-radius: 8rpx;
  618. margin-left: 60rpx;
  619. }
  620. }
  621. .handlebox{
  622. padding-bottom: 130rpx;
  623. }
  624. .bottom{
  625. width: 100%;
  626. height: 90rpx;
  627. display: flex;
  628. align-items: center;
  629. justify-content: center;
  630. position: fixed;
  631. bottom: 0;
  632. left: 0;
  633. font-size: 36rpx;
  634. color: #fff;
  635. background: #4B7902;
  636. }
  637. </style>