element的描述列表<el-descriptions>添加字典翻译功能

标题1

 可以利用对象赋值进行翻译功能:

HTML代码:

<el-descriptions border :column="2" direction="vertical">
 <el-descriptions-item label="单位类别">
          {{
            companyTypeFormat(viewForm.companyType?viewForm.companyType:'')
          }}
 </el-descriptions-item>
</el-descriptions>

标题2

 函数方法:(其中this.selectDictLabel方法,会写到下边"标题3")

函数代码:

methods: {
    //单位类别字典翻译
    companyTypeFormat(row, column) {
      return this.selectDictLabel(this.dict.type.DWLB, row.companyType);
    }
}

标题3

公共翻译方法(别忘了区mian.js全局注册)

Vue.prototype.selectDictLabel = selectDictLabel

// 回显数据字典
export function selectDictLabel(datas, value) {
  if (value === undefined) {
    return "";
  }
  var actions = [];
  Object.keys(datas).some((key) => {
    if (datas[key].value == ('' + value)) {
      actions.push(datas[key].label);
      return true;
    }
  })
  if (actions.length === 0) {
    actions.push(value);
  }
  return actions.join('');
}

<template> <div class="content-box"> <!-- 左侧---> <div class="card filter"> <el-button type="primary" class="add-btn" @click="openDrawerType">新增字典</el-button> <el-input v-model="filterText" class="filterTextInput" placeholder="请输入" clearable /> </div> <!-- 右侧-数据列 --> <div class="descriptions-box"> <div class="box-tip card"> <el-button type="primary" class="add-btn" @click="openDrawer('新增字段值', [])">新增字段</el-button> </div> <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam" :data-callback="dataCallback"> <template #operation="scope"> <el-button type="primary" link @click="openDrawer('编辑字段值', scope.row)">编辑</el-button> <el-button v-if="scope.row.status == 'enabled'" type="primary" style="color:#FF0000" link @click="changeStatus(scope.row)">禁用</el-button> <el-button v-if="scope.row.status == 'disabled'" type="primary" style="color:#49C625" link @click="changeStatus(scope.row)">启用</el-button> <el-button type="primary" link @click="deleteAccount(scope.row)">删除</el-button> </template> </ProTable> </div> <!-- 新增字典类型 --> <addType ref="dialogAddType"/> <!-- 新增编辑字段 --> <addDataDictionary ref="dialogAddDataDictionary"/> </div> </template> <script setup lang="ts" name="dataDictionary"> import { ref, watch, reactive, inject, onMounted } from "vue"; import { ElTree, FormInstance, FormRules, ElMessage } from "element-plus"; import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface"; import { Supplier } from "@/api/interface"; import ProTable from "@/components/ProTable/index.vue"; import addDataDictionary from "@/views/system/dataDictionary/addDataDictionary.vue"; import addType from "@/views/system/dataDictionary/addType.vue"; import { setValueList, addDictionaryType, addDictionaryValue } from '@/api/modules/public'; const treeRef = ref<InstanceType<typeof ElTree>>(); const treeData = ref<any[]>([]); onMounted(async () => { getTableList() }) // 左侧树 const getTableList = async () => { const { data } = await setValueList(); treeData.value = data || []; console.log('data',treeData.value) } // 初始化参数 const pageData = reactive({}) // ProTable 实例 const proTable = ref<ProTableInstance>(); const initParam = reactive({}); // 表格配置项 const columns = reactive<ColumnProps<Supplier.pageList>[]>([]) const dataCallback = (data: any) => { return {} } // 搜索过滤 const filterText = ref(""); watch(filterText, val => { treeRef.value!.filter(val); }); // 新增字典类型 const dialogAddType = ref<InstanceType<typeof addType> | null>(null); const openDrawerType = () => { const params = { api: addDictionaryType, row:{}, getTableListData:getTableList } dialogAddType.value?.acceptParams(params); } // 新增 const dialogAddDataDictionary = ref<InstanceType<typeof addDataDictionary> | null>(null); const openDrawer = (title: string, row: any) => { const params = { title:title, row:row, isView:false, api: title === "新增数据字典" ? addDictionaryType : addDictionaryValue, // getTableListData:getTableList } dialogAddDataDictionary.value?.acceptParams(params); } // 修改状态 const changeStatus = async (row: Supplier.pageList) => { } // 删除 const deleteAccount = async (row: Supplier.pageList) => { } </script> <style scoped lang="scss"> @use "@/styles/treeIndex.scss"; </style> 修改语法错误
07-30
<template> <div class="content-box"> <!-- 左侧---> <div class="card filter left-list"> <el-button type="primary" class="add-btn" @click="openDrawerType('新增数据字典',[])">新增字典</el-button> <el-input v-model="filterText" class="filterTextInput" placeholder="请输入" clearable /> <div class="list-box"> <template v-if="treeData.length"> <div :class="['item', { active: activeTypeItem.id === item.id }]" v-for="item in filteredTreeData" :key="item.id" @click="handleItemClick(item)"> <div>{{ item.name }}</div> <div class="right-opearte"> <span @click.stop="openDrawerType('编辑数据字典',item)" v-if="hasBtnPermission( 'system:dataDictionary:btn-editrype' ) "><i class="el-icon-edit"></i>编辑</span> <span @click.stop="handleDelType(item)" v-if="hasBtnPermission( 'system:dataDictionary:btn-deleteType' ) "><i class="el-icon-delete"></i>删除</span> </div> </div> </template> </div> </div> <!-- 右侧-数据列 --> <div class="descriptions-box"> <div class="box-tip card"> <el-button type="primary" class="add-btn" @click="openDrawer('新增字段值', [])">新增字段</el-button> </div> <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam" :data-callback="dataCallback"> <template #operation="scope"> <el-button type="primary" link @click="openDrawer('编辑字段值', scope.row)">编辑</el-button> <el-button v-if="scope.row.status == 'enabled'" type="primary" style="color:#FF0000" link @click="changeStatus(scope.row)">禁用</el-button> <el-button v-if="scope.row.status == 'disabled'" type="primary" style="color:#49C625" link @click="changeStatus(scope.row)">启用</el-button> <el-button type="primary" link @click="deleteAccount(scope.row)">删除</el-button> </template> </ProTable> </div> <!-- 新增字典类型 --> <addType ref="dialogAddType"/> <!-- 新增编辑字段 --> <addDataDictionary ref="dialogAddDataDictionary"/> </div> </template> <script setup lang="ts" name="dataDictionary"> import { ref, watch, reactive, inject, onMounted, } from "vue"; import { ElTree, FormInstance, FormRules, ElMessage, } from "element-plus"; import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface"; import { Supplier } from "@/api/interface"; import ProTable from "@/components/ProTable/index.vue"; import addDataDictionary from "@/views/system/dataDictionary/addDataDictionary.vue"; import addType from "@/views/system/dataDictionary/addType.vue"; import { setValueList, addDictionaryType, addDictionaryValue } from '@/api/modules/public'; import { da } from "element-plus/es/locale"; const hasBtnPermission: any = inject('hasBtnPermission'); const treeData = ref<any[]>([]); const activeTypeItem = ref<Record<string, any>>({}); const filteredTreeData = ref<any[]>([]); const filterText = ref(""); const defaultProps = { children: "children", label: "label" }; watch( () => filterText.value, (val) => { if (!val) { filteredTreeData.value = treeData.value; } else { const keyword = val.toLowerCase(); filteredTreeData.value = treeData.value.filter(item => item.name?.toLowerCase().includes(keyword) ); } }, { immediate: true } ); // 左侧树 const getTableList = async (params: any) => { const { data } = await setValueList(params); treeData.value = data || []; filteredTreeData.value = data || [] return { list: data || [] }; } const dataCallback = (data: any) => { return data; } const handleItemClick = (data: any) => { activeTypeItem.value = data console.log('data',data) // const response = await assetClassificationInfo({ id: data.id }) } const handleEditType = () => { } const handleDelType = () => { } // 初始化参数 const pageData = reactive({}) // ProTable 实例 const initParam = reactive({}); // 表格配置项 const proTable = ref<ProTableInstance>(); const columns = reactive<ColumnProps<Supplier.pageList>[]>([ // { prop: "realname", label: "姓名", search: { el: "input" } }, ]) // 搜索过滤 const filterNode = (value: string, node: any) => { if (!value) return true; return node.data.label.includes(value); }; // 新增字典类型 const dialogAddType = ref<InstanceType<typeof addType> | null>(null); const openDrawerType = (title: string,row:any) => { const params = { title:title, api: title === "新增数据字典" ? addDictionaryType : addDictionaryType, row:row, getTableListData:getTableList } dialogAddType.value?.acceptParams(params); } // 新增 const dialogAddDataDictionary = ref<InstanceType<typeof addDataDictionary> | null>(null); const openDrawer = (title: string, row: any) => { const params = { title:title, row:row, isView:false, api: title === "新增数据字典" ? addDictionaryType : addDictionaryValue, // getTableListData:getTableList } dialogAddDataDictionary.value?.acceptParams(params); } // 修改状态 const changeStatus = async (row: Supplier.pageList) => { } // 删除 const deleteAccount = async (row: Supplier.pageList) => { } </script> <style scoped lang="scss"> @use "@/styles/treeIndex.scss"; .left-list{ .list-box { height: calc(100% - 95px); overflow: auto; margin-top: 10px; } .item { cursor: pointer; display: flex; justify-content: space-between; padding: 5px 10px; border-radius: 4px; font-size: 14px; color: #606266; &.active { background: #e6f5f3 !important; } &:hover { background: rgb(245, 247, 250); } span { cursor: pointer; margin-left: 10px; i { margin-right: 3px; } &:first-of-type { color: #009688; } &:last-of-type { color: #f56c6c; } } } } </style> <template> <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="550px" :title="drawerProps.title" :close-on-click-modal="false"> <el-form ref="ruleFormRef" label-width="52px" :rules="rules" :model="typeItem"> <el-form-item label="编码" prop="code"> <el-input v-model="typeItem.code" placeholder="请填写" class="input-width" maxlength="50" clearable /> </el-form-item> <el-form-item label="名称" prop="name"> <el-input v-model="typeItem.name" placeholder="请填写" class="input-width" maxlength="50" clearable /> </el-form-item> <el-form-item label="备注"> <el-input v-model="typeItem.remark" :rows="6" type="textarea" placeholder="请填写备注" maxlength="5000" show-word-limit clearable></el-input> </el-form-item> </el-form> <template #footer> <el-button @click="drawerVisible = false">取消</el-button> <el-button v-show="!drawerProps.isView" type="primary" @click="handleSubmit">确定</el-button> </template> </el-drawer> </template> <script setup lang="ts" name="addType"> import { ref, reactive } from "vue"; import { AssetClassification } from "@/api/interface"; import { ElMessage, FormInstance } from "element-plus"; const rules = reactive({ code: [{ required: true, message: "请填写字典编码", trigger: "blur" }], name: [{ required: true, message: "请填写字典名称", trigger: "blur" }], }) interface typeItem { code:'', name:'', id:'', remark:'', } interface DrawerProps { title: string, api?: (params: any) => Promise<any>; getTableListData?: () => void; row: Partial<AssetClassification.pageList>; } const formData = ref<Partial<AssetClassification.pageList>>({}); const drawerVisible = ref(false); const drawerProps = ref<DrawerProps>({ title: "", row:{} }) // 接收父组件传过来的参数 const acceptParams = (params: DrawerProps) => { console.log('params',params) typeItem.value = JSON.parse(JSON.stringify(params.row)); drawerProps.value = params; drawerVisible.value = true; } // 操作 const ruleFormRef = ref<FormInstance>(); const handleSubmit = () => { ruleFormRef.value!.validate(async valid => { if (!valid) return; try { await drawerProps.value.api!(drawerProps.value.row); ElMessage.success({ message: `操作成功!` }); drawerProps.value.getTableListData!(); drawerVisible.value = false; } catch (error) { console.log(error); } }) } defineExpose({ acceptParams }); </script> 优化
07-30
<template> <div class="content-box"> <div class="card filter"> <el-button type="primary" class="add-btn" @click="openDrawer('add', '新增非标准资产', [])">新增非标准资产</el-button> <el-input v-model="filterText" class="filterTextInput" placeholder="请输入" clearable /> <div class="list-box"> <template v-if="filteredTreeData.length"> <div :class="['item', { active: activeTypeItem.id === item.id }]" v-for="item in filteredTreeData" :key="item.id" @click="handleItemClick(item)"> <div>{{item.name}}</div> <div class="right-opearte"> <span @click.stop="openDrawer('edit','编辑数据字典', item)"><i class="el-icon-edit"></i>编辑</span> <span @click.stop="handleDelType(item)"><i class="el-icon-delete"></i>删除</span> </div> </div> </template> </div> </div> <div class="descriptions-box"> <div style="height:100%;width:100%" v-if="Object.keys(activeTypeItem).length"> <div class="box-tip card"> <el-button type="primary" class="add-btn" @click="openDrawer('childAdd', '新增字段', [])">新增字段</el-button> </div> <div class="table-main card" style="height: calc(100% - 65px);"> <div class="table-header"> <div v-if="toolButton" class="header-button-ri"> <slot name="toolButton"> <el-button :icon="Refresh" circle @click="refreshData" /> <el-button :icon="Operation" circle @click="openColSetting" /> </slot> </div> </div> <el-table :data="tableData" border style="width: 100%" :header-cell-style="{ background: '#f5f7fa', color: '#606266', textAlign: 'center' }"> <el-table-column prop="fieldName" label="字段名称" align="center"/> <el-table-column prop="isRequire" label="必填项" align="center" /> <el-table-column prop="sort" label="排序" align="center"/> <el-table-column prop="status" label="状态" align="center"> <template #default="scope"> <ElTag :type="scope.row.status == 1 ? 'success' : 'danger'">{{scope.row.status == 1 ? '启用' :'禁用'}}</ElTag> </template> </el-table-column> <el-table-column label="操作" align="center"> <template #default="scope"> <el-button type="primary" link @click="openDrawer('childEdit','编辑字段', scope.row)">编辑</el-button> <el-button v-if="scope.row.status == '1'" type="primary" style="color:#FF0000" link @click="changeStatus(scope.row,0)">禁用</el-button> <el-button v-if="scope.row.status == '0'" type="primary" style="color:#49C625" link @click="changeStatus(scope.row,1)">启用</el-button> <el-button type="primary" link @click="deleteAccount(scope.row)">删除</el-button> </template> </el-table-column> <!-- 无数据 --> <template #empty> <div class="table-empty"> <slot name="empty"> <img src="@/assets/images/notData.png" alt="notData" /> <div>暂无数据</div> </slot> </div> </template> </el-table> <Pagination v-if="tableData.length > 0" :pageable="pagination" :handle-size-change="handleSizeChange" :handle-current-change="handleCurrentChange" /> </div> </div> <div class="card empty" v-else> <el-empty description="请先选择非标准资产"></el-empty> </div> </div> <!-- 新增非标准字段 --> <addNewFields ref="dialogAddNewFields" /> <!-- 列设置 --> <ColSetting v-if="toolButton" ref="colRef" v-model:col-setting="colSetting" /> </div> </template> <script setup lang="ts" name="standardProductFieldManage"> import { ref, reactive,onMounted ,watch} from "vue"; import { ElTree,ElTable, FormInstance, FormRules, ElMessage,ElTag } from "element-plus"; import { Supplier } from "@/api/interface"; import Pagination from "@/components/ProTable/components/Pagination.vue"; import { ProTableInstance, ColumnProps,TypeProps } from "@/components/ProTable/interface"; import { Refresh, Operation, Search } from "@element-plus/icons-vue"; import ColSetting from "@/components/ProTable/components/ColSetting.vue"; import addNewFields from "@/views/system/standardProductFieldManage/addNewFields.vue"; import { nonstandardList, editNonstandard, editNonstandardClild, deleteNonstandard ,nonstandardClildList,statusNonstandardClild,deleteNonstandardClild} from '@/api/modules/public'; import { da } from "element-plus/es/locale"; import { useHandleData } from "@/hooks/useHandleData"; // 初始化参数 const treeData = ref<any[]>([]); const filteredTreeData = ref<any[]>([]); const activeTypeItem = ref<Record<string, any>>({}); const filterText = ref(""); const toolButton = ref(true) // 右侧表格数据 const tableData = ref<any[]>([]); const pagination = ref({ pageNum: 1, pageSize: 10, total: 0, }); watch( () => filterText.value, (val) => { if (!val) { filteredTreeData.value = treeData.value; } else { const keyword = val.toLowerCase(); filteredTreeData.value = treeData.value.filter(item => item.name?.toLowerCase().includes(keyword) ); } }, { immediate: true } ); onMounted(async () => { getTreeList() }) // 左侧树、 const getTreeList = async () => { const data = await nonstandardList({}); treeData.value = data || []; filteredTreeData.value = data || [] // 编辑数据后,右侧数据更新 if (Object.keys(activeTypeItem.value).length > 0) { getTableList() } } // 点击左侧,更新右侧列表 const handleItemClick = async (data: any) => { activeTypeItem.value = data; getTableList() } const handleSizeChange = (size) => { pagination.value.pageSize = size; getTableList(); }; const handleCurrentChange = (currentPage) => { pagination.value.pageNum = currentPage; getTableList(); } // 刷新 const refreshData = () => { pagination.value.pageNum = 1 getTableList(); } // 接收 columns 并设置为响应式 const tableColumns = reactive<ColumnProps[]>(treeData.value); // column 列类型 const columnTypes: TypeProps[] = ["selection", "radio", "index", "expand", "sort"]; const colRef = ref(); const colSetting = treeData.value!.filter(item => { console.log('item',tableData) const { type, prop, isShow } = item; return !columnTypes.includes(type!) && prop !== "operation" && isShow; }); const openColSetting = () => { console.log('23',tableData) colRef.value.openColSetting(); } // 调用列表接口 const getTableList = async () => { const formData = { assetNonStandardId: activeTypeItem.value.id, pageNum: pagination.value.pageNum, pageSize: pagination.value.pageSize, }; const { code, msg, data } = await nonstandardClildList(formData) if(code == 0) { tableData.value = data.dataList; pagination.value.total = data.totalCount; } else { ElMessage.error(msg); } } // 表格配置项 const columns = reactive<ColumnProps<Supplier.pageList>[]>([ { prop: "fieldName", label: "单位名称", }, ]) // 新增,编辑 const dialogAddNewFields = ref<InstanceType<typeof addNewFields> | null>(null); const openDrawer = async (type: string, title: string, row: any) => { console.log('activeTypeItem.value',activeTypeItem.value) const params = { type: type, title: title, isView: false, row: {...row}, activeTypeItem:{...activeTypeItem.value}, api: type == 'add' || type == 'edit' ? editNonstandard : editNonstandardClild, getTableListData: getTreeList } dialogAddNewFields.value?.acceptParams(params); } // 删除资产 const handleDelType = async (params) => { await useHandleData(deleteNonstandard, { id: params.id }, `确认删除`); getTreeList() } // 修改状态 const changeStatus = async (row: Supplier.pageList,type:string) => { await useHandleData(statusNonstandardClild, { id: row.id, status: type }, `确定${type == 1 ? '启用' : '禁用'}`); getTreeList(); } // 删除 const deleteAccount = async (row: Supplier.pageList) => { await useHandleData(deleteNonstandardClild, { id: row.id }, `确认删除`); getTreeList() } </script> <style scoped lang="scss"> @use "@/styles/treeIndex.scss"; .list-box { height: calc(100% - 95px); margin-top: 10px; overflow: auto; } .item { display: flex; justify-content: space-between; padding: 5px 10px; font-size: 14px; color: #606266; cursor: pointer; border-radius: 4px; &.active { background: #e6f5f3 !important; } &:hover { background: rgb(245 247 250); } span { margin-left: 10px; cursor: pointer; i { margin-right: 3px; } &:first-of-type { color: #009688; } &:last-of-type { color: #f56c6c; } } } .empty { width: 100%; height: 100%; .el-empty { transform: translate(0, 50%); } } // .el-tables{ // height: calc(100% - 65px); // } .bindUserRight_bottom{ display: flex; justify-content: flex-end; margin-top: 20px; } </style><template> <!-- 列设置 --> <el-drawer v-model="drawerVisible" title="列设置" size="450px" :close-on-click-modal="false"> <div class="table-main"> <el-table :data="colSetting" :border="true" row-key="prop" default-expand-all :tree-props="{ children: '_children' }"> <el-table-column prop="label" align="center" label="列名" /> <el-table-column v-slot="scope" prop="isShow" align="center" label="显示"> <el-switch v-model="scope.row.isShow"></el-switch> </el-table-column> <el-table-column v-slot="scope" prop="sortable" align="center" label="排序"> <el-switch v-model="scope.row.sortable"></el-switch> </el-table-column> <template #empty> <div class="table-empty"> <img src="@/assets/images/notData.png" alt="notData" /> <div>暂无可配置列</div> </div> </template> </el-table> </div> </el-drawer> </template> <script setup lang="ts" name="ColSetting"> import { ref } from "vue"; import { ColumnProps } from "@/components/ProTable/interface"; defineProps<{ colSetting: ColumnProps[] }>(); const drawerVisible = ref<boolean>(false); const openColSetting = () => { drawerVisible.value = true; }; defineExpose({ openColSetting }); </script> <style scoped lang="scss"> .cursor-move { cursor: move; } </style> 点击openColSetting,打开ColSetting列设置,传递table表头列给ColSetting弹窗界面,如何把表头传到子界面
最新发布
08-02
<template> <div class="content-box"> <!-- 左侧---> <div class="card filter left-list"> <el-button type="primary" class="add-btn" @click="openDrawerType('新增字段值',[])">新增字典</el-button> <el-input v-model="filterText" class="filterTextInput" placeholder="请输入" clearable /> <div class="list-box"> <template v-if="treeData.length"> <div :class="['item', { active: activeTypeItem.id === item.id }]" v-for="item in treeData" :key="item.id" @click="handleItemClick(item)"> <div>{{ item.name }}</div> <div class="right-opearte"> <span @click.stop="openDrawerType('编辑字段值',item)" v-if="hasBtnPermission( 'system:dataDictionary:btn-editrype' ) "><i class="el-icon-edit"></i>编辑</span> <span @click.stop="handleDelType(item)" v-if="hasBtnPermission( 'system:dataDictionary:btn-deleteType' ) "><i class="el-icon-delete"></i>删除</span> </div> </div> </template> </div> </div> <!-- 右侧-数据列 --> <div class="descriptions-box"> <div class="box-tip card"> <el-button type="primary" class="add-btn" @click="openDrawer('新增字段值', [])">新增字段</el-button> </div> <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam" :data-callback="dataCallback"> <template #operation="scope"> <el-button type="primary" link @click="openDrawer('编辑字段值', scope.row)">编辑</el-button> <el-button v-if="scope.row.status == 'enabled'" type="primary" style="color:#FF0000" link @click="changeStatus(scope.row)">禁用</el-button> <el-button v-if="scope.row.status == 'disabled'" type="primary" style="color:#49C625" link @click="changeStatus(scope.row)">启用</el-button> <el-button type="primary" link @click="deleteAccount(scope.row)">删除</el-button> </template> </ProTable> </div> <!-- 新增字典类型 --> <addType ref="dialogAddType"/> <!-- 新增编辑字段 --> <addDataDictionary ref="dialogAddDataDictionary"/> </div> </template> <script setup lang="ts" name="dataDictionary"> import { ref, watch, reactive, inject, onMounted } from "vue"; import { ElTree, FormInstance, FormRules, ElMessage } from "element-plus"; import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface"; import { Supplier } from "@/api/interface"; import ProTable from "@/components/ProTable/index.vue"; import addDataDictionary from "@/views/system/dataDictionary/addDataDictionary.vue"; import addType from "@/views/system/dataDictionary/addType.vue"; import { setValueList, addDictionaryType, addDictionaryValue } from '@/api/modules/public'; import { da } from "element-plus/es/locale"; const hasBtnPermission: any = inject('hasBtnPermission'); const treeRef = ref<InstanceType<typeof ElTree>>(); const treeData = ref<any[]>([]); const activeTypeItem = ref<Record<string, any>>({}); const filterText = ref(""); const defaultProps = { children: "children", label: "label" }; // 左侧树 const getTableList = async (params: any) => { const { data } = await setValueList(params); treeData.value = data || []; console.log('treeData.value',treeData.value) } const dataCallback = (data: any) => { return data; } const handleItemClick = (data: any) => { activeTypeItem.value = data console.log('data',data) } const handleEditType = () => { } const handleDelType = () => { } // 初始化参数 const pageData = reactive({}) // ProTable 实例 const initParam = reactive({}); // 表格配置项 const proTable = ref<ProTableInstance>(); const columns = reactive<ColumnProps<Supplier.pageList>[]>([]) // 搜索过滤 watch(filterText, (val) => { treeRef.value?.filter(val); }); const filterNode = (value: string, node: any) => { if (!value) return true; return node.data.label.includes(value); }; // 新增字典类型 const dialogAddType = ref<InstanceType<typeof addType> | null>(null); const openDrawerType = (title: string,row:any) => { const params = { title:title, api: addDictionaryType, row:row, getTableListData:getTableList } dialogAddType.value?.acceptParams(params); } // 新增 const dialogAddDataDictionary = ref<InstanceType<typeof addDataDictionary> | null>(null); const openDrawer = (title: string, row: any) => { const params = { title:title, row:row, isView:false, api: title === "新增数据字典" ? addDictionaryType : addDictionaryValue, // getTableListData:getTableList } dialogAddDataDictionary.value?.acceptParams(params); } // 修改状态 const changeStatus = async (row: Supplier.pageList) => { } // 删除 const deleteAccount = async (row: Supplier.pageList) => { } </script> <style scoped lang="scss"> @use "@/styles/treeIndex.scss"; .left-list{ .list-box { height: calc(100% - 95px); overflow: auto; margin-top: 10px; } .item { cursor: pointer; display: flex; justify-content: space-between; padding: 5px 10px; border-radius: 4px; font-size: 14px; color: #606266; &.active { background: #e6f5f3 !important; } &:hover { background: rgb(245, 247, 250); } span { cursor: pointer; margin-left: 10px; i { margin-right: 3px; } &:first-of-type { color: rgb(0, 110, 255); } &:last-of-type { color: #f40; } } } } </style> <template> <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="550px" :title="drawerProps.title" :close-on-click-modal="false"> <el-form ref="ruleFormRef" label-width="52px" :rules="rules" :model="typeItem"> <el-form-item label="编码" prop="code"> <el-input v-model="typeItem.code" placeholder="请填写" class="input-width" maxlength="50" clearable /> </el-form-item> <el-form-item label="名称" prop="name"> <el-input v-model="typeItem.name" placeholder="请填写" class="input-width" maxlength="50" clearable /> </el-form-item> <el-form-item label="备注"> <el-input v-model="typeItem.remark" :rows="6" type="textarea" placeholder="请填写备注" maxlength="5000" show-word-limit clearable></el-input> </el-form-item> </el-form> <template #footer> <el-button @click="drawerVisible = false">取消</el-button> <el-button v-show="!drawerProps.isView" type="primary" @click="handleSubmit">确定</el-button> </template> </el-drawer> </template> <script setup lang="ts" name="addType"> import { ref, reactive } from "vue"; import { AssetClassification } from "@/api/interface"; import { ElMessage, FormInstance } from "element-plus"; const rules = reactive({ code: [{ required: true, message: "请填写字典编码", trigger: "blur" }], name: [{ required: true, message: "请填写字典名称", trigger: "blur" }], }) const typeItem = ref<Record<string, any>>({}); interface DrawerProps { title: string, api?: (params: any) => Promise<any>; getTableListData?: () => void; row: Partial<AssetClassification.pageList>; } const drawerVisible = ref(false); const drawerProps = ref<DrawerProps>({ title: "", row:{} }) // 接收父组件传过来的参数 const acceptParams = (params: DrawerProps) => { console.log('params',params) drawerProps.value = params; typeItem.value = params.row drawerVisible.value = true; } // 操作 const ruleFormRef = ref<FormInstance>(); const handleSubmit = () => { ruleFormRef.value!.validate(async valid => { if (!valid) return; try { await drawerProps.value.api!(drawerProps.value.row); ElMessage.success({ message: `操作成功!` }); drawerProps.value.getTableListData!(); drawerVisible.value = false; } catch (error) { console.log(error); } }) } defineExpose({ acceptParams }); </script>
07-30
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值