index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. rules: [
  142. {
  143. required: true,
  144. editDisabled: false,
  145. message: "请填写工装编码",
  146. trigger: "blur",
  147. },
  148. ],
  149. },
  150. {
  151. label: "工装名称",
  152. prop: "materialName",
  153. width: 140,
  154. overHidden: true,
  155. search: true,
  156. rules: [
  157. {
  158. required: true,
  159. message: "请填写工装名称",
  160. trigger: "blur",
  161. },
  162. ],
  163. },
  164. {
  165. label: "工装属性",
  166. prop: "attributeDictValue",
  167. search: true,
  168. filterable: true,
  169. type: "select",
  170. width: 100,
  171. overHidden: true,
  172. dicData: dicts.material_properties,
  173. props: { label: "dictLabel", value: "dictValue" },
  174. rules: [
  175. {
  176. required: true,
  177. message: "请选择工装属性",
  178. trigger: "blur",
  179. },
  180. ],
  181. },
  182. {
  183. label: "工装规格",
  184. prop: "spec",
  185. width: 100,
  186. overHidden: true,
  187. rules: [
  188. {
  189. required: true,
  190. message: "请填写工装规格",
  191. trigger: "blur",
  192. },
  193. ],
  194. },
  195. {
  196. label: "单位",
  197. prop: "unitDictValue",
  198. filterable: true,
  199. type: "select",
  200. dicData: dicts.danwei_type,
  201. props: { label: "dictLabel", value: "dictValue" },
  202. rules: [
  203. {
  204. required: true,
  205. message: "请选择单位",
  206. trigger: "blur",
  207. },
  208. ],
  209. },
  210. {
  211. label: "工装级别",
  212. prop: "levelDictValue",
  213. search: true,
  214. filterable: true,
  215. type: "select",
  216. width: 100,
  217. overHidden: true,
  218. dicData: dicts.material_level,
  219. props: { label: "dictLabel", value: "dictValue" },
  220. rules: [
  221. {
  222. required: true,
  223. message: "请选择工装级别",
  224. trigger: "blur",
  225. },
  226. ],
  227. },
  228. {
  229. label: "维修厂家",
  230. prop: "manufacturer",
  231. width: 100,
  232. overHidden: true,
  233. rules: [
  234. {
  235. required: true,
  236. message: "请填写维修厂家",
  237. trigger: "blur",
  238. },
  239. ],
  240. },
  241. {
  242. label: "质检方案",
  243. prop: "inspectDictValue",
  244. search: true,
  245. filterable: true,
  246. type: "select",
  247. width: 100,
  248. overHidden: true,
  249. dicData: dicts.quality_testing_plan,
  250. props: { label: "dictLabel", value: "dictValue" },
  251. },
  252. {
  253. label: "适用平台",
  254. prop: "applicablePlatformsDictValue",
  255. search: true,
  256. filterable: true,
  257. type: "select",
  258. width: 100,
  259. overHidden: true,
  260. dicData: dicts.applicable_platforms,
  261. props: { label: "dictLabel", value: "dictValue" },
  262. rules: [
  263. {
  264. required: true,
  265. message: "请选择适用平台",
  266. trigger: "blur",
  267. },
  268. ],
  269. },
  270. {
  271. label: "质量等级",
  272. prop: "qualityLevelDictValue",
  273. search: true,
  274. width: 100,
  275. overHidden: true,
  276. filterable: true,
  277. type: "select",
  278. dicData: dicts.quality_grade,
  279. props: { label: "dictLabel", value: "dictValue" },
  280. rules: [
  281. {
  282. required: true,
  283. message: "请选择质量等级",
  284. trigger: "blur",
  285. },
  286. ],
  287. },
  288. {
  289. label: "选用类型",
  290. prop: "selectionDictValue",
  291. search: true,
  292. filterable: true,
  293. width: 100,
  294. overHidden: true,
  295. type: "select",
  296. dicData: dicts.selection_type,
  297. props: { label: "dictLabel", value: "dictValue" },
  298. },
  299. { label: "客户型号", prop: "customerModel", width: 100, overHidden: true },
  300. {
  301. label: "保质期(天)",
  302. prop: "qualityGuaranteePeriod",
  303. width: 100,
  304. overHidden: true,
  305. type: "number",
  306. min: 0,
  307. },
  308. {
  309. label: "封装方法",
  310. prop: "packageDictValue",
  311. search: true,
  312. width: 100,
  313. overHidden: true,
  314. filterable: true,
  315. type: "select",
  316. dicData: dicts.packaging_method,
  317. props: { label: "dictLabel", value: "dictValue" },
  318. },
  319. {
  320. label: "筛选规范",
  321. prop: "selectionSpec",
  322. width: 150,
  323. overHidden: true,
  324. type: "textarea",
  325. span: 18,
  326. },
  327. {
  328. label: "备注",
  329. prop: "remark",
  330. width: 150,
  331. overHidden: true,
  332. type: "textarea",
  333. span: 18,
  334. },
  335. ],
  336. });
  337. </script>