123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <hc-card title="试验汇总分类配置">
- <template #extra>
- <el-button hc-btn type="primary" @click="addRowClick">新增</el-button>
- </template>
- <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
- <template #action="{ row }">
- <el-link type="primary" @click="editRowClick(row)">编辑</el-link>
- <el-link type="warning" @click="partitioningClick(row)">配置划分</el-link>
- <el-link type="success" @click="associationList(row)">关联清表</el-link>
- <el-link type="info">数据映射配置</el-link>
- <el-link type="danger" @click="delRowClick(row)">删除</el-link>
- </template>
- </hc-table>
- <template #action>
- <hc-pages :pages="searchForm" @change="pageChange" />
- </template>
- <!-- 新增/修改 -->
- <hc-dialog v-model="isRowInfoShow" widths="400px" is-footer-center :title="isNullES(formModel.id) ? '新增' : '修改'" @close="rowInfoClose">
- <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="top" label-width="auto" size="large">
- <el-form-item label="分类名称:" prop="className">
- <el-input v-model="formModel.className" clearable placeholder="请输入分类名称" />
- </el-form-item>
- </el-form>
- <template #footer>
- <el-button hc-btn @click="rowInfoClose">取消</el-button>
- <el-button hc-btn type="primary" :loading="rowInfoLoading" @click="rowInfoSubmit">提交</el-button>
- </template>
- </hc-dialog>
- <!-- 配置划分 -->
- <HcPartitioning v-model="isPartitioningShow" :data="partitioningData" @close="partitioningClose" @finish="getTableData" />
- <!-- 关联清表 -->
- <HcAssociationList
- v-model="isAssociationShow"
- :info="associationInfo"
- :type="3"
- />
- </hc-card>
- </template>
- <script setup>
- import { nextTick, onActivated, ref } from 'vue'
- import { deepClone, formValidate, getArrValue, isNullES } from 'js-fast-way'
- import { HcDelMsg } from 'hc-vue3-ui'
- import HcPartitioning from './test-collect/partitioning.vue'
- import mainApi from '~api/desk/test-collect'
- import HcAssociationList from '../project/list/association-list.vue'
- //激活
- onActivated(() => {
- searchClick()
- })
- //搜索表单
- const searchForm = ref({ current: 1, size: 30, total: 0 })
- //搜索
- const searchClick = () => {
- searchForm.value.current = 1
- getTableData()
- }
- //分页
- const pageChange = ({ current, size }) => {
- searchForm.value.current = current
- searchForm.value.size = size
- getTableData()
- }
- //表格数据
- const tableData = ref([])
- const tableColumn = ref([
- { key: 'className', name: '分类名称' },
- { key: 'action', name: '操作', width: 320, align: 'center' },
- ])
- //获取表格数据
- const tableLoading = ref(false)
- const getTableData = async () => {
- tableData.value = []
- tableLoading.value = true
- const { data } = await mainApi.page({
- ...searchForm.value,
- total: null,
- })
- tableLoading.value = false
- tableData.value = getArrValue(data?.records)
- searchForm.value.total = data?.total || 0
- }
- //新增
- const addRowClick = () => {
- formModel.value = {}
- isRowInfoShow.value = true
- }
- //编辑
- const editRowClick = (item) => {
- formModel.value = deepClone(item)
- isRowInfoShow.value = true
- }
- //新增编辑弹窗
- const isRowInfoShow = ref(false)
- const rowInfoLoading = ref(false)
- //表单
- const formRef = ref(null)
- const formModel = ref({})
- const formRules = { className: { required: true, trigger: 'blur', message: '请输入分类名称' } }
- //确认提交
- const rowInfoSubmit = async () => {
- const isForm = await formValidate(formRef.value)
- if (!isForm) return
- rowInfoLoading.value = true
- const { isRes } = await mainApi.submit(formModel.value)
- rowInfoLoading.value = false
- if (!isRes) return
- window.$message.success('操作成功')
- rowInfoClose()
- getTableData().then()
- }
- //关闭表单
- const rowInfoClose = () => {
- isRowInfoShow.value = false
- rowInfoLoading.value = false
- formModel.value = {}
- }
- //删除
- const delRowClick = (item) => {
- HcDelMsg(async (resolve) => {
- const { isRes } = await mainApi.del(item.id)
- resolve() //关闭弹窗的回调
- if (!isRes) return
- window.$message.success('删除成功')
- getTableData().then()
- })
- }
- //配置划分
- const isPartitioningShow = ref(false)
- const partitioningData = ref({})
- const partitioningClick = async (item) => {
- partitioningData.value = deepClone(item)
- await nextTick()
- isPartitioningShow.value = true
- }
- //关闭 配置划分
- const partitioningClose = () => {
- isPartitioningShow.value = false
- partitioningData.value = {}
- }
- //关联清表
- const isAssociationShow = ref(false)
- const associationInfo = ref({})
- const associationList = async (item) => {
- associationInfo.value = item
- await nextTick()
- isAssociationShow.value = true
- }
- </script>
- <style lang="scss">
- </style>
|