index.vue 6.8 KB

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