index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud
  4. ref="crudRef"
  5. v-model:search="search"
  6. v-model="form"
  7. :data="data"
  8. :option="option"
  9. v-model:page="page"
  10. @row-save="createRow"
  11. @row-update="updateRow"
  12. @row-del="deleteRow"
  13. @search-change="searchChange"
  14. @search-reset="resetChange"
  15. @size-change="dataList"
  16. @current-change="dataList"
  17. @selection-change="selectionChange"
  18. >
  19. <template #menu="{ row, index, type }">
  20. <el-button
  21. @click="showTable(row)"
  22. link
  23. type="primary"
  24. size="small"
  25. >查看</el-button
  26. >
  27. <el-button
  28. type="primary"
  29. size="small"
  30. link
  31. @click="showSeq(row.seqList)"
  32. >查看管号</el-button
  33. >
  34. <el-button
  35. link
  36. @click="doEdit(row, index)"
  37. type="primary"
  38. v-if="row.state === 0 || row.state === 1"
  39. size="small"
  40. >编辑</el-button
  41. >
  42. <el-button
  43. @click="operation(row)"
  44. link
  45. size="small"
  46. type="primary"
  47. >返工工序</el-button
  48. >
  49. <el-button
  50. link
  51. @click="handle(row, index, 2)"
  52. type="primary"
  53. v-if="row.state === 0"
  54. size="small"
  55. >驳回</el-button
  56. >
  57. <el-button
  58. link
  59. @click="handle(row, index, 1)"
  60. type="primary"
  61. v-if="row.state === 0"
  62. size="small"
  63. >确认返工</el-button
  64. >
  65. <!-- <el-button
  66. link
  67. v-if="row.state === 1"
  68. @click="handle(row, index, 3)"
  69. type="primary"
  70. size="small"
  71. >返工完成</el-button
  72. >-->
  73. <el-button
  74. link
  75. v-if="row.state === 1"
  76. @click="handle(row, index, 3)"
  77. type="primary"
  78. size="small"
  79. >返工完成</el-button
  80. >
  81. <el-button
  82. @click="document(row)"
  83. link
  84. size="small"
  85. v-if="row.state > 0 && row.state!==2 "
  86. type="primary"
  87. >领料单</el-button
  88. >
  89. </template>
  90. <template #menu-right="{}">
  91. <el-button
  92. class="ml-3"
  93. @click="exportData('/api/v1/rework/record/export')"
  94. >
  95. <template #icon> <i-ep-download /> </template>导出
  96. </el-button>
  97. </template>
  98. </avue-crud>
  99. <el-dialog
  100. v-model="dialog.visible"
  101. :title="dialog.title"
  102. width="900px"
  103. @close="closeOperation"
  104. :destroy-on-close="true"
  105. >
  106. <ReworkItem
  107. :recordId="record.id"
  108. :dialog="dialog"
  109. :status="record.state"
  110. />
  111. </el-dialog>
  112. <el-dialog
  113. v-model="dialog1.visible"
  114. :title="dialog1.title"
  115. width="900px"
  116. @close="dialog1.visible=false"
  117. :destroy-on-close="true"
  118. >
  119. <ReworkDocument
  120. :recordId="record.id"
  121. :dialog="dialog1"
  122. :orderCode="record.orderCode"
  123. :status="record.state"
  124. />
  125. </el-dialog>
  126. <el-dialog
  127. v-model="dialog2.visible"
  128. :title="dialog2.title"
  129. width="950px"
  130. @close="dialog2.visible = false"
  131. >
  132. <el-card
  133. style="cursor: pointer; font-size: 20px"
  134. shadow="always"
  135. :key="item"
  136. v-for="item in showSeqList"
  137. >{{ item }}</el-card
  138. >
  139. </el-dialog>
  140. <ReworkShow v-model="showState" :tableData="tableData" />
  141. </div>
  142. </template>
  143. <script setup>
  144. import { useCrud } from "@/hooks/userCrud";
  145. import dictDataUtil from "@/common/configs/dictDataUtil";
  146. import ButtonPermKeys from "@/common/configs/buttonPermission";
  147. import { useCommonStoreHook, useDictionaryStore } from "@/store";
  148. import ReworkItem from "@/views/quality/rework/components/rework-detail.vue";
  149. import { ref } from "vue";
  150. import { handleReworkRecord, getReworkItem } from "@/api/fault/index";
  151. import ReworkShow from "@/views/quality/rework/components/rework-show.vue";
  152. import ReworkDocument from "@/views/quality/rework/components/rework-document.vue";
  153. // 数据字典相关
  154. const { dicts } = useDictionaryStore();
  155. const showSeqList = ref([]);
  156. // 传入一个url,后面不带/
  157. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  158. useCrud({
  159. src: "/api/v1/rework/record",
  160. });
  161. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  162. Methords; //增删改查
  163. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  164. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  165. const tableData = ref({});
  166. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  167. const dialog = ref({
  168. title: "关联工序",
  169. visible: false,
  170. });
  171. const dialog1 = ref({
  172. title: "领料单",
  173. visible: false,
  174. });
  175. const dialog2 = reactive({
  176. title: "管号列表",
  177. visible: false,
  178. });
  179. const showSeq = (seqs) => {
  180. showSeqList.value = seqs;
  181. dialog2.visible = true;
  182. };
  183. const doEdit = (row, index) => {
  184. crudRef.value && crudRef.value.rowEdit(row, index);
  185. };
  186. onMounted(() => {
  187. dataList();
  188. });
  189. const record = ref({});
  190. const operation = (row) => {
  191. record.value = row;
  192. dialog.value.visible = true;
  193. };
  194. const document = (row) => {
  195. record.value = row;
  196. console.log(record.value);
  197. dialog1.value.visible = true;
  198. };
  199. const showState = ref(false);
  200. const showTable = (row) => {
  201. reworkItem.value.recordId = row.id;
  202. getReworkItem(reworkItem.value).then((data) => {
  203. if (data.code === "200") {
  204. tableData.value = row;
  205. tableData.value.itemList = data.data;
  206. showState.value = true;
  207. } else {
  208. ElMessage({
  209. message: data.msg,
  210. type: "error",
  211. });
  212. }
  213. });
  214. };
  215. const closeOperation = () => {
  216. dialog.value.visible = false;
  217. };
  218. const handleData = ref({});
  219. const reworkItem = ref({});
  220. const handle = (row, index, state) => {
  221. handleData.value.id = row.id;
  222. handleData.value.state = state;
  223. handleData.value.seqNos = row.seqNos;
  224. handleReworkRecord(handleData.value).then((data) => {
  225. if (data.code === "200") {
  226. ElMessage({
  227. message: data.msg,
  228. type: "success",
  229. });
  230. dataList();
  231. } else {
  232. ElMessage({
  233. message: data.msg,
  234. type: "error",
  235. });
  236. }
  237. });
  238. };
  239. // 设置表格列或者其他自定义的option
  240. option.value = Object.assign(option.value, {
  241. searchEnter: true,
  242. selection: false,
  243. addBtn: false,
  244. delBtn: false,
  245. editBtn: false,
  246. viewBtn: false,
  247. column: [
  248. {
  249. label: "生产批号",
  250. prop: "workOrderCode",
  251. editDisabled: true,
  252. overHidden: true,
  253. width: 120,
  254. search: true,
  255. },
  256. {
  257. label: "产品名称",
  258. prop: "materialName",
  259. editDisabled: true,
  260. search: true,
  261. },
  262. {
  263. label: "数量",
  264. editDisabled: true,
  265. prop: "num",
  266. },
  267. {
  268. label: "管号",
  269. prop: "seqNo",
  270. search: true,
  271. editDisabled: true,
  272. hide: true,
  273. display: false,
  274. },
  275. {
  276. label: "返工原因",
  277. prop: "reason",
  278. width: 160,
  279. search: true,
  280. overHidden: true,
  281. type: "textarea",
  282. },
  283. {
  284. label: "产品规格",
  285. prop: "materialModel",
  286. width: 160,
  287. search: true,
  288. overHidden: true,
  289. },
  290. {
  291. label: "返工内容",
  292. prop: "remark",
  293. width: 160,
  294. overHidden: true,
  295. type: "textarea",
  296. },
  297. {
  298. label: "状态",
  299. prop: "state",
  300. type: "select",
  301. display: false,
  302. dicData: [
  303. {
  304. label: "待处理",
  305. value: 0,
  306. },
  307. {
  308. label: "返工中",
  309. value: 1,
  310. },
  311. {
  312. label: "驳回",
  313. value: 2,
  314. },
  315. {
  316. label: "返工完成",
  317. value: 3,
  318. },
  319. ],
  320. },
  321. {
  322. label: "创建人",
  323. prop: "creator",
  324. editDisplay: false,
  325. },
  326. {
  327. label: "创建日期",
  328. prop: "created",
  329. type: "date",
  330. width: 160,
  331. editDisplay: false,
  332. overHidden: true,
  333. },
  334. {
  335. label: "日期",
  336. prop: "createdSearch",
  337. width: 160,
  338. type: "daterange",
  339. searchRange: true,
  340. display: false,
  341. hide: true,
  342. startPlaceholder: "开始范围",
  343. endPlaceholder: "结束范围",
  344. format: "YYYY-MM-DD",
  345. valueFormat: "YYYY-MM-DD",
  346. overHidden: true,
  347. search: true,
  348. },
  349. ],
  350. });
  351. </script>