index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <ele-page flex-table>
  3. <books-search @search="reload"></books-search>
  4. <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns">
  5. <template #toolbar>
  6. <el-button
  7. type="primary"
  8. plain
  9. :icon="PlusOutlined"
  10. v-permission="'data:books:add'"
  11. @click="handleUpdate()"
  12. >
  13. 新增图书
  14. </el-button>
  15. <el-button
  16. type="danger"
  17. plain
  18. :icon="DeleteOutlined"
  19. v-permission="'data:books:batchDelete'"
  20. @click="handleBatchDelete()"
  21. >
  22. 批量删除
  23. </el-button>
  24. <el-button
  25. type="primary"
  26. plain
  27. v-permission="'data:books:import'"
  28. @click="handleImportExcel"
  29. :icon="UploadOutlined"
  30. >
  31. 导入EXCEL
  32. </el-button>
  33. <el-button
  34. type="success"
  35. plain
  36. v-permission="'data:books:export'"
  37. @click="handleExportExcel"
  38. :icon="DownloadOutlined"
  39. >
  40. 查询结果导出
  41. </el-button>
  42. <el-button
  43. type="primary"
  44. plain
  45. v-permission="'data:books:uploadImage'"
  46. @click="handleUploadImage"
  47. :icon="CloudUploadOutlined"
  48. >
  49. 上传图片
  50. </el-button>
  51. <el-button
  52. type="info"
  53. plain
  54. v-permission="'data:books:importLog'"
  55. @click="handleImportLog"
  56. :icon="LogOutlined"
  57. >
  58. 导入记录
  59. </el-button>
  60. <el-button
  61. type="info"
  62. plain
  63. v-permission="'data:books:exportLog'"
  64. @click="handleExportLog"
  65. :icon="LogOutlined"
  66. >
  67. 导出记录
  68. </el-button>
  69. </template>
  70. <template #cover="{ row }">
  71. <el-image
  72. style="width: 80px; height: 100px"
  73. fit="cover"
  74. :src="row.cover"
  75. />
  76. </template>
  77. <template #baseInfo="{ row }">
  78. <book-base-info :row="row" @click="handleUpdate"></book-base-info>
  79. </template>
  80. <template #action="{ row }">
  81. <div>
  82. <el-button
  83. type="warning"
  84. link
  85. v-permission="'data:books:changeLogs'"
  86. @click="handleChangeLogs(row)"
  87. >
  88. [变动记录]
  89. </el-button>
  90. <el-button
  91. type="success"
  92. link
  93. v-permission="'data:books:update'"
  94. @click="handleUpdate(row)"
  95. >
  96. [编辑]
  97. </el-button>
  98. </div>
  99. </template>
  100. </common-table>
  101. <books-edit ref="editRef" @success="reload()"></books-edit>
  102. <books-import ref="importRef" v-model="showImport"></books-import>
  103. <books-change-log ref="changeLogRef"></books-change-log>
  104. <upload-image ref="uploadImageRef"></upload-image>
  105. </ele-page>
  106. </template>
  107. <script setup>
  108. import { ref, reactive } from 'vue';
  109. import {
  110. PlusOutlined,
  111. DeleteOutlined,
  112. DownloadOutlined,
  113. UploadOutlined,
  114. LogOutlined,
  115. CloudUploadOutlined
  116. } from '@/components/icons';
  117. import { dayjs } from 'element-plus';
  118. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  119. import booksEdit from '@/views/data/books/components/books-edit.vue';
  120. import booksSearch from '@/views/data/books/components/books-search.vue';
  121. import booksImport from '@/views/data/books/components/books-import.vue';
  122. import booksChangeLog from '@/views/data/books/components/books-change-log.vue';
  123. import bookBaseInfo from '@/views/data/books/components/book-base-info.vue';
  124. import uploadImage from '@/views/data/books/components/upload-image.vue';
  125. import { useDictData } from '@/utils/use-dict-data';
  126. defineOptions({ name: 'recycleOrderCancelled' });
  127. const [perCheckDicts] = useDictData(['is_common_yes']);
  128. /** 表格列配置 */
  129. const columns = ref([
  130. {
  131. type: 'selection',
  132. columnKey: 'selection',
  133. width: 50,
  134. align: 'center',
  135. fixed: 'left'
  136. },
  137. {
  138. label: '图片',
  139. prop: 'cover',
  140. slot: 'cover',
  141. align: 'center'
  142. },
  143. {
  144. label: '基础信息',
  145. prop: 'baseInfo',
  146. slot: 'baseInfo',
  147. align: 'center',
  148. minWidth: 320
  149. },
  150. {
  151. label: '人工核实',
  152. prop: 'perCheck',
  153. formatter: (row) =>
  154. perCheckDicts.value.find((d) => d.dictValue == row.perCheck)?.dictLabel,
  155. align: 'center'
  156. },
  157. {
  158. columnKey: 'action',
  159. label: '操作',
  160. width: 200,
  161. align: 'center',
  162. slot: 'action'
  163. }
  164. ]);
  165. /** 页面组件实例 */
  166. const pageRef = ref(null);
  167. const pageConfig = reactive({
  168. pageUrl: '/book/bookInfo/list',
  169. exportUrl: '/book/bookInfo/export',
  170. fileName: '图书基础数据',
  171. cacheKey: 'books-base-data'
  172. });
  173. //导出excel
  174. function handleExportExcel() {
  175. pageRef.value?.exportData('图书基础数据');
  176. }
  177. //导入
  178. const showImport = ref(false);
  179. function handleImportExcel() {
  180. showImport.value = true;
  181. }
  182. //刷新表格
  183. function reload(where) {
  184. pageRef.value?.reload(where);
  185. }
  186. //批量删除
  187. function handleBatchDelete(row) {
  188. let selections = row ? [row] : pageRef.value?.getSelections();
  189. let ids = selections.map((item) => item.id).join(',');
  190. console.log(ids, selections);
  191. let url = `/book/bookInfo/removeById/${ids}`;
  192. pageRef.value?.operatBatch({
  193. title: '确认删除?',
  194. method: 'post',
  195. url,
  196. row
  197. });
  198. }
  199. //新增编辑图书
  200. const editRef = ref(null);
  201. function handleUpdate(row) {
  202. editRef.value?.handleOpen(row);
  203. }
  204. //变动记录
  205. const changeLogRef = ref(null);
  206. function handleChangeLogs(row) {
  207. changeLogRef.value?.handleOpen(row);
  208. }
  209. //上传图片
  210. const uploadImageRef = ref(null);
  211. function handleUploadImage() {
  212. uploadImageRef.value?.handleOpen();
  213. }
  214. //导出记录
  215. function handleExportLog() {}
  216. //导入记录
  217. function handleImportLog() {}
  218. </script>