dialog-lotReporting.vue 11 KB

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