dialog-lotReporting.vue 12 KB

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