index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="body">
  3. <div class="opera">
  4. <el-switch
  5. v-model="value"
  6. size="large"
  7. style="--el-switch-on-color: red; --el-switch-off-color: #13ce66"
  8. active-text="剔除"
  9. inactive-text="返工"
  10. >
  11. <template #active-action>
  12. <span class="custom-active-action" style="font-weight: 600">T</span>
  13. </template>
  14. <template #inactive-action>
  15. <span class="custom-inactive-action" style="font-weight: 600">F</span>
  16. </template></el-switch
  17. >
  18. </div>
  19. <el-scrollbar class="containerBox" v-if="!value">
  20. <div style="margin-bottom: 10px; display: flex; justify-content: center">
  21. <el-button type="primary" v-if="formStatus" @click="toAdd"
  22. >新增</el-button
  23. >
  24. <el-button type="primary" v-else @click="toList">返回</el-button>
  25. </div>
  26. <template v-if="formStatus">
  27. <el-table class="table" :data="tableData">
  28. <el-table-column label="物料名称" prop="materialName" />
  29. <el-table-column label="数量" prop="num" />
  30. <el-table-column label="返工原因" prop="reason" />
  31. <el-table-column label="返工内容" prop="remark" />
  32. </el-table>
  33. <Pagination
  34. v-model:limit="limit"
  35. v-model:page="page"
  36. :position="'right'"
  37. :total="total"
  38. @pagination="getPagination"
  39. />
  40. </template>
  41. <template v-else>
  42. <el-scrollbar class="form">
  43. <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules">
  44. <el-form-item
  45. :label="`流转卡号数量[${ruleForm.seqList.length}]`"
  46. prop="seqNoList"
  47. >
  48. <el-select
  49. v-model="ruleForm.seqList"
  50. multiple
  51. placeholder="请选择"
  52. value-key="value"
  53. @change="selectProcessWorkSeqChange"
  54. >
  55. <el-option
  56. v-for="item in infoData?.processWorkSeq"
  57. :key="item"
  58. :label="item"
  59. :value="item"
  60. />
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item label="返工工序" prop="itemList">
  64. <el-select
  65. v-model="ruleForm.itemList"
  66. multiple
  67. placeholder="请选择"
  68. value-key="operationId"
  69. >
  70. <el-option
  71. v-for="item in operationList"
  72. :key="item.operationId"
  73. :label="item.operationName"
  74. :value="item"
  75. />
  76. </el-select>
  77. </el-form-item>
  78. <el-form-item label="返工原因" prop="reason">
  79. <el-input v-model="ruleForm.reason" />
  80. </el-form-item>
  81. <el-form-item label="返工内容" prop="remark">
  82. <el-input v-model="ruleForm.remark" />
  83. </el-form-item>
  84. </el-form>
  85. </el-scrollbar>
  86. <div class="btns">
  87. <el-button type="primary" @click="submit">提交</el-button>
  88. </div>
  89. </template>
  90. </el-scrollbar>
  91. <el-scrollbar class="containerBox" v-else> 2 </el-scrollbar>
  92. </div>
  93. </template>
  94. <script setup>
  95. import {
  96. breakReportInfoById,
  97. operationListByIds,
  98. } from "@/api/process/reportBreak";
  99. import { addRework, getList } from "@/api/rework";
  100. import { useProcessStore } from "@/store/modules/processView";
  101. const processStore = useProcessStore();
  102. const ruleForm = ref({
  103. seqList: [],
  104. });
  105. const tableData = ref([]);
  106. const toAdd = () => {
  107. formStatus.value = false;
  108. breakReportInfoById(processStore.scanInfo.id).then((res) => {
  109. infoData.value = res.data;
  110. });
  111. };
  112. const toList = () => {
  113. resetForm();
  114. formStatus.value = true;
  115. };
  116. const resetForm = () => {
  117. ruleForm.value = { seqList: [] };
  118. };
  119. const getPagination = async () => {
  120. const { data } = await getList({
  121. pageNo: page.value,
  122. pageSize: limit.value,
  123. seqNo: processStore.useSeqNo,
  124. });
  125. tableData.value = data;
  126. };
  127. const formStatus = ref(true);
  128. const submit = async () => {
  129. ruleFormRef.value.validate((valid) => {
  130. if (valid) {
  131. addTask();
  132. } else {
  133. ElMessage.error("请检查是否有未填项");
  134. }
  135. });
  136. };
  137. const addTask = async () => {
  138. const { code } = await addRework({
  139. ...ruleForm.value,
  140. materialCode: processStore.scanInfo.materialCode,
  141. materialName: processStore.scanInfo.materialName,
  142. operationId: processStore.scanInfo.operationId,
  143. operationName: processStore.scanInfo.operationName,
  144. processId: processStore.scanInfo.id,
  145. workOrderCode: processStore.odersData.workOrderCode,
  146. });
  147. if (code == "200") {
  148. ElMessage.success("操作成功!");
  149. }
  150. };
  151. const value = ref(false);
  152. const valueStatus = ref(false);
  153. const ruleFormRef = ref(null);
  154. const total = ref(0);
  155. const page = ref(1);
  156. const limit = ref(10);
  157. const operationList = ref([]);
  158. const infoData = ref({});
  159. const rules = reactive({
  160. location: [
  161. {
  162. required: true,
  163. message: "Please select a location",
  164. trigger: "change",
  165. },
  166. ],
  167. });
  168. const selectProcessWorkSeqChange = () => {
  169. operationListByIds(ruleForm.value.seqList).then((res) => {
  170. operationList.value = res.data;
  171. });
  172. };
  173. onMounted(() => {
  174. getPagination();
  175. });
  176. </script>
  177. <style lang="scss" scoped>
  178. .table {
  179. height: calc(100vh - 240px);
  180. border-radius: 16px;
  181. }
  182. .body {
  183. width: 100%;
  184. height: calc(100vh - 60px);
  185. .opera {
  186. height: 40px;
  187. display: flex;
  188. justify-content: center;
  189. align-items: center;
  190. background-color: white;
  191. padding-right: 8%;
  192. }
  193. }
  194. .containerBox {
  195. height: calc(100vh - 100px);
  196. padding: 20px;
  197. }
  198. :deep(.el-switch__label) {
  199. span {
  200. font-size: 20px !important;
  201. line-height: 25px !important;
  202. }
  203. }
  204. .form {
  205. width: 50%;
  206. max-width: 600px;
  207. height: calc(100vh - 240px);
  208. background-color: white;
  209. margin: 0 auto;
  210. padding: 0 20px;
  211. padding-top: 20px;
  212. border-radius: 16px;
  213. }
  214. .btns {
  215. height: 40px;
  216. display: flex;
  217. justify-content: center;
  218. align-items: center;
  219. width: 50%;
  220. max-width: 600px;
  221. margin: 0 auto;
  222. }
  223. </style>