manualImport.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div>
  3. <m-filter :option="filter" @search="handleSearch" />
  4. <m-table
  5. class="mt-3"
  6. :loading="loading"
  7. :headers="headers"
  8. :items="items"
  9. :total="total"
  10. :show-select="false"
  11. :is-tools="false"
  12. :page-info="pageInfo"
  13. @pageHandleChange="pageHandleChange"
  14. @sort="handleSort"
  15. >
  16. <template #navBtn>
  17. <v-btn class="buttons" rounded elevation="5" color="primary" @click="handleImport">
  18. <v-icon left>mdi-plus</v-icon>
  19. 新增
  20. </v-btn>
  21. </template>
  22. </m-table>
  23. <m-dialog :title="title" :visible.sync="show" @submit="handleSubmit">
  24. <ManualImportEdit></ManualImportEdit>
  25. </m-dialog>
  26. </div>
  27. </template>
  28. <script>
  29. import MFilter from '@/components/Filter'
  30. import MTable from '@/components/List/table.vue'
  31. import MDialog from '@/components/Dialog'
  32. import ManualImportEdit from '../components/ManualImportEdit'
  33. export default {
  34. name: 'manual-import',
  35. components: { MFilter, MTable, MDialog, ManualImportEdit },
  36. data () {
  37. return {
  38. loading: false,
  39. show: false,
  40. filter: {
  41. list: [
  42. { type: 'textField', value: '', label: '名称', key: 'name' },
  43. { type: 'autocomplete', value: null, label: '选择', key: 'type', items: [] }
  44. ]
  45. },
  46. queryData: {
  47. name: null
  48. },
  49. headers: [
  50. { text: '标题', align: 'start', value: 'title' },
  51. { text: '姓名', align: 'start', value: 'name' },
  52. { text: '来源', align: 'start', value: 'source' },
  53. { text: '创建日期', align: 'start', value: 'createDate' },
  54. { text: '操作', align: 'start', value: 'actions' }
  55. ],
  56. itemData: {},
  57. items: [],
  58. orders: [],
  59. pageInfo: {
  60. size: 10,
  61. current: 1
  62. },
  63. total: 0
  64. }
  65. },
  66. computed: {
  67. title () {
  68. return Object.keys(this.itemData).length ? '编辑' : '新增'
  69. }
  70. },
  71. created () {
  72. this.init()
  73. },
  74. methods: {
  75. async init () {},
  76. handleSearch (val) {
  77. Object.assign(this.queryData, val)
  78. this.pageInfo.current = 1
  79. this.init()
  80. },
  81. handleImport () {
  82. this.itemData = {}
  83. this.show = true
  84. },
  85. async handleEdit (item) {
  86. this.itemData = item
  87. this.show = true
  88. },
  89. handleDelete (ids) {
  90. if (Array.isArray(ids) && !ids.length) return this.$snackbar.warning('请选择要删除的选项')
  91. this.$confirm('提示', '是否删除该选项')
  92. .then(async () => {
  93. try {
  94. this.$snackbar.success('删除成功')
  95. this.init()
  96. } catch (error) {
  97. this.$snackbar.error('删除失败')
  98. }
  99. })
  100. },
  101. handleSubmit () {},
  102. pageHandleChange (page) {
  103. this.pageInfo.current = page
  104. this.init()
  105. },
  106. handleSort (val) {
  107. this.orders = val
  108. this.init()
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. </style>