This commit is contained in:
sjl
2024-12-05 13:51:47 +08:00
parent f06a8d6b15
commit 5bdc44b301
4 changed files with 57 additions and 26 deletions

View File

@@ -40,16 +40,15 @@
<script lang="ts" setup>
import { ref, reactive, computed, onMounted, watch } from "vue";
import { useAuthStore } from "@/stores/modules/auth";
const title = ref("模拟式模块");
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
import { useRouter } from "vue-router";
const title = ref("模拟式模块");
const router = useRouter();
const authStore = useAuthStore();
const modeStore = useModeStore();
watch(() => modeStore.currentMode, (newVal) => {
//console.log('当前模式:', newVal);
switch (newVal) {
onMounted(() => {
switch (modeStore.currentMode) {
case '模拟式':
title.value = '模拟式模块';
break;

View File

@@ -11,18 +11,18 @@
>
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
<el-button v-auth.testSource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增
<el-button :disabled="isDisable" v-auth.testSource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增
</el-button>
<el-button v-auth.testSource="'delete'" type='danger' :icon='Delete'
plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
plain :disabled='isDisable || !scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
删除
</el-button>
</template>
<!-- 表格操作 -->
<template #operation='scope'>
<el-button type="primary" link :icon='CopyDocument' @click="copyRow(scope.row)">复制</el-button>
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row.id)'>删除</el-button>
<!-- <el-button type="primary" link :icon='CopyDocument' @click="copyRow(scope.row)">复制</el-button> -->
<el-button :disabled="isDisable" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
<el-button :disabled="isDisable" type='primary' link :icon='Delete' @click='handleDelete(scope.row.id)'>删除</el-button>
</template>
</ProTable>
@@ -40,15 +40,23 @@ import ParameterPopup from '@/views/machine/testSource/components/parameterPopup
import {reactive, ref, watch} from 'vue'
import {generateUUID} from "@/styles";
import {defineEmits} from "vue/dist/vue";
import { ElMessage } from 'element-plus'
const parameterPopup = ref()
const dictStore = useDictStore()
// ProTable 实例
const proTable = ref<ProTableInstance>()
const tableData = ref<any[]>([])
const props = defineProps<{
parameterStr: string;
}>();
const props = defineProps({
parameterStr: {
type: String,
required: true,
},
isDisable: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['change-parameter'])
@@ -105,7 +113,14 @@ const getTreeData = (data: TestSource.ParameterType[]): TestSource.ParameterType
}
const columns = reactive<ColumnProps<any>[]>([
{type: 'selection', fixed: 'left', width: 70},
{type: 'selection', fixed: 'left', width: 70,
selectable(row, index) {
if (props.isDisable) {
return false;
}
return true;
},
},
{type: 'index', fixed: 'left', width: 70, label: '序号'},
{
prop: 'sourceParamType',
@@ -179,6 +194,8 @@ const copyRow = (row) => {
const getParameter = (data: TestSource.ParameterType) => {
let index = originalParameterArr.findIndex(item => item.id === data.id)
if (index === -1) {
data.id = generateUUID()
// 新增
@@ -193,7 +210,7 @@ const getParameter = (data: TestSource.ParameterType) => {
//清空数据
const clearData = () => {
console.log('clearData')
//console.log('clearData')
originalParameterArr = []
tableData.value = []
}

View File

@@ -1,7 +1,7 @@
<template>
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
<div >
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' >
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' :disabled="tableIsDisable">
<el-row :gutter="24">
<!-- <el-col :span="8">-->
<!-- <el-form-item label="检测源名称" prop="name" >-->
@@ -36,11 +36,11 @@
</el-form>
</div>
<ParameterTable :parameterStr="formContent.parameter" @change-parameter="changeParameter" ref="parameterTable"/>
<ParameterTable :parameterStr="formContent.parameter" @change-parameter="changeParameter" ref="parameterTable" :is-disable="tableIsDisable"/>
<template #footer>
<div>
<el-button @click='close()'> </el-button>
<el-button type="primary" @click='save()'>保存</el-button>
<el-button :disabled="tableIsDisable" @click='close()'> </el-button>
<el-button :disabled="tableIsDisable" type="primary" @click='save()'>保存</el-button>
</div>
</template>
</el-dialog>
@@ -61,7 +61,7 @@ const dictStore = useDictStore()
const mode = ref()
const modeId = ref()
const parameterTable = ref()
const tableIsDisable = ref(true)
function useMetaInfo() {
const dialogVisible = ref(false)
@@ -91,8 +91,20 @@ const resetFormContent = () => {
}
let dialogTitle = computed(() => {
return titleType.value === 'add' ? '新增检测源' : '编辑检测源'
})
switch (titleType.value) {
case 'add':
tableIsDisable.value = false
return '新增检测源';
case 'edit':
tableIsDisable.value = false
return '编辑检测源';
case 'view':
tableIsDisable.value = true
return '查看检测源';
default:
return ''; // 默认情况,可选
}
});
let dictTypeCode = computed(() => {
return 'S_Dev_Type_' + dictStore.getDictData('Pattern').find(item => item.id === modeId.value)?.code
@@ -119,6 +131,7 @@ const close = () => {
const save = () => {
try {
dialogFormRef.value?.validate(async (valid: boolean) => {
console.log("11111111111111111")
if (valid) {
if (formContent.value.id) {
await updateTestSource(formContent.value);

View File

@@ -16,6 +16,7 @@
</template>
<!-- 表格操作 -->
<template #operation='scope'>
<el-button type='primary' link :icon='View' @click="openDialog('view', scope.row)">查看</el-button>
<el-button v-auth.testSource="'edit'" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
<el-button v-auth.testSource="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
</template>
@@ -57,7 +58,8 @@
// 表格配置项
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'selection', fixed: 'left', width: 70 ,
},
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'name',