index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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">
  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. <uni-popup ref="popup" type="top" :animation="true" style="" background-color="#ffffff">
  36. <div style="height:50px"/>
  37. <uni-forms-item name="process" label="工序" :label-width="lableWidth" style="margin:5px;width:300px" labelAlign="right">
  38. <uni-data-select
  39. v-model="processCode"
  40. :localdata="processList"
  41. @change="changeProcess"
  42. ></uni-data-select>
  43. </uni-forms-item>
  44. <uni-forms-item name="workstation" label="工作站" :label-width="lableWidth" style="margin:5px;width:300px" labelAlign="right">
  45. <uni-data-select
  46. v-model="workstationCode"
  47. :localdata="workstationList"
  48. @change="changeWorksta"
  49. ></uni-data-select>
  50. </uni-forms-item>
  51. </uni-popup>
  52. <uni-popup ref="feedbackPopup" type="top" :animation="true" background-color="#ffffff">
  53. <uni-forms-item name="stockQty" label="合格品数" :label-width="lableWidth" labelAlign="right">
  54. <uni-easyinput type="number" :inputBorder="true"
  55. v-model="feedbackForm.quantityQualify" @input="bqslInputHandle" ></uni-easyinput>
  56. </uni-forms-item>
  57. <uni-forms-item name="stockQty" label="不良品数" :label-width="lableWidth" labelAlign="right">
  58. <uni-easyinput type="number" :inputBorder="true"
  59. v-model="feedbackForm.quantityUnqualify" @input="bqslInputHandle" ></uni-easyinput>
  60. </uni-forms-item>
  61. <button type="primary" plain="true" @click="handlefeedback">确定</button>
  62. </uni-popup>
  63. <view class="page-bottom">
  64. <view class="p-b-btn" @click="changeStatus('START')" v-if="taskData.status =='NORMAL'">
  65. <text class="box-text">开始</text>
  66. </view>
  67. <view class="p-b-btn" @click="changeStatus('PAUSE')" v-else-if="taskData.status =='START'">
  68. <text class="box-text">暂停</text>
  69. </view>
  70. <view class="p-b-btn" @click="changeStatus('START')" v-else-if="taskData.status =='PAUSE'">
  71. <text class="box-text">继续</text>
  72. </view>
  73. <view class="p-b-btn" v-else></view>
  74. <view class="p-b-btn" @click="changeStatus('FINISHED')" v-if="taskData.status!=null && taskData.status!=''">
  75. <text class="box-text">完成</text>
  76. </view>
  77. <view class="p-b-btn" v-else></view>
  78. <view class="p-b-btn" @click="doFeedback" v-if="taskData.status!=null && taskData.status!=''">
  79. <text class="box-text">报工</text>
  80. </view>
  81. <view class="p-b-btn" v-else></view>
  82. <view class="p-b-btn" @click="handleBack">
  83. <text class="box-text">返回</text>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import { processList,workstationList,taskList,changeTaskStatus,feedback } from '@/api/mes/pro.js'
  90. export default {
  91. onLoad(option) {
  92. this.processName = uni.getStorageSync('processName');
  93. this.processCode = uni.getStorageSync('processCode');
  94. this.processId = uni.getStorageSync('processId');
  95. this.workstationName = uni.getStorageSync('workstationName');
  96. this.workstationCode = uni.getStorageSync('workstationCode');
  97. this.workstationId = uni.getStorageSync('workstationId');
  98. },
  99. data() {
  100. return {
  101. title:"生产",
  102. lableWidth:"80px",
  103. barCode:'',//条码值
  104. //切换工作站
  105. showWorkstationFlag:false,
  106. processName:null,//当前工序
  107. processCode:null,
  108. processId:null,//当前工序id
  109. workstationName:null,//当前工作站
  110. workstationCode:null,//
  111. workstationId:null,//当前工作站id
  112. processList: [], //工序清单
  113. workstationList: [], //工作站清单
  114. currentFlag: 0,
  115. //任务卡片
  116. taskList: [],
  117. taskData:{},//选中的任务
  118. //报工
  119. feedbackForm:{quantityQualify:0,quantityUnqualify:0}
  120. }
  121. },
  122. methods: {
  123. //刷新按钮
  124. handleReload(){
  125. this.getTaskList();
  126. uni.showToast({
  127. title: '刷新成功',
  128. icon: 'none',
  129. duration: 1500
  130. });
  131. },
  132. handleWork(){
  133. //查询工序
  134. processList().then(res => {
  135. if(res.code === 200){
  136. this.processList = res.data.map(item => ({
  137. value: item.processCode,
  138. text: item.processName,
  139. id: item.processId
  140. }));
  141. //显示工站弹出窗
  142. this.$refs.popup.open('top')
  143. }
  144. });
  145. //如果有工序id,查询工作站
  146. if(this.processId !== null && this.processId !== ''){
  147. //查询工作站
  148. this.getWorkstationList();
  149. }
  150. },
  151. //工序变更,获取工作站
  152. changeProcess() {
  153. //赋值工序id
  154. let process = this.processList.find(item => item.value === this.processCode)
  155. this.processName = process==null ? null:process.text;
  156. this.processId = process==null ? null:process.id;
  157. uni.setStorageSync('processName', this.processName);
  158. uni.setStorageSync('processCode', this.processCode);
  159. uni.setStorageSync('processId', this.processId);
  160. //查询工作站
  161. this.getWorkstationList();
  162. //清空工作站
  163. this.workstationName=null
  164. this.workstationCode=null
  165. this.workstationId=null
  166. uni.setStorageSync('workstationName', '');
  167. uni.setStorageSync('workstationCode', '');
  168. uni.setStorageSync('workstationId', '');
  169. },
  170. //查询工作站
  171. getWorkstationList(){
  172. workstationList({processCode: this.processCode}).then(res => {
  173. if(res.code === 200){
  174. this.workstationList = res.data.map(item => ({
  175. value: item.workstationCode,
  176. text: item.workstationName,
  177. id: item.workstationId
  178. }));
  179. }
  180. });
  181. },
  182. //工作站变更
  183. changeWorksta(){
  184. let workstation = this.workstationList.find(item => item.value === this.workstationCode)
  185. this.workstationName = workstation==null ? null:workstation.text;
  186. this.workstationId = workstation==null ? null:workstation.id;
  187. uni.setStorageSync('workstationName', this.workstationName);
  188. uni.setStorageSync('workstationCode', this.workstationCode);
  189. uni.setStorageSync('workstationId', this.workstationId);
  190. //查询任务
  191. this.getTaskList();
  192. },
  193. //查询任务列表
  194. getTaskList() {
  195. taskList({workstationId: this.workstationId}).then(res => {
  196. if(res.code === 200){
  197. this.taskList = res.rows;
  198. }
  199. });
  200. },
  201. //选中任务
  202. shiftTask(task){
  203. this.taskData = task
  204. },
  205. //状态按钮
  206. changeStatus(status) {
  207. this.taskData.status = status;
  208. let params = {
  209. taskId: this.taskData.taskId,
  210. taskCode: this.taskData.taskCode,
  211. workstationId: this.workstationId,
  212. workstationCode: this.workstationCode,
  213. workstationName: this.workstationName,
  214. status: status
  215. };
  216. changeTaskStatus(params).then(res => {
  217. if (res.code == '200') {
  218. uni.showToast({
  219. title: '变更成功',
  220. icon: 'none'
  221. });
  222. this.getTaskList();//刷新任务
  223. //清空选中任务
  224. if(status=='FINISHED'){
  225. this.taskData={};
  226. }
  227. }
  228. });
  229. },
  230. //生产报工按钮
  231. doFeedback() {
  232. this.$refs.feedbackPopup.open('bottom')
  233. },
  234. //返回按钮
  235. handleBack(){
  236. uni.showModal({
  237. title: '提示',
  238. content: '确认返回?',
  239. success: function (res) {
  240. if (res.confirm) {
  241. uni.navigateBack();
  242. } else if (res.cancel) {
  243. }
  244. }
  245. });
  246. },
  247. //提交按钮
  248. handlefeedback(){
  249. //汇总数量
  250. let quantityQualify = this.feedbackForm.quantityQualify==null || this.feedbackForm.quantityQualify=='' ? 0:this.feedbackForm.quantityQualify
  251. let quantityUnqualify = this.feedbackForm.quantityUnqualify==null || this.feedbackForm.quantityUnqualify=='' ? 0:this.feedbackForm.quantityUnqualify
  252. let quantity = 0 + parseFloat(quantityQualify) + parseFloat(quantityUnqualify);
  253. if(quantityQualify<0 || quantityUnqualify<0){
  254. uni.showToast({
  255. title: "数量有误!",
  256. icon: 'none'
  257. });
  258. return true;
  259. }
  260. if(quantity===0){
  261. uni.showToast({
  262. title: "请输入合格品数量或者不良品数量!",
  263. icon: 'none'
  264. });
  265. return true;
  266. }
  267. let userName = uni.getStorageSync('u1')
  268. let nickName = uni.getStorageSync('name')
  269. let params = {
  270. taskId: this.taskData.taskId,
  271. quantityFeedback: quantity,
  272. quantityQualified: quantityQualify,
  273. quantityUnquanlified: quantityUnqualify,
  274. userName: userName,
  275. nickName: nickName,
  276. // 报工类型 : UNI SELF
  277. feedbackType: 'SELF',
  278. //工序
  279. processId: this.processId,
  280. processName: this.processName,
  281. itemId: this.taskData.itemId,
  282. itemName: this.taskData.itemName,
  283. itemCode: this.taskData.itemCode
  284. }
  285. feedback(params).then(res => {
  286. if(res.code === 200){
  287. uni.showToast({
  288. title: '上报成功',
  289. icon: 'none'
  290. });
  291. }
  292. this.getTaskList();
  293. });
  294. },
  295. bqslInputHandle(value){ //数量输入完成校验
  296. if(value < 0){
  297. uni.showToast({
  298. title: "数量有误",
  299. icon: "none"
  300. })
  301. return;
  302. }
  303. },
  304. }
  305. }
  306. </script>
  307. <style>
  308. @import "@/static/scss/stock.css";
  309. </style>