index.vue 11 KB

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