index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view class="uni-column" style="padding: 24rpx">
  3. <view v-if="listData.length>0" style="margin-bottom: 20rpx;">
  4. <view>
  5. <view class="item-info uni-row">
  6. <view style="flex: 3;">
  7. <button :class="[checkAll ? 'active' : 'select' ]" @click="handleAll"
  8. style="margin-left: 0px;;">全选</button>
  9. </view>
  10. <uni-data-select v-model=" workshopId" :localdata="workshopList" @change="handleChangeWorkshop"
  11. :clear="false" class="label right"
  12. style="width: 50rpx; outline: 2rpx solid #999999;border-radius: 10rpx;flex: 1;"></uni-data-select>
  13. </view>
  14. </view>
  15. </view>
  16. <view v-if="listData.length>0" style="height: calc(100% - 200rpx); overflow: auto;">
  17. <view v-for="(item, index) in listData" :key="index" :class="{'list-item':true,'selected':isSelected(item)}"
  18. @click="handleSelection(item)">
  19. <view class="title-container uni-row">
  20. <view class="title uni-row"><text class="label">{{item.lotCode}}</text></view>
  21. <view><button class="start-batch-btn uni-row" type=primary @click='handleAdd'>换箱</button></view>
  22. </view>
  23. <view class="item-info uni-row">
  24. <text class="label">产品描述</text>
  25. <text class="label right">{{item['productDescription']}}</text>
  26. </view>
  27. <view class="item-info uni-row">
  28. <text class="label">关联箱号</text>
  29. <text class="label right">{{item['carrierName']}}</text>
  30. </view>
  31. <view class="item-info uni-row">
  32. <text class="label">下序</text>
  33. <text class="label right">{{item['process']}}</text>
  34. </view>
  35. <view class="item-info uni-row">
  36. <text class="label">下序工段</text>
  37. <text class="label right">{{item['dept']}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="listData.length==0" style="color: #999;margin: 50% auto;">
  42. <text>扫码开始快速报工</text>
  43. </view>
  44. <view v-if="listData.length==0" class='bottom-btn-container'>
  45. <button class="start-batch-btn uni-row" type=primary @click='handleAdd'>扫码开始报工</button>
  46. </view>
  47. <view v-if="listData.length>0" class='btn uni-row'>
  48. <button class='bottom-btn left-btn' type="warn" @click="handleEnd">结束报工</button>
  49. <button class='bottom-btn right-btn' type="primary" @click="handleContinue">继续扫码</button>
  50. </view>
  51. <dialog-lotReporting ref="lotReporting"></dialog-lotReporting>
  52. </view>
  53. </template>
  54. <script setup>
  55. import {
  56. getPlanDetailsList
  57. } from '@/api/business/planDetails.js'
  58. import { store } from '@/store/index.js'
  59. import {
  60. getDayWorkList,
  61. showDaywork,
  62. showDayworkSave,
  63. turnoverDelete
  64. } from '@/api/business/dayWork.js'
  65. import {
  66. getQuickDayworkList,
  67. finishQuick,
  68. getDayworkByCarrierId,
  69. reportDaywork
  70. } from '@/api/business/quickDaywork'
  71. import {
  72. ref
  73. } from 'vue'
  74. import path from '@/api/base/path.js'
  75. const lotReporting = ref(null)
  76. const workshopId = ref();
  77. const form = ref([]); //表单数据true
  78. const checkAll = ref(false); //是否全选
  79. const listData = ref([]);
  80. const selection = ref([]); //选中数据
  81. const workshopList = ref([]); //车间数据
  82. //初始化
  83. function init() {
  84. uni.showLoading({
  85. title: '加载中'
  86. });
  87. getQuickDayworkList({
  88. deptId: store.curDeptDetails.deptId,
  89. }).then(res => {
  90. console.log(res)
  91. if (res.code == 200) {
  92. listData.value = res.data
  93. uni.hideLoading();
  94. }
  95. uni.hideLoading();
  96. })
  97. }
  98. function handleAdd() {
  99. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  100. if (mpaasScanModule) {
  101. // 调用插件的 mpaasScan 方法
  102. mpaasScanModule.mpaasScan({
  103. // 扫码识别类型,参数可多选,qrCode、barCode,
  104. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  105. scanType: ["qrCode", "barCode"],
  106. // 是否隐藏相册,默认false不隐藏
  107. hideAlbum: false,
  108. },
  109. (ret) => {
  110. let vehicleObj = JSON.parse(ret.resp_result);
  111. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  112. uni.showToast({
  113. icon: "none",
  114. title: "请扫载具码",
  115. duration: 1000
  116. })
  117. return;
  118. }
  119. getDayworkByCarrierId({
  120. carrierId: vehicleObj.carrierId,
  121. status: 7
  122. }).then(response => {
  123. if (response.code == 200) {
  124. if (response.data.length > 0) {
  125. lotReporting.value.open(response.data);
  126. } else {
  127. uni.showToast({
  128. icon: 'none',
  129. title: '该批次不在此计划单内',
  130. duration: 2000
  131. })
  132. }
  133. } else {
  134. uni.showToast({
  135. icon: 'none',
  136. title: response.msg,
  137. duration: 2000
  138. })
  139. }
  140. })
  141. }
  142. );
  143. } else {
  144. // 测试时用
  145. getDayworkByCarrierId({
  146. carrierId: '1770342949115183106',
  147. status: 7
  148. }).then(response => {
  149. console.log(response)
  150. if (response.code == 200) {
  151. //
  152. if (response.data.length > 0) {
  153. // console.log(response.data)
  154. lotReporting.value.open(response.data);
  155. } else {
  156. uni.showToast({
  157. icon: 'none',
  158. title: '该批次不在此计划单内',
  159. duration: 2000
  160. })
  161. }
  162. } else {
  163. uni.showToast({
  164. icon: 'none',
  165. title: response.msg,
  166. duration: 2000
  167. })
  168. }
  169. })
  170. }
  171. // lotReporting.value.open(data);
  172. }
  173. // 全选按钮操作
  174. function handleAll() {
  175. //清空选中数据
  176. selection.value.length = 0;
  177. if (checkAll.value) {
  178. //变更选中状态
  179. checkAll.value = false;
  180. } else {
  181. checkAll.value = true;
  182. form.value.findIndex(item => handleSelection(item))
  183. }
  184. }
  185. function handleChangeWorkshop() {}
  186. function isSelected(item) {
  187. return selection.value.includes(item);
  188. }
  189. //
  190. function handleSelection(item) {
  191. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  192. if (buttonIndex > -1) {
  193. selection.value.splice(buttonIndex, 1); // 取消选中
  194. } else {
  195. selection.value.push(item); // 选中
  196. }
  197. if (selection.value.length == form.value.length) {
  198. checkAll.value = true;
  199. } else {
  200. checkAll.value = false;
  201. }
  202. }
  203. init();
  204. </script>
  205. <style lang="scss">
  206. $nav-height: 60rpx;
  207. .bottom-btn-container {
  208. position: fixed;
  209. top: 80%;
  210. right: 20rpx;
  211. left: 20rpx;
  212. .start-batch-btn {
  213. margin-bottom: 24rpx;
  214. border-radius: 8rpx;
  215. background-color: #00e2a6;
  216. width: 80%;
  217. }
  218. }
  219. .active {
  220. flex: 1;
  221. height: 40rpx;
  222. font-size: 20rpx;
  223. background-color: #5e6eff;
  224. border: 1px solid #5e6eff;
  225. color: #000000;
  226. }
  227. .select {
  228. flex: 1;
  229. height: 40rpx;
  230. font-size: 20rpx;
  231. background-color: #5e6eff;
  232. border: 1px solid #5e6eff;
  233. color: #ffffff;
  234. }
  235. .btn {
  236. position: fixed;
  237. right: 0;
  238. bottom: 0;
  239. left: 0;
  240. height: 100rpx;
  241. padding: 16rpx 24rpx;
  242. align-items: center;
  243. background-color: #FFFFFF;
  244. justify-content: space-between;
  245. .bottom-btn {
  246. flex: 1;
  247. font-size: 28rpx;
  248. color: #FFFFFF;
  249. &.left-btn {
  250. // background-color: #a4adb3;
  251. }
  252. &.right-btn {
  253. background-color: #1684fc;
  254. margin-left: 24rpx;
  255. }
  256. }
  257. }
  258. .box-bg {
  259. width: 100%;
  260. background-color: #F5F5F5;
  261. padding: 5rpx 0;
  262. justify-content: space-around;
  263. align-items: center;
  264. .input-view {
  265. width: 100%;
  266. flex: 4;
  267. background-color: #f8f8f8;
  268. height: $nav-height;
  269. border: 1rpx solid #999;
  270. border-radius: 15rpx;
  271. padding: 0 15rpx;
  272. flex-wrap: nowrap;
  273. margin: 0 10rpx 20rpx;
  274. line-height: $nav-height;
  275. .input-uni-icon {
  276. line-height: $nav-height;
  277. }
  278. .nav-bar-input {
  279. width: 80%;
  280. height: $nav-height;
  281. line-height: $nav-height;
  282. padding: 0 5rpx;
  283. background-color: #f8f8f8;
  284. }
  285. }
  286. .search {
  287. width: 20%;
  288. text-align: center;
  289. color: #808080;
  290. margin-top: -20rpx;
  291. }
  292. }
  293. .uni-column {
  294. background-color: rgba(245, 245, 245, 1);
  295. height: calc(100% - 40rpx);
  296. }
  297. .list-item {
  298. background-color: #fff;
  299. position: relative;
  300. padding: 16rpx;
  301. padding-bottom: 24rpx;
  302. border-radius: 24rpx;
  303. margin-bottom: 24rpx;
  304. .title-container {
  305. justify-content: space-between;
  306. margin-top: 8rpx;
  307. margin-bottom: 16rpx;
  308. .title {
  309. height: 48rpx;
  310. align-items: center;
  311. .label {
  312. font-size: 32rpx;
  313. font-weight: bold;
  314. &.code {
  315. margin-left: 8rpx;
  316. }
  317. }
  318. }
  319. .tag {
  320. border: 1px solid #1ce5b0;
  321. background-color: #f6fffd;
  322. padding: 8rpx;
  323. border-radius: 8rpx;
  324. .label {
  325. color: #1ce5b0;
  326. font-size: 24rpx;
  327. }
  328. &.not-start {
  329. border: 1px solid #bbbbbb;
  330. background-color: #f5f5f5;
  331. .label {
  332. color: #bbbbbb;
  333. }
  334. }
  335. }
  336. }
  337. .item-info {
  338. margin-bottom: 8rpx;
  339. .label {
  340. font-size: 28rpx;
  341. width: 150rpx;
  342. color: #808080;
  343. &.right {
  344. flex: 1;
  345. color: #000000;
  346. }
  347. }
  348. }
  349. }
  350. .selected {
  351. border: 1rpx solid #c0c4fc;
  352. background-color: #c0c4fc;
  353. /* 选中之后样式 */
  354. }
  355. </style>