dialog-turnoverApplication.vue 5.2 KB

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