drawing-page.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-form ref="formRef" v-model="form" :option="option" @submit="rowSave">
  4. <template #drawingPath="scope">
  5. <!-- <single-upload v-model="form.drawingPath" :generatePdf="true"/>-->
  6. <FilesUpload
  7. v-model:src-list="srcList"
  8. v-model:pdf-list="pdfUrlList"
  9. v-model:file-name-list="fileNameList"
  10. v-model:file-list="fileList"
  11. :limit="10"
  12. :generate-pdf="true"
  13. @finished="testFiles"
  14. :key="uploadKey"
  15. />
  16. </template>
  17. </avue-form>
  18. <avue-crud
  19. ref="crudRef"
  20. v-model:search="search"
  21. v-model="form"
  22. :data="data"
  23. :option="option"
  24. v-model:page="page"
  25. @row-save="addRow"
  26. @row-update="updateRow"
  27. @row-del="deleteRow"
  28. @search-change="searchChange"
  29. @search-reset="resetChange"
  30. @size-change="dataList"
  31. @current-change="dataList"
  32. @selection-change="selectionChange"
  33. search-option="false"
  34. >
  35. <template #menu-left="{ size }">
  36. <el-button
  37. :disabled="toDeleteIds.length < 1"
  38. type="danger"
  39. icon="el-icon-delete"
  40. :size="size"
  41. @click="multipleDelete"
  42. >删除</el-button
  43. >
  44. <el-select
  45. v-model="version"
  46. placeholder="请选择BOM版本"
  47. style="width: 150px; margin-left: 15px"
  48. @change="getVersionDrawing"
  49. >
  50. <el-option
  51. v-for="item in options"
  52. :key="item"
  53. :label="item"
  54. :value="item"
  55. />
  56. </el-select>
  57. </template>
  58. <template #menu="{ row, index, type }">
  59. <PDFView
  60. :need-to-show-pdf="true"
  61. content-type="button"
  62. :is-link="true"
  63. :show-pdf-number="1"
  64. :pdf-source="filePath + row.pdfPath"
  65. />
  66. </template>
  67. </avue-crud>
  68. </div>
  69. </template>
  70. <script setup>
  71. import { ref, getCurrentInstance } from "vue";
  72. import { useCrud } from "@/hooks/userCrud";
  73. import ButtonPermKeys from "@/common/configs/buttonPermission";
  74. import { useCommonStoreHook } from "@/store";
  75. import { useDictionaryStore } from "@/store";
  76. import { addDrawing, getDrawing } from "@/api/drawing";
  77. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  78. const fileList = ref([]);
  79. const uploadKey = ref(false);
  80. const { dicts } = useDictionaryStore();
  81. const filePath = import.meta.env.VITE_APP_UPLOAD_URL;
  82. const test = () => {
  83. isShowTable.value = true;
  84. tableType.value = tableType.value == 1 ? 2 : 1;
  85. };
  86. const testFiles = () => {
  87. form.value.pdfPathList = pdfUrlList.value;
  88. form.value.drawingPathList = srcList.value;
  89. form.value.drawingPath = srcList.value[0];
  90. form.value.fileNameList = fileNameList.value;
  91. };
  92. // 传入一个url,后面不带/
  93. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  94. useCrud({
  95. src: "/api/v1/base/drawing",
  96. });
  97. const { dataList } = Methords; //增删改查
  98. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  99. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  100. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  101. // const permission = reactive({
  102. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  103. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  104. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  105. // menu: true,
  106. // });
  107. const formRef = ref(null);
  108. const version = ref({
  109. value: "0",
  110. label: "请选择图纸版本",
  111. });
  112. const options = ref([]);
  113. const fileUrl = ref(""); //单文件
  114. const pdfUrlList = ref([]);
  115. const srcList = ref([]);
  116. const fileNameList = ref([]);
  117. import dictDataUtil from "@/common/configs/dictDataUtil";
  118. const getVersionDrawing = () => {
  119. if (version.value.value != "0") {
  120. search.value.materialCode = props.materialCode;
  121. search.value.drawingVersion = version.value;
  122. dataList();
  123. }
  124. };
  125. const addRow = (form2, done) => {
  126. createRow(form, done, done);
  127. pdfUrlList.value = [];
  128. srcList.value = [];
  129. fileNameList.value = [];
  130. };
  131. function rowSave(form, done) {
  132. form.associationCode = props.materialCode;
  133. form.associationName = props.materialName;
  134. addDrawing(form).then((data) => {
  135. if (data.code === "200") {
  136. ElMessage({
  137. message: data.msg,
  138. type: "success",
  139. });
  140. fileNameList.value = [];
  141. srcList.value = [];
  142. pdfUrlList.value = [];
  143. fileList.value = [];
  144. formRef.value.resetForm();
  145. uploadKey.value = !uploadKey.value;
  146. dataList();
  147. } else {
  148. ElMessage({
  149. message: data.msg,
  150. type: "error",
  151. });
  152. }
  153. });
  154. done();
  155. }
  156. onMounted(() => {
  157. // console.log("crudRef", crudRef)
  158. getDrawing(props.materialCode).then((data) => {
  159. if (data.code === "200") {
  160. options.value = Array.from(data.data);
  161. } else {
  162. ElMessage({
  163. message: data.msg,
  164. type: "error",
  165. });
  166. }
  167. });
  168. search.value.materialCode = props.materialCode;
  169. dataList();
  170. });
  171. const ctableRef = ref(null);
  172. // 设置表格列或者其他自定义的option
  173. option.value = Object.assign(option.value, {
  174. selection: true,
  175. column: [
  176. {
  177. label: "物料编号",
  178. prop: "associationCode",
  179. hide: true,
  180. display: false,
  181. },
  182. {
  183. label: "物料编号",
  184. prop: "associationName",
  185. hide: true,
  186. display: false,
  187. },
  188. {
  189. label: "图纸编号",
  190. prop: "drawingCode",
  191. rules: [
  192. {
  193. required: true,
  194. message: "图纸编号不能为空",
  195. trigger: "blur",
  196. },
  197. ],
  198. },
  199. {
  200. label: "图纸标题",
  201. prop: "drawingTitle",
  202. rules: [
  203. {
  204. required: true,
  205. message: "图纸名称不能为空",
  206. trigger: "blur",
  207. },
  208. ],
  209. },
  210. {
  211. label: "图纸类型",
  212. prop: "drawingDictValue",
  213. filterable: true,
  214. type: "select",
  215. width: 100,
  216. overHidden: true,
  217. dicUrl: dictDataUtil.request_url + "drawing_type",
  218. props: { label: "dictLabel", value: "dictValue" },
  219. rules: [
  220. {
  221. required: true,
  222. message: "请选择物料属性",
  223. trigger: "blur",
  224. },
  225. ],
  226. },
  227. {
  228. label: "文件名称",
  229. prop: "fileName",
  230. span: 24,
  231. width: 120,
  232. overHidden: true,
  233. display: false,
  234. },
  235. {
  236. label: "文件数组",
  237. prop: "drawingPathList",
  238. span: 24,
  239. hide: true,
  240. display: false,
  241. },
  242. {
  243. label: "pdf数组",
  244. prop: "pdfPathList",
  245. span: 24,
  246. hide: true,
  247. display: false,
  248. },
  249. {
  250. label: "文件名称数组",
  251. prop: "fileNameList",
  252. span: 24,
  253. slot: true,
  254. hide: true,
  255. display: false,
  256. },
  257. {
  258. label: "版本",
  259. prop: "drawingVersion",
  260. type: "number",
  261. precision: 1,
  262. rules: [
  263. {
  264. required: true,
  265. message: "版本号不能为空",
  266. trigger: "blur",
  267. },
  268. ],
  269. click() {
  270. dialog1.visible = true;
  271. },
  272. },
  273. {
  274. label: "图纸上传",
  275. prop: "drawingPath",
  276. span: 24,
  277. slot: true,
  278. hide: true,
  279. rules: [
  280. {
  281. required: true,
  282. message: "图纸上传不能为空",
  283. trigger: "blur",
  284. },
  285. ],
  286. /*formatter: (row, column, cellValue, index) => {
  287. return `<img src="${row.drawingPath}" alt="${row.drawingPath}" width="50" height="50">`;
  288. }
  289. */
  290. },
  291. ],
  292. delBtn: false,
  293. editBtn: false,
  294. viewBtn: false,
  295. addBtn: false,
  296. });
  297. const props = defineProps({
  298. materialCode: {
  299. type: String,
  300. default: () => {
  301. return 0;
  302. },
  303. },
  304. materialName: {
  305. type: String,
  306. default: () => {
  307. return 0;
  308. },
  309. },
  310. dialog: {
  311. type: Object,
  312. default: () => {
  313. return {};
  314. },
  315. },
  316. });
  317. </script>