semiProductJobBom.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name"> 报工信息: ({{list.length || 0}})个</view>
  5. </view>
  6. <view class="material " v-for="(it, idx) in list" :key="idx">
  7. <view class="content_table">
  8. <view class="item rx-sc">
  9. <view class="rx">
  10. <view class="lable lable190 rx-cc ">
  11. <view class="round">{{idx + 1}}</view>物料编码
  12. </view>
  13. <view class="content rx-bc">
  14. <view>{{it.code}} </view>
  15. <view
  16. v-if="Object.prototype.hasOwnProperty.call(it, 'extInfo') && Object.prototype.hasOwnProperty.call(it.extInfo, 'productionTimes') && Object.prototype.hasOwnProperty.call(it.extInfo.productionTimes,item.currentTaskDiagram.taskId) ">
  17. {{ it.extInfo.productionTimes[item.currentTaskDiagram.taskId]}}
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="item rx-sc">
  23. <view class="rx">
  24. <view class="lable lable150 rx-cc ">名称</view>
  25. <view class="content rx-sc">
  26. <view>{{it.name}} <text v-if="[2, 23,9,28].includes(Number(it.rootCategoryLevelId))">
  27. ({{it.rootCategoryLevelId == 2 ? '在制品' : it.rootCategoryLevelId == 23 ? '半成品' : it.rootCategoryLevelId == 9 ? '产品' : it.rootCategoryLevelId == 28 ? '废品' : '' }})
  28. </text> </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="item rx-sc">
  33. <view class="rx">
  34. <view class="lable lable150 rx-cc ">型号</view>
  35. <view class="content rx-sc">
  36. <view>{{it.modelType}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="item rx-sc">
  41. <view class="rx ww50 ">
  42. <view class="lable lable150 rx-cc ">物料代号</view>
  43. <view class="content content_num">
  44. <view v-if='isDetails'>{{it.extInfo.materielCode }}</view>
  45. <input class="uni-input" v-else v-model="it.extInfo.materielCode"></input>
  46. </view>
  47. </view>
  48. <view class="rx ww50">
  49. <view class="lable lable150 rx-cc ">客户代号</view>
  50. <view class="content content_num">
  51. <view v-if='isDetails'>{{it.extInfo.clientCode }}</view>
  52. <input class="uni-input" v-else v-model="it.extInfo.clientCode"></input>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="item rx-sc">
  57. <view class="rx ww50 ">
  58. <view class="lable lable150 rx-cc ">刻码</view>
  59. <view class="content content_num ">
  60. <view v-if='isDetails'>{{it.extInfo.engrave }}</view>
  61. <input class="uni-input" v-else v-model="it.extInfo.engrave"></input>
  62. </view>
  63. </view>
  64. <view class="rx ww50">
  65. <view class="lable lable150 rx-cc ">位置</view>
  66. <view class="content content_num">
  67. <view v-if='isDetails'>{{it.extInfo.position }}</view>
  68. <input class="uni-input" v-else v-model="it.extInfo.position"></input>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="item rx-sc">
  73. <view class="rx ww50">
  74. <view class="lable lable150 rx-cc ">设备</view>
  75. <view class="content ">
  76. <view>{{ it.deviceName || it.extInfo.deviceName }}</view>
  77. </view>
  78. </view>
  79. <view class="rx ww50">
  80. <view class="lable lable150 rx-cc ">炉次号</view>
  81. <view class="content content_num ">
  82. <view v-if='isDetails'>{{it.extInfo.heatNumber }}</view>
  83. <input class="uni-input" v-else v-model="it.extInfo.heatNumber"></input>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="content_table2">
  89. <view class="head row rx-sc">
  90. <view class="item ww25" style="font-size: 20rpx;">{{it.extInfo.newWeight ? '上道工序重量' : '物料重量' }}
  91. {{it.extInfo.weightUnit}}
  92. </view>
  93. <view class="item ww25">报工重量{{it.extInfo.weightUnit}}</view>
  94. <view class="item ww25" v-if="isFirstTask == 1">质检结果
  95. </view>
  96. <view class="item ww25" :class="[ isFirstTask == 1 ? 'ww25' : 'ww50' ]">处置
  97. </view>
  98. </view>
  99. <view class="table">
  100. <view class="tr row rx-sc">
  101. <view class="item ww25">{{it.extInfo.newWeight ? it.extInfo.newWeight : it.extInfo.weight }}
  102. </view>
  103. <view class="item ww25 content_num">
  104. <view v-if='isDetails'>{{it.extInfo.reportWeight }}</view>
  105. <input class="uni-input" v-else v-model="it.extInfo.reportWeight" type='digit'></input>
  106. </view>
  107. <view class="item ww25" @click="openNumerate(it, idx)" v-if="isFirstTask == 1">
  108. <view class="numerate">点击计算</view>
  109. </view>
  110. <view class="item" v-if='isDetails' :class="[ isFirstTask == 1 ? 'ww25' : 'ww50' ]">
  111. {{it.extInfo.taskName}}
  112. </view>
  113. <view class="item " v-else :class="[ isFirstTask == 1 ? 'ww25' : 'ww50' ]">
  114. <zxz-uni-data-select :localdata="stepsList" v-model="it.extInfo.taskId" dataValue='taskId'
  115. format='{taskTypeName}' dataKey="taskId" filterable
  116. @change=" e => it.extInfo.taskName = e.taskTypeName"
  117. :clear='false'></zxz-uni-data-select>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. <u-popup :show="show" mode='center' v-if='show' :closeOnClickOverlay='false'>
  124. <view class="popup_box">
  125. <view class="title_box rx-bc">
  126. <view class="name">工序计算列表</view>
  127. <view class="btn_box rx-ec">
  128. <view class="btn" @click="handAddParam">新增</view>
  129. </view>
  130. </view>
  131. <view class="content_table2">
  132. <view class="head row rx-sc">
  133. <view class="item ww30">工序名称</view>
  134. <view class="item ww20">坯体密度</view>
  135. <view class="item ww20">密度系数</view>
  136. <view class="item ww20">重量</view>
  137. <view class="item ww10">操作</view>
  138. </view>
  139. <view class="table">
  140. <view class="tr row rx-sc" v-for="(it, idx) in paramList" :key='idx'>
  141. <view class="item rx-bc ww30">
  142. <zxz-uni-data-select :localdata="stepsList" v-model="it.taskId" dataValue='taskId'
  143. format='{taskTypeName}' dataKey="taskId" filterable
  144. @change=" e => it.taskName = e.taskTypeName" :clear='false'></zxz-uni-data-select>
  145. </view>
  146. <view class="item ww20 content_num">
  147. <input class="uni-input" v-model="it.billet" type="digit"
  148. @input="changeInp(it, idx)"></input>
  149. </view>
  150. <view class="item ww20 content_num">
  151. <input class="uni-input" v-model="it.density" type="digit"
  152. @input="changeInp(it, idx)"></input>
  153. </view>
  154. <view class="item ww20" v-if=" (idx == 0 || idx != paramList.length - 1)">
  155. < {{it.CVIWeight}} </view>
  156. <view class="item ww20" v-if=" paramList.length > 1 && idx == paramList.length - 1">
  157. ≥ {{it.CVIWeight }}
  158. </view>
  159. <view class="item ww10 rx-cc" @click="getDelete(idx)">
  160. <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="20"
  161. color="#fa3534"></uni-icons>
  162. </view>
  163. </view>
  164. </view>
  165. <view class="formula_box">计算公式: 物料重量/坯体密度*密度系数 </view>
  166. <view class="rx-cc">
  167. <u-button size="small" class="u-reset-button" style="width: 300rpx;margin: 20rpx;"
  168. type="success" @click="paramSave">工序列表保存</u-button>
  169. </view>
  170. <view class="reportWeight rx-sc">
  171. 物料重量: {{weight}} ;
  172. 报工重量: {{reportWeight}}
  173. </view>
  174. </view>
  175. <view class="operate_box rx-sc">
  176. <u-button size="small" class="u-reset-button" @click="cancel">取消</u-button>
  177. <u-button size="small" class="u-reset-button" type="success" @click="save">确定</u-button>
  178. </view>
  179. </view>
  180. </u-popup>
  181. </view>
  182. </template>
  183. <script>
  184. import {
  185. getTaskInstanceList
  186. } from '@/api/pda/workOrder.js'
  187. import {
  188. saveParam,
  189. getComputeParam
  190. } from '@/api/pda/tangu.js'
  191. export default {
  192. props: {
  193. item: {
  194. type: Object,
  195. default: () => {}
  196. },
  197. list: {
  198. type: Array,
  199. default: () => []
  200. },
  201. isDetails: {
  202. type: Boolean,
  203. default: false
  204. },
  205. equipmentList: {
  206. type: Array,
  207. default: () => []
  208. },
  209. },
  210. watch: {
  211. equipmentList: {
  212. immediate: true,
  213. deep: true,
  214. handler(newVal) {
  215. this.deviceList = newVal
  216. this.changeHeatNumber()
  217. }
  218. },
  219. },
  220. data() {
  221. return {
  222. taskTypeName: null,
  223. isFirstTask: null,
  224. stepsList: [],
  225. show: false,
  226. rowIt: [],
  227. paramList: [],
  228. paramObj: {},
  229. weight: 0,
  230. reportWeight: 0,
  231. resultObj: {},
  232. resultIdx: 0,
  233. deviceList: []
  234. }
  235. },
  236. created() {
  237. this.taskTypeName = this.item.currentTaskDiagram.taskTypeName
  238. this.isFirstTask = this.item.currentTaskDiagram.isFirstTask
  239. this.getSteps()
  240. this.getCompute()
  241. },
  242. methods: {
  243. getSteps() {
  244. getTaskInstanceList(this.item.workOrderId).then(res => {
  245. this.stepsList = res
  246. })
  247. },
  248. getCompute() {
  249. getComputeParam(this.item.workOrderId, this.item.currentTaskDiagram.taskId).then(res => {
  250. this.paramList = []
  251. this.paramList = res && res.paramList || []
  252. this.paramObj = res || {}
  253. })
  254. },
  255. handAddParam() {
  256. // billet: null,
  257. // density: null,
  258. // result: null,
  259. // PIPDensity: null,
  260. // volume: null,
  261. // coefficient: null
  262. if (this.isFirstTask == 1) {
  263. this.paramList.push({
  264. taskId: null,
  265. taskName: null,
  266. })
  267. }
  268. },
  269. getDelete(idx) {
  270. this.paramList.splice(idx, 1)
  271. },
  272. changeInp(item, index) {
  273. if (Number(item.billet) && Number(item.density)) {
  274. this.paramList[index].CVIWeight = (Number(this.weight) / item.billet * item.density).toFixed(2)
  275. }
  276. },
  277. paramSave() {
  278. if (this.isFirstTask == 1 && this.paramList.length > 0) {
  279. let bol
  280. let _i
  281. bol = this.paramList.every((e, i) => {
  282. _i = i + 1
  283. return e.taskId && e.billet && e.density
  284. })
  285. if (!bol) {
  286. uni.showToast({
  287. title: `请完善第${_i}计算数据`,
  288. icon: 'none'
  289. })
  290. return false
  291. }
  292. if (this.paramList.length < 1) {
  293. uni.showToast({
  294. title: `请输入二个以上计算数据`,
  295. icon: 'none'
  296. })
  297. return false
  298. }
  299. }
  300. let param = {}
  301. if (!Object.prototype.hasOwnProperty.call(this.paramObj, 'id')) {
  302. param = {
  303. paramList: this.paramList,
  304. workOrderId: this.item.workOrderId,
  305. taskId: this.item.currentTaskDiagram.taskId
  306. }
  307. } else {
  308. this.paramObj.paramList = this.paramList
  309. param = this.paramObj
  310. }
  311. saveParam(param).then(res => {
  312. uni.showToast({
  313. icon: 'none',
  314. title: '操作成功'
  315. })
  316. this.getCompute()
  317. })
  318. },
  319. openNumerate(row, idx) {
  320. if (!row.extInfo.reportWeight) {
  321. uni.showToast({
  322. icon: 'none',
  323. title: '请先输入报工重量'
  324. })
  325. return false
  326. }
  327. this.weight = row.extInfo.weight
  328. this.reportWeight = row.extInfo.reportWeight
  329. this.resultIdx = idx
  330. this.show = true
  331. },
  332. cancel() {
  333. this.show = false
  334. this.reportWeight = 0
  335. this.weight = 0
  336. },
  337. taskChange(e) {
  338. console.log(e)
  339. },
  340. save() {
  341. if (this.isFirstTask == 1) {
  342. this.resultObj = {}
  343. if (Number(this.reportWeight) < Number(this.paramList[0].CVIWeight)) {
  344. this.resultObj = this.paramList[0]
  345. this.setDataSave()
  346. return false
  347. }
  348. if (Number(this.reportWeight) >= this.paramList[this.paramList.length - 1].CVIWeight) {
  349. this.resultObj = this.paramList[this.paramList.length - 1]
  350. this.setDataSave()
  351. return false
  352. }
  353. for (let i = 1; i < this.paramList.length; i++) {
  354. console.log(i)
  355. console.log(11, Number(this.paramList[i - 1].CVIWeight), Number(this.reportWeight))
  356. if (Number(this.paramList[i - 1].CVIWeight) < Number(this.reportWeight) && Number(this
  357. .reportWeight) < Number(this.paramList[i].CVIWeight)) {
  358. this.resultObj = this.paramList[i]
  359. break;
  360. }
  361. }
  362. this.setDataSave()
  363. }
  364. },
  365. setDataSave() {
  366. this.$set(this.list[this.resultIdx].extInfo, 'taskId', this.resultObj.taskId)
  367. this.$set(this.list[this.resultIdx].extInfo, 'density', this.resultObj.density)
  368. this.$set(this.list[this.resultIdx].extInfo, 'billet', this.resultObj.billet)
  369. this.$set(this.list[this.resultIdx].extInfo, 'taskName', this.resultObj.taskName)
  370. this.cancel()
  371. },
  372. changeHeatNumber() {
  373. this.deviceList.forEach(f => {
  374. this.list.forEach(o => {
  375. if (o.deviceId && f.id == o.deviceId && this.deviceList.length > 1) {
  376. o.extInfo.heatNumber = f.extInfo.heatNumber
  377. } else if (this.deviceList.length == 1) {
  378. o.extInfo.heatNumber = this.deviceList[0].extInfo.heatNumber
  379. this.$forceUpdate()
  380. }
  381. })
  382. })
  383. },
  384. }
  385. }
  386. </script>
  387. <style lang="scss" scoped>
  388. .title_box {
  389. margin-top: 20rpx;
  390. .name {
  391. font-size: 28rpx;
  392. font-style: normal;
  393. font-weight: 400;
  394. color: $theme-color;
  395. padding-left: 20rpx;
  396. position: relative;
  397. &:before {
  398. position: absolute;
  399. content: '';
  400. left: 0rpx;
  401. top: 0rpx;
  402. bottom: 0rpx;
  403. width: 4rpx;
  404. height: 28rpx;
  405. background: $theme-color;
  406. margin: auto;
  407. }
  408. }
  409. .btn_box {
  410. .btn {
  411. padding: 0 18rpx;
  412. height: 50rpx;
  413. line-height: 50rpx;
  414. background: $theme-color;
  415. font-size: 26rpx;
  416. font-style: normal;
  417. font-weight: 400;
  418. font-size: 24rpx;
  419. color: #fff;
  420. border-radius: 4rpx;
  421. margin-left: 24rpx;
  422. }
  423. }
  424. }
  425. .material {
  426. margin-top: 10rpx;
  427. .content_table {
  428. width: 100%;
  429. border: 2rpx solid $border-color;
  430. .item {
  431. display: flex;
  432. border-bottom: 2rpx solid $border-color;
  433. .lable {
  434. width: 132rpx;
  435. text-align: center;
  436. background-color: #F7F9FA;
  437. font-size: 26rpx;
  438. border-right: 2rpx solid $border-color;
  439. flex-shrink: 0;
  440. }
  441. .lable150 {
  442. width: 156rpx !important;
  443. font-size: 24rpx;
  444. }
  445. .lable190 {
  446. width: 190rpx !important;
  447. font-size: 24rpx;
  448. }
  449. .ww80 {
  450. width: 80rpx;
  451. }
  452. .content {
  453. width: 518rpx;
  454. min-height: 64rpx;
  455. font-size: 28rpx;
  456. line-height: 28rpx;
  457. font-style: normal;
  458. font-weight: 400;
  459. padding: 18rpx 8rpx;
  460. box-sizing: border-box;
  461. word-wrap: break-word;
  462. flex-grow: 1 !important;
  463. .unit {
  464. padding: 0 4rpx;
  465. font-size: 24rpx;
  466. color: #404446;
  467. }
  468. .penalize {
  469. width: 160rpx;
  470. line-height: 60rpx;
  471. background: $theme-color;
  472. font-size: 24rpx;
  473. text-align: center;
  474. color: #fff;
  475. }
  476. }
  477. .content_H {
  478. min-height: 92rpx;
  479. }
  480. .pd4 {
  481. padding: 4rpx 8rpx;
  482. }
  483. &:last-child {
  484. border-bottom: none;
  485. }
  486. }
  487. .ww55 {
  488. width: 55%;
  489. }
  490. .ww50 {
  491. width: 50%;
  492. }
  493. .ww45 {
  494. width: 45%;
  495. }
  496. }
  497. }
  498. .content_table2 {
  499. width: 100%;
  500. .row {
  501. width: 100%;
  502. .item {
  503. color: #404446;
  504. font-size: 28rpx;
  505. padding-left: 12rpx;
  506. }
  507. .color157 {
  508. color: $theme-color;
  509. }
  510. .ww30 {
  511. width: 30%;
  512. }
  513. .ww20 {
  514. width: 20%;
  515. }
  516. .ww15 {
  517. width: 15%;
  518. }
  519. .ww25 {
  520. width: 25%;
  521. }
  522. .ww50 {
  523. width: 50%;
  524. }
  525. .ww10 {
  526. width: 10%;
  527. }
  528. }
  529. .head {
  530. height: 64rpx;
  531. background: #F7F9FA;
  532. border-top: 2rpx solid #E3E5E5;
  533. border-left: 2rpx solid #E3E5E5;
  534. .item {
  535. height: 64rpx;
  536. line-height: 64rpx;
  537. border-right: 2rpx solid #E3E5E5;
  538. box-sizing: border-box;
  539. font-size: 22rpx;
  540. }
  541. }
  542. .tr {
  543. border-top: 2rpx solid #E3E5E5;
  544. border-left: 2rpx solid #E3E5E5;
  545. .item {
  546. font-size: 24rpx;
  547. min-height: 74rpx;
  548. display: flex;
  549. align-items: center;
  550. border-right: 2rpx solid #E3E5E5;
  551. box-sizing: border-box;
  552. white-space: normal;
  553. word-break: break-all;
  554. }
  555. &:last-child {
  556. border-bottom: 2rpx solid #E3E5E5;
  557. }
  558. .numerate {
  559. font-size: 22rpx;
  560. color: $theme-color;
  561. }
  562. }
  563. }
  564. .content_num {
  565. display: flex;
  566. align-items: center;
  567. padding: 0 4rpx;
  568. /deep/ .uni-input-input {
  569. border: 2rpx solid #F0F8F2;
  570. background: #F0F8F2;
  571. color: $theme-color;
  572. }
  573. }
  574. .round {
  575. width: 32rpx;
  576. height: 32rpx;
  577. line-height: 32rpx;
  578. text-align: center;
  579. border-radius: 50%;
  580. background: $theme-color;
  581. font-size: 24rpx;
  582. font-style: normal;
  583. font-weight: 400;
  584. color: #fff;
  585. margin-right: 18rpx;
  586. }
  587. .popup_box {
  588. width: 94vw;
  589. padding: 16rpx 12rpx;
  590. box-sizing: border-box;
  591. }
  592. .operate_box {
  593. margin-top: 32rpx;
  594. padding: 10rpx 100rpx;
  595. /deep/ .u-button {
  596. width: 160rpx;
  597. }
  598. }
  599. .formula_box {
  600. font-size: 24rpx;
  601. font-style: normal;
  602. font-weight: 400;
  603. margin-top: 12rpx;
  604. }
  605. .reportWeight {
  606. font-size: 24rpx;
  607. font-style: normal;
  608. font-weight: 400;
  609. margin-top: 30rpx;
  610. text {
  611. color: $theme-color;
  612. }
  613. }
  614. </style>