oneJobBom.vue 17 KB

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