oneJobBom.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  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"
  129. v-if="taskTypeName == 'CVI' && (idx == 0 || idx != paramList.length - 1)">
  130. < <input class="uni-input" v-model="it.density" type="digit"></input>
  131. </view>
  132. <view class="item ww20 "
  133. v-if="taskTypeName == 'CVI' && paramList.length > 1 && idx == paramList.length - 1">
  134. ≥ <input class="uni-input" disabled
  135. v-model="it.density = paramList[paramList.length - 2].density"
  136. type="digit"></input>
  137. </view>
  138. <view class="item ww20 content_num" v-if="taskTypeName == 'CVI'">
  139. <input class="uni-input" v-model="it.billet" type="digit"
  140. @input="changeInp(it, idx)"></input>
  141. </view>
  142. <view class="item ww20" v-if="taskTypeName == 'CVI'">
  143. {{reportWeight}}
  144. </view>
  145. <!-- -------------PIP ------------- -->
  146. <view class="item ww20 content_num" v-if="taskTypeName == 'PIP'">
  147. <input class="uni-input" v-model="it.volume" type="digit"
  148. @input="jsPIPWeight(it, idx)"></input>
  149. </view>
  150. <view class="item ww20 content_num" v-if="taskTypeName == 'PIP'">
  151. <input class="uni-input" v-model="it.PIPDensity" type="digit"
  152. @input="jsPIPWeight(it, idx)"></input>
  153. </view>
  154. <view class="item ww15 content_num" v-if="taskTypeName == 'PIP'">
  155. <input class="uni-input" v-model="it.coefficient" type="digit"
  156. @input="jsPIPWeight(it, idx)"></input>
  157. </view>
  158. <view class="item ww15 " v-if="taskTypeName == 'PIP'">
  159. < {{it.PIPWeight}} </view>
  160. <view class="item ww10 rx-cc" @click="getDelete(idx)">
  161. <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="20"
  162. color="#fa3534"></uni-icons>
  163. </view>
  164. </view>
  165. </view>
  166. <view class="formula_box" v-if="taskTypeName == 'CVI'">计算公式: 报工重量*坯体密度/物料重量 </view>
  167. <view class="formula_box" v-if="taskTypeName == 'PIP'">计算公式: 坯体图体积*要求密度*系数 </view>
  168. <view class="rx-cc">
  169. <u-button size="small" class="u-reset-button" style="width: 300rpx;margin: 20rpx;"
  170. type="success" @click="paramSave">工序列表保存</u-button>
  171. </view>
  172. <view class="reportWeight rx-sc">
  173. 物料重量: {{weight}} ;
  174. 报工重量: {{reportWeight}}
  175. <text v-if="taskTypeName == 'CVI'">; 密度系数:{{ densityFactor }} </text>
  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. },
  209. watch: {
  210. },
  211. data() {
  212. return {
  213. taskTypeName: null,
  214. stepsList: [],
  215. show: false,
  216. rowIt: [],
  217. paramList: [],
  218. paramObj: {},
  219. weight: 0,
  220. reportWeight: 0,
  221. densityFactor: 0,
  222. resultObj: {},
  223. resultIdx: 0,
  224. }
  225. },
  226. created() {
  227. this.taskTypeName = this.item.currentTaskDiagram.taskTypeName
  228. this.getSteps()
  229. this.getCompute()
  230. },
  231. methods: {
  232. getSteps() {
  233. getTaskInstanceList(this.item.workOrderId).then(res => {
  234. this.stepsList = res
  235. })
  236. },
  237. getCompute() {
  238. getComputeParam(this.item.workOrderId, this.item.currentTaskDiagram.taskId).then(res => {
  239. this.paramList = []
  240. this.paramList = res.paramList
  241. this.paramObj = res
  242. })
  243. },
  244. handAddParam() {
  245. // billet: null,
  246. // density: null,
  247. // result: null,
  248. // PIPDensity: null,
  249. // volume: null,
  250. // coefficient: null
  251. if (this.taskTypeName == 'CVI') {
  252. this.paramList.push({
  253. taskId: null,
  254. taskName: null,
  255. })
  256. } else if (this.taskTypeName == 'PIP') {
  257. if (this.paramList.length < 1) {
  258. this.paramList.push({
  259. taskId: null,
  260. taskName: null,
  261. })
  262. } else {
  263. uni.showToast({
  264. title: `PIP计算重量,只要一条数据`,
  265. icon: 'none'
  266. })
  267. }
  268. }
  269. },
  270. getDelete(idx) {
  271. this.paramList.splice(idx, 1)
  272. },
  273. changeInp(item, index) {
  274. if (Number(item.billet)) {
  275. this.paramList.forEach(e => {
  276. e.billet = item.billet
  277. e.result = (Number(this.reportWeight) * item.billet / this.weight).toFixed(2)
  278. })
  279. }
  280. },
  281. jsPIPWeight(item, index) {
  282. console.log(item)
  283. this.paramList[index].PIPWeight = Number(item.volume * item.PIPDensity * item.coefficient).toFixed(2)
  284. },
  285. paramSave() {
  286. if (this.taskTypeName == 'CVI' && this.paramList.length > 0) {
  287. let bol
  288. let _i
  289. bol = this.paramList.every((e, i) => {
  290. _i = i + 1
  291. return e.taskId && e.billet && e.density
  292. })
  293. if (!bol) {
  294. uni.showToast({
  295. title: `请完善第${_i}计算数据`,
  296. icon: 'none'
  297. })
  298. return false
  299. }
  300. if (this.paramList.length < 1) {
  301. uni.showToast({
  302. title: `请输入二个以上计算数据`,
  303. icon: 'none'
  304. })
  305. return false
  306. }
  307. }
  308. let param = {}
  309. if (!this.paramObj.hasOwnProperty('id')) {
  310. param = {
  311. paramList: this.paramList,
  312. workOrderId: this.item.workOrderId,
  313. taskId: this.item.currentTaskDiagram.taskId
  314. }
  315. } else {
  316. this.paramObj.paramList = this.paramList
  317. param = this.paramObj
  318. }
  319. saveParam(param).then(res => {
  320. uni.showToast({
  321. icon: 'none',
  322. title: '操作成功'
  323. })
  324. this.getCompute()
  325. if (this.paramList.length > 0) {
  326. this.densityFactor = Number(this.reportWeight * this.paramList[0].billet / this.weight)
  327. .toFixed(2)
  328. }
  329. })
  330. },
  331. openNumerate(row, idx) {
  332. if (!row.extInfo.reportWeight) {
  333. uni.showToast({
  334. icon: 'none',
  335. title: '请先输入报工重量'
  336. })
  337. return false
  338. }
  339. this.weight = row.extInfo.weight || '20.2'
  340. this.reportWeight = row.extInfo.reportWeight
  341. this.resultIdx = idx
  342. if (this.paramList.length > 0) {
  343. this.densityFactor = Number(this.reportWeight * this.paramList[0].billet / this.weight).toFixed(2)
  344. }
  345. this.show = true
  346. },
  347. cancel() {
  348. this.show = false
  349. this.reportWeight = 0
  350. this.weight = 0
  351. },
  352. taskChange(e) {
  353. console.log(e)
  354. },
  355. save() {
  356. if (this.taskTypeName == 'CVI') {
  357. this.resultObj = {}
  358. if (Number(this.densityFactor) < this.paramList[0].density) {
  359. this.resultObj = this.paramList[0]
  360. this.setDataSave()
  361. return false
  362. }
  363. if (Number(this.densityFactor) >= this.paramList[this.paramList.length - 1].density) {
  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. if (Number(this.paramList[i - 1].density) < Number(this.densityFactor) <= Number(this.paramList[i]
  370. .density)) {
  371. this.resultObj = this.paramList[i]
  372. break;
  373. }
  374. }
  375. this.setDataSave()
  376. } else if (this.taskTypeName == 'PIP') {
  377. this.resultObj = {}
  378. if (Number(this.reportWeight) < this.paramList[0].PIPWeight) {
  379. this.resultObj = this.paramList[0]
  380. this.setDataSave()
  381. return false
  382. } else {
  383. for (let i = 1; i < this.stepsList.length; i++) {
  384. if (this.paramList[0].taskId == this.stepsList[i].taskId) {
  385. this.resultObj.taskId = this.stepsList[i + 1].taskId
  386. this.resultObj.taskName = this.stepsList[i + 1].taskTypeName
  387. break;
  388. }
  389. }
  390. }
  391. this.setDataSave()
  392. }
  393. },
  394. setDataSave() {
  395. this.$set(this.list[this.resultIdx].extInfo, 'taskId', this.resultObj.taskId)
  396. this.$set(this.list[this.resultIdx].extInfo, 'density', this.resultObj.density)
  397. this.$set(this.list[this.resultIdx].extInfo, 'billet', this.resultObj.billet)
  398. this.$set(this.list[this.resultIdx].extInfo, 'taskName', this.resultObj.taskName)
  399. this.cancel()
  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: 190rpx !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. margin-top: 16rpx;
  518. .row {
  519. width: 100%;
  520. .item {
  521. color: #404446;
  522. font-size: 28rpx;
  523. padding-left: 12rpx;
  524. }
  525. .color157 {
  526. color: $theme-color;
  527. }
  528. .ww30 {
  529. width: 30%;
  530. }
  531. .ww20 {
  532. width: 20%;
  533. }
  534. .ww15 {
  535. width: 15%;
  536. }
  537. .ww25 {
  538. width: 25%;
  539. }
  540. .ww50 {
  541. width: 50%;
  542. }
  543. .ww10 {
  544. width: 10%;
  545. }
  546. }
  547. .head {
  548. height: 64rpx;
  549. background: #F7F9FA;
  550. border-top: 2rpx solid #E3E5E5;
  551. border-left: 2rpx solid #E3E5E5;
  552. .item {
  553. height: 64rpx;
  554. line-height: 64rpx;
  555. border-right: 2rpx solid #E3E5E5;
  556. box-sizing: border-box;
  557. font-size: 22rpx;
  558. }
  559. }
  560. .tr {
  561. border-top: 2rpx solid #E3E5E5;
  562. border-left: 2rpx solid #E3E5E5;
  563. .item {
  564. font-size: 24rpx;
  565. min-height: 74rpx;
  566. display: flex;
  567. align-items: center;
  568. border-right: 2rpx solid #E3E5E5;
  569. box-sizing: border-box;
  570. white-space: normal;
  571. word-break: break-all;
  572. }
  573. &:last-child {
  574. border-bottom: 2rpx solid #E3E5E5;
  575. }
  576. .numerate {
  577. font-size: 22rpx;
  578. color: $theme-color;
  579. }
  580. }
  581. }
  582. .content_num {
  583. display: flex;
  584. align-items: center;
  585. padding: 0 4rpx;
  586. /deep/ .uni-input-input {
  587. border: 2rpx solid #F0F8F2;
  588. background: #F0F8F2;
  589. color: $theme-color;
  590. }
  591. }
  592. .round {
  593. width: 32rpx;
  594. height: 32rpx;
  595. line-height: 32rpx;
  596. text-align: center;
  597. border-radius: 50%;
  598. background: $theme-color;
  599. font-size: 24rpx;
  600. font-style: normal;
  601. font-weight: 400;
  602. color: #fff;
  603. margin-right: 18rpx;
  604. }
  605. .popup_box {
  606. width: 94vw;
  607. padding: 16rpx 12rpx;
  608. box-sizing: border-box;
  609. }
  610. .operate_box {
  611. margin-top: 32rpx;
  612. padding: 10rpx 100rpx;
  613. /deep/ .u-button {
  614. width: 160rpx;
  615. }
  616. }
  617. .formula_box {
  618. font-size: 24rpx;
  619. font-style: normal;
  620. font-weight: 400;
  621. margin-top: 12rpx;
  622. }
  623. .reportWeight {
  624. font-size: 24rpx;
  625. font-style: normal;
  626. font-weight: 400;
  627. margin-top: 30rpx;
  628. text {
  629. color: $theme-color;
  630. }
  631. }
  632. </style>