dialog-lotReporting.vue 11 KB

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