ShouShuBuWeiWeiHu.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="layout_container">
  3. <header>
  4. 部位名称:
  5. <el-input v-model="shouShuBuWeiBianMa" clearable prefix-icon="Search" style="width: 120px"/>
  6. <el-divider direction="vertical"></el-divider>
  7. 新增部位名称:
  8. <el-input v-model="newPart" :maxlength="16" clearable prefix-icon="Plus" show-word-limit
  9. style="width: 260px"></el-input>
  10. <el-button icon="Plus" type="success" @click="clickToAddPart">新增</el-button>
  11. </header>
  12. <div class="layout_main layout_el-table">
  13. <el-table :data="tempData.slice((shuJu.currentPage - 1) * 30, shuJu.currentPage * 30)"
  14. highlight-current-row>
  15. <el-table-column label="编码" prop="code"></el-table-column>
  16. <el-table-column label="名称" prop="name"></el-table-column>
  17. <el-table-column label="操作">
  18. <template #default="scope">
  19. <el-popconfirm
  20. cancel-button-text="取消"
  21. confirm-button-text="确认"
  22. icon="Info"
  23. iconColor="#F56C6C"
  24. title="是否删除该手术"
  25. @confirm="delPart(scope.$index, scope.row.code)"
  26. >
  27. <template #reference>
  28. <el-button icon="Delete" size="small" type="danger">删除</el-button>
  29. </template>
  30. </el-popconfirm>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. <el-pagination :current-page="shuJu.currentPage"
  35. :page-size="30"
  36. :total="shuJu.total"
  37. background
  38. layout=" prev, pager, next,total"
  39. @current-change="fanYe"/>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup>
  44. import {addASurgicalSite, huoQuShouShuBuWei, removeSurgicalSite} from '@/api/zhu-yuan-yi-sheng/shou-shu-shen-qing'
  45. import {computed} from 'vue'
  46. import {stringIsBlank} from '@/utils/blank-utils'
  47. import {ElMessage} from 'element-plus'
  48. const shouShuBuWeiBianMa = ref('')
  49. const shuJu = ref({
  50. data: [],
  51. currentPage: 1,
  52. total: 0,
  53. })
  54. const newPart = ref('')
  55. const tempData = computed(() => {
  56. shuJu.value.total = shuJu.value.data.length
  57. return shuJu.value.data.filter((item) => {
  58. return item.name.toString().indexOf(shouShuBuWeiBianMa.value) > -1
  59. })
  60. })
  61. const fanYe = (val) => {
  62. shuJu.value.currentPage = val
  63. }
  64. const clickToAddPart = () => {
  65. if (stringIsBlank(newPart.value)) {
  66. ElMessage.error('请先输入部位名称')
  67. return
  68. }
  69. addASurgicalSite(newPart.value).then((res) => {
  70. shuJu.value.data.push({
  71. code: res,
  72. name: newPart.value,
  73. })
  74. newPart.value = ''
  75. })
  76. }
  77. const delPart = (index, code) => {
  78. removeSurgicalSite(code).then(() => {
  79. shuJu.value.data.splice(index, 1)
  80. })
  81. }
  82. onMounted(() => {
  83. huoQuShouShuBuWei(shouShuBuWeiBianMa.value).then((res) => {
  84. shuJu.value.data = res
  85. shuJu.value.total = shuJu.value.data.length
  86. })
  87. })
  88. </script>