125 lines
3.4 KiB
Vue
125 lines
3.4 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<!-- 列表 -->
|
|
<!-- 搜索 -->
|
|
<!-- <page-search
|
|
ref="searchRef"
|
|
:search-config="searchConfig"
|
|
@query-click="handleQueryClick"
|
|
@reset-click="handleResetClick"
|
|
/> -->
|
|
<!-- 列表 -->
|
|
<page-content
|
|
ref="contentRef"
|
|
:content-config="contentConfig"
|
|
@add-click="handleAddClick"
|
|
@edit-click="handleEditClick"
|
|
@export-click="handleExportClick"
|
|
@search-click="handleSearchClick"
|
|
@toolbar-click="handleToolbarClick"
|
|
@operat-click="handleOperatClick"
|
|
@filter-change="handleFilterChange"
|
|
>
|
|
<template #status="scope">
|
|
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
|
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
|
</el-tag>
|
|
</template>
|
|
<template #options="scope">
|
|
{{ returnOptionsLabel(scope.prop, scope.row[scope.prop]) }}
|
|
</template>
|
|
<template #switch="scope">
|
|
<el-switch
|
|
v-model="scope.row[scope.prop]"
|
|
disabled
|
|
:active-value="1"
|
|
:inactive-value="0"
|
|
></el-switch>
|
|
</template>
|
|
<template #mobile="scope">
|
|
<el-text>{{ scope.row[scope.prop] }}</el-text>
|
|
<copy-button
|
|
v-if="scope.row[scope.prop]"
|
|
:text="scope.row[scope.prop]"
|
|
style="margin-left: 2px"
|
|
/>
|
|
</template>
|
|
</page-content>
|
|
|
|
<!-- 新增 -->
|
|
<page-modal
|
|
ref="addModalRef"
|
|
:modal-config="addModalConfig"
|
|
@submit-click="handleSubmitClick"
|
|
></page-modal>
|
|
|
|
<!-- 编辑 -->
|
|
<page-modal
|
|
ref="editModalRef"
|
|
:modal-config="editModalConfig"
|
|
@submit-click="handleSubmitClick"
|
|
></page-modal>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import VersionApi from "@/api/system/version";
|
|
import type { IObject, IOperatData } from "@/components/CURD/types";
|
|
import usePage from "@/components/CURD/usePage";
|
|
import addModalConfig from "./config/add";
|
|
import contentConfig from "./config/content";
|
|
import editModalConfig from "./config/edit";
|
|
import searchConfig from "./config/search";
|
|
import { returnOptionsLabel } from "./config/config";
|
|
import { isSyncStatus } from "@/utils/index";
|
|
|
|
const {
|
|
searchRef,
|
|
contentRef,
|
|
addModalRef,
|
|
editModalRef,
|
|
handleQueryClick,
|
|
handleResetClick,
|
|
// handleAddClick,
|
|
// handleEditClick,
|
|
handleSubmitClick,
|
|
handleExportClick,
|
|
handleSearchClick,
|
|
handleFilterChange,
|
|
} = usePage();
|
|
|
|
if (isSyncStatus()) {
|
|
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){
|
|
contentConfig.toolbar?.splice(0, 1)
|
|
}
|
|
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("edit") != -1){
|
|
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(0, 1)
|
|
}
|
|
}
|
|
// 新增
|
|
async function handleAddClick() {
|
|
addModalRef.value?.setModalVisible();
|
|
// addModalConfig.formItems[2]!.attrs!.data =
|
|
}
|
|
// 编辑
|
|
async function handleEditClick(row: IObject) {
|
|
editModalRef.value?.handleDisabled(false);
|
|
editModalRef.value?.setModalVisible();
|
|
// 根据id获取数据进行填充
|
|
console.log(row);
|
|
editModalRef.value?.setFormData({ ...row });
|
|
}
|
|
1;
|
|
// 其他工具栏
|
|
function handleToolbarClick(name: string) {
|
|
console.log(name);
|
|
if (name === "custom1") {
|
|
ElMessage.success("点击了自定义1按钮");
|
|
}
|
|
}
|
|
// 其他操作列
|
|
async function handleOperatClick(data: IOperatData) {
|
|
console.log(data);
|
|
}
|
|
</script>
|