8
0

test-collect.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <hc-card title="试验汇总分类配置">
  3. <template #extra>
  4. <el-button hc-btn type="primary" @click="addRowClick">新增</el-button>
  5. </template>
  6. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
  7. <template #action="{ row }">
  8. <el-link type="primary" @click="editRowClick(row)">编辑</el-link>
  9. <el-link type="warning" @click="partitioningClick(row)">配置划分</el-link>
  10. <el-link type="success" @click="associationList(row)">关联清表</el-link>
  11. <el-link type="info">数据映射配置</el-link>
  12. <el-link type="danger" @click="delRowClick(row)">删除</el-link>
  13. </template>
  14. </hc-table>
  15. <template #action>
  16. <hc-pages :pages="searchForm" @change="pageChange" />
  17. </template>
  18. <!-- 新增/修改 -->
  19. <hc-dialog v-model="isRowInfoShow" widths="400px" is-footer-center :title="isNullES(formModel.id) ? '新增' : '修改'" @close="rowInfoClose">
  20. <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="top" label-width="auto" size="large">
  21. <el-form-item label="分类名称:" prop="className">
  22. <el-input v-model="formModel.className" clearable placeholder="请输入分类名称" />
  23. </el-form-item>
  24. </el-form>
  25. <template #footer>
  26. <el-button hc-btn @click="rowInfoClose">取消</el-button>
  27. <el-button hc-btn type="primary" :loading="rowInfoLoading" @click="rowInfoSubmit">提交</el-button>
  28. </template>
  29. </hc-dialog>
  30. <!-- 配置划分 -->
  31. <HcPartitioning v-model="isPartitioningShow" :data="partitioningData" @close="partitioningClose" @finish="getTableData" />
  32. <!-- 关联清表 -->
  33. <HcAssociationList
  34. v-model="isAssociationShow"
  35. :info="associationInfo"
  36. :type="3"
  37. />
  38. </hc-card>
  39. </template>
  40. <script setup>
  41. import { nextTick, onActivated, ref } from 'vue'
  42. import { deepClone, formValidate, getArrValue, isNullES } from 'js-fast-way'
  43. import { HcDelMsg } from 'hc-vue3-ui'
  44. import HcPartitioning from './test-collect/partitioning.vue'
  45. import mainApi from '~api/desk/test-collect'
  46. import HcAssociationList from '../project/list/association-list.vue'
  47. //激活
  48. onActivated(() => {
  49. searchClick()
  50. })
  51. //搜索表单
  52. const searchForm = ref({ current: 1, size: 30, total: 0 })
  53. //搜索
  54. const searchClick = () => {
  55. searchForm.value.current = 1
  56. getTableData()
  57. }
  58. //分页
  59. const pageChange = ({ current, size }) => {
  60. searchForm.value.current = current
  61. searchForm.value.size = size
  62. getTableData()
  63. }
  64. //表格数据
  65. const tableData = ref([])
  66. const tableColumn = ref([
  67. { key: 'className', name: '分类名称' },
  68. { key: 'action', name: '操作', width: 320, align: 'center' },
  69. ])
  70. //获取表格数据
  71. const tableLoading = ref(false)
  72. const getTableData = async () => {
  73. tableData.value = []
  74. tableLoading.value = true
  75. const { data } = await mainApi.page({
  76. ...searchForm.value,
  77. total: null,
  78. })
  79. tableLoading.value = false
  80. tableData.value = getArrValue(data?.records)
  81. searchForm.value.total = data?.total || 0
  82. }
  83. //新增
  84. const addRowClick = () => {
  85. formModel.value = {}
  86. isRowInfoShow.value = true
  87. }
  88. //编辑
  89. const editRowClick = (item) => {
  90. formModel.value = deepClone(item)
  91. isRowInfoShow.value = true
  92. }
  93. //新增编辑弹窗
  94. const isRowInfoShow = ref(false)
  95. const rowInfoLoading = ref(false)
  96. //表单
  97. const formRef = ref(null)
  98. const formModel = ref({})
  99. const formRules = { className: { required: true, trigger: 'blur', message: '请输入分类名称' } }
  100. //确认提交
  101. const rowInfoSubmit = async () => {
  102. const isForm = await formValidate(formRef.value)
  103. if (!isForm) return
  104. rowInfoLoading.value = true
  105. const { isRes } = await mainApi.submit(formModel.value)
  106. rowInfoLoading.value = false
  107. if (!isRes) return
  108. window.$message.success('操作成功')
  109. rowInfoClose()
  110. getTableData().then()
  111. }
  112. //关闭表单
  113. const rowInfoClose = () => {
  114. isRowInfoShow.value = false
  115. rowInfoLoading.value = false
  116. formModel.value = {}
  117. }
  118. //删除
  119. const delRowClick = (item) => {
  120. HcDelMsg(async (resolve) => {
  121. const { isRes } = await mainApi.del(item.id)
  122. resolve() //关闭弹窗的回调
  123. if (!isRes) return
  124. window.$message.success('删除成功')
  125. getTableData().then()
  126. })
  127. }
  128. //配置划分
  129. const isPartitioningShow = ref(false)
  130. const partitioningData = ref({})
  131. const partitioningClick = async (item) => {
  132. partitioningData.value = deepClone(item)
  133. await nextTick()
  134. isPartitioningShow.value = true
  135. }
  136. //关闭 配置划分
  137. const partitioningClose = () => {
  138. isPartitioningShow.value = false
  139. partitioningData.value = {}
  140. }
  141. //关联清表
  142. const isAssociationShow = ref(false)
  143. const associationInfo = ref({})
  144. const associationList = async (item) => {
  145. associationInfo.value = item
  146. await nextTick()
  147. isAssociationShow.value = true
  148. }
  149. </script>
  150. <style lang="scss">
  151. </style>