dialog-lotReporting.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view class="mask" v-if="isLoading"></view>
  3. <dialog-baseLong class="dialog-body" ref="baseDialog" title="添加批次报工">
  4. <view>
  5. <!-- <view v-for="(item, index) in lotData" :key="index" class="list-item"> -->
  6. <view class="item-info uni-row">
  7. <text class="label">批次号</text>
  8. <text class="label right"
  9. style="word-wrap: break-word;">{{ lotData.map(v => v.lotCode).join(",") }}</text>
  10. </view>
  11. <!-- <view class="item-info uni-row">
  12. <text class="label">生产计划单号</text>
  13. <text class="label right">{{ item['productionPlanNo'] }}</text>
  14. </view> -->
  15. <view class="item-info uni-row">
  16. <text class="label">产品描述</text>
  17. <text class="label right" style="word-wrap: break-word;">{{ item['productDescription'] }}</text>
  18. </view>
  19. <view class="item-info uni-row">
  20. <text class="label">箱号</text>
  21. <text class="label right">{{ item['carrierName'] }}</text>
  22. </view>
  23. <view class="item-info uni-row">
  24. <text class="label">上序</text>
  25. <view class="label right uni-row">{{ item['lastProcess'] ? item['lastProcess'].processAlias : '-' }}
  26. </view>
  27. </view>
  28. <view class="item-info uni-row">
  29. <text class="label">当前序</text>
  30. <view class="label right uni-row" style="display: flex; flex-direction: row; flex-wrap: wrap;">
  31. <view>{{ item['process'] ? item['process'].processAlias : '-' }}
  32. </view>
  33. <view style="color: #1684fc;" @click.stop="handleClickProcessList(item)">(&nbsp;工艺列表&nbsp;)
  34. </view>
  35. </view>
  36. </view>
  37. <view class="item-info uni-row">
  38. <text class="label">下序</text>
  39. <view class="label right uni-row">{{ item['nextProcess'] ? item['nextProcess'].processAlias : '-' }}
  40. </view>
  41. </view>
  42. <!-- <view class='middle'>
  43. <view class='segment'></view>
  44. <uni-icons type="paperclip" size="30" style="margin: 10rpx;"></uni-icons>
  45. <view class='segment'></view>
  46. </view> -->
  47. <!-- </view> -->
  48. <!-- </view>
  49. <view class="list-item"> -->
  50. <view class="item-info uni-row">
  51. <view class="label">设备</view>
  52. <view class="label right">
  53. <uni-data-select v-model="equipmentDetail" :localdata="equipmentDetailList" :clear="false"
  54. style="outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  55. </view>
  56. </view>
  57. <view class="item-info uni-row">
  58. <text class="label">下序车间</text>
  59. <uni-data-select v-model="curDaywork.workshopId" :localdata="workshopList"
  60. @change="handleChangeWorkshop" :clear="false"
  61. style="outline: 2rpx solid #999999;border-radius: 10rpx;"></uni-data-select>
  62. </view>
  63. <view class="item-info uni-row">
  64. <text class="label">下序工段</text>
  65. <uni-data-select v-model="curDaywork.deptId" :localdata="deptList" :clear="false"
  66. style="outline: 2rpx solid #999999;border-radius: 10rpx;"
  67. @change="handleDeptChange"></uni-data-select>
  68. </view>
  69. <view v-if="!isWx" class="item-info uni-row" style="margin-top: 12rpx;">
  70. <text class="label" style="width: 250rpx;">是否包装签票</text><text style="margin-left: 24rpx;"
  71. class="label right">否</text>
  72. <switch class="switch" @change="switchChange" :checked="normalStatus"
  73. style="transform: scale(0.8);align-items: center;font-size:32rpx ;"
  74. color="rgba(103, 195, 55, 1.0)" />
  75. <text class=" label right">是</text>
  76. </view>
  77. <view class="add-btn-container uni-row">
  78. <button type="default" class="leftBtn" @click="handleFinishScan">结束扫码</button>
  79. <button type="default" class="rightBtn" @click="handleContinueScan">继续扫码</button>
  80. </view>
  81. </view>
  82. <!-- 抽屉 -->
  83. <view>
  84. </view>
  85. <view style="z-index: 99999;">
  86. <!-- <uni-drawer ref="showRight" mode="right" :mask-click="true">
  87. <view class="scroll-view">
  88. <scroll-view class="scroll-view-box" style="height:100%;">
  89. <view style="width: 100%;text-align: center;;font-size: 48rpx;margin: 48rpx 0 24rpx 0;">工艺列表
  90. </view>
  91. <view style="font-size: 24rpx;width: 100%;text-align: center;color: red;margin-bottom: 48rpx;">
  92. 仅显示当前工序后面工艺</view>
  93. <view class="info-content" v-for="(item,index) in curProcessAfte" :key="index"
  94. style="width: 100%;margin: 8rpx 0 8rpx 14%;">
  95. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  96. </view>
  97. </scroll-view>
  98. </view>
  99. </uni-drawer> -->
  100. <uni-drawer ref="showRight" mode="right" :mask-click="true">
  101. <view style="text-align: center; font-size: 48rpx; padding: 48rpx 0 24rpx 0;margin-top: 20px;">工艺列表
  102. </view>
  103. <view style="font-size: 24rpx;text-align: center;color: red; margin-bottom: 16rpx;">
  104. 仅显示当前工序后面工艺
  105. </view>
  106. <view><button v-if="!editStatus" class="start-batch-btn" style="margin-bottom: 16rpx;" type="primary"
  107. @click="handleOpenDrawing">查看本工序图纸</button></view>
  108. <scroll-view scroll-y="true" style="height: 70%;" @touchmove.stop>
  109. <view v-for="(item,index) in curProcessAfte" :key="index"
  110. style="padding: 8rpx 5% 8rpx 14%; border-top: 1px solid #cccccc">
  111. <text>{{ index + 1 }}.{{item.processAlias}}</text>
  112. </view>
  113. </scroll-view>
  114. </uni-drawer>
  115. </view>
  116. </dialog-baseLong>
  117. </template>
  118. <script setup>
  119. import {
  120. ref,
  121. getCurrentInstance,
  122. toRef
  123. } from 'vue'
  124. import {
  125. getDictInfoByType
  126. } from '@/api/dict/dict.js'
  127. import {
  128. getQuickDayworkList,
  129. finishQuick,
  130. getDayworkByCarrierId,
  131. reportDaywork
  132. } from '@/api/business/quickDaywork'
  133. import {
  134. store
  135. } from '@/store/index.js'
  136. const props = defineProps({
  137. getList: {
  138. type: Function,
  139. default: () => {}
  140. }
  141. })
  142. const emit = defineEmits();
  143. const baseDialog = ref(null)
  144. const lotData = ref(null)
  145. const curDaywork = ref({})
  146. const productId = ref("")
  147. const isWx = ref(false)
  148. const normalStatus = ref(false)
  149. const processCode = ref("")
  150. const technologicalProcessId = ref("")
  151. const equipmentDetail = ref(null)
  152. const equipmentDetailList = ref([])
  153. const currentLotCode = ref("")
  154. const workshopList = ref([])
  155. const processAlias = ref("")
  156. const curProcessAfte = ref([])
  157. const deptList = ref([])
  158. const item = ref({})
  159. const isLoading = ref(false);
  160. const lastRequestTimestamp = ref(0);
  161. const editStatus = ref(false)
  162. const showRight = ref(null) // 抽屉
  163. function open(data) {
  164. // if (data === 'test') {
  165. // baseDialog.value.open()
  166. // lotData.value = [{
  167. // lotCode: '测试',
  168. // process: { processAlias: '测试长数据结果' }
  169. // }, {
  170. // lotCode: '测试',
  171. // process: { processAlias: '测试长数据结果' }
  172. // }, {
  173. // lotCode: '测试',
  174. // process: { processAlias: '测试长数据结果' }
  175. // }]
  176. // item.value = {
  177. // lotCode: '测试',
  178. // process: { processAlias: '测试长数据结果' }
  179. // }
  180. // } else {
  181. lotData.value = data.items
  182. item.value = data.items[0]
  183. // lotData.value.map(v => v.lotCode).join(",")
  184. baseDialog.value.open()
  185. workshopList.value = data.workShops.map(v => ({
  186. value: v.id,
  187. text: v.name,
  188. deptList: v.depts
  189. }))
  190. equipmentDetailList.value = data.equipmentDetailList.length > 0 ? data.equipmentDetailList.map(item => ({
  191. text: item.commonCode,
  192. value: item.commonId
  193. })) : [];
  194. console.log(workshopList.value)
  195. curDaywork.value = {}
  196. equipmentDetail.value = null
  197. deptList.value = []
  198. init()
  199. // }
  200. }
  201. function init() {
  202. //查询车间
  203. }
  204. function handleClickProcessList(item) {
  205. console.log(item, 7979)
  206. if (item.isWasteRecycling == 1 || item.isAmend == 1) {
  207. editStatus.value = true
  208. } else {
  209. editStatus.value = false
  210. }
  211. var filteredProcess = item.processSequence.filter(i => i.processStepNumber == item.process.processStepNumber);
  212. processCode.value = filteredProcess[0].processCode
  213. processAlias.value = filteredProcess[0].processAlias
  214. productId.value = item.daywork.productId
  215. technologicalProcessId.value = item.technologicalProcessId
  216. currentLotCode.value = item.lotCode
  217. curProcessAfte.value = lotData.value[0].nextProcesses;
  218. showRight.value.open();
  219. }
  220. //切换车间
  221. function handleChangeWorkshop(arg) {
  222. // console.log(arg)
  223. deptList.value = workshopList.value.find(v => v.value === arg).deptList.map(v => ({
  224. value: v.deptId,
  225. text: v.deptName,
  226. isSortPackaging: v.isSortPackaging,
  227. code: v.deptCode
  228. }))
  229. normalStatus.value = false
  230. isWx.value = false
  231. }
  232. //结束扫码
  233. function handleFinishScan() {
  234. // 保存新报工信息
  235. // 然后关闭dialog
  236. // console.log(props)
  237. addDayworkItem(() => {
  238. props.getList()
  239. baseDialog.value.close()
  240. })
  241. }
  242. //打开电子图纸
  243. function handleOpenDrawing() {
  244. // 对 technologicalProcessDetailId 进行URL编码
  245. var encodedId = encodeURIComponent(productId.value);
  246. var enTechnologicalProcessId = encodeURIComponent(technologicalProcessId.value);
  247. var enprocessCode = encodeURIComponent(processCode.value);
  248. var encodeCode = encodeURIComponent(currentLotCode.value);
  249. var enProcessAlias = encodeURIComponent(processAlias.value);
  250. // 构建查询参数字符串
  251. var queryParam =
  252. `param1=${encodedId}&param2=${encodeCode}&param3=${enprocessCode}&param4=${enTechnologicalProcessId}&param5=${enProcessAlias}`;
  253. // 使用模板字符串构建完整的URL
  254. var navigateUrl = `/pages/drawingMenu/index?${queryParam}`;
  255. // 导航到指定页面
  256. uni.navigateTo({
  257. url: navigateUrl
  258. });
  259. }
  260. function handleDeptChange() {
  261. console.log(deptList.value)
  262. let deptInfo = deptList.value.find(item => item.value == curDaywork.value.deptId)
  263. console.log(deptInfo)
  264. if (deptInfo.code == '170000') {
  265. isWx.value = true
  266. } else {
  267. isWx.value = false
  268. }
  269. if (deptInfo.isSortPackaging == 1) {
  270. normalStatus.value = true
  271. } else {
  272. normalStatus.value = false
  273. }
  274. }
  275. function switchChange(event) {
  276. console.log(event.detail.value)
  277. //是
  278. if (event.detail.value) {
  279. normalStatus.value = true
  280. } else {
  281. //否
  282. normalStatus.value = false
  283. }
  284. }
  285. function addDayworkItem(callback) {
  286. // 判断选择下工段和下车间
  287. if (curDaywork.value.workshopId == null || curDaywork.value.deptId == null || deptList.value.find(v => v.value ===
  288. curDaywork.value.deptId) == null) {
  289. uni.showToast({
  290. icon: 'none',
  291. title: '请选择周转车间和下序工段'
  292. })
  293. return
  294. }
  295. if (equipmentDetail.value == null) {
  296. console.log("999")
  297. uni.showToast({
  298. icon: 'none',
  299. title: '请选择设备'
  300. })
  301. return
  302. }
  303. const params = lotData.value.map(v => ({
  304. ...v,
  305. daywork: {
  306. ...v.daywork,
  307. processId: v.process.id,
  308. processStepNumber: v.process.processStepNumber,
  309. technologicalProcessDetailId: v.process.technologicalProcessDetailId
  310. },
  311. quickInfo: {
  312. deptId: curDaywork.value.deptId,
  313. workshopId: curDaywork.value.workshopId,
  314. deptName: deptList.value.find(v => v.value === curDaywork.value.deptId).text,
  315. isSortPackaging: normalStatus.value ? "1" : "0"
  316. },
  317. tenantId: !store.tenantId ? store.userInfo.tenantId : store.tenantId,
  318. equipmentDetailId: equipmentDetail.value,
  319. equipmentDetailCode: equipmentDetailList.value.filter(item => item.value == equipmentDetail.value)[
  320. 0]
  321. .text
  322. }))
  323. console.log(params)
  324. isLoading.value = true; // 显示遮罩层
  325. uni.showLoading({
  326. title: '加载中'
  327. });
  328. reportDaywork(params).then(res => {
  329. isLoading.value = false;
  330. uni.hideLoading();
  331. callback()
  332. })
  333. // callback()
  334. }
  335. //继续扫码
  336. function handleContinueScan() {
  337. // 保存报工信息
  338. // 调用前一个页面的扫码方法
  339. // 关闭dialog
  340. // console.log(props)
  341. addDayworkItem(() => {
  342. props.getList()
  343. baseDialog.value.close()
  344. emit("scan")
  345. })
  346. }
  347. function close() {
  348. baseDialog.value.close()
  349. }
  350. defineExpose({
  351. open
  352. })
  353. </script>
  354. <style lang="scss">
  355. .dialog-body {
  356. // height: 60%;
  357. // margin: auto auto;
  358. overflow: auto;
  359. }
  360. .item-info {
  361. margin: 8rpx;
  362. .label {
  363. font-size: 28rpx;
  364. width: 220rpx;
  365. color: #808080;
  366. &.right {
  367. flex: 1;
  368. color: #000000;
  369. }
  370. }
  371. }
  372. .middle {
  373. display: flex;
  374. flex-direction: row;
  375. align-items: center;
  376. justify-content: center
  377. }
  378. .segment {
  379. width: 280rpx;
  380. background-color: rgba(213, 213, 213, 1);
  381. border: 1rpx solid rgba(213, 213, 213, 1);
  382. }
  383. .middle {
  384. display: flex;
  385. flex-direction: row;
  386. align-items: center;
  387. justify-content: center
  388. }
  389. .segment {
  390. width: 80rpx;
  391. background-color: rgba(213, 213, 213, 1);
  392. border: 1rpx solid rgba(213, 213, 213, 1);
  393. }
  394. .add-btn-container {
  395. // margin-top: 32rpx;
  396. .leftBtn {
  397. flex: 1;
  398. background-color: rgb(164, 173, 179);
  399. color: #FFFFFF;
  400. }
  401. .rightBtn {
  402. flex: 1;
  403. margin-left: 24rpx;
  404. background-color: rgb(91, 214, 165);
  405. color: #FFFFFF;
  406. }
  407. }
  408. .drawer {
  409. display: block;
  410. position: absolute;
  411. top: 43px;
  412. width: 220px;
  413. bottom: 0;
  414. background-color: #FFFFFF;
  415. transition: transform 0.3s ease;
  416. }
  417. .mask {
  418. position: fixed;
  419. top: 0;
  420. left: 0;
  421. right: 0;
  422. bottom: 0;
  423. background-color: rgba(0, 0, 0, 0.5);
  424. z-index: 2000;
  425. display: flex;
  426. justify-content: center;
  427. align-items: center;
  428. }
  429. .mask .loading-text {
  430. color: #fff;
  431. font-size: 36rpx;
  432. }
  433. </style>