2024-11-21 14:42:26 +08:00
|
|
|
<template>
|
2025-02-13 16:15:26 +08:00
|
|
|
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="1400px">
|
|
|
|
|
<TestScriptDetail :options="secondLevelOptions" />
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div>
|
|
|
|
|
<el-button @click="close()">取 消</el-button>
|
|
|
|
|
<el-button type="primary" @click="save()">保存脚本</el-button>
|
|
|
|
|
<!-- <el-button type="primary" @click='save()'>脚本另存为</el-button> -->
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="基础信息"
|
|
|
|
|
v-model="basicInformation"
|
|
|
|
|
@close="closeInformation"
|
|
|
|
|
v-bind="dialogBig"
|
|
|
|
|
width="500px"
|
|
|
|
|
>
|
|
|
|
|
<div class="dialog-content">
|
|
|
|
|
<el-form :model="formContent" label-width="auto" class="form-one">
|
|
|
|
|
<el-form-item label="脚本名称" prop="name">
|
|
|
|
|
<el-input v-model.trim="formContent.name" placeholder="请输入脚本名称" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="参照标准名称" prop="standardName">
|
|
|
|
|
<el-input v-model.trim="formContent.standardName" placeholder="请输入参照标准名称" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="标准推行年份" prop="standardTime">
|
2024-12-24 20:22:36 +08:00
|
|
|
<el-date-picker
|
2025-02-13 16:15:26 +08:00
|
|
|
v-model="formContent.standardTime"
|
|
|
|
|
type="year"
|
|
|
|
|
placeholder="请选择标准推行年份"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="检测脚本值类型">
|
|
|
|
|
<el-select v-model="formContent.selectedValue" filterable clearable placeholder="请选择值类型">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in dictStore.getDictData('Script_Value_Type')"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div>
|
|
|
|
|
<el-button @click="closeInformation()">取 消</el-button>
|
|
|
|
|
<el-button type="primary">确定</el-button>
|
|
|
|
|
<!-- <el-button type="primary" @click='save()'>脚本另存为</el-button> -->
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-dialog>
|
2024-11-21 14:42:26 +08:00
|
|
|
</template>
|
2025-02-13 16:15:26 +08:00
|
|
|
<script setup lang="ts">
|
2024-12-24 20:22:36 +08:00
|
|
|
import { dialogBig } from '@/utils/elementBind'
|
2025-02-13 16:15:26 +08:00
|
|
|
import { computed, ref } from 'vue'
|
2024-12-24 20:22:36 +08:00
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2025-02-13 16:15:26 +08:00
|
|
|
import TestScriptDetail from '@/views/machine/testScript/components/testScriptDetail.vue'
|
|
|
|
|
import { type TestScript } from '@/api/device/interface/testScript'
|
|
|
|
|
import type { Dict } from '@/api/system/dictionary/interface'
|
2025-02-14 16:22:45 +08:00
|
|
|
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
|
2025-02-13 16:15:26 +08:00
|
|
|
import type { CascaderOption } from 'element-plus'
|
2024-12-24 20:22:36 +08:00
|
|
|
const modeId = ref()
|
2025-02-13 16:15:26 +08:00
|
|
|
const secondLevelOptions: any[] = []
|
|
|
|
|
const basicInformation: boolean = ref(false)
|
2024-11-21 14:42:26 +08:00
|
|
|
// 定义弹出组件元信息
|
|
|
|
|
const dialogFormRef = ref()
|
2024-12-24 20:22:36 +08:00
|
|
|
const dictStore = useDictStore()
|
2025-02-13 16:15:26 +08:00
|
|
|
function useMetaInfo() {
|
2024-11-21 14:42:26 +08:00
|
|
|
const dialogVisible = ref(false)
|
2024-12-24 20:22:36 +08:00
|
|
|
const titleType = ref('add')
|
|
|
|
|
const formContent = ref<TestScript.ResTestScript>({
|
2025-02-13 16:15:26 +08:00
|
|
|
name: '',
|
2024-12-24 20:22:36 +08:00
|
|
|
type: '',
|
2025-02-13 16:15:26 +08:00
|
|
|
valueType: '',
|
2024-12-24 20:22:36 +08:00
|
|
|
pattern: modeId.value,
|
|
|
|
|
standardName: '',
|
|
|
|
|
standardTime: '',
|
2025-02-13 16:15:26 +08:00
|
|
|
state: 1,
|
|
|
|
|
selectedValue: ''
|
2024-12-24 20:22:36 +08:00
|
|
|
})
|
2025-02-13 16:15:26 +08:00
|
|
|
return { dialogVisible, titleType, formContent }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
2024-12-24 20:22:36 +08:00
|
|
|
|
2025-02-13 16:15:26 +08:00
|
|
|
let dialogTitle = computed(() => {
|
2024-12-24 20:22:36 +08:00
|
|
|
return titleType.value === 'add' ? '新增检测脚本' : '编辑检测脚本'
|
2025-02-13 16:15:26 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 清空formContent
|
|
|
|
|
const resetFormContent = () => {
|
2024-11-21 14:42:26 +08:00
|
|
|
formContent.value = {
|
2025-02-13 16:15:26 +08:00
|
|
|
name: '',
|
2024-12-24 20:22:36 +08:00
|
|
|
type: '',
|
2025-02-13 16:15:26 +08:00
|
|
|
valueType: '',
|
2024-12-24 20:22:36 +08:00
|
|
|
pattern: modeId.value,
|
|
|
|
|
standardName: '',
|
|
|
|
|
standardTime: '',
|
2025-02-13 16:15:26 +08:00
|
|
|
state: 1
|
2024-11-21 14:42:26 +08:00
|
|
|
}
|
2025-02-13 16:15:26 +08:00
|
|
|
}
|
2024-11-21 14:42:26 +08:00
|
|
|
|
2025-02-13 16:15:26 +08:00
|
|
|
// 关闭弹窗
|
|
|
|
|
const close = () => {
|
2024-11-21 14:42:26 +08:00
|
|
|
dialogVisible.value = false
|
|
|
|
|
// 清空dialogForm中的值
|
|
|
|
|
resetFormContent()
|
|
|
|
|
// 重置表单
|
|
|
|
|
dialogFormRef.value?.resetFields()
|
2025-02-13 16:15:26 +08:00
|
|
|
}
|
|
|
|
|
// 关闭信息弹框
|
|
|
|
|
const closeInformation = () => {
|
|
|
|
|
basicInformation.value = false
|
2024-11-21 14:42:26 +08:00
|
|
|
}
|
|
|
|
|
|
2025-02-13 16:15:26 +08:00
|
|
|
// 保存数据
|
|
|
|
|
const save = () => {
|
|
|
|
|
basicInformation.value = true
|
|
|
|
|
}
|
2024-11-21 14:42:26 +08:00
|
|
|
|
|
|
|
|
// 打开弹窗,可能是新增,也可能是编辑
|
2025-02-13 16:15:26 +08:00
|
|
|
const open = async (sign: string, row: any, currentMode: string, id: string) => {
|
2025-02-14 16:22:45 +08:00
|
|
|
const dictCode = 'Script_Indicator_Items' // 替换为实际需要的字典代码
|
2025-02-13 16:15:26 +08:00
|
|
|
const resDictTree: Dict.ResDictTree = {
|
2025-02-14 16:22:45 +08:00
|
|
|
name: '',
|
2024-12-26 09:28:19 +08:00
|
|
|
id: '',
|
|
|
|
|
pid: '',
|
|
|
|
|
pids: '',
|
2025-02-14 16:22:45 +08:00
|
|
|
code: dictCode,
|
2024-12-26 09:28:19 +08:00
|
|
|
sort: 0
|
2025-02-13 16:15:26 +08:00
|
|
|
}
|
2025-02-14 16:22:45 +08:00
|
|
|
const result = await getDictTreeByCode(resDictTree)
|
2025-02-13 16:15:26 +08:00
|
|
|
const allOptions = convertToOptions(result.data as Dict.ResDictTree[])
|
|
|
|
|
|
|
|
|
|
secondLevelOptions.push(...(allOptions[0]?.children || []))
|
2024-12-26 09:28:19 +08:00
|
|
|
|
2025-02-13 16:15:26 +08:00
|
|
|
//console.log('secondLevelOptions',secondLevelOptions);
|
2024-12-26 09:28:19 +08:00
|
|
|
|
2025-02-13 16:15:26 +08:00
|
|
|
if (id != '') {
|
|
|
|
|
//新增的时候才会重新赋值值类型
|
|
|
|
|
formContent.value.valueType = id
|
2024-12-26 09:28:19 +08:00
|
|
|
}
|
2024-12-24 20:22:36 +08:00
|
|
|
titleType.value = sign
|
2025-02-13 16:15:26 +08:00
|
|
|
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
2024-12-26 09:28:19 +08:00
|
|
|
|
2024-11-21 14:42:26 +08:00
|
|
|
// 重置表单
|
|
|
|
|
dialogFormRef.value?.resetFields()
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
}
|
2024-12-26 09:28:19 +08:00
|
|
|
|
2025-02-13 16:15:26 +08:00
|
|
|
// 转换函数
|
|
|
|
|
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
2024-12-26 09:28:19 +08:00
|
|
|
return dictTree.map(item => ({
|
|
|
|
|
value: item.id,
|
|
|
|
|
label: item.name,
|
|
|
|
|
children: item.children ? convertToOptions(item.children) : undefined
|
2025-02-13 16:15:26 +08:00
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-21 14:42:26 +08:00
|
|
|
// 对外映射
|
|
|
|
|
defineExpose({ open })
|
2024-12-24 20:22:36 +08:00
|
|
|
</script>
|
|
|
|
|
<style scoped>
|
|
|
|
|
/* .dialog-content {
|
|
|
|
|
padding: 10px;
|
|
|
|
|
} */
|
2025-02-13 16:15:26 +08:00
|
|
|
</style>
|