index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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="addRow"
  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 #drawingPath-form="scope">
  20. <!-- <single-upload v-model="form.drawingPath" :generatePdf="true"/>-->
  21. <FilesUpload
  22. v-model:src-list="srcList"
  23. v-model:pdf-list="pdfUrlList"
  24. v-model:file-name-list="fileNameList"
  25. :limit="10"
  26. :generate-pdf="true"
  27. @finished="testFiles"
  28. />
  29. </template>
  30. <template #signatureState="scope">
  31. <el-switch
  32. active-value="1"
  33. inactive-value="0"
  34. inline-prompt
  35. active-text="启用"
  36. inactive-text="禁用"
  37. v-model="scope.row.signatureState"
  38. @click="changeItem(scope.row)"
  39. class="ml-2"
  40. style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
  41. />
  42. </template>
  43. <template #menu="{ row, index, type }">
  44. <a :href="downloadUrl(row.signatureFiles)"
  45. ><el-button type="primary" text>下载</el-button>
  46. </a>
  47. <el-button @click="toEdiet(row)" text type="primary">修改</el-button>
  48. <el-button @click="deleteRecord(row, index, done)" text type="primary"
  49. >删除</el-button
  50. >
  51. <el-button @click="toLook(row.signatureFiles)" text type="primary"
  52. >预览</el-button
  53. >
  54. </template>
  55. <template #menu-left="{ size }">
  56. <el-button
  57. type="primary"
  58. @click="
  59. editStatus = false;
  60. addShow = true;
  61. "
  62. >新增</el-button
  63. >
  64. </template>
  65. </avue-crud>
  66. <div id="imgeview">
  67. <el-image
  68. style="width: 1px; height: 1px"
  69. :src="Logo"
  70. :zoom-rate="1.2"
  71. :max-scale="7"
  72. :min-scale="0.2"
  73. :initial-index="0"
  74. :preview-src-list="imgSrcList"
  75. :hide-on-click-modal="true"
  76. fit="cover"
  77. />
  78. </div>
  79. </div>
  80. <OpSignature v-if="addShow" @close="closeShow" :editStatus :rowObj />
  81. </template>
  82. <script setup>
  83. import { ref, getCurrentInstance } from "vue";
  84. import { useCrud } from "@/hooks/userCrud";
  85. import Logo from "@/assets/logo.png";
  86. import { useCommonStoreHook, useDictionaryStore } from "@/store";
  87. import { updateSignature } from "@/api/signature";
  88. import dictDataUtil from "@/common/configs/dictDataUtil";
  89. import PDFView from "@/components/PDFView/index.vue";
  90. import OpSignature from "./components/opSignature.vue";
  91. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  92. // 数据字典相关
  93. const { dicts } = useDictionaryStore();
  94. const downloadUrl = (url) => {
  95. return url;
  96. };
  97. const toLook = (url) => {
  98. imgSrcList.value = [];
  99. imgSrcList.value.push(url);
  100. setTimeout(() => {
  101. document
  102. .getElementById("imgeview")
  103. .firstElementChild.firstElementChild.click();
  104. }, 0);
  105. };
  106. const rowObj = ref(null);
  107. const toEdiet = (row) => {
  108. editStatus.value = true;
  109. rowObj.value = row;
  110. addShow.value = true;
  111. };
  112. const imgSrcList = ref([]);
  113. const editStatus = ref(false);
  114. const addShow = ref(false);
  115. const closeShow = () => {
  116. addShow.value = false;
  117. dataList();
  118. };
  119. const pdfUrlList = ref([]);
  120. const srcList = ref([]);
  121. const fileNameList = ref([]);
  122. const testFiles = () => {
  123. form.value.pdfPathList = pdfUrlList.value;
  124. form.value.drawingPathList = srcList.value;
  125. form.value.drawingPath = srcList.value[0];
  126. form.value.fileNameList = fileNameList.value;
  127. };
  128. const changeItem = (row) => {
  129. updateSignature(row).then(() => {
  130. ElMessage.success("操作成功");
  131. dataList();
  132. });
  133. };
  134. const addRow = (form2, done) => {
  135. createRow(form, done, done);
  136. pdfUrlList.value = [];
  137. srcList.value = [];
  138. fileNameList.value = [];
  139. };
  140. // 传入一个url,后面不带/
  141. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  142. useCrud({
  143. src: "/api/v1/base/signature",
  144. });
  145. const {
  146. dataEditList,
  147. createRow,
  148. updateRow,
  149. deleteRow,
  150. searchChange,
  151. dataList,
  152. resetChange,
  153. } = Methords; //增删改查
  154. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  155. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  156. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  157. onMounted?.(() => {
  158. dataEditList();
  159. });
  160. // 设置表格列或者其他自定义的option
  161. option.value = Object.assign(option.value, {
  162. selection: false,
  163. viewBtn: false,
  164. editBtn: false,
  165. delBtn: false,
  166. menu: true,
  167. addBtn: false,
  168. column: [
  169. {
  170. label: "签章名称",
  171. prop: "signatureName",
  172. search: true,
  173. overHidden: true,
  174. },
  175. {
  176. label: "签章人名称",
  177. prop: "signUser",
  178. search: true,
  179. overHidden: true,
  180. },
  181. {
  182. label: "签章类型",
  183. prop: "signatureType",
  184. overHidden: true,
  185. search: true,
  186. type: "select",
  187. dicData: dicts.signature_type,
  188. props: { label: "dictLabel", value: "dictValue" },
  189. },
  190. {
  191. label: "签章归属",
  192. prop: "signatureAttribution",
  193. type: "select",
  194. search: true,
  195. overHidden: true,
  196. editDisplay: false,
  197. addDisplay: false,
  198. dicData: dicts.signature_attribution,
  199. props: { label: "dictLabel", value: "dictValue" },
  200. },
  201. {
  202. label: "创建时间",
  203. prop: "created",
  204. overHidden: true,
  205. display: false,
  206. },
  207. {
  208. label: "启用状态",
  209. slot: true,
  210. headerAlign: "center",
  211. prop: "signatureState",
  212. width: 100,
  213. addDisplay: false,
  214. },
  215. ],
  216. });
  217. const deleteRecord = (row, index, done) => {
  218. deleteRow(row, index, done);
  219. dataEditList();
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. #imgeview {
  224. position: fixed;
  225. top: -2px;
  226. z-index: 99999;
  227. }
  228. </style>