index.vue 12 KB

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