mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -1,12 +1,71 @@
|
||||
// options推荐写法
|
||||
// 1. 定义一个 `ref`数组
|
||||
import { type Ref, ref } from "vue";
|
||||
import { type OptionsRow } from "plus-pro-components";
|
||||
import { computed, type Ref, ref } from "vue";
|
||||
import { type OptionsRow, type PlusColumn } from "plus-pro-components";
|
||||
import { api } from "@/api/isvList";
|
||||
import { api as groupApi } from "@/api/permGroup";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { search } from "@/views/isv/list/index";
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgGroupSetting = ref(false);
|
||||
export const settingGroupFormData = ref<any>({
|
||||
isvId: 0,
|
||||
groupCodeList: []
|
||||
});
|
||||
|
||||
const groupList: Ref<OptionsRow[]> = ref([]);
|
||||
// 2. 异步函数获取到值赋值到 `ref`
|
||||
const loadGroup = async () => {
|
||||
//
|
||||
console.log(groupList);
|
||||
const loadGroup = () => {
|
||||
groupApi.listAll().then(resp => {
|
||||
const rows = resp.data;
|
||||
/*
|
||||
options.value = [
|
||||
{ label: '未解决', value: '0', color: 'red' },
|
||||
{ label: '已解决', value: '1', color: 'blue' }
|
||||
]
|
||||
*/
|
||||
groupList.value = rows.map(row => {
|
||||
return {
|
||||
label: row.groupName,
|
||||
value: row.groupCode
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
loadGroup();
|
||||
|
||||
export const groupColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组",
|
||||
width: 120,
|
||||
prop: "groupCodeList",
|
||||
valueType: "checkbox",
|
||||
// options推荐写法
|
||||
// 3. 用 computed 返回 ref 的 value
|
||||
options: computed(() => groupList.value)
|
||||
}
|
||||
];
|
||||
|
||||
export const settingGroup = (row: any) => {
|
||||
api.listGroup(row.id).then(resp => {
|
||||
settingGroupFormData.value = {
|
||||
isvId: row.id,
|
||||
groupCodeList: resp.data
|
||||
};
|
||||
dlgGroupSetting.value = true;
|
||||
});
|
||||
};
|
||||
|
||||
export const handleUpdateGroup = () => {
|
||||
const data = settingGroupFormData.value;
|
||||
|
||||
api.updateGroup(data.isvId, data.groupCodeList).then(() => {
|
||||
ElMessage({
|
||||
message: "保存成功",
|
||||
type: "success"
|
||||
});
|
||||
dlgGroupSetting.value = false;
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user