edit-formula-dialog.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <hc-dialog v-model="isShow" is-footer-center title=" 元素公式(WBS级)" widths="56rem" :loading="submitLoading" :footer="false" @close="dialogClose" @save="saveElementHandle">
  3. <hc-search-input v-model="queryValue" class="mb-4 w-100" @search="getEditEleList" />
  4. <hc-table :column="tableColumn" :datas="editEleList" :loading="tableLoading">
  5. <template #action="{ row, index }">
  6. <el-link type="warning">全局公式</el-link>
  7. <el-link type="primary">节点公式</el-link>
  8. </template>
  9. </hc-table>
  10. </hc-dialog>
  11. </template>
  12. <script setup>
  13. import { ref, watch } from 'vue'
  14. import mainApi from '~api/wbs/wbsforelement'
  15. import { getArrValue } from 'js-fast-way'
  16. const props = defineProps({
  17. tableId: {
  18. type: String,
  19. default: '',
  20. },
  21. })
  22. //事件
  23. const emit = defineEmits(['close'])
  24. //双向绑定
  25. // eslint-disable-next-line no-undef
  26. const isShow = defineModel('modelValue', {
  27. default: false,
  28. })
  29. //监听显示
  30. watch(isShow, (val) => {
  31. if (val) {
  32. getEditEleList()
  33. } else {
  34. emit('close')
  35. }
  36. })
  37. const tableId = ref(props.tableId)
  38. //监听数据
  39. watch(
  40. () => [props.tableId],
  41. ([tid]) => {
  42. tableId.value = tid
  43. },
  44. { deep: true },
  45. )
  46. //关闭弹窗
  47. const dialogClose = () => {
  48. isShow.value = false
  49. emit('close')
  50. }
  51. const submitLoading = ref(false)
  52. const saveElementHandle = async () => {}
  53. const tableColumn = [
  54. { key: 'eName', name: '元素名称' },
  55. { key: 'action', name: '操作', width: 150, align: 'center' },
  56. ]
  57. const tableLoading = ref(false)
  58. const editEleList = ref([])
  59. const queryValue = ref('')
  60. const getEditEleList = async () => {
  61. tableLoading.value = true
  62. const { data } = await mainApi.getTableElements({
  63. id: tableId.value,
  64. search: queryValue.value,
  65. type: 1,
  66. })
  67. tableLoading.value = false
  68. editEleList.value = getArrValue(data)
  69. }
  70. </script>