surveyTab.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div>
  3. <CostAuditTable
  4. :table-data="surveyData.list"
  5. :columns="getSurveyColumns()"
  6. :show-index="true"
  7. :show-action-column="true"
  8. ></CostAuditTable>
  9. <!-- 成本调查表查看弹窗 -->
  10. <SurveyDialog
  11. :dialog-visible="contentEditDialogVisible"
  12. :dialog-title="contentEditDialogTitle"
  13. :form-data="contentEditForm"
  14. :disabled="contentEditDisabled"
  15. @cancel="handleContentEditCancel"
  16. />
  17. </div>
  18. </template>
  19. <script>
  20. import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
  21. import SurveyDialog from '@/views/costAudit/baseInfo/catalogManage/surveyDialog.vue'
  22. export default {
  23. components: {
  24. CostAuditTable,
  25. SurveyDialog,
  26. },
  27. props: {
  28. // 父组件传递的参数
  29. project: {
  30. type: Object,
  31. default: () => {},
  32. },
  33. isView: {
  34. type: Boolean,
  35. default: false,
  36. },
  37. surveyData: {
  38. type: Object,
  39. default: () => {},
  40. },
  41. },
  42. data() {
  43. return {
  44. // 内容编辑弹窗相关
  45. contentEditDialogVisible: false,
  46. contentEditDialogTitle: '内容维护',
  47. contentEditDisabled: true,
  48. contentEditForm: {
  49. surveyTemplateName: '',
  50. templateType: '1',
  51. // 单记录列表
  52. tableHeaders: [],
  53. // 固定表列表
  54. fixedTable: [],
  55. // 动态表列表
  56. dynamicTable: [],
  57. },
  58. }
  59. },
  60. mounted() {
  61. // this.getSurveyData()
  62. },
  63. methods: {
  64. // 获取带操作按钮的表格列配置
  65. getSurveyColumns() {
  66. const columns = JSON.parse(
  67. JSON.stringify(this.surveyData.surveyColumns || [])
  68. )
  69. const actionColumn = columns.find((col) => col.prop === 'action')
  70. if (actionColumn) {
  71. actionColumn.actions = [
  72. {
  73. name: 'view',
  74. label: '查看模板',
  75. type: 'text',
  76. onClick: this.handleViewTemplate,
  77. },
  78. ]
  79. }
  80. return columns
  81. },
  82. // 查看成本调查表内容弹窗
  83. handleViewTemplate(data) {
  84. // 设置表单数据
  85. this.contentEditForm = {
  86. surveyTemplateName: data.surveyTemplateName || '',
  87. templateType: data.templateType || '',
  88. data:
  89. {
  90. ...data,
  91. surveyId: data.surveyTemplateId,
  92. } || {},
  93. }
  94. // 设置弹窗标题
  95. this.contentEditDialogTitle = '查看'
  96. // 显示弹窗
  97. this.contentEditDialogVisible = true
  98. },
  99. // 关闭内容编辑弹窗
  100. handleContentEditCancel() {
  101. this.contentEditDialogVisible = false
  102. // 重置表单数据
  103. this.contentEditForm = {
  104. surveyTemplateName: '',
  105. templateType: '1',
  106. tableHeaders: [],
  107. fixedTable: [],
  108. dynamicTable: [],
  109. }
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="scss" scoped></style>