oneJobBom.vue 17 KB

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