steps.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="body">
  3. <div
  4. class="steps"
  5. v-for="(item, index) in opsArray"
  6. :key="index"
  7. @click="boxClick(item, index)"
  8. >
  9. <div
  10. :class="
  11. item.exists == true
  12. ? selectStepIndex == index
  13. ? 'stepBox stepBoxHover'
  14. : 'stepBox'
  15. : 'stepBox stepExistsHover'
  16. "
  17. >
  18. <div style="display: flex; align-items: center">
  19. <div
  20. :class="
  21. selectStepIndex == index
  22. ? 'stepIndex stepIndexHover'
  23. : 'stepIndex'
  24. "
  25. >
  26. <span
  27. :class="
  28. selectStepIndex == index
  29. ? 'indexText hoverTextColor'
  30. : 'indexText'
  31. "
  32. >{{ index + 1 }}</span
  33. >
  34. </div>
  35. <div class="midTextBox">
  36. <div
  37. :class="
  38. selectStepIndex == index ? 'stepName stepNameHover' : 'stepName'
  39. "
  40. >
  41. {{ item.operationName }}
  42. </div>
  43. <div
  44. :class="
  45. selectStepIndex == index
  46. ? 'stepStation stepStationHover'
  47. : 'stepStation'
  48. "
  49. >
  50. {{ item.operationCode }}
  51. </div>
  52. </div>
  53. </div>
  54. <div
  55. :class="selectStepIndex == index ? 'timeBox timeBoxHover' : 'timeBox'"
  56. >
  57. {{ item.completeNum }}
  58. </div>
  59. </div>
  60. <div v-if="item.exists != true" class="existsText">
  61. 注:该工位在计划上未分配此工序任务!
  62. </div>
  63. <div class="line" v-if="index != opsArray.length - 1"></div>
  64. </div>
  65. <el-empty v-if="!opsArray" description="暂无数据" />
  66. <!-- 弹窗 -->
  67. <el-dialog
  68. v-model="centerDialogVisible"
  69. width="500"
  70. align-center
  71. style="border-radius: 16px"
  72. >
  73. <template #header>
  74. <div class="titleText" style="text-align: center">通知</div>
  75. </template>
  76. <span class="titleText">已选择好工序,点击确认立即开工</span>
  77. <template #footer>
  78. <div class="dialog-footer">
  79. <el-button @click="centerDialogVisible = false">取消</el-button>
  80. <el-button type="primary" @click="getScanData"> 确定 </el-button>
  81. </div>
  82. </template>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script lang="ts" setup>
  87. import { useProcessStore } from "@/store";
  88. import { emitter, EventsNames } from "@/utils/common";
  89. import { getScan } from "@/api/process";
  90. const store = useProcessStore();
  91. const selectSeqArray = inject("selectSeqArray");
  92. const ordersDataArray = inject("ordersDataArray");
  93. const props = defineProps<{
  94. opsArray?: object;
  95. }>();
  96. //步骤显示index
  97. const router = useRouter();
  98. const selectStepIndex = ref(null);
  99. const selectedOderStatus = inject("selectedOderStatus");
  100. const selectOrderIndex = inject("selectOrderIndex");
  101. const centerDialogVisible = ref(false);
  102. const emitFnc = () => {
  103. emitter.emit(EventsNames.PROCESS_STEPOBJ, {
  104. index: selectStepIndex.value,
  105. });
  106. };
  107. emitter.on(EventsNames.PROCESS_STEPINDEX, (val: any) => {
  108. selectStepIndex.value = val;
  109. });
  110. emitter.on(EventsNames.PROCESS_REDER, () => {
  111. selectStepIndex.value = null;
  112. });
  113. // const setStepIndex = () => {
  114. // for (let i = 0; i < props.opsArray.length; i++) {
  115. // if (props.opsArray[i].opComplete == false) {
  116. // selectStepIndex.value = i;
  117. // return;
  118. // }
  119. // }
  120. // };
  121. const boxClick = (item, index) => {
  122. if (item.exists != true) return;
  123. selectSeqArray.value =
  124. ordersDataArray.value[selectOrderIndex.value].ops[index].seqs;
  125. store.odersData.operationId = item.operationId;
  126. store.processInfo.operationCode = item.operationCode;
  127. store.processInfo.operationName = item.operationName;
  128. selectStepIndex.value = index;
  129. emitFnc();
  130. // centerDialogVisible.value = true;
  131. };
  132. const getScanData = async () => {
  133. try {
  134. const { code, data, msg } = await getScan({
  135. operationId: Number(store.odersData.operationId),
  136. qrCode: store.odersData.qrCode,
  137. workOrderCode: store.odersData.workOrderCode,
  138. //stationId暂时随便传一个
  139. stationId: 1,
  140. });
  141. if (code == "200") {
  142. store.scanInfo = data;
  143. router.push({ path: "/pro-steps" });
  144. }
  145. } catch {
  146. } finally {
  147. centerDialogVisible.value = false;
  148. }
  149. };
  150. watch(
  151. () => props.opsArray,
  152. () => {
  153. if (props.opsArray.length > 0) {
  154. selectStepIndex.value = null;
  155. // setStepIndex();
  156. if (selectStepIndex.value !== null) {
  157. boxClick(props.opsArray[selectStepIndex.value], selectStepIndex.value);
  158. } else {
  159. emitFnc();
  160. }
  161. } else {
  162. selectStepIndex.value = null;
  163. }
  164. }
  165. );
  166. watch(
  167. () => selectedOderStatus.value,
  168. () => {
  169. selectStepIndex.value = null;
  170. }
  171. );
  172. onBeforeUnmount(() => {
  173. emitter.off(EventsNames.PROCESS_STEPOBJ);
  174. });
  175. </script>
  176. <style lang="scss" scoped>
  177. .body {
  178. width: 100%;
  179. }
  180. .existsText {
  181. margin-left: 40px;
  182. font-size: $f16;
  183. font-weight: 500;
  184. color: #303030;
  185. }
  186. .stepBox {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. height: 88px;
  191. border-radius: 44px;
  192. background-color: white;
  193. box-shadow: 0px 1px 1px 1px #00000025;
  194. }
  195. .stepBoxHover {
  196. box-shadow: 0px 0px 0px 0px;
  197. background-color: $select-hover;
  198. }
  199. .stepExistsHover {
  200. background-color: grey;
  201. cursor: not-allowed;
  202. }
  203. .stepBoxDisabled {
  204. background-color: green;
  205. cursor: not-allowed;
  206. }
  207. .stepIndexHover {
  208. border-color: white !important;
  209. span {
  210. color: white;
  211. }
  212. }
  213. .stepNameHover {
  214. color: white !important;
  215. }
  216. .stepStationHover {
  217. color: white !important;
  218. }
  219. .timeBoxHover {
  220. color: white !important;
  221. }
  222. .hoverTextColor {
  223. color: white !important;
  224. }
  225. .stepIndex {
  226. width: 88px;
  227. height: 88px;
  228. border: 2px solid #303030;
  229. border-radius: 44px;
  230. @include flex;
  231. .indexText {
  232. font-size: $f24;
  233. color: #303030;
  234. }
  235. }
  236. .midTextBox {
  237. margin-left: 10px;
  238. .stepName {
  239. font-size: $f24;
  240. color: $font-default-black;
  241. }
  242. .stepStation {
  243. font-size: $f20;
  244. color: $font-default-60;
  245. line-height: 20px;
  246. }
  247. }
  248. .timeBox {
  249. margin-right: 20px;
  250. @include flex;
  251. font-size: $f24;
  252. }
  253. .line {
  254. border-right: 1px solid #303030;
  255. height: 15px;
  256. width: 1px;
  257. margin-left: 44px;
  258. }
  259. </style>