状态
-
+
-
- {{ row.updated_time.split("+")[0].replace("T", " ").replace("Z", " ") }}
-
-
+
+ :values="[2, 1]"
+ v-model="row.status">
-
- 编辑
- 删除
+
+ 编辑
+ 删除
上移
下移
- 编辑
+ 编辑
上移
下移
@@ -111,23 +108,32 @@
-
+
+
+
+
+
+
+
-
+
+
+
+
-
+
@@ -183,6 +189,14 @@ import { Search } from "@element-plus/icons-vue";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
const bgForm = ref(null);
+const validateNumber = (rule, value, callback) => {
+ if (value !== "" && /^(?:[1-9]\d*)$/.test(value) == false) {
+ callback(new Error("请输入正整数"));
+ } else {
+ callback();
+ }
+};
+
const headers = computed(() => {
let _headers = [
{
@@ -191,17 +205,17 @@ const headers = computed(() => {
},
{
label: "描述",
- prop: "describe",
+ prop: "description",
minWidth: 360,
},
{
label: "更新时间",
- prop: "updated_time",
+ prop: "updated_at",
width: 220,
},
{
label: "是否启用",
- prop: "state",
+ prop: "status",
},
{
label: "操作",
@@ -211,18 +225,25 @@ const headers = computed(() => {
},
];
- if (state.nodeClassifyId === "59315100-5c2a-4381-83fe-32934605f0a9") {
- _headers.splice(1, 0, {
- label: "版本数",
- prop: "total_children",
- });
- }
- if (state.nodeClassifyId === "b3a083ee-a8c1-8ca4-f9a1-ea01692a0f1a") {
- _headers.splice(1, 0, {
- label: "服务名称",
- prop: "service_name",
- });
+ if (state.nodeClassifyId === 3) {
+ _headers.splice(
+ 1,
+ 0,
+ {
+ label: "单位",
+ prop: "unit",
+ },
+ {
+ label: "值域上限",
+ prop: "max_val",
+ },
+ {
+ label: "值域下限",
+ prop: "min_val",
+ }
+ );
}
+
return _headers;
});
const state = reactive({
@@ -230,15 +251,14 @@ const state = reactive({
typeList: [], // 分类数据
typeKeyword: "", // 分类删选关键词
nodeClassifyId: null, // 当前选中分类的uuid 用于新增字典
- nodeId: null, // 当前选中分类的id 用于请求列表
timer: null, // 定时器
tableRows: [], // 表格数据
tableTotal: 0, // 表格数据条数
filter: {
- state: "",
+ status: "",
search: "",
page: 1,
- limit: 10,
+ page_size: 10,
}, // 表格筛选项
stateOptions: [
{
@@ -260,17 +280,19 @@ const state = reactive({
addDialog: false,
formData: {
name: "",
- describe: "",
- state: 1,
- p_dict_id: "",
+ description: "",
+ status: 1,
+ unit: "",
+ max_val: "",
+ min_val: "",
},
rules: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
- describe: [
+ description: [
{ required: true, message: "请输入描述", trigger: "blur" },
{ max: 200, message: "描述最大为200字", trigger: "blur" },
],
- state: [{ required: true, message: "请选择是否启用", trigger: "change" }],
+ status: [{ required: true, message: "请选择是否启用", trigger: "change" }],
},
fatherRow: null,
});
@@ -289,15 +311,14 @@ const backDict = () => {
changePage(1);
};
const nodeClick = (item) => {
- state.nodeId = item.id;
dictLevel.value = 1;
state.fatherRow = null;
- state.nodeClassifyId = item.classify_id;
+ state.nodeClassifyId = item.class_id;
state.filter = {
- state: "",
+ status: "",
search: "",
page: 1,
- limit: 10,
+ page_size: 10,
};
changePage(1);
}; // 切换字典分类
@@ -313,18 +334,15 @@ const searchType = () => {
const getTypeList = () => {
let params = {
- name: state.typeKeyword,
+ class_name: state.typeKeyword,
};
axios
- .get(`/apaas/system/v5/dictionary/classify/list`, { params })
+ .get(`/v1/api/dict/classList`, { params })
.then((res) => {
if (res.data.code == 200) {
state.typeList = res.data.data || [];
- state.nodeClassifyId = state.typeList[0].classify_id || null;
- state.nodeId = state.typeList[0].id || null;
- if (state.nodeId) {
- getTableRows();
- }
+ state.nodeClassifyId = state.typeList[0].class_id || null;
+ getTableRows();
} else {
ElMessage.error(res.data.data);
}
@@ -345,19 +363,18 @@ const filterAction = () => {
const filterClear = () => {
state.filter = {
- state: "",
+ status: "",
search: "",
- limit: 10,
+ page_size: 10,
page: 1,
};
changePage(1);
}; // 重置筛选项
const getTableRows = () => {
- let params = { ...state.filter };
- params.id = state.nodeId;
+ let params = { ...state.filter, class: state.nodeClassifyId };
axios
- .get(`/apaas/system/v5/dictionary/list`, {
+ .get(`/v1/api/dict`, {
params,
})
.then((res) => {
@@ -388,13 +405,13 @@ const getTableRows = () => {
}; // 获取表格数据
const changeUseRow = (row) => {
- axios.put(`/apaas/system/v5/dictionary/state?id=${row.id}&state=${row.state}`).then((res) => {
+ axios.put(`/v1/api/dict/status?id=${row.id}&status=${row.status}`).then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);
changePage(1);
} else {
ElMessage.error(res.data.data);
- row.state = row.state == 0 ? 1 : 0;
+ row.status = row.status == 2 ? 1 : 2;
}
});
}; // 启用禁用
@@ -405,16 +422,18 @@ const changePage = (page) => {
}; // 改变页码
const changeSize = (size) => {
- state.filter.limit = size;
+ state.filter.page_size = size;
changePage(1);
}; // 改变每页条数
const register = () => {
state.formData = {
name: "",
- describe: "",
- state: 1,
- p_dict_id: state.fatherRow ? state.fatherRow.dict_id : "",
+ description: "",
+ status: 1,
+ unit: "",
+ max_val: "",
+ min_val: "",
};
if (state.bgForm) {
nextTick().then(() => {
@@ -430,24 +449,24 @@ const register = () => {
}; // 新增字典按钮
const edit_row = (row) => {
- axios
- .get(`/apaas/system/v5/dictionary/${row.id}`)
- .then((res) => {
- if (res.data.code == 200) {
- state.actionRow = res.data.data;
- state.formData = {
- name: state.actionRow.name,
- describe: state.actionRow.describe,
- state: state.actionRow.state,
- p_dict_id: state.actionRow.p_dict_id,
- };
- } else {
- ElMessage.error(res.data.data);
- }
- })
- .catch((err) => {
- console.log(err);
- });
+ state.actionRow = row;
+ if (row.class === 3) {
+ state.formData = {
+ name: row.name,
+ unit: row.unit,
+ max_val: row.max_val,
+ min_val: row.min_val,
+ description: row.description,
+ status: row.status,
+ };
+ } else {
+ state.formData = {
+ name: row.name,
+ description: row.description,
+ status: row.status,
+ };
+ }
+
if (state.bgForm) {
nextTick().then(() => {
state.bgForm.validate((valid) => {
@@ -467,10 +486,15 @@ const addConfirm = () => {
if (state.addType == 1) {
// 新增
let params = {
- classify_id: state.nodeClassifyId,
+ class: state.nodeClassifyId,
...state.formData,
};
- axios.post(`/apaas/system/v5/dictionary/add`, params).then((res) => {
+ if (state.nodeClassifyId !== 3) {
+ delete params.min_val;
+ delete params.max_val;
+ delete params.unit;
+ }
+ axios.post(`/v1/api/dict`, params).then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);
state.addDialog = false;
@@ -483,9 +507,15 @@ const addConfirm = () => {
// 编辑
let params = {
id: state.actionRow.id,
+ class: state.actionRow.class,
...state.formData,
};
- axios.put(`/apaas/system/v5/dictionary/update`, params).then((res) => {
+ if (state.actionRow.class !== 3) {
+ delete params.min_val;
+ delete params.max_val;
+ delete params.unit;
+ }
+ axios.put(`/v1/api/dict`, params).then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);
state.addDialog = false;
@@ -505,7 +535,7 @@ const delete_row = (row) => {
}; // 删除按钮
const deleteData = () => {
- axios.delete(`/apaas/system/v5/dictionary/${state.actionRow.id}`).then((res) => {
+ axios.delete(`/v1/api/dict?id=${state.actionRow.id}`).then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);
state.dialogDelete = false;
@@ -542,7 +572,7 @@ const moveRow = (row, type) => {
},
];
axios
- .put(`/apaas/system/v5/dictionary/sort`, [...params])
+ .put(`/v1/api/dict/sort`, [...params])
.then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);