You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.6 KiB

  1. <script setup lang="ts">
  2. import { delPhoto, photoList } from 'apis/home'
  3. import Photo from 'components/home/Photo/index.vue'
  4. import { ElMessageBox } from 'element-plus'
  5. import { FtMessage } from 'libs/message'
  6. import { ref, useTemplateRef } from 'vue'
  7. const btnList = [
  8. {
  9. name: '查看照片',
  10. type: 'primary',
  11. serverUrl: 'edit',
  12. serverCondition: 1,
  13. },
  14. {
  15. name: '删除',
  16. type: 'danger',
  17. serverUrl: 'del',
  18. serverCondition: 2,
  19. },
  20. ]
  21. const columns = [
  22. {
  23. type: 'selection',
  24. },
  25. {
  26. title: '模式',
  27. key: 'mode',
  28. },
  29. {
  30. title: '矿石名称',
  31. key: 'oreName',
  32. },
  33. {
  34. title: '工艺名称',
  35. key: 'craftsName',
  36. },
  37. {
  38. title: '创建时间',
  39. key: 'createTime',
  40. },
  41. ]
  42. const tableRef = useTemplateRef('tableRef')
  43. const del = async (selectedRows: any) => {
  44. const ids = selectedRows.map((item: any) => item.id)
  45. await ElMessageBox.confirm('确定删除当前选中的行?', '消息', {
  46. confirmButtonText: '确认',
  47. cancelButtonText: '取消',
  48. type: 'warning',
  49. })
  50. await delPhoto(ids)
  51. FtMessage.success('删除成功')
  52. tableRef.value?.initData()
  53. }
  54. const id = ref(0)
  55. const photoVisible = ref(false)
  56. const edit = (selectedRows: any) => {
  57. id.value = selectedRows[0].id
  58. photoVisible.value = true
  59. }
  60. </script>
  61. <template>
  62. <div>
  63. <FtTable ref="tableRef" has-header has-page :columns="columns" :btn-list="btnList" :get-data-fn="photoList" @edit="edit" @del="del" />
  64. <Photo v-if="photoVisible" :id @cancel="photoVisible = false" />
  65. </div>
  66. </template>
  67. <style scoped lang="scss">
  68. </style>