semiProductJobBom.vue 17 KB

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