index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div class="">
  3. <toolbar @on-filter="filterData" @on-reset="filterData" />
  4. <base-table
  5. class="m-10 bg-w p-20 br-10"
  6. :columns="columns"
  7. :items="items"
  8. :pagination="pagination"
  9. :page-change="pageChange"
  10. >
  11. <template v-slot:batch-btn-box="{ selected }">
  12. <!-- <el-col :span="1.5">
  13. <el-button
  14. type="success"
  15. plain
  16. icon="el-icon-edit"
  17. size="mini"
  18. :disabled="selected | singleBatch"
  19. @click="handleUpdate(selected)"
  20. v-hasPermi="['car:brand:edit']"
  21. >修改</el-button
  22. >
  23. </el-col> -->
  24. <el-col :span="1.5">
  25. <el-button
  26. type="primary"
  27. plain
  28. size="mini"
  29. :disabled="selected | multipleBatch"
  30. @click="handleAudit(selected)"
  31. >批量审核</el-button
  32. >
  33. </el-col>
  34. </template>
  35. </base-table>
  36. </div>
  37. </template>
  38. <script>
  39. import toolbar from './toolbar';
  40. import mxFilterList from '@/mixins/filterList';
  41. import { getPage } from '@/api/photoWarehouse';
  42. const checkArr = (arr) => {
  43. if (Array.isArray(arr)) {
  44. if (arr.length === 0) {
  45. return 'null';
  46. } else if (arr.length === 1) {
  47. return 'single';
  48. } else {
  49. return 'multiple';
  50. }
  51. } else {
  52. throw new Error('ErrorType, we need Array', arr);
  53. }
  54. };
  55. export default {
  56. name: 'photoVerifyManagement',
  57. components: { toolbar },
  58. filters: {
  59. // 单选可用
  60. singleBatch: (arr) => {
  61. return checkArr(arr) !== 'single';
  62. },
  63. // 非空可用
  64. multipleBatch: (arr) => {
  65. return checkArr(arr) === 'null';
  66. },
  67. },
  68. mixins: [
  69. mxFilterList({
  70. fetchList: getPage // 在下方data再声明一个 fetchList: iGetList 同等效果
  71. })
  72. ],
  73. data() {
  74. return {
  75. columns: [
  76. {
  77. key: 'selection',
  78. },
  79. {
  80. key: 'id',
  81. name: '标识',
  82. width: this.$col.b
  83. },
  84. {
  85. key: 'location',
  86. name: '上传位置',
  87. minWidth: this.$col.b,
  88. render: (h, { row }) =>
  89. h(
  90. 'span',
  91. `${row.kindergartenName}${
  92. row.activityName ? '/' + row.activityName : ''
  93. }`
  94. )
  95. },
  96. {
  97. key: 'listPreview',
  98. name: '列表缩略图',
  99. minWidth: this.$col.b,
  100. render: (h, { row }) => {
  101. if (!row.listPreview) {
  102. return h('span', '图片正在处理中请稍等...');
  103. }
  104. return h('img', {
  105. style: {
  106. width: '160px',
  107. height: '90px'
  108. },
  109. class: 'pre-img',
  110. attrs: {
  111. src: row.listPreview
  112. },
  113. on: {
  114. click: () =>
  115. this.$AdvanceViewImageModal({
  116. items: [{ src: row.listPreview }]
  117. })
  118. }
  119. });
  120. }
  121. },
  122. {
  123. key: 'detailPreview',
  124. name: '详情缩略图',
  125. minWidth: this.$col.b,
  126. render: (h, { row }) => {
  127. if (!row.detailPreview) {
  128. return h('span', '图片正在处理中请稍等...');
  129. }
  130. return h('img', {
  131. style: {
  132. width: '160px',
  133. height: '90px'
  134. },
  135. class: 'pre-img',
  136. attrs: {
  137. src: row.detailPreview
  138. },
  139. on: {
  140. click: () =>
  141. this.$AdvanceViewImageModal({
  142. items: [{ src: row.detailPreview }]
  143. })
  144. }
  145. });
  146. }
  147. },
  148. {
  149. key: 'createAt',
  150. name: '上传时间',
  151. width: this.$col.b
  152. },
  153. {
  154. key: 'auditStatus',
  155. name: '状态',
  156. width: this.$col.s,
  157. type: 'tag',
  158. fetchTagType: val => {
  159. switch (val) {
  160. case 1:
  161. return 'success';
  162. case 0:
  163. return 'info';
  164. case -1:
  165. return 'error';
  166. default:
  167. return 'info';
  168. }
  169. },
  170. tagName: row => {
  171. switch (row.auditStatus) {
  172. case 1:
  173. return '通过';
  174. case 0:
  175. return '待审核';
  176. case -1:
  177. return '拒绝';
  178. default:
  179. return '-';
  180. }
  181. }
  182. },
  183. {
  184. key: 'action',
  185. name: '操作',
  186. width: '120',
  187. render: (h, { row }) => {
  188. const action = [];
  189. row.auditStatus !== 1 &&
  190. action.push(
  191. h(
  192. 'el-button',
  193. {
  194. props: {
  195. type: 'text'
  196. },
  197. on: {
  198. click: () =>
  199. this.$PhotoVerifyItemModal({
  200. id: row.id,
  201. auditStatus: row.auditStatus
  202. })
  203. }
  204. },
  205. '审核'
  206. )
  207. );
  208. return h('div', action);
  209. }
  210. }
  211. ]
  212. };
  213. },
  214. created() {
  215. this.$g_on('photo_reload', this.reload);
  216. },
  217. beforeDestroy() {
  218. this.$g_off('photo_reload', this.reload);
  219. },
  220. methods: {
  221. handleAudit(arr) {
  222. this.$PhotoVerifyMultItemModal({
  223. ids: arr.map(x => x.id)
  224. })
  225. }
  226. }
  227. };
  228. </script>
  229. <style type="scss" scoped></style>