bottomTable.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div>
  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. @selection-change="selectionChange"
  14. @sortable-change="onSortChange"
  15. @search-change="searchChange"
  16. @search-reset="resetChange"
  17. @size-change="dataList"
  18. @current-change="dataList"
  19. >
  20. <template #filePath-form="scope">
  21. <!-- <single-upload v-model="form.filePath" />
  22. <FilesUpload v-model:src="form.filePath" v-model:src-list="form.filePath" /> -->
  23. <div style="height: 100px; width: 100px; overflow: hidden">
  24. <PDFView
  25. :need-to-show-pdf="true"
  26. content-type="button"
  27. :is-link="true"
  28. :show-pdf-number="form.showAppointPageNum"
  29. :pdf-source="pdfPath"
  30. />
  31. </div>
  32. </template>
  33. <template #filePath="{ row }">
  34. <PDFView
  35. :need-to-show-pdf="true"
  36. content-type="button"
  37. btnText="查看PDF"
  38. :is-link="true"
  39. :pdf-source="getSOAPpdf(row)"
  40. />
  41. </template>
  42. </avue-crud>
  43. <CommonTable
  44. ref="commonTableRef"
  45. :tableTitle="tableTitle"
  46. :tableType="commonTableType"
  47. @selected-sure="onSelectedFinish"
  48. />
  49. <el-dialog v-model="dialogVisible">
  50. <VuePdfEmbed :source="previewImgUrl" annotation-layer text-layer />
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script setup>
  55. import { ref, getCurrentInstance } from "vue";
  56. import { useCrud } from "@/hooks/userCrud";
  57. import { getTableConfig } from "./configs";
  58. import PDFView from "@/components/PDFView/index.vue";
  59. import VuePdfEmbed from "vue-pdf-embed";
  60. import {
  61. saveCompoents,
  62. getBomVersion,
  63. getRouteMaxVersion,
  64. } from "@/api/craft/process/index";
  65. import SingleUpload from "@/components/Upload/SingleUpload.vue";
  66. const props = defineProps({
  67. tableTitle: {
  68. default: "",
  69. type: String,
  70. },
  71. tableType: {
  72. default: "",
  73. type: String,
  74. },
  75. });
  76. const route = useRoute();
  77. const tableConfig = getTableConfig(route.fullPath.split("/")[4]);
  78. // 传入一个url,后面不带/
  79. const { url, form, data, option, search, page, toDeleteIds, Methords, Utils } =
  80. useCrud({
  81. src: tableConfig[props.tableType].url,
  82. });
  83. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  84. Methords; //增删改查
  85. const { selectionChange, multipleUpdate } = Methords; //选中和批量删除事件
  86. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  87. const bomVersion = ref(null);
  88. const pdfPath = ref(null);
  89. const startCreat = () => {
  90. if (props.tableType === "wuliaocaiji") {
  91. if (data.value && data.value.length > 0) {
  92. bomVersion.value = data.value[0].recordVersion;
  93. }
  94. if (!route.fullPath.split("/")[5]) {
  95. ElMessage.error("物料编号读取错误");
  96. return;
  97. }
  98. //根据物料编码和版本号获取对应的物料BOM
  99. let bomParam = {
  100. materialCode: route.fullPath.split("/")[5],
  101. };
  102. //根据物料编码和版本号获取对应的物料BOM
  103. commonTableType.value = "MARTERIAL";
  104. nextTick(() => {
  105. commonTableRef.value?.startSelect({});
  106. commonTableRef.value?.refreshDictData(
  107. "bomVersion",
  108. resListMap,
  109. "value"
  110. );
  111. commonTableRef.value?.mergeOption({
  112. searchShow: bomVersion.value ? false : true,
  113. });
  114. });
  115. /*getBomVersion(bomParam).then((res) => {
  116. let resListMap = [];
  117. //说明时物料采集的添加框 进行物料采集的下拉框数据获取
  118. res?.data.forEach((versions) => {
  119. resListMap.push({
  120. label: versions.bomVersion,
  121. value: versions.bomVersion,
  122. });
  123. });
  124. //查询参数
  125. let configParam = {};
  126. configParam.materialCode = route.fullPath.split("/")[5];
  127. if (bomVersion.value) {
  128. configParam.bomVersion = bomVersion.value;
  129. }
  130. //根据物料编码和版本号获取对应的物料BOM
  131. commonTableType.value = "MARTERIAL";
  132. nextTick(() => {
  133. commonTableRef.value?.startSelect(configParam);
  134. commonTableRef.value?.refreshDictData(
  135. "bomVersion",
  136. resListMap,
  137. "value"
  138. );
  139. commonTableRef.value?.mergeOption({
  140. searchShow: bomVersion.value ? false : true,
  141. });
  142. });
  143. });*/
  144. } else if (props.tableType === "dianjian") {
  145. commonTableType.value = "OP_CHECK";
  146. nextTick(() => {
  147. commonTableRef.value?.startSelect();
  148. });
  149. } else if (props.tableType === "ESOP") {
  150. commonTableType.value = "ESOP";
  151. nextTick(() => {
  152. commonTableRef.value?.startSelect({
  153. materialCode: route.fullPath.split("/")[5],
  154. enable: 1,
  155. });
  156. });
  157. } else {
  158. crudRef.value && crudRef.value.rowAdd();
  159. }
  160. };
  161. const saveSortData = async () => {
  162. multipleUpdate();
  163. };
  164. defineExpose({ startCreat, saveSortData });
  165. const onSortChange = () => {
  166. data.value.forEach((item) => {
  167. console.log(item.id);
  168. });
  169. };
  170. const routeId = ref("");
  171. // ============公共弹窗table选择相关,物料采集等使用===============
  172. const commonTableRef = ref({});
  173. const commonTableType = ref("MARTERIAL");
  174. const onSelectedFinish = (itemValue) => {
  175. crudRef.value && crudRef.value.rowAdd();
  176. if (props.tableType === "wuliaocaiji") {
  177. /* form.value.itemName = itemValue.bomMaterialName;
  178. form.value.itemCode = itemValue.bomMaterialCode;
  179. form.value.itemModel = itemValue.bomMaterialAttribute;
  180. form.value.recordVersion = itemValue.bomVersion;
  181. form.value.num = itemValue.bomMaterialNumber;*/
  182. form.value.itemName = itemValue.materialName;
  183. form.value.itemCode = itemValue.materialCode;
  184. form.value.itemModel = itemValue.spec;
  185. //form.value.recordVersion = itemValue.bomVersion;
  186. form.value.num = 1
  187. form.value.traceType = "S";
  188. form.value.unit = itemValue.unitDictValue;
  189. } else if (props.tableType === "dianjian") {
  190. form.value.checkName = itemValue.checkName;
  191. form.value.checkCode = itemValue.checkCode;
  192. form.value.content = itemValue.content;
  193. form.value.standard = itemValue.standard;
  194. form.value.upper = itemValue.upper;
  195. form.value.lower = itemValue.lower;
  196. form.value.unit = itemValue.unit;
  197. } else if (props.tableType === "ESOP") {
  198. form.value.filePath = itemValue.pdfPath;
  199. pdfPath.value = import.meta.env.VITE_APP_UPLOAD_URL + itemValue.pdfPath;
  200. form.value.drawingCode = itemValue.drawingCode;
  201. form.value.recordVersion = itemValue.drawingVersion;
  202. form.value.sortNum = itemValue.sort;
  203. form.value.title = itemValue.drawingTitle;
  204. }
  205. };
  206. const previewImgUrl = ref("");
  207. const dialogVisible = ref(false);
  208. const imgUrlClick = (itemValue) => {
  209. previewImgUrl.value =
  210. import.meta.env.VITE_APP_UPLOAD_URL + itemValue.filePath;
  211. dialogVisible.value = true;
  212. };
  213. const getSOAPpdf = (itemValue) => {
  214. return import.meta.env.VITE_APP_UPLOAD_URL + itemValue.filePath;
  215. };
  216. onMounted(() => {
  217. routeId.value = route.fullPath.split("/")[6];
  218. search.value.operationId = route.fullPath.split("/")[4];
  219. url.value = tableConfig[props.tableType].url;
  220. option.value = Object.assign(option.value, {
  221. addBtn: false,
  222. searchShow: false,
  223. header: false,
  224. sortable: true,
  225. column: tableConfig[props.tableType].column,
  226. });
  227. dataList();
  228. getRouteMaxVersion(
  229. route.fullPath.split("/")[6] ? route.fullPath.split("/")[6] : routeId.value
  230. ).then(({ data }) => {
  231. if (data) {
  232. bomVersion.value = data;
  233. }
  234. });
  235. });
  236. watch(
  237. () => props.tableType,
  238. () => {
  239. routeId.value = route.fullPath.split("/")[6];
  240. url.value = tableConfig[props.tableType].url;
  241. option.value = Object.assign(option.value, {
  242. addBtn: false,
  243. searchShow: false,
  244. header: false,
  245. sortable: true,
  246. column: tableConfig[props.tableType].column,
  247. });
  248. dataList();
  249. getRouteMaxVersion(
  250. route.fullPath.split("/")[6]
  251. ? route.fullPath.split("/")[6]
  252. : routeId.value
  253. ).then(({ data }) => {
  254. if (data) {
  255. bomVersion.value = data;
  256. }
  257. });
  258. }
  259. );
  260. </script>