|
@@ -0,0 +1,283 @@
|
|
|
+<template>
|
|
|
+ <hc-dialog
|
|
|
+ v-model="isShow"
|
|
|
+ is-footer-center
|
|
|
+ title=" 节点参数"
|
|
|
+ @close="dialogClose"
|
|
|
+ @save="saveElementHandle"
|
|
|
+ widths="56rem"
|
|
|
+ :loading="submitLoading"
|
|
|
+ >
|
|
|
+ <hc-card-item>
|
|
|
+ <template #extra>
|
|
|
+ <el-button size="small" type="primary" @click="addRowClick"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
+ <el-button size="small" type="warning">刷新</el-button>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="success"
|
|
|
+ @click="setParamNameClick"
|
|
|
+ >设置参数名称</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <hc-table
|
|
|
+ :column="tableColumn"
|
|
|
+ :datas="tableData"
|
|
|
+ :loading="tableLoading"
|
|
|
+ >
|
|
|
+ <template #name="{ row, index }">
|
|
|
+ <el-select
|
|
|
+ v-model="row.k"
|
|
|
+ placeholder="请选择"
|
|
|
+ filterable
|
|
|
+ block
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in nameList"
|
|
|
+ :key="item.k"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.k"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ <template #v="{ row, index }">
|
|
|
+ <hc-table-input v-model="row.v" />
|
|
|
+ </template>
|
|
|
+ <template #remark="{ row, index }">
|
|
|
+ <hc-table-input v-model="row.remark" />
|
|
|
+ </template>
|
|
|
+ <template #action="{ row, index }">
|
|
|
+ <el-link type="warning">关联元素</el-link>
|
|
|
+
|
|
|
+ <el-link type="danger" @click="delRowClick(index, row)"
|
|
|
+ >删除</el-link
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </hc-table>
|
|
|
+ </hc-card-item>
|
|
|
+ <hc-dialog
|
|
|
+ v-model="setNameShow"
|
|
|
+ is-footer-center
|
|
|
+ title=" 设置参数名称"
|
|
|
+ @close="nameClosedialogClose"
|
|
|
+ @save="saveNameHandle"
|
|
|
+ widths="56rem"
|
|
|
+ :loading="setNameLoading"
|
|
|
+ >
|
|
|
+ <hc-card-item>
|
|
|
+ <template #extra>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="addNameRowClick"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <hc-table
|
|
|
+ :column="nameTableColumn"
|
|
|
+ :datas="nameTableData"
|
|
|
+ :loading="nameTableLoading"
|
|
|
+ >
|
|
|
+ <template #name="{ row, index }">
|
|
|
+ <hc-table-input v-model="row.name" />
|
|
|
+ </template>
|
|
|
+ <template #k="{ row, index }">
|
|
|
+ <hc-table-input v-model="row.k" />
|
|
|
+ </template>
|
|
|
+ <template #remark="{ row, index }">
|
|
|
+ <hc-table-input v-model="row.remark" />
|
|
|
+ </template>
|
|
|
+ <template #action="{ row, index }">
|
|
|
+ <el-link type="danger" @click="delNameClick(row, index)"
|
|
|
+ >删除</el-link
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </hc-table>
|
|
|
+ </hc-card-item>
|
|
|
+ </hc-dialog>
|
|
|
+ </hc-dialog>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { ref, watch } from "vue";
|
|
|
+import mainWbsApi from "~api/wbs/wbsforelement";
|
|
|
+import mainApi from "~api/wbs/tree";
|
|
|
+import { getArrValue } from "js-fast-way";
|
|
|
+const props = defineProps({
|
|
|
+ nodeId: {
|
|
|
+ type: String,
|
|
|
+ default: "",
|
|
|
+ },
|
|
|
+});
|
|
|
+//事件
|
|
|
+const emit = defineEmits(["close"]);
|
|
|
+//双向绑定
|
|
|
+// eslint-disable-next-line no-undef
|
|
|
+const isShow = defineModel("modelValue", {
|
|
|
+ default: false,
|
|
|
+});
|
|
|
+//监听显示
|
|
|
+watch(isShow, (val) => {
|
|
|
+ if (val) {
|
|
|
+ getTableData();
|
|
|
+ getNameList();
|
|
|
+ } else {
|
|
|
+ emit("close");
|
|
|
+ }
|
|
|
+});
|
|
|
+const nodeId = ref(props.nodeId);
|
|
|
+const delIds = ref([]);
|
|
|
+//监听数据
|
|
|
+watch(
|
|
|
+ () => [props.nodeId],
|
|
|
+ ([tid]) => {
|
|
|
+ nodeId.value = tid;
|
|
|
+ },
|
|
|
+ { deep: true }
|
|
|
+);
|
|
|
+//关闭弹窗
|
|
|
+const dialogClose = () => {
|
|
|
+ isShow.value = false;
|
|
|
+ emit("close");
|
|
|
+};
|
|
|
+const submitLoading = ref(false);
|
|
|
+const saveElementHandle = async () => {
|
|
|
+ let tag = true;
|
|
|
+ tableData.value.forEach((val) => {
|
|
|
+ if (!val.k | !val.v) {
|
|
|
+ return (tag = false);
|
|
|
+ }
|
|
|
+ for (let i = 0; i < nameList.value.length; i++) {
|
|
|
+ if (nameList.value[i].k == val.k) {
|
|
|
+ val.name = nameList.value[i].name;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (tag) {
|
|
|
+ submitLoading.value = true;
|
|
|
+ const { error, code, data } = await mainApi.saveOrUpdateBatch({
|
|
|
+ scopeType: 1,
|
|
|
+
|
|
|
+ nodeId: nodeId.value,
|
|
|
+ wps: tableData.value,
|
|
|
+ type: 1,
|
|
|
+ delIds: delIds.value,
|
|
|
+ });
|
|
|
+ submitLoading.value = false;
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success("设置参数节点成功");
|
|
|
+ delIds.value = [];
|
|
|
+ getTableData();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.$message.warning("请填写所有的参数名称和参数值KEY");
|
|
|
+ }
|
|
|
+};
|
|
|
+const tableColumn = [
|
|
|
+ { key: "name", name: "参数名称", align: "center" },
|
|
|
+ { key: "v", name: "参数值KEY", align: "center" },
|
|
|
+ { key: "remark", name: "描述", align: "center" },
|
|
|
+ { key: "action", name: "操作", align: "center" },
|
|
|
+];
|
|
|
+const tableLoading = ref(false);
|
|
|
+const tableData = ref([]);
|
|
|
+
|
|
|
+const getTableData = async () => {
|
|
|
+ tableLoading.value = true;
|
|
|
+ const { data } = await mainApi.parameters({
|
|
|
+ wbsId: nodeId.value,
|
|
|
+ });
|
|
|
+
|
|
|
+ tableData.value = getArrValue(data);
|
|
|
+ tableLoading.value = false;
|
|
|
+ tableData.value = getArrValue(data);
|
|
|
+};
|
|
|
+const nameList = ref([]);
|
|
|
+const getNameList = async () => {
|
|
|
+ const { data } = await mainApi.keymap({});
|
|
|
+
|
|
|
+ nameList.value = getArrValue(data);
|
|
|
+};
|
|
|
+const addRowClick = () => {
|
|
|
+ tableData.value.unshift({
|
|
|
+ k: "",
|
|
|
+ v: "",
|
|
|
+ remark: "",
|
|
|
+ nodeId: nodeId.value,
|
|
|
+ type: 1,
|
|
|
+ });
|
|
|
+};
|
|
|
+const delRowClick = (index, row) => {
|
|
|
+ delIds.value.push(row.id);
|
|
|
+ tableData.value.splice(index, 1);
|
|
|
+};
|
|
|
+//设置节点参数名称
|
|
|
+const setNameShow = ref(false);
|
|
|
+const nameTableData = ref([]);
|
|
|
+const setParamNameClick = async () => {
|
|
|
+ setNameShow.value = true;
|
|
|
+ await getNameList();
|
|
|
+ nameTableData.value = [...nameList.value];
|
|
|
+};
|
|
|
+const nameClosedialogClose = () => {};
|
|
|
+const setNameLoading = ref(false);
|
|
|
+const saveNameHandle = async () => {
|
|
|
+ //设置参数名称中的保存按钮
|
|
|
+ if (nameTableData.value.length) {
|
|
|
+ let tag = true;
|
|
|
+ nameTableData.value.forEach((val) => {
|
|
|
+ if (!val.name || !val.k) {
|
|
|
+ return (tag = false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (tag) {
|
|
|
+ setNameLoading.value = true;
|
|
|
+ const { error, code, data } = await mainApi.saveOrUpdateBatch({
|
|
|
+ scopeType: 1,
|
|
|
+ nodeId: nodeId.value,
|
|
|
+ wps: nameTableData.value,
|
|
|
+ type: 0,
|
|
|
+ delIds: delIds.value,
|
|
|
+ });
|
|
|
+ setNameLoading.value = false;
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message.success("操作成功");
|
|
|
+ setNameShow.value = false;
|
|
|
+ delIds.value = [];
|
|
|
+ getNameList();
|
|
|
+ getTableData();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.$message.warning("请填写所有的参数名称和参数值KEY");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.$message.warning("请先添加参数");
|
|
|
+ }
|
|
|
+};
|
|
|
+const nameTableColumn = [
|
|
|
+ { key: "name", name: "参数名称", align: "center" },
|
|
|
+ { key: "k", name: "参数值KEY", align: "center" },
|
|
|
+ { key: "remark", name: "描述", align: "center" },
|
|
|
+ { key: "action", name: "操作", align: "center" },
|
|
|
+];
|
|
|
+
|
|
|
+const nameTableLoading = ref(false);
|
|
|
+const addNameRowClick = () => {
|
|
|
+ nameTableData.value.unshift({
|
|
|
+ name: "",
|
|
|
+ remark: "",
|
|
|
+ k: "",
|
|
|
+ type: 0,
|
|
|
+ nodeId: nodeId.value,
|
|
|
+ });
|
|
|
+};
|
|
|
+const delNameClick = (row, index) => {
|
|
|
+ delIds.value.push(row.id);
|
|
|
+ nameTableData.value.splice(index, 1);
|
|
|
+};
|
|
|
+</script>
|