semiProductJobBom.vue 17 KB

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