books-edit.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!-- 搜索表单 -->
  2. <template>
  3. <simple-form-modal
  4. :title="title"
  5. :items="formItems"
  6. ref="editRef"
  7. :baseUrl="baseUrl"
  8. width="1080px"
  9. :formProps="{ grid: 8 }"
  10. :formatData="formatData"
  11. labelWidth="120px"
  12. @success="(data) => emit('success', data)"
  13. :body-style="{ overflow: 'auto' }"
  14. >
  15. <template #other>
  16. <div class="image-pos" id="image-pos">
  17. <image-upload
  18. :limit="1"
  19. v-model="formData.cover"
  20. :item-style="{ width: '260px', height: '320px', margin: 0 }"
  21. :button-style="{ width: '260px', height: '320px', margin: 0 }"
  22. />
  23. </div>
  24. </template>
  25. </simple-form-modal>
  26. </template>
  27. <script setup>
  28. import { reactive, ref, defineEmits, getCurrentInstance } from 'vue';
  29. import { useFormData } from '@/utils/use-form-data';
  30. import SimpleFormModal from '@/components/CommonPage/SimpleFormModal.vue';
  31. import ImageUpload from '@/components/ImageUpload/index.vue';
  32. const { proxy } = getCurrentInstance();
  33. //获取省市
  34. const provinceList = ref([]);
  35. const cityList = ref([]);
  36. const title = ref('新增图书');
  37. const emit = defineEmits(['success']);
  38. let colProps = { style: { marginRight: '15px' } };
  39. const formItems = reactive([
  40. { type: 'input', label: '书名', prop: 'bookName', required: true },
  41. { type: 'input', label: 'ISBN', prop: 'isbn', required: true, colProps },
  42. // { type: 'imageUpload', label: '封面', prop: 'cover', props: { limit: 1 } },
  43. { type: 'input', label: '作者', prop: 'author', required: true },
  44. { type: 'input', label: '定价', prop: 'price', required: true, colProps },
  45. { type: 'input', label: '出版社', prop: 'publish', required: true },
  46. {
  47. type: 'date',
  48. label: '出版时间',
  49. prop: 'pubDate',
  50. required: true,
  51. props: {
  52. format: 'YYYY-MM-DD',
  53. valueFormat: 'YYYY-MM-DD'
  54. },
  55. colProps
  56. },
  57. {
  58. type: 'dictSelect',
  59. label: '分类标签',
  60. prop: 'bookTag',
  61. props: { code: 'book_tag' }
  62. },
  63. { type: 'input', label: '中图法分类', prop: 'chineCateNo', colProps },
  64. { type: 'input', label: '丛书提名', prop: 'bookPut' },
  65. { type: 'input', label: '其他提名', prop: 'otherPut', colProps },
  66. { type: 'input', label: '主题', prop: 'bookTopic' },
  67. { type: 'input', label: '语种', prop: 'lang', colProps },
  68. { type: 'input', label: '开本尺寸', prop: 'bookFormat' },
  69. { type: 'input', label: '装帧', prop: 'bookPack', colProps },
  70. { type: 'input', label: '翻译人', prop: 'translator' },
  71. {
  72. type: 'dictSelect',
  73. label: '是否套装',
  74. prop: 'suit',
  75. props: { code: 'is_common_yes' }
  76. },
  77. { type: 'input', label: '中图法分类名称', prop: 'chineCateName' },
  78. { type: 'input', label: '总页数', prop: 'pageTotal' },
  79. {
  80. type: 'dictSelect',
  81. label: '人工核实',
  82. prop: 'perCheck',
  83. props: { code: 'is_common_yes' }
  84. },
  85. { type: 'input', label: '字数', prop: 'worldCount' },
  86. { type: 'input', label: '出版地', prop: 'putAddress' },
  87. { type: 'input', label: '读者对象', prop: 'readers' },
  88. { type: 'input', label: '版本', prop: 'bookVersion' },
  89. { type: 'input', label: '印刷厂', prop: 'printHouse' },
  90. {
  91. type: 'date',
  92. label: '印刷时间',
  93. prop: 'printTime',
  94. props: {
  95. format: 'YYYY-MM-DD',
  96. valueFormat: 'YYYY-MM-DD'
  97. }
  98. },
  99. { type: 'input', label: '印刷数量', prop: 'printNum' },
  100. {
  101. type: 'textarea',
  102. label: '图书短评',
  103. prop: 'shortReview',
  104. colProps: { span: 24 }
  105. },
  106. {
  107. type: 'editor',
  108. label: '书嗨推荐',
  109. prop: 'shuhiRecommend',
  110. colProps: { span: 24 }
  111. },
  112. {
  113. type: 'editor',
  114. label: '书嗨摘要',
  115. prop: 'shuhiBlurb',
  116. colProps: { span: 24 }
  117. },
  118. {
  119. type: 'editor',
  120. label: '内容简介',
  121. prop: 'contentBlurb',
  122. colProps: { span: 24 }
  123. },
  124. {
  125. type: 'editor',
  126. label: '作者简介',
  127. prop: 'anthorBlurb',
  128. colProps: { span: 24 }
  129. },
  130. {
  131. type: 'editor',
  132. label: '图书目录',
  133. prop: 'catalog',
  134. colProps: { span: 24 }
  135. }
  136. ]);
  137. //默认值
  138. const baseUrl = reactive({
  139. add: '/book/bookInfo/save',
  140. update: '/book/bookInfo/update',
  141. detail: '/book/bookInfo/getDetail'
  142. });
  143. const formData = ref({ perCheck: '1', suit: '0', bookTag: '1' });
  144. const editRef = ref(null);
  145. function handleOpen(data = {}) {
  146. title.value = data && data.id ? '编辑图书' : '新增图书';
  147. formData.value = Object.assign(formData.value, data || {});
  148. editRef.value?.handleOpen(formData.value);
  149. }
  150. //格式化数据
  151. function formatData(data) {
  152. let values = JSON.parse(JSON.stringify(data));
  153. let bookBlurb = {
  154. bookId: data.id,
  155. isbn: data.isbn,
  156. shuhiRecommend: data.shuhiRecommend,
  157. shuhiBlurb: data.shuhiBlurb,
  158. contentBlurb: data.contentBlurb,
  159. anthorBlurb: data.anthorBlurb,
  160. catalog: data.catalog
  161. };
  162. values.bookBlurb = bookBlurb;
  163. return values;
  164. }
  165. //回填数据
  166. function fallbackData(data) {
  167. let values = JSON.parse(JSON.stringify(data));
  168. if (data.bookBlurb) {
  169. values.shuhiRecommend = data.bookBlurb.shuhiRecommend;
  170. values.shuhiBlurb = data.bookBlurb.shuhiBlurb;
  171. values.contentBlurb = data.bookBlurb.contentBlurb;
  172. values.anthorBlurb = data.bookBlurb.anthorBlurb;
  173. values.catalog = data.bookBlurb.catalog;
  174. }
  175. return values;
  176. }
  177. defineExpose({ handleOpen });
  178. </script>
  179. <style lang="scss">
  180. .image-pos {
  181. position: absolute;
  182. right: 40px;
  183. top: 16px;
  184. z-index:10
  185. }
  186. </style>