index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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-left="{ size }">
  20. <el-button
  21. :disabled="toDeleteIds.length < 1"
  22. type="danger"
  23. icon="el-icon-delete"
  24. :size="size"
  25. @click="multipleDelete"
  26. >删除</el-button
  27. ></template
  28. >
  29. <template #menu-right="{}">
  30. <el-dropdown split-button
  31. >导入
  32. <template #dropdown>
  33. <el-dropdown-menu>
  34. <el-dropdown-item
  35. @click="downloadTemplate('/api/v1/base/frock/template')"
  36. >
  37. <i-ep-download />下载模板
  38. </el-dropdown-item>
  39. <el-dropdown-item @click="importExcelData">
  40. <i-ep-top />导入数据
  41. </el-dropdown-item>
  42. </el-dropdown-menu>
  43. </template>
  44. </el-dropdown>
  45. <el-button
  46. class="ml-3"
  47. @click="exportData('/api/v1/base/frock/export')"
  48. >
  49. <template #icon> <i-ep-download /> </template>导出
  50. </el-button>
  51. </template>
  52. </avue-crud>
  53. <el-dialog
  54. v-model="dialog.visible"
  55. :title="dialog.title"
  56. width="900px"
  57. @close="dialog.visible = false"
  58. :destroy-on-close="true"
  59. >
  60. <drawing-page
  61. :materialCode="drawingDetail.materialCode"
  62. :materialName="drawingDetail.materialName"
  63. :dialog="dialog"
  64. />
  65. </el-dialog>
  66. <ExcelUpload ref="uploadRef" @finished="uploadFinished" />
  67. </div>
  68. </template>
  69. <script setup lang="ts">
  70. import { ref, getCurrentInstance } from "vue";
  71. import { useCrud } from "@/hooks/userCrud";
  72. import ButtonPermKeys from "@/common/configs/buttonPermission";
  73. import {
  74. useCommonStoreHook,
  75. useDictionaryStore,
  76. useDictionaryStoreHook,
  77. } from "@/store";
  78. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  79. const { dicts } = useDictionaryStore();
  80. const test = () => {
  81. isShowTable.value = true;
  82. tableType.value = tableType.value == 1 ? 2 : 1;
  83. };
  84. const dialog = reactive({
  85. title: "图纸",
  86. visible: false,
  87. });
  88. const drawingDetail = ref(null);
  89. const drawing = (row) => {
  90. drawingDetail.value = row;
  91. dialog.visible = true;
  92. };
  93. // 传入一个url,后面不带/
  94. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  95. useCrud({
  96. src: "/api/v1/base/frock",
  97. });
  98. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  99. Methords; //增删改查
  100. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  101. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  102. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  103. // const permission = reactive({
  104. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  105. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  106. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  107. // menu: true,
  108. // });
  109. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  110. const router = useRouter?.();
  111. const binding = (row) => {
  112. router.push(`/base/bom/${row.materialCode}`);
  113. };
  114. onMounted?.(() => {
  115. // 设置表格列或者其他自定义的option
  116. dataList();
  117. });
  118. /**
  119. * 上传excel相关
  120. */
  121. const uploadRef = ref(null);
  122. const uploadFinished = () => {
  123. // 上传完成后的刷新操作
  124. page.currentPage = 1;
  125. dataList();
  126. };
  127. const importExcelData = () => {
  128. if (uploadRef.value) {
  129. uploadRef.value.show("/api/v1/base/frock/import");
  130. }
  131. };
  132. option.value = Object.assign(option.value, {
  133. selection: true,
  134. column: [
  135. {
  136. label: "工装编码",
  137. prop: "materialCode",
  138. width: 130,
  139. overHidden: true,
  140. search: true,
  141. display: false,
  142. rules: [
  143. {
  144. required: true,
  145. editDisabled: false,
  146. message: "请填写工装编码",
  147. trigger: "blur",
  148. },
  149. ],
  150. },
  151. {
  152. label: "工装名称",
  153. prop: "materialName",
  154. width: 140,
  155. overHidden: true,
  156. search: true,
  157. rules: [
  158. {
  159. required: true,
  160. message: "请填写工装名称",
  161. trigger: "blur",
  162. },
  163. ],
  164. },
  165. {
  166. label: "工装属性",
  167. prop: "attributeDictValue",
  168. search: true,
  169. filterable: true,
  170. type: "select",
  171. width: 100,
  172. overHidden: true,
  173. dicData: dicts.material_properties,
  174. props: { label: "dictLabel", value: "dictValue" },
  175. rules: [
  176. {
  177. required: true,
  178. message: "请选择工装属性",
  179. trigger: "blur",
  180. },
  181. ],
  182. },
  183. {
  184. label: "工装规格",
  185. prop: "spec",
  186. width: 100,
  187. overHidden: true,
  188. rules: [
  189. {
  190. required: true,
  191. message: "请填写工装规格",
  192. trigger: "blur",
  193. },
  194. ],
  195. },
  196. {
  197. label: "单位",
  198. prop: "unitDictValue",
  199. filterable: true,
  200. type: "select",
  201. dicData: dicts.danwei_type,
  202. props: { label: "dictLabel", value: "dictValue" },
  203. rules: [
  204. {
  205. required: true,
  206. message: "请选择单位",
  207. trigger: "blur",
  208. },
  209. ],
  210. },
  211. {
  212. label: "工装级别",
  213. prop: "levelDictValue",
  214. search: true,
  215. filterable: true,
  216. type: "select",
  217. width: 100,
  218. overHidden: true,
  219. dicData: dicts.material_level,
  220. props: { label: "dictLabel", value: "dictValue" },
  221. rules: [
  222. {
  223. required: true,
  224. message: "请选择工装级别",
  225. trigger: "blur",
  226. },
  227. ],
  228. },
  229. {
  230. label: "维修厂家",
  231. prop: "manufacturer",
  232. width: 100,
  233. overHidden: true,
  234. rules: [
  235. {
  236. required: true,
  237. message: "请填写维修厂家",
  238. trigger: "blur",
  239. },
  240. ],
  241. },
  242. {
  243. label: "质检方案",
  244. prop: "inspectDictValue",
  245. search: true,
  246. filterable: true,
  247. type: "select",
  248. width: 100,
  249. overHidden: true,
  250. dicData: dicts.quality_testing_plan,
  251. props: { label: "dictLabel", value: "dictValue" },
  252. },
  253. {
  254. label: "适用平台",
  255. prop: "applicablePlatformsDictValue",
  256. search: true,
  257. filterable: true,
  258. type: "select",
  259. width: 100,
  260. overHidden: true,
  261. dicData: dicts.applicable_platforms,
  262. props: { label: "dictLabel", value: "dictValue" },
  263. rules: [
  264. {
  265. required: true,
  266. message: "请选择适用平台",
  267. trigger: "blur",
  268. },
  269. ],
  270. },
  271. {
  272. label: "质量等级",
  273. prop: "qualityLevelDictValue",
  274. search: true,
  275. width: 100,
  276. overHidden: true,
  277. filterable: true,
  278. type: "select",
  279. dicData: dicts.quality_grade,
  280. props: { label: "dictLabel", value: "dictValue" },
  281. rules: [
  282. {
  283. required: true,
  284. message: "请选择质量等级",
  285. trigger: "blur",
  286. },
  287. ],
  288. },
  289. {
  290. label: "选用类型",
  291. prop: "selectionDictValue",
  292. search: true,
  293. filterable: true,
  294. width: 100,
  295. overHidden: true,
  296. type: "select",
  297. dicData: dicts.selection_type,
  298. props: { label: "dictLabel", value: "dictValue" },
  299. },
  300. { label: "客户型号", prop: "customerModel", width: 100, overHidden: true },
  301. {
  302. label: "保质期(天)",
  303. prop: "qualityGuaranteePeriod",
  304. width: 100,
  305. overHidden: true,
  306. type: "number",
  307. min: 0,
  308. },
  309. {
  310. label: "封装方法",
  311. prop: "packageDictValue",
  312. search: true,
  313. width: 100,
  314. overHidden: true,
  315. filterable: true,
  316. type: "select",
  317. dicData: dicts.packaging_method,
  318. props: { label: "dictLabel", value: "dictValue" },
  319. },
  320. {
  321. label: "筛选规范",
  322. prop: "selectionSpec",
  323. width: 150,
  324. overHidden: true,
  325. type: "textarea",
  326. span: 18,
  327. },
  328. {
  329. label: "备注",
  330. prop: "remark",
  331. width: 150,
  332. overHidden: true,
  333. type: "textarea",
  334. span: 18,
  335. },
  336. ],
  337. });
  338. </script>