dialog-changeTurnover.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <dialog-base ref="baseDialog" title="周转申请">
  3. <view class="list-container">
  4. <view><text style="margin: 0 0 0 5rpx;">请选择周转类型</text></view>
  5. <view class="btn uni-row">
  6. <view v-for="(item,index) in turnoverType"
  7. :class="{ 'middle-btn': true, 'active': item.dictValue == curDayworkItem.turnoverType }"
  8. @click="selectTurnoverType(item)"><text class="label"
  9. style="font-size: 30rpx;">{{item.dictLabel}}</text></view>
  10. </view>
  11. <view class="" style="margin: 0 20rpx 20rpx 0;width: 88%;">
  12. <uni-section title="请选择下序工段" title-font-size="32rpx" style="margin: 0 0 0 -16rpx;"
  13. v-if="curDayworkItem.turnoverType == '2'">
  14. <uni-data-select v-model="curDayworkItem.deptId" :localdata="outsideDepts"
  15. :clear="false"
  16. style="margin: 0 0 0 16rpx;outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  17. </uni-section>
  18. </view>
  19. </view>
  20. <view class="add-btn-container uni-row">
  21. <button type="default" class="btn" @click="handleConfirm">确认</button>
  22. </view>
  23. </dialog-base>
  24. </template>
  25. <script setup>
  26. import {
  27. ref,
  28. getCurrentInstance
  29. } from 'vue'
  30. import {
  31. onLoad
  32. } from '@dcloudio/uni-app'
  33. import {
  34. getDictInfoByType
  35. } from '@/api/dict/dict.js'
  36. import {
  37. turnover,
  38. updateTurnoverInfo
  39. } from '@/api/business/dayWorkItem.js'
  40. import {
  41. getDeptList
  42. } from '@/api/dept/dept.js'
  43. import {
  44. store
  45. } from '@/store/index.js'
  46. const baseDialog = ref(null)
  47. const turnoverType = ref([])
  48. const turnoverArea = ref([])
  49. const curDayworkItem = ref({
  50. turnoverType: 1
  51. })
  52. const dayworkInfo = ref(null)
  53. const deptList = ref([]) // 工段列表
  54. const outsideDepts = ref([]) // 车间外工段
  55. const emit = defineEmits(['reflushTurnoverList']) // 自定义调用父组件方法
  56. onLoad(() => {
  57. })
  58. function open(data) {
  59. resetPage();
  60. dayworkInfo.value = data;
  61. console.log(store)
  62. console.log(dayworkInfo.value)
  63. init();
  64. baseDialog.value.open();
  65. }
  66. defineExpose({
  67. open
  68. })
  69. function close() {
  70. baseDialog.value.close()
  71. }
  72. function resetPage() {
  73. turnoverType.value = []
  74. turnoverArea.value = []
  75. curDayworkItem.value = {
  76. turnoverType: 1
  77. }
  78. deptList.value = []
  79. outsideDepts.value = []
  80. }
  81. function init() {
  82. getDictInfoByType('daywork_turnover_type').then(res => {
  83. turnoverType.value = res.data.filter(item => {return item.dictValue !=1 && item.dictValue !=3 });
  84. })
  85. getDeptList({
  86. tenantId:store.tenantId,
  87. productionPlanDetailId: dayworkInfo.value.daywork.productionPlanDetailId,
  88. lotId:dayworkInfo.value.daywork.lotId,
  89. isWasteRecycling:dayworkInfo.value.daywork.isWasteRecycling,
  90. isAmend: dayworkInfo.value.daywork.isAmend
  91. }).then(res => {
  92. deptList.value = res.data.filter(item => {return item.deptName.trim() != dayworkInfo.value.preDeptName.trim()});
  93. for (let i = 0; i < deptList.value.length; i++) {
  94. outsideDepts.value.push({
  95. text: deptList.value[i].deptName,
  96. value: deptList.value[i].deptId,
  97. data: deptList.value[i]
  98. })
  99. }
  100. console.log(outsideDepts.value)
  101. })
  102. }
  103. function selectTurnoverType(item) {
  104. curDayworkItem.value.turnoverType = item.dictValue;
  105. }
  106. function handleValidate(data) {
  107. console.log(data)
  108. if (data.turnoverArea == "" || data.deptId == null) {
  109. return false;
  110. } else {
  111. return true;
  112. }
  113. }
  114. function handleConfirm() {
  115. // curDayworkItem.value.dayworkId = store.dayworkInfo.id;
  116. // 设置周转下一个车间名
  117. for (let i = 0; i < deptList.value.length; i++) {
  118. if (deptList.value[i].deptId == curDayworkItem.value.deptId) {
  119. curDayworkItem.value.deptName = deptList.value[i].deptName;
  120. }
  121. }
  122. if (!handleValidate(curDayworkItem.value)) {
  123. uni.showToast({
  124. icon: "none",
  125. title: '请选择完整信息'
  126. });
  127. } else {
  128. curDayworkItem.value.dayworkId = dayworkInfo.value.daywork.id
  129. curDayworkItem.value.processStepNumber = dayworkInfo.value.processStepNumber
  130. console.log(curDayworkItem.value)
  131. close();
  132. updateTurnoverInfo(curDayworkItem.value).then(res => {
  133. if (res.code === 200) {
  134. uni.showToast({
  135. icon: 'success',
  136. title: '操作成功'
  137. });
  138. emit('reflushTurnoverList');
  139. } else {
  140. uni.showToast({
  141. icon: 'none',
  142. title: '操作失败'
  143. });
  144. }
  145. })
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. .dialog-body {
  151. .list-container {
  152. width: 100%;
  153. .list-title {
  154. margin-top: 24rpx;
  155. .label {
  156. font-size: 32rpx;
  157. }
  158. }
  159. .turnArea {
  160. flex-wrap: wrap;
  161. height: auto;
  162. max-height: 200rpx;
  163. overflow: auto;
  164. }
  165. .btn {
  166. margin-top: 24rpx;
  167. .middle-btn {
  168. margin-right: 32rpx;
  169. align-items: center;
  170. justify-content: center;
  171. padding-left: 0;
  172. height: 80rpx;
  173. width: 220rpx;
  174. border-radius: 8rpx;
  175. background-color: #FFFFFF;
  176. border: 1px solid #999999;
  177. background-color: #FFFFFF;
  178. }
  179. .label {
  180. font-size: 24rpx;
  181. color: #000000;
  182. }
  183. .active {
  184. border-color: #1684fc;
  185. background-color: rgb(236, 245, 255);
  186. .label {
  187. color: #1684fc;
  188. }
  189. }
  190. }
  191. }
  192. .add-btn-container {
  193. margin-top: 32rpx;
  194. .btn {
  195. flex: 1;
  196. background-color: rgb(255, 121, 1);
  197. color: #FFFFFF;
  198. }
  199. }
  200. }
  201. </style>