dialog-turnoverApplication.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. console.log(data)
  114. if(data.turnoverType === "0" || data.turnoverArea === "" || data.deptId === "0") {
  115. return false;
  116. }
  117. else {
  118. return true;
  119. }
  120. }
  121. function handleConfirm() {
  122. curDayworkItem.value.id = null;
  123. curDayworkItem.value.status = '4';
  124. curDayworkItem.value.startTime = timestampToTime(new Date());
  125. curDayworkItem.value.technologicalProcessId = dayworkInfo.value.technologicalProcessId;
  126. if (!store.tenantId) {
  127. curDayworkItem.value.tenantId = store.userInfo.tenantId;
  128. } else {
  129. curDayworkItem.value.tenantId = store.tenantId;
  130. }
  131. console.log(deptList.value)
  132. // 设置周转下一个车间名
  133. for (let i = 0; i < deptList.value.length; i++) {
  134. if(deptList.value[i].deptId == curDayworkItem.value.value){
  135. curDayworkItem.value.deptName = deptList.value[i].text;
  136. }
  137. }
  138. console.log(curDayworkItem.value);
  139. if(!handleValidate(curDayworkItem.value)) {
  140. uni.showToast({
  141. icon: 'error',
  142. title: '请选择完整信息',
  143. duration: 2000
  144. });
  145. }
  146. else {
  147. saveDayWorkItem(curDayworkItem.value).then(res => {
  148. if (res.code === 200) {
  149. uni.showToast({
  150. icon: 'success',
  151. title: '操作成功',
  152. duration: 2000
  153. });
  154. close();
  155. } else {
  156. uni.showToast({
  157. icon: 'error',
  158. title: '操作失败',
  159. duration: 2000
  160. });
  161. close();
  162. }
  163. })
  164. }
  165. }
  166. function handleChange() {
  167. console.log(curDayworkItem.value)
  168. }
  169. </script>
  170. <style lang="scss">
  171. .dialog-body {
  172. .list-container {
  173. width: 100%;
  174. .list-title {
  175. margin-top: 24rpx;
  176. .label {
  177. font-size: 32rpx;
  178. }
  179. }
  180. .btn {
  181. margin-top: 24rpx;
  182. .middle-btn {
  183. margin-right: 32rpx;
  184. align-items: center;
  185. justify-content: center;
  186. padding-left: 0;
  187. height: 80rpx;
  188. width: 220rpx;
  189. border-radius: 8rpx;
  190. background-color: #FFFFFF;
  191. border: 1px solid #999999;
  192. background-color: #FFFFFF;
  193. }
  194. .label {
  195. font-size: 24rpx;
  196. color: #000000;
  197. }
  198. .active {
  199. border-color: #1684fc;
  200. background-color: rgb(236, 245, 255);
  201. .label {
  202. color: #1684fc;
  203. }
  204. }
  205. }
  206. }
  207. .add-btn-container {
  208. margin-top: 32rpx;
  209. .btn {
  210. flex: 1;
  211. background-color: rgb(255, 121, 1);
  212. color: #FFFFFF;
  213. }
  214. }
  215. }
  216. </style>