dialog-receipt.vue 5.7 KB

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