index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="app-container">
  3. <uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar :title="title"
  4. left-text="任务" @clickLeft="handleReload"
  5. :right-text="workstationName==null || workstationName=='' ? '工站' : workstationName" @clickRight="handleWork"/>
  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"></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="Object.keys(taskData).length === 0">
  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>
  35. <view class="cpck-content" v-if="Object.keys(taskData).length !== 0">
  36. <scroll-view scroll-top="0" :show-scrollbar="true" scroll-y="true" class="scroll-Y">
  37. <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">
  38. <text class="uni-body" style="font-size: 16px;">
  39. <p><span class="titleV">物料编码:</span><span class="detailV">{{item.itemCode}}</span></p>
  40. <p><span class="titleV">物料名称:</span><span class="detailV">{{item.itemName}}</span></p>
  41. <p><span class="titleV">规格型号:</span><span class="detailV">{{item.specification}}</span></p>
  42. <p><span class="titleV">单位:</span><span class="detailV">{{item.unitOfMeasure}}</span></p>
  43. <p><span class="titleV">可用数量:</span><span class="detailV">{{item.quantityAvailable}}</span></p>
  44. </text>
  45. </uni-card>
  46. </scroll-view>
  47. </view>
  48. <view class="page-bottom">
  49. <view class="p-b-btn" @click="searchIconClick('lld')" v-if="Object.keys(taskData).length !== 0">
  50. <text class="box-text">领料单</text>
  51. </view>
  52. <view class="p-b-btn" v-else></view>
  53. <view class="p-b-btn" @click="handleRemove" v-if="Object.keys(taskData).length !== 0">
  54. <text class="box-text">移除</text>
  55. </view>
  56. <view class="p-b-btn" v-else></view>
  57. <view class="p-b-btn" @click="handleConsume" v-if="Object.keys(taskData).length !== 0">
  58. <text class="box-text">消耗</text>
  59. </view>
  60. <view class="p-b-btn" v-else></view>
  61. <view class="p-b-btn" @click="handleBack">
  62. <text class="box-text">返回</text>
  63. </view>
  64. </view>
  65. <uni-popup ref="consumeFormPopup" type="top" :animation="true" background-color="#ffffff">
  66. <uni-forms-item name="stockQty" label="消耗数量" :label-width="lableWidth" labelAlign="right">
  67. <uni-easyinput type="number" :inputBorder="true"
  68. v-model="consumeForm.quantityConsumed" @input="bqslInputHandle" ></uni-easyinput>
  69. </uni-forms-item>
  70. <button type="primary" plain="true" @click="handleConsumeForm">确定</button>
  71. </uni-popup>
  72. <!-- 领料单 弹窗 -->
  73. <lldPopup ref="lldPopup" :title="lldTitle" :idxFlag="lldFlag" :formData="formData" @sendData="getSendData"/>
  74. </view>
  75. </template>
  76. <script>
  77. import lldPopup from './popup/commonpopup.vue' // 基础资料
  78. import { processList,workstationList,taskList,changeTaskStatus,feedback,addIssue,taskIssueList,removeTaskIssue,consumeTaskIssue } from '@/api/mes/pro.js'
  79. export default {
  80. components: {
  81. lldPopup
  82. },
  83. onLoad(option) {
  84. this.processName = uni.getStorageSync('processName');
  85. this.processCode = uni.getStorageSync('processCode');
  86. this.processId = uni.getStorageSync('processId');
  87. this.workstationName = uni.getStorageSync('workstationName');
  88. this.workstationCode = uni.getStorageSync('workstationCode');
  89. this.workstationId = uni.getStorageSync('workstationId');
  90. //进入加载任务
  91. this.getTaskList()
  92. this.formData.workstationId=this.workstationId
  93. },
  94. data() {
  95. return {
  96. title:"工序",
  97. lableWidth:"80px",
  98. barCode:'',//条码值
  99. //切换工作站
  100. showWorkstationFlag:false,
  101. processName:null,//当前工序
  102. processCode:null,
  103. processId:null,//当前工序id
  104. workstationName:null,//当前工作站
  105. workstationCode:null,//
  106. workstationId:null,//当前工作站id
  107. processList: [], //工序清单
  108. workstationList: [], //工作站清单
  109. currentFlag: 0,
  110. //任务卡片
  111. taskList: [],
  112. taskData:{},//选中的任务
  113. taskId:null,//任务id
  114. //领料单弹窗
  115. lldTitle: "领料单",
  116. lldFlag: "lld",
  117. formData: {},//workstationId工作站id、workorderId任务id
  118. //投料卡片
  119. itemList: [],//投料清单
  120. itemData:{},//选中的投料
  121. //消耗弹窗
  122. consumeForm: {quantityConsumed:0},
  123. }
  124. },
  125. methods: {
  126. //任务按钮
  127. handleReload(){
  128. this.taskData = {}
  129. this.getTaskList()
  130. uni.showToast({
  131. title: '刷新成功',
  132. icon:'none',
  133. duration: 1500
  134. })
  135. },
  136. handleWork(){
  137. //查询工序
  138. processList().then(res => {
  139. if(res.code === 200){
  140. this.processList = res.data.map(item => ({
  141. value: item.processCode,
  142. text: item.processName,
  143. id: item.processId
  144. }));
  145. //显示工站弹出窗
  146. this.$refs.popup.open('top')
  147. }
  148. });
  149. //如果有工序id,查询工作站
  150. if(this.processId !== null && this.processId !== ''){
  151. //查询工作站
  152. this.getWorkstationList();
  153. }
  154. },
  155. //工序变更,获取工作站
  156. changeProcess() {
  157. //赋值工序id
  158. let process = this.processList.find(item => item.value === this.processCode)
  159. this.processName = process==null ? null:process.text;
  160. this.processId = process==null ? null:process.id;
  161. uni.setStorageSync('processName', this.processName);
  162. uni.setStorageSync('processCode', this.processCode);
  163. uni.setStorageSync('processId', this.processId);
  164. //查询工作站
  165. this.getWorkstationList();
  166. //清空工作站
  167. this.workstationName=null
  168. this.workstationCode=null
  169. this.workstationId=null
  170. uni.setStorageSync('workstationName', '');
  171. uni.setStorageSync('workstationCode', '');
  172. uni.setStorageSync('workstationId', '');
  173. },
  174. //查询工作站
  175. getWorkstationList(){
  176. workstationList({processCode: this.processCode}).then(res => {
  177. if(res.code === 200){
  178. this.workstationList = res.data.map(item => ({
  179. value: item.workstationCode,
  180. text: item.workstationName,
  181. id: item.workstationId
  182. }));
  183. }
  184. });
  185. },
  186. //工作站变更
  187. changeWorksta(){
  188. let workstation = this.workstationList.find(item => item.value === this.workstationCode)
  189. this.workstationName = workstation==null ? null:workstation.text;
  190. this.workstationId = workstation==null ? null:workstation.id;
  191. uni.setStorageSync('workstationName', this.workstationName);
  192. uni.setStorageSync('workstationCode', this.workstationCode);
  193. uni.setStorageSync('workstationId', this.workstationId);
  194. //查询任务
  195. this.getTaskList();
  196. },
  197. //查询任务列表
  198. getTaskList() {
  199. taskList({workstationId: this.workstationId}).then(res => {
  200. if(res.code === 200){
  201. this.taskList = res.rows;
  202. }
  203. });
  204. },
  205. //选中任务
  206. shiftTask(task){
  207. this.taskData = task
  208. this.formData.workorderId = task.workorderId
  209. this.taskId = task.taskId
  210. this.getIssueList()
  211. },
  212. //选中投料清单
  213. shiftItem(item){
  214. this.itemData = item
  215. console.log(item)
  216. },
  217. //添加领料单的某行到当前的投料清单
  218. handleAdd(row) {
  219. let params = {
  220. taskId: this.taskId,
  221. workstationId: this.workstationId,
  222. //孙一石 工站id修改
  223. sourceDocId: row.sourceDocId,
  224. sourceDocType: 'ISSUE',
  225. sourceLineId: row.sourceLineId,
  226. itemCode: row.itemCode,
  227. itemName: row.itemName,
  228. unitOfMeasure: row.unitOfMeasure,
  229. batchCode: row.batchCode,
  230. quantityIssued: row.quantityIssued,
  231. quantityAvailable: row.quantityIssued
  232. }
  233. addIssue(params).then(res => {
  234. if(res.code === 200){
  235. this.getIssueList();
  236. uni.showToast({
  237. title: '操作成功',
  238. icon:'none',
  239. duration: 1500
  240. })
  241. }
  242. });
  243. },
  244. // 从投料清单中删除一条
  245. handleRemove() {
  246. let item = this.itemData;
  247. removeTaskIssue({recordId: item.recordId}).then(res => {
  248. if(res.code === 200){
  249. this.getIssueList();
  250. uni.showToast({
  251. title: '操作成功',
  252. icon:'none',
  253. duration: 1500
  254. })
  255. }
  256. });
  257. },
  258. // 从投料清单中消耗数量
  259. handleConsume() {
  260. let item = this.itemData;
  261. this.consumeForm.itemName = item.itemName
  262. this.consumeForm.itemCode = item.itemCode
  263. this.consumeForm.unitOfMeasure = item.unitOfMeasure
  264. this.consumeForm.quantityConsumed = item.quantityAvailable
  265. this.consumeForm.sourceDocId = item.sourceDocId
  266. this.consumeForm.sourceLineId = item.sourceLineId
  267. this.consumeForm.taskId = item.taskId
  268. this.consumeForm.workstationId = item.workstationId
  269. this.consumeForm.sourceBatchCode = item.batchCode
  270. this.$refs.consumeFormPopup.open('bottom')
  271. },
  272. handleConsumeForm(){
  273. let params= {
  274. sourceDocId: this.consumeForm.sourceDocId,
  275. sourceLineId: this.consumeForm.sourceLineId,
  276. itemName: this.consumeForm.itemName,
  277. itemCode: this.consumeForm.itemCode,
  278. unitOfMeasure: this.consumeForm.unitOfMeasure,
  279. quantityConsumed: this.consumeForm.quantityConsumed,
  280. taskId: this.consumeForm.taskId,
  281. workstationId: this.consumeForm.workstationId,
  282. sourceBatchCode: this.consumeForm.sourceBatchCode
  283. }
  284. consumeTaskIssue(params).then(res => {
  285. if(res.code === 200){
  286. this.getIssueList();
  287. uni.showToast({
  288. title: '操作成功',
  289. icon:'none',
  290. duration: 1500
  291. })
  292. }
  293. });
  294. },
  295. //获取当前工作台、当前生产任务的投料清单
  296. getIssueList() {
  297. taskIssueList({workstationId:this.workstationId}).then(res => {
  298. if(res.code === 200){
  299. this.itemList = res.data;
  300. console.log(this.itemList)
  301. }
  302. });
  303. },
  304. searchIconClick(type){// 显示基础资料
  305. switch (type){
  306. case "lld": // 任务编码
  307. this.$refs.lldPopup.showPopup();
  308. break;
  309. default:
  310. break;
  311. }
  312. },
  313. getSendData(res){ //基础资料
  314. let cFlag = res.currentFlag;
  315. let obj = {};
  316. switch (cFlag){
  317. case "lld": // 选择领料单
  318. this.handleAdd(res.selectData)
  319. break;
  320. default:
  321. break;
  322. }
  323. },
  324. //返回按钮
  325. handleBack(){
  326. uni.showModal({
  327. title: '提示',
  328. content: '确认返回?',
  329. success: function (res) {
  330. if (res.confirm) {
  331. uni.navigateBack();
  332. } else if (res.cancel) {
  333. }
  334. }
  335. });
  336. },
  337. bqslInputHandle(value){ //数量输入完成校验
  338. if(value < 0){
  339. uni.showToast({
  340. title: "数量有误",
  341. icon: "none"
  342. })
  343. return;
  344. }
  345. },
  346. }
  347. }
  348. </script>
  349. <style>
  350. @import "@/static/scss/stock.css";
  351. </style>