oneJobBom.vue 17 KB

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