drawing-page.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. searchEnter: true,
  175. selection: true,
  176. column: [
  177. {
  178. label: "物料编号",
  179. prop: "associationCode",
  180. hide: true,
  181. display: false,
  182. },
  183. {
  184. label: "物料编号",
  185. prop: "associationName",
  186. hide: true,
  187. display: false,
  188. },
  189. {
  190. label: "图纸编号",
  191. prop: "drawingCode",
  192. rules: [
  193. {
  194. required: true,
  195. message: "图纸编号不能为空",
  196. trigger: "blur",
  197. },
  198. ],
  199. },
  200. {
  201. label: "图纸标题",
  202. prop: "drawingTitle",
  203. rules: [
  204. {
  205. required: true,
  206. message: "图纸名称不能为空",
  207. trigger: "blur",
  208. },
  209. ],
  210. },
  211. {
  212. label: "图纸类型",
  213. prop: "drawingDictValue",
  214. filterable: true,
  215. type: "select",
  216. width: 100,
  217. overHidden: true,
  218. dicUrl: dictDataUtil.request_url + "drawing_type",
  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: "fileName",
  231. span: 24,
  232. width: 120,
  233. overHidden: true,
  234. display: false,
  235. },
  236. {
  237. label: "文件数组",
  238. prop: "drawingPathList",
  239. span: 24,
  240. hide: true,
  241. display: false,
  242. },
  243. {
  244. label: "pdf数组",
  245. prop: "pdfPathList",
  246. span: 24,
  247. hide: true,
  248. display: false,
  249. },
  250. {
  251. label: "文件名称数组",
  252. prop: "fileNameList",
  253. span: 24,
  254. slot: true,
  255. hide: true,
  256. display: false,
  257. },
  258. {
  259. label: "版本",
  260. prop: "drawingVersion",
  261. type: "number",
  262. precision: 1,
  263. rules: [
  264. {
  265. required: true,
  266. message: "版本号不能为空",
  267. trigger: "blur",
  268. },
  269. ],
  270. click() {
  271. dialog1.visible = true;
  272. },
  273. },
  274. {
  275. label: "图纸上传",
  276. prop: "drawingPath",
  277. span: 24,
  278. slot: true,
  279. hide: true,
  280. rules: [
  281. {
  282. required: true,
  283. message: "图纸上传不能为空",
  284. trigger: "blur",
  285. },
  286. ],
  287. /*formatter: (row, column, cellValue, index) => {
  288. return `<img src="${row.drawingPath}" alt="${row.drawingPath}" width="50" height="50">`;
  289. }
  290. */
  291. },
  292. ],
  293. delBtn: false,
  294. editBtn: false,
  295. viewBtn: false,
  296. addBtn: false,
  297. });
  298. const props = defineProps({
  299. materialCode: {
  300. type: String,
  301. default: () => {
  302. return 0;
  303. },
  304. },
  305. materialName: {
  306. type: String,
  307. default: () => {
  308. return 0;
  309. },
  310. },
  311. dialog: {
  312. type: Object,
  313. default: () => {
  314. return {};
  315. },
  316. },
  317. });
  318. </script>