index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. if (selection.value.length === 0) {
  268. uni.showToast({
  269. icon: 'none',
  270. title: '请选择完成报工批次'
  271. })
  272. return
  273. }
  274. finishQuick(selection.value).then(res => {
  275. console.log(res)
  276. if (res.code === 200) {
  277. init()
  278. }
  279. })
  280. }
  281. // init();
  282. </script>
  283. <style lang="scss">
  284. $nav-height: 60rpx;
  285. .bottom-btn-container {
  286. position: fixed;
  287. top: 80%;
  288. right: 20rpx;
  289. left: 20rpx;
  290. .start-batch-btn {
  291. margin-bottom: 24rpx;
  292. border-radius: 8rpx;
  293. background-color: #00e2a6;
  294. width: 80%;
  295. }
  296. }
  297. .active {
  298. flex: 1;
  299. height: 40rpx;
  300. font-size: 20rpx;
  301. background-color: #5e6eff;
  302. border: 1px solid #5e6eff;
  303. color: #000000;
  304. }
  305. .select {
  306. flex: 1;
  307. height: 40rpx;
  308. font-size: 20rpx;
  309. background-color: #5e6eff;
  310. border: 1px solid #5e6eff;
  311. color: #ffffff;
  312. }
  313. .btn {
  314. position: fixed;
  315. right: 0;
  316. bottom: 0;
  317. left: 0;
  318. height: 100rpx;
  319. padding: 16rpx 24rpx;
  320. align-items: center;
  321. background-color: #FFFFFF;
  322. justify-content: space-between;
  323. .bottom-btn {
  324. flex: 1;
  325. font-size: 28rpx;
  326. color: #FFFFFF;
  327. &.left-btn {
  328. // background-color: #a4adb3;
  329. }
  330. &.right-btn {
  331. background-color: #1684fc;
  332. margin-left: 24rpx;
  333. }
  334. }
  335. }
  336. .box-bg {
  337. width: 100%;
  338. background-color: #F5F5F5;
  339. padding: 5rpx 0;
  340. justify-content: space-around;
  341. align-items: center;
  342. .input-view {
  343. width: 100%;
  344. flex: 4;
  345. background-color: #f8f8f8;
  346. height: $nav-height;
  347. border: 1rpx solid #999;
  348. border-radius: 15rpx;
  349. padding: 0 15rpx;
  350. flex-wrap: nowrap;
  351. margin: 0 10rpx 20rpx;
  352. line-height: $nav-height;
  353. .input-uni-icon {
  354. line-height: $nav-height;
  355. }
  356. .nav-bar-input {
  357. width: 80%;
  358. height: $nav-height;
  359. line-height: $nav-height;
  360. padding: 0 5rpx;
  361. background-color: #f8f8f8;
  362. }
  363. }
  364. .search {
  365. width: 20%;
  366. text-align: center;
  367. color: #808080;
  368. margin-top: -20rpx;
  369. }
  370. }
  371. .uni-column {
  372. background-color: rgba(245, 245, 245, 1);
  373. height: calc(100% - 40rpx);
  374. }
  375. .list-item {
  376. background-color: #fff;
  377. position: relative;
  378. padding: 16rpx;
  379. padding-bottom: 24rpx;
  380. border-radius: 24rpx;
  381. margin-bottom: 24rpx;
  382. .title-container {
  383. justify-content: space-between;
  384. margin-top: 8rpx;
  385. margin-bottom: 16rpx;
  386. .title {
  387. height: 48rpx;
  388. align-items: center;
  389. .label {
  390. font-size: 32rpx;
  391. font-weight: bold;
  392. &.code {
  393. margin-left: 8rpx;
  394. }
  395. }
  396. }
  397. .tag {
  398. border: 1px solid #1ce5b0;
  399. background-color: #f6fffd;
  400. padding: 8rpx;
  401. border-radius: 8rpx;
  402. .label {
  403. color: #1ce5b0;
  404. font-size: 24rpx;
  405. }
  406. &.not-start {
  407. border: 1px solid #bbbbbb;
  408. background-color: #f5f5f5;
  409. .label {
  410. color: #bbbbbb;
  411. }
  412. }
  413. }
  414. }
  415. .item-info {
  416. margin-bottom: 8rpx;
  417. .label {
  418. font-size: 28rpx;
  419. width: 150rpx;
  420. color: #808080;
  421. &.right {
  422. flex: 1;
  423. color: #000000;
  424. }
  425. }
  426. }
  427. }
  428. .selected {
  429. border: 1rpx solid #c0c4fc;
  430. background-color: #c0c4fc;
  431. /* 选中之后样式 */
  432. }
  433. </style>