index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="">
  3. <toolbar @on-filter="filterData" @on-reset="filterData" />
  4. <div class="m-10 bg-w p-20 br-10">
  5. <el-button type="primary" icon="el-icon-plus" @click="$PhotoUploadModal()"
  6. >新增</el-button
  7. >
  8. <el-button
  9. type="primary"
  10. icon="el-icon-plus"
  11. @click="$PhotoMultUploadModal()"
  12. >批量新增</el-button
  13. >
  14. <base-table
  15. :columns="columns"
  16. :items="items"
  17. :pagination="pagination"
  18. :page-change="pageChange"
  19. />
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import toolbar from './toolbar';
  25. import mxFilterList from '@/mixins/filterList';
  26. import { getPage, delItem } from '@/api/photoWarehouse';
  27. export default {
  28. name: 'PhotoVerify',
  29. components: { toolbar },
  30. mixins: [
  31. mxFilterList({
  32. fetchList: getPage // 在下方data再声明一个 fetchList: iGetList 同等效果
  33. })
  34. ],
  35. data() {
  36. return {
  37. columns: [
  38. {
  39. key: 'location',
  40. name: '上传位置',
  41. minWidth: this.$col.b,
  42. render: (h, { row }) =>
  43. h(
  44. 'span',
  45. `${row.kindergartenName}${
  46. row.activityName ? '/' + row.activityName : ''
  47. }`
  48. )
  49. },
  50. {
  51. key: 'listPreview',
  52. name: '列表缩略图',
  53. minWidth: this.$col.b,
  54. render: (h, { row }) => {
  55. if (!row.listPreview) {
  56. return h('span', '图片正在处理中请稍等...');
  57. }
  58. return h('img', {
  59. style: {
  60. width: '160px',
  61. height: '90px'
  62. },
  63. class: 'pre-img',
  64. attrs: {
  65. src: row.listPreview
  66. },
  67. on: {
  68. click: () =>
  69. this.$AdvanceViewImageModal({
  70. items: [{ src: row.listPreview }]
  71. })
  72. }
  73. });
  74. }
  75. },
  76. {
  77. key: 'detailPreview',
  78. name: '详情缩略图',
  79. minWidth: this.$col.b,
  80. render: (h, { row }) => {
  81. if (!row.detailPreview) {
  82. return h('span', '图片正在处理中请稍等...');
  83. }
  84. return h('img', {
  85. style: {
  86. width: '160px',
  87. height: '90px'
  88. },
  89. class: 'pre-img',
  90. attrs: {
  91. src: row.detailPreview
  92. },
  93. on: {
  94. click: () =>
  95. this.$AdvanceViewImageModal({
  96. items: [{ src: row.detailPreview }]
  97. })
  98. }
  99. });
  100. }
  101. },
  102. {
  103. key: 'createAt',
  104. name: '上传时间',
  105. width: this.$col.b
  106. },
  107. {
  108. key: 'auditStatus',
  109. name: '状态',
  110. width: this.$col.s,
  111. type: 'tag',
  112. fetchTagType: val => {
  113. switch (val) {
  114. case 1:
  115. return 'success';
  116. case 0:
  117. return 'info';
  118. case -1:
  119. return 'error';
  120. default:
  121. return 'info';
  122. }
  123. },
  124. tagName: row => {
  125. switch (row.auditStatus) {
  126. case 1:
  127. return '通过';
  128. case 0:
  129. return '待审核';
  130. case -1:
  131. return '拒绝';
  132. default:
  133. return '-';
  134. }
  135. }
  136. },
  137. {
  138. key: 'action',
  139. name: '操作',
  140. width: '120',
  141. render: (h, { row }) => {
  142. const action = [];
  143. row.auditStatus !== 1 &&
  144. action.push(
  145. h(
  146. 'BaseBtn',
  147. {
  148. props: {
  149. popip: true,
  150. txt: '删除',
  151. type: 'text'
  152. },
  153. class: 'ml-10',
  154. on: {
  155. ok: () => this.handleDelItem(row)
  156. }
  157. },
  158. '删除'
  159. )
  160. );
  161. return h('div', action);
  162. }
  163. }
  164. ]
  165. };
  166. },
  167. created() {
  168. this.$g_on('photo_reload', this.reload);
  169. },
  170. beforeDestroy() {
  171. this.$g_off('photo_reload', this.reload);
  172. },
  173. methods: {
  174. async handleDelItem(item) {
  175. const { success, msg } = await delItem({
  176. id: item.id
  177. });
  178. if (success) {
  179. this.$success('删除成功!');
  180. this.$g_emit('photo_reload');
  181. }
  182. }
  183. }
  184. };
  185. </script>
  186. <style type="scss" scoped></style>