index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <view class="uni-column" style="padding: 24rpx">
  3. <view v-if="allData.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="allData.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="allData.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="allData.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="allData.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. // 创建一个引用来存储最后一次请求的时间戳
  102. const lastRequestTimestamp = ref(0);
  103. const listData = ref([]);
  104. const allData = ref([])
  105. const selection = ref([]); //选中数据
  106. const workshopList = ref([]); //车间数据
  107. onShow(() => {
  108. init()
  109. })
  110. //初始化
  111. function init() {
  112. // console.log(store.curDeptDetails)
  113. uni.showLoading({
  114. title: '加载中'
  115. });
  116. checkAll.value = false
  117. getQuickDayworkList({
  118. deptId: store.curDeptDetails.deptId,
  119. }).then(res => {
  120. // console.log(res)
  121. if (res.code == 200) {
  122. allData.value = res.rows
  123. if (allData.value.length == 0) {
  124. listData.value = []
  125. }
  126. uni.hideLoading();
  127. }
  128. if (res.other.workShops != null) {
  129. workshopList.value = res.other.workShops.map(v => ({
  130. value: v.id,
  131. text: v.name,
  132. depts: v.depts
  133. }))
  134. if ((workshopId.value == null || !workshopList.value.some(e => e.value === workshopId.value)) &&
  135. workshopList.value.length > 0) {
  136. workshopId.value = workshopList.value[0].value
  137. handleChangeWorkshop(workshopId.value)
  138. } else {
  139. handleChangeWorkshop(workshopId.value)
  140. }
  141. } else {
  142. workshopList.value = []
  143. }
  144. uni.hideLoading();
  145. })
  146. }
  147. // 搜索按钮操作
  148. function handleSearch() {
  149. searchRef.value.open();
  150. }
  151. function refreshSearch(input) {
  152. // console.log(input)
  153. keyword.value = input
  154. handleChangeWorkshop(workshopId.value)
  155. }
  156. function handleAdd() {
  157. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  158. if (mpaasScanModule) {
  159. // 调用插件的 mpaasScan 方法
  160. mpaasScanModule.mpaasScan({
  161. // 扫码识别类型,参数可多选,qrCode、barCode,
  162. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  163. scanType: ["qrCode", "barCode"],
  164. // 是否隐藏相册,默认false不隐藏
  165. hideAlbum: false,
  166. },
  167. (ret) => {
  168. let vehicleObj = JSON.parse(ret.resp_result);
  169. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  170. uni.showToast({
  171. icon: "none",
  172. title: "请扫载具码",
  173. duration: 1000
  174. })
  175. return;
  176. }
  177. getDayworkByCarrierId({
  178. carrierId: vehicleObj.carrierId,
  179. deptId: store.curDeptDetails.deptId,
  180. status: 7
  181. }).then(response => {
  182. if (response.code == 200) {
  183. // console.log(response.data.items.length)
  184. // console.log(response.data)
  185. if (response.data.items.length > 0) {
  186. lotReporting.value.open(response.data);
  187. } else {
  188. uni.showToast({
  189. icon: 'none',
  190. title: '该批次不在此计划单内',
  191. duration: 2000
  192. })
  193. }
  194. } else {
  195. uni.showToast({
  196. icon: 'none',
  197. title: response.msg,
  198. duration: 2000
  199. })
  200. }
  201. })
  202. }
  203. );
  204. } else {
  205. // 测试时用
  206. getDayworkByCarrierId({
  207. carrierId: '1747500987688890381',
  208. status: 7,
  209. deptId: store.curDeptDetails.deptId,
  210. }).then(response => {
  211. // console.log(response)
  212. if (response.code == 200) {
  213. //
  214. if (response.data.items.length > 0) {
  215. // console.log(response.data)
  216. lotReporting.value.open(response.data);
  217. } else {
  218. uni.showToast({
  219. icon: 'none',
  220. title: '该批次不在此计划单内',
  221. duration: 2000
  222. })
  223. }
  224. } else {
  225. uni.showToast({
  226. icon: 'none',
  227. title: response.msg,
  228. duration: 2000
  229. })
  230. }
  231. })
  232. }
  233. // lotReporting.value.open(data);
  234. }
  235. function handleContinue() {
  236. // lotReporting.value.open('test')
  237. handleAdd()
  238. }
  239. // 全选按钮操作
  240. function handleAll() {
  241. //清空选中数据
  242. selection.value.length = 0;
  243. if (checkAll.value) {
  244. //变更选中状态
  245. checkAll.value = false;
  246. } else {
  247. checkAll.value = true;
  248. listData.value.findIndex(item => handleSelection(item))
  249. }
  250. }
  251. function handleChangeWorkshop(arg) {
  252. const workshop = workshopList.value.find(v => v.value === arg)
  253. // console.log(allData.value)
  254. // console.log(workshop)
  255. // console.log()
  256. listData.value = allData.value.filter(v => workshop.depts.some(e => e.deptId === v.quickInfo.deptId) && (v.lotCode
  257. .includes(keyword.value) || v.productDescription.includes(keyword.value)))
  258. }
  259. function isSelected(item) {
  260. return selection.value.includes(item);
  261. }
  262. //
  263. function handleSelection(item) {
  264. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  265. if (buttonIndex > -1) {
  266. selection.value.splice(buttonIndex, 1); // 取消选中
  267. } else {
  268. selection.value.push(item); // 选中
  269. }
  270. if (selection.value.length == listData.value.length) {
  271. checkAll.value = true;
  272. } else {
  273. checkAll.value = false;
  274. }
  275. }
  276. function handleChangeCarrier(item) {
  277. uni.$once('refreshQuickReport', () => {
  278. init()
  279. })
  280. store.dayworkInfo = null
  281. uni.navigateTo({
  282. url: "/pages/changeBox/index",
  283. success: function(res) {
  284. // 通过eventChannel向被打开页面传送数据
  285. res.eventChannel.emit('acceptDataFromOpenerPage', {
  286. data: item
  287. })
  288. }
  289. })
  290. }
  291. function handleEnd() {
  292. if (selection.value.length === 0) {
  293. uni.showToast({
  294. icon: 'none',
  295. title: '请选择完成报工批次'
  296. })
  297. return
  298. }
  299. const currentTime = Date.now();
  300. // 检查是否已经过去了 2 秒
  301. if (currentTime - lastRequestTimestamp.value < 2000) {
  302. // 如果在 2 秒 内已经有请求发出,那么不执行
  303. uni.showToast({
  304. icon: 'none',
  305. title: `请勿重复点击`,
  306. duration: 2000
  307. })
  308. return;
  309. }
  310. // 更新请求时间戳
  311. lastRequestTimestamp.value = currentTime;
  312. finishQuick(selection.value).then(res => {
  313. // console.log(res)
  314. if (res.code === 200) {
  315. init()
  316. }
  317. })
  318. }
  319. // init();
  320. </script>
  321. <style lang="scss">
  322. $nav-height: 60rpx;
  323. .bottom-btn-container {
  324. position: fixed;
  325. top: 80%;
  326. right: 20rpx;
  327. left: 20rpx;
  328. .start-batch-btn {
  329. margin-bottom: 24rpx;
  330. border-radius: 8rpx;
  331. background-color: #00e2a6;
  332. width: 80%;
  333. }
  334. }
  335. .active {
  336. flex: 1;
  337. height: 40rpx;
  338. background-color: #5e6eff;
  339. border: 1px solid #5e6eff;
  340. color: #000000;
  341. }
  342. .select {
  343. flex: 1;
  344. height: 40rpx;
  345. // font-size: 20rpx;
  346. background-color: #5e6eff;
  347. border: 1px solid #5e6eff;
  348. color: #ffffff;
  349. }
  350. .btn {
  351. position: fixed;
  352. right: 0;
  353. bottom: 0;
  354. left: 0;
  355. height: 100rpx;
  356. padding: 16rpx 24rpx;
  357. align-items: center;
  358. background-color: #FFFFFF;
  359. justify-content: space-between;
  360. .bottom-btn {
  361. flex: 1;
  362. font-size: 28rpx;
  363. color: #FFFFFF;
  364. &.left-btn {
  365. // background-color: #a4adb3;
  366. }
  367. &.right-btn {
  368. background-color: #1684fc;
  369. margin-left: 24rpx;
  370. }
  371. }
  372. }
  373. .box-bg {
  374. width: 100%;
  375. background-color: #F5F5F5;
  376. padding: 5rpx 0;
  377. justify-content: space-around;
  378. align-items: center;
  379. .input-view {
  380. width: 100%;
  381. flex: 4;
  382. background-color: #f8f8f8;
  383. height: $nav-height;
  384. border: 1rpx solid #999;
  385. border-radius: 15rpx;
  386. padding: 0 15rpx;
  387. flex-wrap: nowrap;
  388. margin: 0 10rpx 20rpx;
  389. line-height: $nav-height;
  390. .input-uni-icon {
  391. line-height: $nav-height;
  392. }
  393. .nav-bar-input {
  394. width: 80%;
  395. height: $nav-height;
  396. line-height: $nav-height;
  397. padding: 0 5rpx;
  398. background-color: #f8f8f8;
  399. }
  400. }
  401. .search {
  402. width: 20%;
  403. text-align: center;
  404. color: #808080;
  405. margin-top: -20rpx;
  406. }
  407. }
  408. .list-item {
  409. background-color: #fff;
  410. position: relative;
  411. padding: 16rpx;
  412. padding-bottom: 24rpx;
  413. border-radius: 24rpx;
  414. margin-bottom: 24rpx;
  415. .title-container {
  416. justify-content: space-between;
  417. margin-top: 8rpx;
  418. margin-bottom: 16rpx;
  419. .title {
  420. height: 48rpx;
  421. align-items: center;
  422. .label {
  423. font-size: 32rpx;
  424. font-weight: bold;
  425. &.code {
  426. margin-left: 8rpx;
  427. }
  428. }
  429. }
  430. .tag {
  431. border: 1px solid #1ce5b0;
  432. background-color: #f6fffd;
  433. padding: 8rpx;
  434. border-radius: 8rpx;
  435. .label {
  436. color: #1ce5b0;
  437. font-size: 24rpx;
  438. }
  439. &.not-start {
  440. border: 1px solid #bbbbbb;
  441. background-color: #f5f5f5;
  442. .label {
  443. color: #bbbbbb;
  444. }
  445. }
  446. }
  447. }
  448. .item-info {
  449. margin-bottom: 8rpx;
  450. .label {
  451. font-size: 28rpx;
  452. width: 150rpx;
  453. color: #808080;
  454. &.right {
  455. flex: 1;
  456. color: #000000;
  457. }
  458. }
  459. }
  460. }
  461. .selected {
  462. border: 1rpx solid #c0c4fc;
  463. background-color: #c0c4fc;
  464. /* 选中之后样式 */
  465. }
  466. </style>