index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="uni-column" style="height: 100%; background-color: #f5f5f5;">
  3. <scroll-view class="scroll-container" scroll-y>
  4. <view v-for="(item, index) in listData" :key="index" class="list-item"
  5. @click="handleToreportingForWork(item)">
  6. <view class="title-container uni-row" style="justify-content: flex-start;">
  7. <view class="title uni-row">
  8. <text class="label">批次号:</text>
  9. <text class="label code">{{ item['lotCode'] }}</text>
  10. </view>
  11. <view class=" uni-row" style="margin-left: 16rpx;">
  12. <view v-if="item['status'] == 1" class="tag"><text class="label">进行中</text></view>
  13. <!-- <view v-else-if="item['status'] == 2" class="tag turnover "><text class="label">周转中</text>
  14. </view> -->
  15. <view v-else-if="item['status'] == 0" class="tag turnover "><text class="label">未开始</text>
  16. </view>
  17. <view v-else-if="item['status'] == 2" type="default" class="tag finished"><text
  18. class="label">已完成</text></view>
  19. </view>
  20. </view>
  21. <view class="item-info uni-row">
  22. <text class="label">箱号</text>
  23. <text class="label right">{{ item['carrierName'] }}</text>
  24. </view>
  25. <view class="item-info uni-row">
  26. <text class="label">总工时</text>
  27. <text class="label right">{{ item['totalWorkingHours']}}h</text>
  28. </view>
  29. <view class="item-info uni-row">
  30. <text class="label">合格数/投入数</text>
  31. <text class="label right">{{ item['qualifiedQuantity'] }}/{{item['invest']}}</text>
  32. </view>
  33. <view class="item-info uni-row">
  34. <text class="label">上道工序</text>
  35. <text class="label right">{{ item['previousProcess'] }}</text>
  36. </view>
  37. <view class="item-info uni-row">
  38. <text class="label">当前工序</text>
  39. <text class="label right">{{ item['currentProcess'].processAlias }}</text>
  40. </view>
  41. <view class="item-info uni-row">
  42. <text class="label">下道工序</text>
  43. <text class="label right">{{ item['NextProcess'] }}</text>
  44. </view>
  45. <view class="status-btn uni-row">
  46. <view v-if="item['status'] == 1" class=" uni-row">
  47. <button class="turnover-tag" size="mini"
  48. @click.stop="handleShowTurnoverApplication(item)">周转申请</button>
  49. <!-- <button class="reporting-tag" size="mini" @click="handleToreportingForWork">去报工</button> -->
  50. </view>
  51. <view v-else-if="item['status'] == 1" class=" uni-row">
  52. <button class="turnover-tag" size="mini">取消周转</button>
  53. </view>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. <view v-if="bottomStatus == 0" class="bottom uni-row">
  58. <button class="start-batch-btn" type="primary" @click="handleStartNewBatch">开始新批次</button>
  59. </view>
  60. <view v-else-if="bottomStatus == 1" class="bottom uni-row">
  61. <button class="start-batch-btn" type="primary" @click="handleScanCode">扫一扫开始新批次</button>
  62. </view>
  63. <view v-else="bottomStatus == 2" class="bottom uni-row">
  64. <button class="start-batch-btn" style="width: 40%;margin-right: 10rpx;" type="primary"
  65. @click="handleStartNewBatch">开始新批次</button>
  66. <button class="start-batch-btn" style="width: 40%;margin-left: 10rpx" type="primary"
  67. @click="handleScanCode">扫一扫开始新批次</button>
  68. </view>
  69. <dialog-lot ref="lotDialog" @submit="handleDoIt" />
  70. <dialog-turnoverApplication ref="turnoverApplicationDialog" />
  71. </view>
  72. </template>
  73. <script setup>
  74. import {
  75. reactive,
  76. ref
  77. } from 'vue'
  78. import {
  79. onLoad,
  80. onReady
  81. } from '@dcloudio/uni-app'
  82. import {
  83. getDayWorkList
  84. } from '@/api/business/dayWork.js'
  85. import {
  86. store
  87. } from '@/store/index.js'
  88. import {
  89. showDaywork,showDayworkSave
  90. } from '@/api/business/dayWork.js'
  91. const turnoverApplicationDialog = ref(null)
  92. const lotDialog = ref(null)
  93. const listData = ref([])
  94. const bizDayworkObj = ref({})
  95. const curSubPlan = ref({}) // 子计划单信息
  96. const processInfo = ref([]) // 员工工序信息
  97. const bottomStatus = ref(0) // 底部按钮显示
  98. const reqParam = ref(null);
  99. onLoad(() => {
  100. // let encodeData = encodeURIComponent(store.planSubDetails);
  101. curSubPlan.value = store.planSubDetails || {
  102. processSequence: []
  103. };
  104. console.log(store.planSubDetails)
  105. processInfo.value = store.userProcessInfo || [];
  106. let sunPlanProcesses = [];
  107. let userProcesses = [];
  108. for (let i = 0; i < curSubPlan.value.processSequence.length; i++) {
  109. sunPlanProcesses.push(curSubPlan.value.processSequence[i].id)
  110. }
  111. for (let i = 0; i < processInfo.value.length; i++) {
  112. userProcesses.push(processInfo.value[i].id)
  113. }
  114. // 判断员工开始批次按钮显示bottomStatus状态
  115. if (userProcesses.includes(sunPlanProcesses[0]) && userProcesses.length == 1) {
  116. bottomStatus.value = 0;
  117. } else if (userProcesses.includes(sunPlanProcesses[0]) && userProcesses.length > 1) {
  118. bottomStatus.value = 2;
  119. } else {
  120. bottomStatus.value = 1;
  121. }
  122. init(curSubPlan.value.id);
  123. uni.$on('batchReporting-addBatch', () => {
  124. init(curSubPlan.value.id);
  125. })
  126. })
  127. function handleShowTurnoverApplication(data) {
  128. let _data = data ?? {}
  129. // 调用子组件中的方法
  130. turnoverApplicationDialog.value.open(_data)
  131. }
  132. function handleStartNewBatch() {
  133. uni.navigateTo({
  134. url: "/pages/addNewBatch/index"
  135. })
  136. }
  137. function init(id) {
  138. uni.showLoading({
  139. title: '加载中'
  140. });
  141. let reqData = {};
  142. reqData.productionPlanDetailSubDetailId = id;
  143. // console.log(reqData)
  144. getDayWorkList(reqData).then(res => {
  145. console.log(reqData)
  146. listData.value = res.rows;
  147. console.log(res)
  148. uni.hideLoading();
  149. })
  150. }
  151. function handleToreportingForWork(item) {
  152. store.dayworkInfo = item
  153. uni.navigateTo({
  154. url: "/pages/reportingForWork/index"
  155. })
  156. }
  157. function handleScanCode() {
  158. uni.scanCode({
  159. scanType: ['qrCode'],
  160. onlyFromCamera: true, // 只允许相机扫码
  161. success: function(res) {
  162. console.log(res.result)
  163. let vehicleObj = JSON.parse(res.result);
  164. showDaywork({
  165. carrierId: vehicleObj.carrierId,
  166. status: 7
  167. }).then(response => {
  168. lotDialog.value.open(response.data);
  169. reqParam.value = response.data
  170. })
  171. }
  172. });
  173. }
  174. function handleAddDaywork(data){
  175. for (let i = 0; i < listData.value.length; i++) {
  176. if (Object.entries(listData.value[i]).toString() === Object.entries(data).toString()) {
  177. uni.showToast({
  178. icon: "error",
  179. title: "该批次已存在"
  180. })
  181. console.log("该批次已存在")
  182. return;
  183. }
  184. }
  185. listData.value.push(data);
  186. for (let i = 0; i < listData.value.length; i++) {
  187. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  188. }
  189. console.log(listData.value)
  190. showDayworkSave(data).then(res => {
  191. init(curSubPlan.value.id);
  192. })
  193. }
  194. function handleDoIt(){
  195. handleAddDaywork(reqParam.value);
  196. }
  197. </script>
  198. <style lang="scss">
  199. .scroll-container {
  200. width: 92%;
  201. margin: 24rpx auto 0 auto;
  202. height: 90%;
  203. }
  204. .list-item {
  205. background-color: #fff;
  206. position: relative;
  207. padding: 16rpx;
  208. padding-bottom: 24rpx;
  209. margin-bottom: 24rpx;
  210. border-radius: 10rpx;
  211. .title-container {
  212. margin-top: 8rpx;
  213. margin-bottom: 16rpx;
  214. .title {
  215. height: 48rpx;
  216. align-items: center;
  217. .label {
  218. font-size: 32rpx;
  219. font-weight: bold;
  220. &.code {
  221. margin-left: 8rpx;
  222. }
  223. }
  224. }
  225. .tag {
  226. border: 1px solid #1CE5B0;
  227. background-color: #F6FFFD;
  228. padding: 8rpx;
  229. border-radius: 8rpx;
  230. .label {
  231. color: #1CE5B0;
  232. font-size: 24rpx;
  233. }
  234. &.finished {
  235. border: 1px solid #BBBBBB;
  236. background-color: #F5F5F5;
  237. .label {
  238. color: #BBBBBB;
  239. }
  240. }
  241. &.turnover {
  242. border: 1px solid #FF7901;
  243. background-color: #F6FFFD;
  244. .label {
  245. color: #FF7901;
  246. }
  247. }
  248. }
  249. }
  250. .item-info {
  251. margin-bottom: 8rpx;
  252. .label {
  253. font-size: 28rpx;
  254. width: 220rpx;
  255. color: #808080;
  256. &.right {
  257. flex: 1;
  258. color: #000000;
  259. }
  260. }
  261. }
  262. .status-btn {
  263. justify-content: flex-end;
  264. align-items: center;
  265. .turnover-tag {
  266. padding-right: 12rpx;
  267. padding-left: 12rpx;
  268. border-radius: 8rpx;
  269. border: 1rpx solid #FF7901;
  270. background-color: #FF7901;
  271. font-size: 28rpx;
  272. color: #FFFFFF;
  273. }
  274. .reporting-tag {
  275. padding-right: 12rpx;
  276. padding-left: 12rpx;
  277. border-radius: 8rpx;
  278. margin-left: 16rpx;
  279. border: 1rpx solid #1684fc;
  280. background-color: #1684fc;
  281. font-size: 28rpx;
  282. color: #FFFFFF;
  283. }
  284. }
  285. }
  286. .bottom {
  287. height: 10%;
  288. position: fixed;
  289. right: 0;
  290. bottom: 0;
  291. left: 0;
  292. height: 100rpx;
  293. border-top: 1px solid #999999;
  294. padding: 16rpx 32rpx;
  295. align-items: center;
  296. background-color: #fff;
  297. .start-batch-btn {
  298. flex: 1;
  299. height: 80rpx;
  300. padding-top: 10 rpx;
  301. border-radius: 8rpx;
  302. color: #FFFFFF;
  303. font-size: 28rpx;
  304. }
  305. }
  306. </style>