index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. searchEnter: true,
  174. selection: false,
  175. addBtn: false,
  176. delBtn: false,
  177. editBtn: false,
  178. viewBtn: false,
  179. column: [
  180. {
  181. label: "生产批号",
  182. prop: "workOrderCode",
  183. editDisabled: true,
  184. width: 160,
  185. overHidden: true,
  186. search: true,
  187. },
  188. {
  189. label: "产品名称",
  190. prop: "materialName",
  191. editDisabled: true,
  192. search: true,
  193. },
  194. {
  195. label: "数量",
  196. editDisabled: true,
  197. prop: "num",
  198. },
  199. {
  200. label: "管号",
  201. prop: "seqNos",
  202. editDisabled: true,
  203. },
  204. {
  205. label: "管号",
  206. prop: "seqNo",
  207. search: true,
  208. editDisabled: true,
  209. hide: true,
  210. display: false,
  211. },
  212. {
  213. label: "返工原因",
  214. prop: "reason",
  215. width: 160,
  216. search: true,
  217. overHidden: true,
  218. type: "textarea",
  219. },
  220. {
  221. label: "产品规格",
  222. prop: "materialModel",
  223. width: 160,
  224. search: true,
  225. overHidden: true,
  226. },
  227. {
  228. label: "返工内容",
  229. prop: "remark",
  230. width: 160,
  231. overHidden: true,
  232. type: "textarea",
  233. },
  234. {
  235. label: "状态",
  236. prop: "state",
  237. type: "select",
  238. display: false,
  239. dicData: [
  240. {
  241. label: "待处理",
  242. value: 0,
  243. },
  244. {
  245. label: "返工中",
  246. value: 1,
  247. },
  248. {
  249. label: "驳回",
  250. value: 2,
  251. },
  252. {
  253. label: "返工完成",
  254. value: 3,
  255. },
  256. ],
  257. },
  258. {
  259. label: "返工提出者",
  260. prop: "creator",
  261. editDisplay: false,
  262. },
  263. {
  264. label: "日期",
  265. prop: "created",
  266. type: "date",
  267. width: 160,
  268. format: "YYYY-MM-DD",
  269. valueFormat: "YYYY-MM-DD",
  270. editDisplay: false,
  271. overHidden: true,
  272. },
  273. {
  274. label: "日期",
  275. prop: "createdSearch",
  276. width: 160,
  277. type: "daterange",
  278. searchRange: true,
  279. display: false,
  280. hide: true,
  281. startPlaceholder: "开始范围",
  282. endPlaceholder: "结束范围",
  283. format: "YYYY-MM-DD",
  284. valueFormat: "YYYY-MM-DD",
  285. overHidden: true,
  286. search: true,
  287. },
  288. ],
  289. });
  290. </script>