index.vue 11 KB

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