index.vue 11 KB

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