dialog-selectEquipment.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <dialog-base ref="baseDialog" title="请选择" style="margin: -250rpx auto 0 auto;">
  3. <view>
  4. <uni-section title="设备" type="line">
  5. <!-- <uni-data-select v-model="selectedEquipment" :localdata="equipmentList" :clear="false"
  6. @change="handleEquipmentChange"></uni-data-select> -->
  7. <zxz-uni-data-select v-model="selectedEquipment" filterable :localdata="equipmentList"
  8. placeholder="请选择/输入设备"></zxz-uni-data-select>
  9. </uni-section>
  10. </view>
  11. <view class="add-btn-container uni-row">
  12. <button type="primary" class="btn" @click="handleStart">开始</button>
  13. </view>
  14. </dialog-base>
  15. </template>
  16. <script setup>
  17. import {
  18. ref
  19. } from 'vue'
  20. import {
  21. onLoad
  22. } from '@dcloudio/uni-app'
  23. import {
  24. getProcessList
  25. } from '@/api/business/deptProcess.js'
  26. import {
  27. getUserequipmentList
  28. } from '@/api/business/userEquipment/userEquipment.js'
  29. import {
  30. getUserInfo
  31. } from '@/api/login/index.js'
  32. import {
  33. saveDayWorkItem,
  34. getDayWorkItemList
  35. } from '@/api/business/dayWorkItem.js'
  36. import {
  37. store
  38. } from '@/store/index.js'
  39. import {
  40. getEquipmentByUidAndDid
  41. } from '@/api/resourceGroup/resourceGroupDetail.js'
  42. import {
  43. timestampToTime,
  44. debounce
  45. } from '@/utils/common.js'
  46. import {
  47. getUserByLikeUsername
  48. } from '@/api/sys/user.js'
  49. const baseDialog = ref(null)
  50. const equipments = ref([]) // 接收设备列表信息
  51. const equipmentList = ref([])
  52. const emit = defineEmits(['handleAddDayWorkItem'])
  53. const userId = ref(null)
  54. const firstItem = ref(null);
  55. const sendReqParam = ref({})
  56. const processList = ref([])
  57. const selectedProcess = ref(null)
  58. const selectedEquipment = ref(null)
  59. const flag = ref(false)
  60. const userName = ref(null)
  61. const userList = ref([])
  62. const selectedUserList = ref([])
  63. const showProcessList = ref(true)
  64. onLoad(() => {
  65. userId.value = store.userInfo.userId || "";
  66. })
  67. function resetPage() {
  68. flag.value = false;
  69. userName.value = null;
  70. userList.value = [];
  71. equipmentList.value = [];
  72. selectedEquipment.value = null;
  73. selectedUserList.value = [];
  74. selectedProcess.value = null;
  75. processList.value = [];
  76. showProcessList.value = true;
  77. }
  78. function init() {
  79. getProcessList({
  80. // tenantId: store.tenantId,
  81. deptId: store.curDeptDetails.deptId,
  82. dayworkId: store.dayworkInfo.id
  83. }).then(res => {
  84. console.log(res)
  85. if (res.code == 200) {
  86. //过滤出工序交集store.dayworkInfo.processSequence
  87. let filteredData = store.dayworkInfo.processSequence.filter((item1) => {
  88. return res.data.some(item2 => item2.processCode === item1.processCode) &&
  89. store.dayworkInfo.currentProcess.processStepNumber === item1.processStepNumber;
  90. });
  91. console.log(filteredData)
  92. /* 20240409 修改
  93. for (let i = 0; i < filteredData.length; i++) {
  94. // console.log(processList.value)
  95. processList.value[i] = {
  96. text: filteredData[i].processAlias,
  97. value: filteredData[i].technologicalProcessDetailId,
  98. processId: filterData[i].id
  99. // value: filteredData[i].id
  100. }
  101. // console.log(processList.value)
  102. }
  103. */
  104. console.log(store.dayworkInfo)
  105. processList.value = filteredData.map(v => ({
  106. text: v.processAlias,
  107. value: v.technologicalProcessDetailId,
  108. processId: v.id,
  109. processStepNumber: store.dayworkInfo.currentProcess.processStepNumber
  110. }))
  111. console.log(processList.value)
  112. selectedProcess.value = filteredData[0].technologicalProcessDetailId;
  113. // selectedProcess.value = filteredData[0].processId
  114. // console.log(selectedProcess.value)
  115. isDefaultItem(firstItem.value);
  116. }
  117. })
  118. // Promise.all([getEquipmentByUidAndDid(store.planDetails.id), getDayWorkItemList({
  119. // // userId: store.userInfo.userId,
  120. // // dayworkId: store.dayworkInfo.id,
  121. // status: 1
  122. // })])
  123. // .then(([equipmentRes, response]) => {
  124. // console.log(equipmentRes)
  125. // console.log(response.rows)
  126. // if (equipmentRes.code == 200 && response.code == 200) {
  127. // let equipmentListData = equipmentRes.rows.filter((equipment) => {
  128. // return !response.rows.some((item) => item.equipmentDetailId == equipment.commonId);
  129. // });
  130. // equipmentList.value = equipmentListData.map((equipment) => {
  131. // return {
  132. // text: equipment.commonCode,
  133. // value: equipment
  134. // }
  135. // });
  136. // selectedEquipment.value = equipmentListData.length > 0 ? equipmentListData[0] : null;
  137. // }
  138. // baseDialog.value.open()
  139. // });
  140. getEquipmentByUidAndDid(store.planDetails.id, store.curDeptDetails.deptId, store.dayworkInfo.lotId).then(
  141. equipmentRes => {
  142. if (equipmentRes.code == 200) {
  143. for (var i = 0; i < equipmentRes.rows.length; i++) {
  144. equipmentList.value[i] = {
  145. text: equipmentRes.rows[i].commonCode,
  146. value: equipmentRes.rows[i]
  147. }
  148. }
  149. // selectedEquipment.value = equipmentRes.rows.length > 0 ? equipmentRes.rows[0] : null;
  150. }
  151. baseDialog.value.open()
  152. })
  153. }
  154. function open(data) {
  155. resetPage()
  156. firstItem.value = data;
  157. console.log(store.dayworkInfo)
  158. userName.value = null;
  159. userList.value = [];
  160. init();
  161. }
  162. function isDefaultItem(item) {
  163. if (item) {
  164. showProcessList.value = false;
  165. selectedProcess.value = null;
  166. }
  167. }
  168. function close() {
  169. baseDialog.value.close()
  170. }
  171. defineExpose({
  172. open
  173. })
  174. function handleProcessChange() {
  175. }
  176. function handleEquipmentChange() {
  177. }
  178. function handleSearchUserName() {
  179. if (userName.value) {
  180. getUserByLikeUsername(userName.value).then(res => {
  181. if (res.code == 200) {
  182. userList.value = res.data;
  183. }
  184. })
  185. }
  186. }
  187. function handleClickUserName(item) {
  188. selectedUserList.value.push(item);
  189. userList.value = [];
  190. }
  191. function handleBlur() {
  192. setTimeout(function() {
  193. userList.value = [];
  194. }, 200)
  195. }
  196. function handleRemoveUserName(item) {
  197. selectedUserList.value.splice(selectedUserList.value.indexOf(item), 1);
  198. }
  199. function switchChange(e) {
  200. flag.value = e.detail.value;
  201. }
  202. function handleStart() {
  203. uni.showModal({
  204. title: "提示",
  205. content: "确认开始新的报工吗",
  206. success: function(res) {
  207. if (res.confirm) {
  208. handleDoStart();
  209. } else if (res.cancel) {
  210. close();
  211. }
  212. }
  213. })
  214. }
  215. function handleDoStart() {
  216. if (!selectedEquipment.value) {
  217. uni.showToast({
  218. icon: "none",
  219. title: "未选择设备"
  220. })
  221. selectedProcess.value = null;
  222. selectedEquipment.value = null;
  223. return;
  224. }
  225. close();
  226. if (firstItem.value) {
  227. sendReqParam.value = {
  228. ...firstItem.value,
  229. /* 20240408 前版本
  230. processId: selectedProcess.value,
  231. */
  232. technologicalProcessDetailId: store.dayworkInfo.processSequence.filter(v => v.processStepNumber ==
  233. store.dayworkInfo.currentProcess.processStepNumber)[0].technologicalProcessDetailId,
  234. processId: store.dayworkInfo.currentProcess.id,
  235. equipmentDetailId: selectedEquipment.value.commonId,
  236. processStepNumber: store.dayworkInfo.currentProcess.processStepNumber,
  237. equipmentDetailCode: selectedEquipment.value.commonCode,
  238. startTime: timestampToTime(new Date()),
  239. status: 1,
  240. collaborationList: selectedUserList.value
  241. };
  242. console.log(sendReqParam.value)
  243. emit('handleAddDayWorkItem', sendReqParam.value);
  244. } else {
  245. emit('handleAddDayWorkItem', {
  246. /* 20240408 前版本
  247. processId: selectedProcess.value,
  248. */
  249. technologicalProcessDetailId: store.dayworkInfo.processSequence.filter(v => v.processStepNumber ==
  250. store.dayworkInfo.currentProcess.processStepNumber)[0].technologicalProcessDetailId,
  251. processId: store.dayworkInfo.currentProcess.id,
  252. // processId: store.dayworkInfo.processSequence.findIndex(v => v.technologicalProcessDetailId === selectedProcess.value) >= 0 ? store.dayworkInfo.processSequence.find(v => v.technologicalProcessDetailId === selectedProcess.value).id : null,
  253. equipmentDetailId: selectedEquipment.value.commonId,
  254. processStepNumber: store.dayworkInfo.currentProcess.processStepNumber,
  255. equipmentDetailCode: selectedEquipment.value.commonCode,
  256. collaborationList: selectedUserList.value
  257. });
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. .dialog-container {
  263. .dialog-body {
  264. margin-top: 180rpx !important;
  265. margin-left: auto !important;
  266. margin-right: auto !important;
  267. .equipment-container {
  268. height: 300rpx;
  269. overflow: auto;
  270. flex-wrap: wrap;
  271. justify-content: flex-start;
  272. margin: 24rpx 0 0 7%;
  273. .item {
  274. width: 236rpx;
  275. height: 60rpx;
  276. text-align: center;
  277. line-height: 60rpx;
  278. border-radius: 6rpx;
  279. margin: 16rpx;
  280. flex: 0 0 40%;
  281. border: 1px solid #000000;
  282. }
  283. .selected {
  284. background-color: #1684fc;
  285. color: #FFF;
  286. }
  287. }
  288. .add-btn-container {
  289. margin-top: 32rpx;
  290. .btn {
  291. flex: 1;
  292. }
  293. }
  294. .switch {
  295. font-size: 26rpx;
  296. align-items: center;
  297. justify-content: space-between;
  298. margin: 16rpx;
  299. }
  300. .userList {
  301. border: 1rpx solid #1684fc;
  302. border-radius: 8rpx;
  303. max-height: 300rpx;
  304. overflow: auto;
  305. width: 100%;
  306. .showUser {
  307. justify-content: flex-start;
  308. flex-wrap: wrap;
  309. .user {
  310. border: 1rpx solid #999;
  311. border-radius: 8rpx;
  312. width: 150rpx;
  313. height: 50rpx;
  314. text-align: center;
  315. line-height: 50rpx;
  316. margin: 10rpx;
  317. overflow: auto;
  318. }
  319. }
  320. }
  321. .selectedUserList {
  322. width: 100%;
  323. justify-content: flex-start;
  324. flex-wrap: wrap;
  325. .selectedUser {
  326. border: 1rpx solid #999;
  327. border-radius: 8rpx;
  328. width: 150rpx;
  329. height: 50rpx;
  330. text-align: center;
  331. line-height: 50rpx;
  332. margin: 20rpx 20rpx 0 0;
  333. justify-content: space-around;
  334. }
  335. }
  336. }
  337. }
  338. </style>