dialog-turnoverApplication.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. const emit = defineEmits('confirm') // 自定义调用父组件方法
  65. onLoad(() => {
  66. })
  67. function open(data) {
  68. dayworkInfo.value = data;
  69. baseDialog.value.open()
  70. init();
  71. }
  72. defineExpose({
  73. open
  74. })
  75. function close() {
  76. baseDialog.value.close()
  77. }
  78. function init() {
  79. getDictInfoByType('daywork_turnover_type').then(res => {
  80. turnoverType.value = res.data;
  81. getDictInfoByType('daywork_turnover_area').then(res => {
  82. turnoverArea.value = res.data;
  83. })
  84. })
  85. getDayWorkItemList({
  86. dayworkId: dayworkInfo.value.id,
  87. userId: store.userInfo.userId
  88. }).then(res => {
  89. console.log(res.rows[0])
  90. curDayworkItem.value = res.rows[0];
  91. })
  92. getDeptList({
  93. isWorkSection: 1
  94. }).then(res => {
  95. console.log(res.data)
  96. for (var i = 0; i < res.data.length; i++) {
  97. deptList.value[i] = {
  98. text: res.data[i].deptName,
  99. value: res.data[i].deptId,
  100. data: res.data[i]
  101. }
  102. }
  103. })
  104. }
  105. function selectTurnoverType(item) {
  106. turnoverTypeChecked.value = item;
  107. curDayworkItem.value.turnoverType = item.dictValue;
  108. }
  109. function selectTurnoverDoor(item) {
  110. turnoverDoorChecked.value = item;
  111. curDayworkItem.value.turnoverArea = item.dictValue;
  112. }
  113. function handleValidate(data){
  114. console.log(data)
  115. if(data.turnoverType === "0" || data.turnoverArea === "" || data.deptId === "0") {
  116. return false;
  117. }
  118. else {
  119. return true;
  120. }
  121. }
  122. function handleConfirm() {
  123. curDayworkItem.value.id = null;
  124. curDayworkItem.value.status = '4';
  125. curDayworkItem.value.startTime = timestampToTime(new Date());
  126. curDayworkItem.value.technologicalProcessId = dayworkInfo.value.technologicalProcessId;
  127. if (!store.tenantId) {
  128. curDayworkItem.value.tenantId = store.userInfo.tenantId;
  129. } else {
  130. curDayworkItem.value.tenantId = store.tenantId;
  131. }
  132. console.log(deptList.value)
  133. // 设置周转下一个车间名
  134. for (let i = 0; i < deptList.value.length; i++) {
  135. if(deptList.value[i].value == curDayworkItem.value.deptId){
  136. curDayworkItem.value.deptName = deptList.value[i].text;
  137. }
  138. }
  139. console.log(curDayworkItem.value);
  140. if(!handleValidate(curDayworkItem.value)) {
  141. uni.showToast({
  142. icon: 'error',
  143. title: '请选择完整信息',
  144. duration: 2000
  145. });
  146. }
  147. else {
  148. saveDayWorkItem(curDayworkItem.value).then(res => {
  149. if (res.code === 200) {
  150. uni.showToast({
  151. icon: 'success',
  152. title: '操作成功',
  153. duration: 2000
  154. });
  155. close();
  156. } else {
  157. uni.showToast({
  158. icon: 'error',
  159. title: '操作失败',
  160. duration: 2000
  161. });
  162. close();
  163. }
  164. })
  165. }
  166. emit('confirm');
  167. }
  168. function handleChange() {
  169. console.log(curDayworkItem.value)
  170. }
  171. </script>
  172. <style lang="scss">
  173. .dialog-body {
  174. .list-container {
  175. width: 100%;
  176. .list-title {
  177. margin-top: 24rpx;
  178. .label {
  179. font-size: 32rpx;
  180. }
  181. }
  182. .btn {
  183. margin-top: 24rpx;
  184. .middle-btn {
  185. margin-right: 32rpx;
  186. align-items: center;
  187. justify-content: center;
  188. padding-left: 0;
  189. height: 80rpx;
  190. width: 220rpx;
  191. border-radius: 8rpx;
  192. background-color: #FFFFFF;
  193. border: 1px solid #999999;
  194. background-color: #FFFFFF;
  195. }
  196. .label {
  197. font-size: 24rpx;
  198. color: #000000;
  199. }
  200. .active {
  201. border-color: #1684fc;
  202. background-color: rgb(236, 245, 255);
  203. .label {
  204. color: #1684fc;
  205. }
  206. }
  207. }
  208. }
  209. .add-btn-container {
  210. margin-top: 32rpx;
  211. .btn {
  212. flex: 1;
  213. background-color: rgb(255, 121, 1);
  214. color: #FFFFFF;
  215. }
  216. }
  217. }
  218. </style>