dialog-receipt.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <dialog-base ref="baseDialog" title="摆放位置">
  3. <view class="list-container">
  4. <!-- <view class="" style="margin: 0 20rpx 20rpx 0;width: 88%;">
  5. <uni-section title="请选择工段" title-font-size="32rpx" style="margin: 0 0 0 -16rpx;">
  6. <uni-data-select v-model="curDept" :localdata="deptList" @change="handleChange"
  7. :clear="false"
  8. style="margin: 0 0 0 16rpx;outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  9. </uni-section>
  10. </view> -->
  11. <view class="list-title">
  12. <text class="label">请选择您存放位置</text>
  13. </view>
  14. <view class="turnArea uni-row">
  15. <view v-for="(item,index) in turnAreaList" class="btn">
  16. <view :class="{ 'middle-btn': true, 'active': handleTurnoverDoor(item) }"
  17. @click="selectTurnoverDoor(item)"><text class="label">{{item.code}}</text></view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="add-btn-container uni-row">
  22. <button type="default" class="btn" @click="handleConfirm">确认</button>
  23. </view>
  24. </dialog-base>
  25. </template>
  26. <script setup>
  27. import {
  28. ref,
  29. getCurrentInstance
  30. } from 'vue'
  31. import {
  32. onLoad
  33. } from '@dcloudio/uni-app'
  34. import {
  35. getDictInfoByType
  36. } from '@/api/dict/dict.js'
  37. import {
  38. getDayWorkItemList,
  39. saveDayWorkItem
  40. } from '@/api/business/dayWorkItem.js'
  41. import {
  42. getDeptList
  43. } from '@/api/dept/dept.js'
  44. import {
  45. getTurnoverListByDeptId
  46. } from '@/api/business/turnover.js'
  47. import {
  48. store
  49. } from '@/store/index.js'
  50. import {
  51. timestampToTime
  52. } from '@/utils/common.js'
  53. const baseDialog = ref(null)
  54. const turnoverArea = ref([])
  55. const curDept = ref(0)
  56. const deptList = ref([]) // 工段列表
  57. const turnAreaList = ref([]) // 周转区列表
  58. const placement = ref(null)
  59. const emit = defineEmits(['submit']);
  60. const selection = ref([])
  61. onLoad(() => {
  62. })
  63. function open() {
  64. resetPage();
  65. baseDialog.value.open();
  66. init();
  67. }
  68. function resetPage() {
  69. deptList.value = [];
  70. turnAreaList.value = [];
  71. curDept.value = 0;
  72. placement.value = null;
  73. }
  74. defineExpose({
  75. open
  76. })
  77. function close() {
  78. baseDialog.value.close()
  79. turnAreaList.value = [];
  80. }
  81. function init() {
  82. handleGetTurnoverListByDId(store.curDeptDetails.deptId);
  83. }
  84. function handleTurnoverDoor(item) {
  85. return selection.value.includes(item);
  86. }
  87. function selectTurnoverDoor(item) {
  88. let index = selection.value.findIndex(selectedItem => selectedItem === item);
  89. if (index > -1) {
  90. selection.value.splice(index, 1);
  91. } else {
  92. selection.value.push(item);
  93. }
  94. console.log(item.code)
  95. placement.value = selection.value.map(item => item.code).join('、');
  96. console.log(placement.value)
  97. }
  98. function handleConfirm() {
  99. if (placement.value) {
  100. emit('submit', placement.value);
  101. close();
  102. } else {
  103. uni.showToast({
  104. icon: 'none',
  105. title: '请选择摆放位置'
  106. })
  107. }
  108. }
  109. // function handleChange() {
  110. // handleGetTurnoverListByDId(curDept.value);
  111. // }
  112. function handleGetTurnoverListByDId(depId) {
  113. // turnAreaList.value = [];
  114. getTurnoverListByDeptId({
  115. deptId: depId,
  116. }).then(res => {
  117. for (var i = 0; i < res.data.length; i++) {
  118. if (res.data[i].status == 0) {
  119. turnAreaList.value[i] = res.data[i];
  120. }
  121. }
  122. })
  123. }
  124. </script>
  125. <style lang="scss">
  126. .dialog-body {
  127. .list-container {
  128. width: 100%;
  129. .list-title {
  130. margin-top: 24rpx;
  131. .label {
  132. font-size: 32rpx;
  133. }
  134. }
  135. .turnArea {
  136. flex-wrap: wrap;
  137. height: auto;
  138. max-height: 200rpx;
  139. overflow: auto;
  140. }
  141. .btn {
  142. margin-top: 24rpx;
  143. .middle-btn {
  144. margin-right: 32rpx;
  145. align-items: center;
  146. justify-content: center;
  147. padding-left: 0;
  148. height: 80rpx;
  149. width: 220rpx;
  150. border-radius: 8rpx;
  151. background-color: #FFFFFF;
  152. border: 1px solid #999999;
  153. background-color: #FFFFFF;
  154. }
  155. .label {
  156. font-size: 24rpx;
  157. color: #000000;
  158. }
  159. .active {
  160. border-color: #1684fc;
  161. background-color: rgb(236, 245, 255);
  162. .label {
  163. color: #1684fc;
  164. }
  165. }
  166. }
  167. }
  168. .add-btn-container {
  169. margin-top: 32rpx;
  170. .btn {
  171. flex: 1;
  172. background-color: #1684fc;
  173. color: #FFFFFF;
  174. }
  175. }
  176. }
  177. </style>