steps.vue 6.8 KB

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