dialog-turnoverApplication.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <dialog-base ref="baseDialog" title="周转申请">
  3. <view class="list-container">
  4. <view class="list-title"><text class="label">请选择周转类型</text></view>
  5. <view class="btn uni-row">
  6. <view v-for="(item,index) in turnoverType" :class="{ 'middle-btn': true, 'active': item == turnoverTypeChecked }"
  7. @click="selectTurnoverType(item)"><text class="label">{{item.dictLabel}}</text></view>
  8. <!-- <view :class="{ 'middle-btn': true, 'active': isRightTurnoverType }"
  9. @click="selectTurnoverType('rightType')"><text class="label">车间外周转</text></view> -->
  10. </view>
  11. <view class="list-title">
  12. <text class="label">请选择周转位置</text>
  13. </view>
  14. <view v-if="curDayworkItem.turnoverType == '2'" v-for="(item,index) in turnoverArea" class="list-container">
  15. <view class="btn uni-row">
  16. <view :class="{ 'middle-btn': true, 'active': item == turnoverDoorChecked }"
  17. @click="selectTurnoverDoor(item)"><text class="label">{{item.dictLabel}}</text></view>
  18. <!-- <view :class="{ 'middle-btn': true, 'active': isRightTurnoverDoor }"
  19. @click="selectTurnoverDoor('rightDoor')"><text class="label">B门</text></view> -->
  20. </view>
  21. </view>
  22. </view>
  23. <view class="add-btn-container uni-row">
  24. <button type="default" class="btn" @click="handleConfirm">确认</button>
  25. </view>
  26. </dialog-base>
  27. </template>
  28. <script setup>
  29. import {
  30. ref,
  31. getCurrentInstance,
  32. onMounted
  33. } from 'vue'
  34. import {
  35. onLoad
  36. } from '@dcloudio/uni-app'
  37. import {
  38. getDictInfoByType
  39. } from '@/api/dict/dict.js'
  40. import {
  41. getDayWorkItemList,saveDayWorkItem
  42. } from '@/api/business/dayWorkItem.js'
  43. import {
  44. store
  45. } from '@/store/index.js'
  46. import { timestampToTime } from '@/utils/common.js'
  47. const baseDialog = ref(null)
  48. const turnoverTypeChecked = ref({})
  49. const turnoverDoorChecked = ref({})
  50. const turnoverType = ref([])
  51. const turnoverArea = ref([])
  52. const curDayworkItem = ref({})
  53. const dayworkInfo = ref(null);
  54. onLoad(() => {
  55. })
  56. function open(data){
  57. dayworkInfo.value = data;
  58. baseDialog.value.open()
  59. init();
  60. }
  61. defineExpose({
  62. open
  63. })
  64. function close() {
  65. baseDialog.value.close()
  66. }
  67. function init() {
  68. getDictInfoByType('daywork_turnover_type').then(res => {
  69. turnoverType.value = res.data;
  70. getDictInfoByType('daywork_turnover_area').then(res => {
  71. turnoverArea.value = res.data;
  72. })
  73. })
  74. getDayWorkItemList(dayworkInfo.value.id).then(res => {
  75. curDayworkItem.value = res.rows[0]
  76. })
  77. }
  78. function selectTurnoverType(item){
  79. turnoverTypeChecked.value = item;
  80. curDayworkItem.value.turnoverType = item.dictValue;
  81. }
  82. function selectTurnoverDoor(item){
  83. turnoverDoorChecked.value = item;
  84. curDayworkItem.value.turnoverArea = item.dictValue;
  85. }
  86. function handleConfirm(){
  87. curDayworkItem.value.id = null;
  88. curDayworkItem.value.status = '4';
  89. curDayworkItem.value.startTime = timestampToTime(new Date());
  90. curDayworkItem.value.technologicalProcessId = dayworkInfo.value.technologicalProcessId;
  91. if(!store.tenantId){
  92. curDayworkItem.value.tenantId = store.userInfo.tenantId;
  93. }else{
  94. curDayworkItem.value.tenantId = store.tenantId;
  95. }
  96. saveDayWorkItem(curDayworkItem.value).then(res => {
  97. if (res.code === 200) {
  98. uni.showToast({
  99. icon: 'success',
  100. title: '操作成功',
  101. duration: 2000
  102. });
  103. close();
  104. } else {
  105. uni.showToast({
  106. icon: 'error',
  107. title: '操作失败',
  108. duration: 2000
  109. });
  110. close();
  111. }
  112. })
  113. }
  114. </script>
  115. <style lang="scss">
  116. .dialog-body {
  117. .list-container {
  118. width: 100%;
  119. display: flex;
  120. align-items: flex-start;
  121. padding: 0 4rpx;
  122. .list-title {
  123. margin-top: 24rpx;
  124. .label {
  125. font-size: 32rpx;
  126. }
  127. }
  128. .btn {
  129. justify-content: space-between;
  130. margin-top: 24rpx;
  131. .middle-btn {
  132. margin-right: 32rpx;
  133. align-items: center;
  134. justify-content: center;
  135. padding-left: 0;
  136. height: 80rpx;
  137. width: 240rpx;
  138. border-radius: 8rpx;
  139. background-color: #FFFFFF;
  140. border: 1px solid #999999;
  141. background-color: #FFFFFF;
  142. }
  143. .label {
  144. font-size: 24rpx;
  145. color: #000000;
  146. }
  147. .active {
  148. border-color: #1684fc;
  149. background-color: rgb(236, 245, 255);
  150. .label {
  151. color: #1684fc;
  152. }
  153. }
  154. }
  155. }
  156. .add-btn-container {
  157. margin-top: 32rpx;
  158. .btn {
  159. flex: 1;
  160. background-color: rgb(255, 121, 1);
  161. color: #FFFFFF;
  162. }
  163. }
  164. }
  165. </style>