index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <view style="height: 100%;display: flex;flex-direction: column;justify-content: space-between;">
  3. <view class="tab-container">
  4. <view :class="['tab-item', isActiveId === 1 ? 'active': '']" @click="handleClickInner(1)">车间内</view>
  5. <view :class="['tab-item', isActiveId === 2 ? 'active': '']" @click="handleClickOut(2)">车间外</view>
  6. </view>
  7. <view class="box-bg uni-row">
  8. <view class="input-view uni-row">
  9. <uni-icons class="input-uni-icon" type="search" size="18" color="#999" />
  10. <input class="nav-bar-input" type="text" v-model="keywords" placeholder="请输入关键字" />
  11. </view>
  12. <view class="search" @click="handleSearch">
  13. 搜索
  14. </view>
  15. </view>
  16. <view class="top-btn-container uni-row">
  17. <button v-if="!checkAll" :disabled="(isActiveId === 1 && innerTurnoverList.length === 0) || (isActiveId === 2 && outTurnoverList.length === 0)" class="bottom-btn" @click="handleAll">全选</button>
  18. <button v-else class="bottom-btn" @click="handleAll">取消全选</button>
  19. </view>
  20. <scroll-view class="scroll-container" scroll-y v-if="isActiveId == 1">
  21. <view v-if="innerTurnoverList.length == 0" class="no-date">
  22. <text>暂无车间内周转批次</text>
  23. </view>
  24. <!-- 车间内列表 -->
  25. <view v-for="(item, index) in innerTurnoverList" :key="index"
  26. :class="{'scroll-item':true,'selected':isSelected(item)}" @click="handleSelection(item)">
  27. <view class="title-container uni-row" style="justify-content: flex-start;">
  28. <view class="title uni-row">
  29. <text class="label">批次号:</text>
  30. <text class="label code">{{ item['lotCode'] }}</text>
  31. </view>
  32. </view>
  33. <view class="item-info uni-row">
  34. <text class="label">产品描述</text>
  35. <text class="label right">{{ item['productDescription'] }}</text>
  36. </view>
  37. <view class="item-info uni-row">
  38. <text class="label">箱号</text>
  39. <text class="label right">{{ item['carrierName'] ? item['carrierName'] : '-' }}</text>
  40. </view>
  41. <view class="item-info uni-row">
  42. <text class="label">合格数量</text>
  43. <text class="label right">{{ item['temporaryProcessQualifiedNum']}}</text>
  44. </view>
  45. <view class="item-info uni-row">
  46. <text class="label">当前工序</text>
  47. <view class="label right uni-row">
  48. {{ item.currentProcess ? item['currentProcess'].processAlias : '-' }}
  49. (<view style="color: #1684fc;" @click.stop="handleClickProcessList(item)">&nbsp;工艺列表&nbsp;
  50. </view>)
  51. </view>
  52. </view>
  53. <view class="item-info uni-row">
  54. <text class="label">下序工段</text>
  55. <text class="label right">{{ item['deptName'] }}</text>
  56. </view>
  57. <view class="item-info uni-row">
  58. <text class="label">摆放位置</text>
  59. <text class="label right">{{ item['place'] ? item['place'] : '-' }}</text>
  60. </view>
  61. <view class="item-info uni-row">
  62. <text class="label">操作者</text>
  63. <text class="label right">{{ item['creatorName'] }}</text>
  64. </view>
  65. </view>
  66. </scroll-view>
  67. <scroll-view class="scroll-container" scroll-y v-if="isActiveId == 2">
  68. <view v-if="outTurnoverList.length == 0" class="no-date">
  69. <text>暂无车间外周转批次</text>
  70. </view>
  71. <view v-for="(item, index) in outTurnoverList" :key="index" :class="{'scroll-item':true,'selected':isSelected(item)}" @click="handleSelection(item)">
  72. <view class="title-container uni-row" style="justify-content: flex-start;">
  73. <view class="title uni-row">
  74. <text class="label">批次号:</text>
  75. <text class="label code">{{ item['lotCode'] }}</text>
  76. </view>
  77. </view>
  78. <view class="item-info uni-row">
  79. <text class="label">产品描述</text>
  80. <text class="label right">{{ item['productDescription'] }}</text>
  81. </view>
  82. <view class="item-info uni-row">
  83. <text class="label">箱号</text>
  84. <text class="label right">{{ item['carrierName'] ? item['carrierName'] : '-' }}</text>
  85. </view>
  86. <view class="item-info uni-row">
  87. <text class="label">合格数量</text>
  88. <text class="label right">{{ item['temporaryProcessQualifiedNum']}}</text>
  89. </view>
  90. <view class="item-info uni-row">
  91. <text class="label">当前工序</text>
  92. <view class="label right uni-row">
  93. {{ item.currentProcess ? item['currentProcess'].processAlias : '-' }}
  94. (<view style="color: #1684fc;" @click.stop="handleClickProcessList(item)">&nbsp;工艺列表&nbsp;
  95. </view>)
  96. </view>
  97. </view>
  98. <view class="item-info uni-row">
  99. <text class="label">下序工段</text>
  100. <text class="label right">{{ item['deptName'] }}</text>
  101. </view>
  102. <view class="item-info uni-row">
  103. <text class="label">摆放位置</text>
  104. <text class="label right">{{ item['place'] ? item['place'] : '-' }}</text>
  105. </view>
  106. <view class="item-info uni-row">
  107. <text class="label">操作者</text>
  108. <text class="label right">{{ item['creatorName'] }}</text>
  109. </view>
  110. </view>
  111. </scroll-view>
  112. <!-- 抽屉 -->
  113. <uni-drawer ref="showRight" mode="right" :mask-click="true">
  114. <view style="text-align: center; font-size: 48rpx; padding: 48rpx 0 24rpx 0;">工艺列表</view>
  115. <view style="font-size: 24rpx;text-align: center;color: red; margin-bottom: 16rpx;">
  116. 仅显示当前工序后面工艺
  117. </view>
  118. <scroll-view scroll-y="true" style="height: 82%;" @touchmove.stop>
  119. <view v-for="(item,index) in curProcessAfte" :key="index"
  120. style="padding: 8rpx 5% 8rpx 14%; border-top: 1px solid #cccccc">
  121. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  122. </view>
  123. </scroll-view>
  124. </uni-drawer>
  125. <view class="bottom-btn-container uni-row">
  126. <button class="bottom-btn" @click="handleStartTurnover">确认周转</button>
  127. </view>
  128. </view>
  129. </template>
  130. <script setup>
  131. import {
  132. ref
  133. } from 'vue'
  134. import {
  135. onLoad,
  136. onReady,
  137. onUnload,
  138. onShow
  139. } from '@dcloudio/uni-app'
  140. import {
  141. getInnerTurnoverByDeptId,
  142. getOutTurnoverByDeptId,
  143. updateDayworkItemInnerTurnover
  144. } from '@/api/business/dayWorkItem.js'
  145. import {
  146. store
  147. } from '@/store/index.js'
  148. const selectedInfo = ref({})
  149. const selection = ref([])
  150. const checkAll = ref(false)
  151. const curProcessAfte = ref([])
  152. const outTurnoverList = ref([])
  153. const innerTurnoverList = ref([])
  154. const deptId = ref(null)
  155. const showRight = ref(null) // 抽屉
  156. const isActiveId = ref(1)
  157. const keywords = ref(null)
  158. onShow(() => {
  159. deptId.value = store.curDeptDetails.deptId;
  160. init();
  161. })
  162. function init() {
  163. checkAll.value = false
  164. getInnerList()
  165. }
  166. function getInnerList() {
  167. getInnerTurnoverByDeptId({
  168. deptId: deptId.value,
  169. keywords: keywords.value
  170. }).then(res => {
  171. if (res.code == 200) {
  172. innerTurnoverList.value = res.data
  173. isActiveId.value = 1
  174. }
  175. })
  176. }
  177. function isSelected(item) {
  178. return selection.value.includes(item);
  179. }
  180. function handleSelection(item) {
  181. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  182. if (buttonIndex > -1) {
  183. selection.value.splice(buttonIndex, 1); // 取消选中
  184. } else {
  185. selection.value.push(item); // 选中
  186. }
  187. if (isActiveId.value == 1) {
  188. console.log(innerTurnoverList.value.length)
  189. console.log(selection.value.length)
  190. if (selection.value.length == innerTurnoverList.value.length) {
  191. checkAll.value = true;
  192. } else {
  193. checkAll.value = false;
  194. }
  195. } else {
  196. if (selection.value.length == outTurnoverList.value.length) {
  197. checkAll.value = true;
  198. } else {
  199. checkAll.value = false;
  200. }
  201. }
  202. }
  203. function handleSearch() {
  204. checkAll.value = false
  205. selection.value = []
  206. if(isActiveId.value == 1) {
  207. getInnerList()
  208. }else {
  209. getOutList()
  210. }
  211. }
  212. function getOutList() {
  213. getOutTurnoverByDeptId({
  214. deptId: deptId.value,
  215. keywords: keywords.value
  216. }).then(res => {
  217. if (res.code == 200) {
  218. outTurnoverList.value = res.data
  219. isActiveId.value = 2
  220. }
  221. })
  222. }
  223. // 全选按钮操作
  224. function handleAll() {
  225. //清空选中数据
  226. selection.value.length = 0;
  227. if (checkAll.value) {
  228. //变更选中状态
  229. checkAll.value = false;
  230. } else {
  231. checkAll.value = true;
  232. if (isActiveId.value == 1) {
  233. innerTurnoverList.value.findIndex(item => handleSelection(item))
  234. } else {
  235. outTurnoverList.value.findIndex(item => handleSelection(item))
  236. }
  237. }
  238. }
  239. function handleStartTurnover() {
  240. if(selection.value.length == 0) {
  241. uni.showToast({
  242. icon: "none",
  243. title: "至少选中一批周转",
  244. duration: 2000
  245. })
  246. }else{
  247. uni.showModal({
  248. title: '提示',
  249. content: `是否已经送达?`,
  250. success: function(res) {
  251. if (res.confirm) {
  252. let dayworkItemList = []
  253. selection.value.forEach(item =>{
  254. dayworkItemList.push(item.dayworkItemList[0])
  255. })
  256. updateDayworkItemInnerTurnover(dayworkItemList).then(res =>{
  257. if(res.code == 200) {
  258. if(isActiveId.value == 1) {
  259. getInnerList()
  260. }else {
  261. getOutList()
  262. }
  263. }
  264. })
  265. } else {}
  266. }
  267. })
  268. }
  269. }
  270. function handleClickProcessList(item) {
  271. let curProcessAfterList = [];
  272. console.log("工序列表", item)
  273. let nextIndex = 0;
  274. for (let i = 0; i < item.processSequence.length; i++) {
  275. if (item.currentProcess.processStepNumber == item.processSequence[i].processStepNumber) {
  276. nextIndex = i;
  277. }
  278. }
  279. for (let i = 0; i < item.processSequence.length; i++) {
  280. if (i > nextIndex) {
  281. curProcessAfterList.push(item.processSequence[i]);
  282. }
  283. }
  284. if (item.status == 3) {
  285. curProcessAfterList.splice(0, 1)
  286. }
  287. console.log(curProcessAfterList)
  288. curProcessAfte.value = curProcessAfterList;
  289. showRight.value.open();
  290. }
  291. function handleClickInner(val) {
  292. selection.value = []
  293. isActiveId.value = val
  294. checkAll.value = false
  295. getInnerList()
  296. }
  297. function handleClickOut(val) {
  298. selection.value = []
  299. isActiveId.value = val
  300. checkAll.value = false
  301. getOutList()
  302. }
  303. </script>
  304. <style lang="scss">
  305. .tab-container {
  306. display: flex;
  307. flex-direction: row;
  308. height: 24px;
  309. .tab-item {
  310. display: flex;
  311. flex-direction: row;
  312. flex: 1;
  313. font-size: 15px;
  314. color: #666;
  315. align-items: center;
  316. justify-content: center;
  317. }
  318. }
  319. .scroll-container {
  320. height: calc(100% - 206px);
  321. background-color: #f5f5f5;
  322. .no-date {
  323. text-align: center;
  324. font-size: 12px;
  325. color: #666;
  326. padding-top: 16px;
  327. }
  328. .scroll-item {
  329. background-color: #fff;
  330. padding: 24rpx;
  331. margin: 24rpx;
  332. border-radius: 8rpx;
  333. .title-container {
  334. justify-content: space-between;
  335. margin-top: 8rpx;
  336. margin-bottom: 16rpx;
  337. .title {
  338. height: 48rpx;
  339. align-items: center;
  340. .label {
  341. color: #1684fc;
  342. font-size: 32rpx;
  343. font-weight: bold;
  344. &.code {
  345. color: #000000;
  346. margin-left: 32rpx;
  347. }
  348. }
  349. }
  350. }
  351. .item-info {
  352. margin-bottom: 16rpx;
  353. .label {
  354. font-size: 28rpx;
  355. width: 160rpx;
  356. color: #808080;
  357. &.right {
  358. flex: 1;
  359. color: #000000;
  360. }
  361. }
  362. }
  363. .right-info {
  364. justify-content: flex-end;
  365. margin-top: 2rpx;
  366. .label {
  367. font-size: 28rpx;
  368. color: #808080;
  369. }
  370. }
  371. }
  372. }
  373. .tab-item.active {
  374. color: rgba(25, 137, 250, 1);
  375. }
  376. .box-bg {
  377. width: 94%;
  378. background-color: #F5F5F5;
  379. padding: 5rpx 16rpx;
  380. height: 50px;
  381. justify-content: space-around;
  382. align-items: center;
  383. margin: 24rpx auto 0;
  384. .input-view {
  385. width: 100%;
  386. flex: 4;
  387. background-color: #f8f8f8;
  388. border: 1rpx solid #999;
  389. border-radius: 15rpx;
  390. padding: 0 15rpx;
  391. flex-wrap: nowrap;
  392. margin: 0 10rpx 0;
  393. .input-uni-icon {
  394. line-height: 60rpx;
  395. }
  396. .nav-bar-input {
  397. width: 80%;
  398. height: 30px;
  399. line-height: 30px;
  400. padding: 0 5rpx;
  401. background-color: #f8f8f8;
  402. }
  403. }
  404. .search {
  405. width: 20%;
  406. text-align: center;
  407. color: #808080;
  408. }
  409. }
  410. .tab-item.active {
  411. color: rgba(25, 137, 250, 1);
  412. font-weight: 700;
  413. }
  414. .selected {
  415. border: 3rpx solid #c0c4fc;
  416. background-color: #c0c4fc;
  417. /* 选中之后样式 */
  418. }
  419. .top-btn-container {
  420. margin: 8px 0 8px 0;
  421. height: 40px;
  422. padding: 0 16px;
  423. align-items: center;
  424. background-color: #fff;
  425. .bottom-btn {
  426. flex: 1;
  427. font-size: 28rpx;
  428. color: #FFFFFF;
  429. background-color: #1684fc;
  430. }
  431. }
  432. .bottom-btn-container {
  433. height: 50px;
  434. border-top: 1px solid #999999;
  435. padding: 0 32px;
  436. align-items: center;
  437. background-color: #fff;
  438. .bottom-btn {
  439. flex: 1;
  440. font-size: 28rpx;
  441. color: #FFFFFF;
  442. background-color: #1684fc;
  443. }
  444. }
  445. </style>