index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <view class="app-container">
  3. <uni-nav-bar class="bar-word" dark :fixed="true" shadow background-color="#007AFF" status-bar :title="title"
  4. :left-text="taskData.taskCode==null || taskData.taskCode=='' ? '任务' : taskData.taskCode" @clickLeft="handleReload" leftWidth="120px"
  5. :right-text="workstationName==null || workstationName=='' ? '工站' : workstationName" @clickRight="handleWork" rightWidth="120px"/>
  6. <view class="scan-header" style="z-index: auto;">
  7. <uni-forms-item name="barCode" label="条码" :label-width="lableWidth" labelAlign="right"
  8. style="margin-bottom: 0px; padding: 0px 15px 0px 15px;" >
  9. <uni-easyinput type="text" :inputBorder="true" v-model="barCode"
  10. :clearable="false" @confirm="scanSearch"></uni-easyinput>
  11. <view class="icon">
  12. <uni-icons type="scan" size="20"></uni-icons>
  13. </view>
  14. </uni-forms-item>
  15. </view>
  16. <view class="cpck-content" v-if="isPopupTask">
  17. <scroll-view scroll-top="0" :show-scrollbar="true" scroll-y="true" class="scroll-Y">
  18. <uni-card v-for="(item, index) in taskList" :key="index" @click="shiftTask(item)" :style="item.taskId===taskData.taskId ? 'background: #fffbc7;' : ''" style="margin: 0px 15px 15px 15px">
  19. <text class="uni-body" style="font-size: 16px;">
  20. <p><span class="titleV">任务编码:</span><span class="detailV">{{item.taskCode}}</span></p>
  21. <p><span class="titleV">产品编码:</span><span class="detailV">{{item.itemCode}}</span></p>
  22. <p><span class="titleV">产品名称:</span><span class="detailV">{{item.itemName}}</span></p>
  23. <p><span class="titleV">规格:</span><span class="detailV">{{item.specification}}</span></p>
  24. <p><span class="titleV">单位:</span><span class="detailV">{{item.unitOfMeasure}}</span></p>
  25. <p><span class="titleV">任务数量:</span><span class="detailV">{{item.quantity}}</span></p>
  26. <p><span class="titleV">生产数量:</span><span class="detailV">{{item.quantityProduced}}</span></p>
  27. <p><span class="titleV">良品数量:</span><span class="detailV">{{item.quantityQuanlify}}</span></p>
  28. <p><span class="titleV">不良数量:</span><span class="detailV">{{item.quantityUnquanlify}}</span></p>
  29. <p><span class="titleV">排产时间:</span><span class="detailV">{{item.startTime}}</span></p>
  30. <p><span class="titleV">需求日期:</span><span class="detailV">{{item.requestDate}}</span></p>
  31. </text>
  32. </uni-card>
  33. </scroll-view>
  34. <view class="page-bottom">
  35. <view class="p-b-btn" @click="changeStatus('START')" v-if="taskData.status =='NORMAL'">
  36. <text class="box-text">开始</text>
  37. </view>
  38. <view class="p-b-btn" @click="changeStatus('PAUSE')" v-else-if="taskData.status =='START'">
  39. <text class="box-text">暂停</text>
  40. </view>
  41. <view class="p-b-btn" @click="changeStatus('START')" v-else-if="taskData.status =='PAUSE'">
  42. <text class="box-text">继续</text>
  43. </view>
  44. <view class="p-b-btn" v-else></view>
  45. <view class="p-b-btn" @click="changeStatus('FINISHED')" v-if="taskData.status!=null && taskData.status!=''">
  46. <text class="box-text">完成</text>
  47. </view>
  48. <view class="p-b-btn" v-else></view>
  49. <view class="p-b-btn" @click="doFeedback" v-if="taskData.status!=null && taskData.status!=''">
  50. <text class="box-text">报工</text>
  51. </view>
  52. <view class="p-b-btn" v-else></view>
  53. <view class="p-b-btn" @click="handleBack">
  54. <text class="box-text">返回</text>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="cpck-content" v-if="!isPopupTask">
  59. <scroll-view scroll-top="0" :show-scrollbar="true" scroll-y="true" class="scroll-Y">
  60. <uni-card v-for="(item, index) in itemList" :key="index" @click="shiftItem(item)" :style="item.recordId===itemData.recordId ? 'background: #fffbc7;' : ''" style="margin: 0px 15px 15px 15px">
  61. <text class="uni-body" style="font-size: 16px;">
  62. <p><span class="titleV">物料编码:</span><span class="detailV">{{item.itemCode}}</span></p>
  63. <p><span class="titleV">物料名称:</span><span class="detailV">{{item.itemName}}</span></p>
  64. <p><span class="titleV">规格型号:</span><span class="detailV">{{item.specification}}</span></p>
  65. <p><span class="titleV">单位:</span><span class="detailV">{{item.unitOfMeasure}}</span></p>
  66. <p><span class="titleV">可用数量:</span>
  67. <uni-easyinput v-if="isEditItemQty && item.recordId===itemData.recordId" type="number" :inputBorder="true"
  68. v-model="editItemQty" focus @change="handleEditItemQty(editItemQty,item)"></uni-easyinput>
  69. <span class="detailV" v-else>{{item.quantityAvailable}}</span>
  70. </p>
  71. </text>
  72. </uni-card>
  73. </scroll-view>
  74. <view class="page-bottom">
  75. <view class="p-b-btn" @click="handleRemove" v-if="Object.keys(taskData).length !== 0">
  76. <text class="box-text">移除</text>
  77. </view>
  78. <view class="p-b-btn" v-else></view>
  79. <view class="p-b-btn" @click="handleConsume" v-if="Object.keys(taskData).length !== 0">
  80. <text class="box-text">消耗</text>
  81. </view>
  82. <view class="p-b-btn" v-else></view>
  83. <view class="p-b-btn"></view>
  84. <view class="p-b-btn" @click="handleBack">
  85. <text class="box-text">返回</text>
  86. </view>
  87. </view>
  88. </view>
  89. <uni-popup ref="popup" type="top" :animation="true" style="" background-color="#ffffff">
  90. <div style="height:50px"/>
  91. <uni-forms-item name="process" label="工序" :label-width="lableWidth" style="margin:5px;width:300px" labelAlign="right">
  92. <uni-data-select
  93. v-model="processCode"
  94. :localdata="processList"
  95. @change="changeProcess"
  96. ></uni-data-select>
  97. </uni-forms-item>
  98. <uni-forms-item name="workstation" label="工作站" :label-width="lableWidth" style="margin:5px;width:300px" labelAlign="right">
  99. <uni-data-select
  100. v-model="workstationCode"
  101. :localdata="workstationList"
  102. @change="changeWorksta"
  103. ></uni-data-select>
  104. </uni-forms-item>
  105. </uni-popup>
  106. <uni-popup ref="feedbackPopup" type="top" :animation="true" background-color="#ffffff">
  107. <uni-forms-item name="stockQty" label="合格品数" :label-width="lableWidth" labelAlign="right">
  108. <uni-easyinput type="number" :inputBorder="true"
  109. v-model="feedbackForm.quantityQualify" @input="bqslInputHandle" ></uni-easyinput>
  110. </uni-forms-item>
  111. <uni-forms-item name="stockQty" label="不良品数" :label-width="lableWidth" labelAlign="right">
  112. <uni-easyinput type="number" :inputBorder="true"
  113. v-model="feedbackForm.quantityUnqualify" @input="bqslInputHandle" ></uni-easyinput>
  114. </uni-forms-item>
  115. <button type="primary" plain="true" @click="handlefeedback">确定</button>
  116. </uni-popup>
  117. <uni-popup ref="consumeFormPopup" type="top" :animation="true" background-color="#ffffff">
  118. <uni-forms-item name="stockQty" label="消耗数量" :label-width="lableWidth" labelAlign="right">
  119. <uni-easyinput type="number" :inputBorder="true"
  120. v-model="consumeForm.quantityConsumed" @input="bqslInputHandle" ></uni-easyinput>
  121. </uni-forms-item>
  122. <button type="primary" plain="true" @click="handleConsumeForm">确定</button>
  123. </uni-popup>
  124. </view>
  125. </template>
  126. <script>
  127. import { processList,workstationList,taskList,changeTaskStatus,feedback,addIssue,updateIssue,taskIssueList,removeTaskIssue,consumeTaskIssue,getMaterial } from '@/api/mes/pro.js'
  128. export default {
  129. onLoad(option) {
  130. this.processName = uni.getStorageSync('processName');
  131. this.processCode = uni.getStorageSync('processCode');
  132. this.processId = uni.getStorageSync('processId');
  133. this.workstationName = uni.getStorageSync('workstationName');
  134. this.workstationCode = uni.getStorageSync('workstationCode');
  135. this.workstationId = uni.getStorageSync('workstationId');
  136. //进入加载任务
  137. this.getTaskList()
  138. },
  139. data() {
  140. return {
  141. title:"生产",
  142. lableWidth:"80px",
  143. barCode:'',//条码值
  144. //切换工作站
  145. showWorkstationFlag:false,
  146. processName:null,//当前工序
  147. processCode:null,
  148. processId:null,//当前工序id
  149. workstationName:null,//当前工作站
  150. workstationCode:null,//
  151. workstationId:null,//当前工作站id
  152. processList: [], //工序清单
  153. workstationList: [], //工作站清单
  154. currentFlag: 0,
  155. //任务卡片
  156. taskList: [],
  157. taskData:{},//选中的任务
  158. taskId:null,//任务id
  159. //报工
  160. feedbackForm:{quantityQualify:0,quantityUnqualify:0},
  161. //投料卡片
  162. itemList: [],//投料清单
  163. itemData:{},//选中的投料
  164. isEditItemQty:false,//当前卡片是否修改数量
  165. editItemQty:0,//修改数量
  166. //消耗弹窗
  167. consumeForm: {quantityConsumed:0},
  168. //显示任务还是投料
  169. isPopupTask: true,
  170. }
  171. },
  172. methods: {
  173. //刷新按钮
  174. handleReload(){
  175. this.getTaskList();
  176. this.isPopupTask=true;
  177. uni.showToast({
  178. title: '刷新成功',
  179. icon: 'none',
  180. duration: 1500
  181. });
  182. },
  183. handleWork(){
  184. //查询工序
  185. processList().then(res => {
  186. if(res.code === 200){
  187. this.processList = res.data.map(item => ({
  188. value: item.processCode,
  189. text: item.processName,
  190. id: item.processId
  191. }));
  192. //显示工站弹出窗
  193. this.$refs.popup.open('top')
  194. }
  195. });
  196. //如果有工序id,查询工作站
  197. if(this.processId !== null && this.processId !== ''){
  198. //查询工作站
  199. this.getWorkstationList();
  200. }
  201. },
  202. //工序变更,获取工作站
  203. changeProcess() {
  204. //赋值工序id
  205. let process = this.processList.find(item => item.value === this.processCode)
  206. this.processName = process==null ? null:process.text;
  207. this.processId = process==null ? null:process.id;
  208. uni.setStorageSync('processName', this.processName);
  209. uni.setStorageSync('processCode', this.processCode);
  210. uni.setStorageSync('processId', this.processId);
  211. //查询工作站
  212. this.getWorkstationList();
  213. //清空工作站
  214. this.workstationName=null
  215. this.workstationCode=null
  216. this.workstationId=null
  217. uni.setStorageSync('workstationName', '');
  218. uni.setStorageSync('workstationCode', '');
  219. uni.setStorageSync('workstationId', '');
  220. },
  221. //查询工作站
  222. getWorkstationList(){
  223. workstationList({processCode: this.processCode}).then(res => {
  224. if(res.code === 200){
  225. this.workstationList = res.data.map(item => ({
  226. value: item.workstationCode,
  227. text: item.workstationName,
  228. id: item.workstationId
  229. }));
  230. }
  231. });
  232. },
  233. //工作站变更
  234. changeWorksta(){
  235. let workstation = this.workstationList.find(item => item.value === this.workstationCode)
  236. this.workstationName = workstation==null ? null:workstation.text;
  237. this.workstationId = workstation==null ? null:workstation.id;
  238. uni.setStorageSync('workstationName', this.workstationName);
  239. uni.setStorageSync('workstationCode', this.workstationCode);
  240. uni.setStorageSync('workstationId', this.workstationId);
  241. //查询任务
  242. this.getTaskList();
  243. },
  244. //生产-任务卡片相关-----------------------
  245. //查询任务列表
  246. getTaskList() {
  247. taskList({workstationId: this.workstationId}).then(res => {
  248. if(res.code === 200){
  249. this.taskList = res.rows;
  250. }
  251. });
  252. },
  253. //选中任务
  254. shiftTask(task){
  255. if(task.taskId == this.taskData.taskId){
  256. this.isPopupTask = false
  257. return true
  258. }
  259. this.taskData = task
  260. this.taskId = task.taskId
  261. this.getIssueList()
  262. this.itemData={}
  263. },
  264. //状态按钮
  265. changeStatus(status) {
  266. this.taskData.status = status;
  267. let params = {
  268. taskId: this.taskData.taskId,
  269. taskCode: this.taskData.taskCode,
  270. workstationId: this.workstationId,
  271. workstationCode: this.workstationCode,
  272. workstationName: this.workstationName,
  273. status: status
  274. };
  275. changeTaskStatus(params).then(res => {
  276. if (res.code == '200') {
  277. uni.showToast({
  278. title: '变更成功',
  279. icon: 'none'
  280. });
  281. this.getTaskList();//刷新任务
  282. //清空选中任务
  283. if(status=='FINISHED'){
  284. this.taskData={};
  285. }
  286. }
  287. });
  288. },
  289. //生产报工按钮
  290. doFeedback() {
  291. this.$refs.feedbackPopup.open('bottom')
  292. },
  293. //工序-投料卡片相关-----------------------
  294. //选中投料清单
  295. shiftItem(item){
  296. if(item.recordId == this.itemData.recordId){
  297. this.editItemQty = item.quantityAvailable;
  298. this.isEditItemQty=true
  299. }else{
  300. this.editItemQty = 0;
  301. this.isEditItemQty=false
  302. }
  303. this.itemData = item
  304. },
  305. //添加领料单的某行到当前的投料清单
  306. handleAdd(row) {
  307. let params = {
  308. taskId: this.taskId,
  309. workstationId: this.workstationId,
  310. //孙一石 工站id修改
  311. sourceDocId: row.sourceDocId,
  312. sourceDocType: 'ISSUE',
  313. sourceLineId: row.sourceLineId,
  314. itemCode: row.itemCode,
  315. itemName: row.itemName,
  316. unitOfMeasure: row.unitOfMeasure,
  317. batchCode: row.batchCode,
  318. quantityIssued: row.quantityIssued,
  319. quantityAvailable: row.quantityIssued
  320. }
  321. addIssue(params).then(res => {
  322. if(res.code === 200){
  323. this.getIssueList();
  324. uni.showToast({
  325. title: '操作成功',
  326. icon:'none',
  327. duration: 1500
  328. })
  329. }
  330. });
  331. },
  332. // 从投料清单中删除一条
  333. handleRemove() {
  334. let item = this.itemData;
  335. removeTaskIssue({recordId: item.recordId}).then(res => {
  336. if(res.code === 200){
  337. this.getIssueList();
  338. uni.showToast({
  339. title: '操作成功',
  340. icon:'none',
  341. duration: 1500
  342. })
  343. }
  344. });
  345. },
  346. // 从投料清单中消耗数量
  347. handleConsume() {
  348. let item = this.itemData;
  349. this.consumeForm.itemName = item.itemName
  350. this.consumeForm.itemCode = item.itemCode
  351. this.consumeForm.unitOfMeasure = item.unitOfMeasure
  352. this.consumeForm.quantityConsumed = item.quantityAvailable
  353. this.consumeForm.sourceDocId = item.sourceDocId
  354. this.consumeForm.sourceLineId = item.sourceLineId
  355. this.consumeForm.taskId = item.taskId
  356. this.consumeForm.workstationId = item.workstationId
  357. this.consumeForm.sourceBatchCode = item.batchCode
  358. this.$refs.consumeFormPopup.open('bottom')
  359. },
  360. //添加消耗
  361. handleConsumeForm(){
  362. let params= {
  363. sourceDocId: this.consumeForm.sourceDocId,
  364. sourceLineId: this.consumeForm.sourceLineId,
  365. itemName: this.consumeForm.itemName,
  366. itemCode: this.consumeForm.itemCode,
  367. unitOfMeasure: this.consumeForm.unitOfMeasure,
  368. quantityConsumed: this.consumeForm.quantityConsumed,
  369. taskId: this.consumeForm.taskId,
  370. workstationId: this.consumeForm.workstationId,
  371. sourceBatchCode: this.consumeForm.sourceBatchCode
  372. }
  373. this.isEditItemQty=false;
  374. consumeTaskIssue(params).then(res => {
  375. if(res.code === 200){
  376. this.getIssueList();
  377. uni.showToast({
  378. title: '操作成功',
  379. icon:'none',
  380. duration: 1500
  381. })
  382. }
  383. });
  384. },
  385. //获取当前工作台、当前生产任务的投料清单
  386. getIssueList() {
  387. taskIssueList({workstationId:this.workstationId}).then(res => {
  388. if(res.code === 200){
  389. this.itemList = res.data;
  390. }
  391. });
  392. },
  393. // 条码框 回车
  394. scanSearch(remark){
  395. this.getDataByRemark(remark);
  396. },
  397. //扫码
  398. getDataByRemark(remark){
  399. remark = remark.replace(/^\s+|\s+$/g, '');
  400. let parts = remark.split("|");
  401. let splitPre = parts[0];
  402. let splitLast = parts[1];
  403. let splitLast2 = parts.length > 2 ? parts[2] : null;
  404. // 条码空 不执行
  405. if(splitLast == ""){
  406. return true;
  407. }
  408. // 扫码
  409. switch (splitPre){
  410. case "m": //物料
  411. this.getScanWlList(splitLast,splitLast2);
  412. break;
  413. default:
  414. uni.showToast({
  415. title: "条码不合法",
  416. icon: "none"
  417. })
  418. break;
  419. }
  420. },
  421. //物料扫码
  422. getScanWlList(barCode,barCode2){
  423. let that = this;
  424. // 物料网络请求
  425. getMaterial(barCode).then(res => {
  426. if(res.code === 200){
  427. let data = res.data;
  428. if(data && Object.keys(data).length !== 0){
  429. let row = {
  430. sourceDocType: 'ISSUE',
  431. itemCode: data.materialCode,
  432. itemName: data.materialName,
  433. unitOfMeasure: data.materialSpecification,
  434. batchCode: barCode2,
  435. quantityIssued: 10,
  436. quantityAvailable: 10,
  437. sourceDocId:0,
  438. }
  439. console.log(row)
  440. this.handleAdd(row)
  441. }else{
  442. uni.showToast({
  443. title: "物料编码无效",
  444. icon: "none"
  445. })
  446. }
  447. }
  448. });
  449. },
  450. //返回按钮
  451. handleBack(){
  452. uni.showModal({
  453. title: '提示',
  454. content: '确认返回?',
  455. success: function (res) {
  456. if (res.confirm) {
  457. uni.navigateBack();
  458. } else if (res.cancel) {
  459. }
  460. }
  461. });
  462. },
  463. //提交按钮
  464. handlefeedback(){
  465. //汇总数量
  466. let quantityQualify = this.feedbackForm.quantityQualify==null || this.feedbackForm.quantityQualify=='' ? 0:this.feedbackForm.quantityQualify
  467. let quantityUnqualify = this.feedbackForm.quantityUnqualify==null || this.feedbackForm.quantityUnqualify=='' ? 0:this.feedbackForm.quantityUnqualify
  468. let quantity = 0 + parseFloat(quantityQualify) + parseFloat(quantityUnqualify);
  469. if(quantityQualify<0 || quantityUnqualify<0){
  470. uni.showToast({
  471. title: "数量有误!",
  472. icon: 'none'
  473. });
  474. return true;
  475. }
  476. if(quantity===0){
  477. uni.showToast({
  478. title: "请输入合格品数量或者不良品数量!",
  479. icon: 'none'
  480. });
  481. return true;
  482. }
  483. let userName = uni.getStorageSync('u1')
  484. let nickName = uni.getStorageSync('name')
  485. let params = {
  486. taskId: this.taskData.taskId,
  487. quantityFeedback: quantity,
  488. quantityQualified: quantityQualify,
  489. quantityUnquanlified: quantityUnqualify,
  490. userName: userName,
  491. nickName: nickName,
  492. // 报工类型 : UNI SELF
  493. feedbackType: 'SELF',
  494. //工序
  495. processId: this.processId,
  496. processName: this.processName,
  497. itemId: this.taskData.itemId,
  498. itemName: this.taskData.itemName,
  499. itemCode: this.taskData.itemCode
  500. }
  501. feedback(params).then(res => {
  502. if(res.code === 200){
  503. uni.showToast({
  504. title: '上报成功',
  505. icon: 'none'
  506. });
  507. }
  508. this.getTaskList();
  509. });
  510. },
  511. //数量输入完成校验
  512. bqslInputHandle(value){
  513. if(value < 0){
  514. uni.showToast({
  515. title: "数量有误",
  516. icon: "none"
  517. })
  518. return;
  519. }
  520. },
  521. //投料数量输入框
  522. handleEditItemQty(value,item) {
  523. if(value < 0){
  524. uni.showToast({
  525. title: "数量有误",
  526. icon: "none"
  527. })
  528. return;
  529. }else{
  530. //获取数量差,用差修改两个数量
  531. let qty = this.editItemQty - item.quantityAvailable
  532. if(qty===0){
  533. return true
  534. }
  535. //修改
  536. let params={};
  537. params.recordId = this.itemData.recordId
  538. params.quantityIssued = item.quantityIssued + parseFloat(qty)
  539. params.quantityAvailable = item.quantityAvailable + parseFloat(qty)
  540. updateIssue(params).then(res => {
  541. if(res.code === 200){
  542. this.getIssueList();
  543. uni.showToast({
  544. title: '操作成功',
  545. icon:'none',
  546. duration: 1500
  547. })
  548. }
  549. });
  550. }
  551. },
  552. }
  553. }
  554. </script>
  555. <style>
  556. @import "@/static/scss/stock.css";
  557. ::v-deep .uni-nav-bar-text,::v-deep .uni-nav-bar-right-text,::v-deep .uni-nav-bar-left-text{
  558. font-size: 16px;
  559. }
  560. /* ::v-deep .bar-word .uni-navbar__header-btns .uni-navbar-btn-icon-right uni-text{
  561. font-size: 16px!important;
  562. } */
  563. ::v-deep .bar-word .uni-navbar__header-btns .uni-navbar-btn-icon-left uni-text{
  564. font-size: 16px!important;
  565. }
  566. </style>
  567. <!-- uni-navbar-btn-text uni-navbar-btn-icon-left -->