|
@@ -1,6 +1,6 @@
|
|
|
<script setup>
|
|
|
import { CirclePlus } from '@element-plus/icons-vue'
|
|
|
-
|
|
|
+import { ElMessageBox } from 'element-plus'
|
|
|
import { getWorkFlowList, getAllWaterFactoryList, getPositionList, getAssayList, putWorkFlow, postWorkFlow, delWorkFlow } from '@/api/configuration'
|
|
|
import { getAllDeviceList} from '@/api/client/manage'
|
|
|
|
|
@@ -20,6 +20,8 @@ const deviceOptions = ref([]);
|
|
|
const pointOptions = ref([]);
|
|
|
const assayOptions = ref([]);
|
|
|
|
|
|
+const assayItems = ref([]);
|
|
|
+
|
|
|
const formData = ref({});
|
|
|
const formRef = ref(null);
|
|
|
|
|
@@ -30,7 +32,24 @@ const rules = {
|
|
|
code: { required: true, message: '请输入化验流程编号', trigger: 'blur' },
|
|
|
deviceId: { required: true, message: '请选择所属设备', trigger: 'blur' },
|
|
|
totalSteps: { required: true, message: '化验总步数', trigger: 'blur' },
|
|
|
- items: { type: 'array', required: true, message: '请添加化验内容', trigger: 'blur' }
|
|
|
+ items: { validator: (rule, any, callback) => {
|
|
|
+ if ( !assayItems.value.length ) {
|
|
|
+ callback(new Error('请添加化验内容'))
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ }, trigger: 'blur'}
|
|
|
+}
|
|
|
+
|
|
|
+// 设备 - list
|
|
|
+const initDeviceOptions = (deviceWorks) => {
|
|
|
+ deviceOptions.value = [];
|
|
|
+ getAllDeviceList({ deviceWorks }).then(({ data }) => deviceOptions.value = data)
|
|
|
+}
|
|
|
+
|
|
|
+// 点位 - list
|
|
|
+const initPositonOptions = (params = {}) => {
|
|
|
+ pointOptions.value = [];
|
|
|
+ getPositionList({ pageNum: 1, pageSize: 10000, ...params }).then(({ rows }) => pointOptions.value = rows)
|
|
|
}
|
|
|
|
|
|
const initPageData = async () => {
|
|
@@ -42,9 +61,9 @@ const initPageData = async () => {
|
|
|
...val,
|
|
|
items: val.items.map(item => ({
|
|
|
...item,
|
|
|
- itemId: item.id,
|
|
|
+ itemId: item.itemId,
|
|
|
itemName: item.assayItem?.name,
|
|
|
- positionId: item.position?.id,
|
|
|
+ positionId: item.positionId,
|
|
|
positionName: item.position?.name,
|
|
|
workflowId: val.id
|
|
|
}))
|
|
@@ -72,6 +91,9 @@ const handleReset = () => {
|
|
|
// 编辑流程
|
|
|
const handleTableEdit = (row) => {
|
|
|
formData.value = { ...row };
|
|
|
+ assayItems.value = [...row.items ];
|
|
|
+ initDeviceOptions(row?.organization?.id);
|
|
|
+ initPositonOptions({deviceId: row?.bizDevice.deviceId});
|
|
|
dialogVisible.value = true;
|
|
|
}
|
|
|
|
|
@@ -80,7 +102,8 @@ const handleDialogConfirm = async () => {
|
|
|
if (!formRef.value) return
|
|
|
await formRef.value.validate(async(valid, fields) => {
|
|
|
if (valid) {
|
|
|
- formData.value.id ? await putWorkFlow(formData.value) : await postWorkFlow(formData.value);
|
|
|
+ const parmas = { ...formData.value, items: assayItems.value };
|
|
|
+ formData.value.id ? await putWorkFlow(parmas) : await postWorkFlow(parmas);
|
|
|
formRef.value.resetFields();
|
|
|
dialogVisible.value = false;
|
|
|
proxy.$modal.msgSuccess("操作成功");
|
|
@@ -94,19 +117,27 @@ const handleDialogConfirm = async () => {
|
|
|
// Dialog - 重置表单
|
|
|
const handleDialogReset = () => {
|
|
|
formData.value = {};
|
|
|
+ deviceOptions.value = [];
|
|
|
+ assayItems.value = [];
|
|
|
formRef.value.resetFields();
|
|
|
}
|
|
|
|
|
|
// Dialog - 新增行
|
|
|
const handleAddRow = () => {
|
|
|
- const { itemId, positionId, id: workflowId } = formData.value;
|
|
|
- if ( !itemId ) {
|
|
|
- return proxy.$modal.msgError("请先选择化验项目");
|
|
|
+ const { organizationId, deviceId, itemId, positionId, id: workflowId } = formData.value;
|
|
|
+ if (!organizationId) {
|
|
|
+ return proxy.$modal.msgError("请先选择所属水厂");
|
|
|
+ }
|
|
|
+ if (!deviceId) {
|
|
|
+ return proxy.$modal.msgError("请先选择所属设备");
|
|
|
}
|
|
|
if ( !positionId ) {
|
|
|
return proxy.$modal.msgError("请先选择取样点位");
|
|
|
}
|
|
|
- formRef.value.validate("items");
|
|
|
+ if ( !itemId ) {
|
|
|
+ return proxy.$modal.msgError("请先选择化验项目");
|
|
|
+ }
|
|
|
+ formRef.value.clearValidate("items");
|
|
|
const params = {
|
|
|
itemId,
|
|
|
itemName: assayOptions.value.find(({ id }) => id === itemId).name,
|
|
@@ -114,8 +145,7 @@ const handleAddRow = () => {
|
|
|
positionName: pointOptions.value.find(({ id }) => id === positionId).name,
|
|
|
workflowId
|
|
|
}
|
|
|
- if ( !formData.value.items?.length ) formData.value.items = [];
|
|
|
- formData.value.items.push(params);
|
|
|
+ assayItems.value.push(params);
|
|
|
}
|
|
|
|
|
|
// Table - 删除
|
|
@@ -128,18 +158,63 @@ const handleDelete = async ({ id }) => {
|
|
|
|
|
|
// Tag - 删除行
|
|
|
const handleCloseTag = (index) => {
|
|
|
- formData.value.items.splice(index, 1);
|
|
|
+ assayItems.value.splice(index, 1);
|
|
|
+}
|
|
|
+
|
|
|
+// Dialog - 选择水厂 - change
|
|
|
+const onWaterFactorySelectChange = (deviceWorks) => {
|
|
|
+ if ( assayItems.value.length > 0 ) {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '切换水厂后将清空化验内容,是否切换?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ formData.value.positionId = '';
|
|
|
+ formData.value.itemId = '';
|
|
|
+ assayItems.value = [];
|
|
|
+ formData.value.deviceId = '';
|
|
|
+ pointOptions.value = [];
|
|
|
+ initDeviceOptions(deviceWorks);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ assayItems.value = [];
|
|
|
+ formData.value.deviceId = '';
|
|
|
+ initDeviceOptions(deviceWorks);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Dialog - 选择设备 - change
|
|
|
+const onDeviceSelectChange = (deviceId) => {
|
|
|
+ if ( assayItems.value?.length > 0 ) {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '切换设备后将清空化验内容,是否切换?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ formData.value.positionId = '';
|
|
|
+ formData.value.itemId = '';
|
|
|
+ assayItems.value = [];
|
|
|
+ initPositonOptions({ deviceId })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ assayItems.value = [];
|
|
|
+ initPositonOptions({ deviceId })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
onMounted(async () => {
|
|
|
// 水厂
|
|
|
getAllWaterFactoryList().then(({ data }) => waterFactoryOptions.value = data)
|
|
|
- // 设备
|
|
|
- getAllDeviceList().then(({ data }) => deviceOptions.value = data)
|
|
|
// 化验项目
|
|
|
getAssayList({ pageNum: 1, pageSize: 9999 }).then(({ rows }) => assayOptions.value = rows)
|
|
|
- // 点位
|
|
|
- getPositionList({ pageNum: 1, pageSize: 10000 }).then(({ rows }) => pointOptions.value = rows)
|
|
|
// 初始化数据
|
|
|
initPageData();
|
|
|
})
|
|
@@ -233,7 +308,7 @@ onMounted(async () => {
|
|
|
</el-col>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="所属水厂" prop="organizationId">
|
|
|
- <el-select v-model="formData.organizationId" placeholder="请选择所属水厂" filterable clearable>
|
|
|
+ <el-select v-model="formData.organizationId" placeholder="请选择所属水厂" filterable clearable @change="onWaterFactorySelectChange">
|
|
|
<el-option v-for="item in waterFactoryOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
@@ -245,7 +320,7 @@ onMounted(async () => {
|
|
|
</el-col>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="所属设备" prop="deviceId">
|
|
|
- <el-select v-model="formData.deviceId" placeholder="请选所属设备" filterable clearable>
|
|
|
+ <el-select v-model="formData.deviceId" placeholder="请选所属设备" filterable clearable @change="onDeviceSelectChange">
|
|
|
<el-option v-for="item in deviceOptions" :key="item.deviceId" :label="item.deviceName" :value="item.deviceId" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
@@ -262,13 +337,14 @@ onMounted(async () => {
|
|
|
<el-form-item label="化验内容" prop="items">
|
|
|
<el-row class="w-full" :gutter="20">
|
|
|
<el-col :span="8">
|
|
|
- <el-select v-model="formData.itemId" placeholder="请选择化验项目" filterable clearable>
|
|
|
- <el-option v-for="item in assayOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
+ <el-select v-model="formData.positionId" placeholder="请选择取样点位" filterable clearable>
|
|
|
+ <el-option v-for="item in pointOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
</el-select>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-select v-model="formData.positionId" placeholder="请选择取样点位" filterable clearable>
|
|
|
- <el-option v-for="item in pointOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
+ {{ formData.itemId }}
|
|
|
+ <el-select v-model="formData.itemId" placeholder="请选择化验项目" filterable clearable>
|
|
|
+ <el-option v-for="item in assayOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
</el-select>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
@@ -276,7 +352,7 @@ onMounted(async () => {
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<div class="w-full min-h-[100px] px-[10px] py-[10px] mt-[30px] bg-[#f3f5f9] space-x-[10px]">
|
|
|
- <el-tag v-for="item, index in formData.items" :key="index" closable type="primary" @close="handleCloseTag(index)">
|
|
|
+ <el-tag v-for="item, index in assayItems" :key="index" closable type="primary" @close="handleCloseTag(index)">
|
|
|
<span>{{ item.itemName }}({{ item.positionName }})</span>
|
|
|
</el-tag>
|
|
|
</div>
|