dialog-lotReporting.vue 11 KB

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