2026-05-13 17:50:49 +08:00

93 lines
2.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file index.vue 规则设定
* @author: w
* @since: 2025-12-29
*/
<template>
<div class="app-container">
<div class="table-toolbar">
<el-button type="success" plain icon="Check" @click="handleSave">保存</el-button>
</div>
<div class="tips">说明:1_2S作为一个警告规则,如果选中这个规则,则表示所有其他失控规则必须先满足说明:25,则视为在控。</div>
<div class="table-row" style="margin-top: 10px;">
<CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig"
@selection-change="handleSelectionChange" />
</div>
</div>
</template>
<script setup lang="ts">
import { saveOpt } from '@/api/liswork/qualityControl'
// import { getDictData, dictData } from '@/hooks'
import { getComDicts } from '@/api/liswork/dict/ComDict'
import { queryValue } from '@/api/liswork/xtwh/ComOpt'
import { ElMessage } from 'element-plus'
const yq = defineModel<string>()
const tableData = ref<Array<any>>([])
const tableRef = ref()
const columns = [
{ label: '有效', type: 'selection', visible: true, width: 50, align: 'center' },
{ label: '规则', prop: 'zddh', visible: true, width: 200, align: 'center' },
{ label: '规则说明', prop: 'zdmc', visible: true, align: 'center' },
];
const tableConfig = {
border: true,
height: '100%',
highlightCurrentRow: true,
}
const zddhStr = ref<string>('')
const handleSelectionChange = (selection: any) => {
zddhStr.value = selection.map((item: any) => { return item.zddh }).join(',')
}
const handleSave = () => {
if (!zddhStr.value) return ElMessage.warning('请至少选择一项规则')
saveOpt([{ yq: yq.value, xxqz: zddhStr.value, xxdh: 'QCRULES' }]).then((res: any) => {
if (res.code == 0) {
ElMessage.success('保存成功')
}
})
}
const getRuleList = () => {
getComDicts({ zdlb: 'ZKGZ' }).then((res: any) => {
tableData.value = res.data || []
queryValue({ yq: yq.value, xxdh: 'QCRULES' }).then((res: any) => {
tableRef.value.clearSelection()
if (res.data) {
const arr = res.data.split(',')
arr.forEach((item: any) => {
const index = tableData.value.findIndex((val: any) => val.zddh === item)
if (index > -1) {
tableRef.value.toggleRowSelection(tableData.value[index], true)
}
})
}
})
})
}
watch(yq, (val) => {
if (val) {
getRuleList()
}
}, { immediate: true })
</script>
<style scoped lang="scss">
.table-row {
height: calc(100% - 135px);
}
.tips {
font-family: SourceHanSansCN, SourceHanSansCN;
font-size: 16px;
color: #409eff;
font-weight: 600;
}
</style>