From fe631515b71782a10a750874f6d4582fe027cd22 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 03 十一月 2025 09:32:49 +0800
Subject: [PATCH] 公司-所有的表格添加斑马纹
---
src/views/system/post/index.vue | 161 ++++++++++++++++++++++++++---------------------------
1 files changed, 79 insertions(+), 82 deletions(-)
diff --git a/src/views/system/post/index.vue b/src/views/system/post/index.vue
index a988d65..39f807f 100644
--- a/src/views/system/post/index.vue
+++ b/src/views/system/post/index.vue
@@ -1,12 +1,12 @@
<template>
<div class="app-container">
- <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
+ <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
<el-form-item label="宀椾綅缂栫爜" prop="postCode">
<el-input
v-model="queryParams.postCode"
placeholder="璇疯緭鍏ュ矖浣嶇紪鐮�"
clearable
- size="small"
+ style="width: 200px"
@keyup.enter="handleQuery"
/>
</el-form-item>
@@ -15,12 +15,12 @@
v-model="queryParams.postName"
placeholder="璇疯緭鍏ュ矖浣嶅悕绉�"
clearable
- size="small"
+ style="width: 200px"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="鐘舵��" prop="status">
- <el-select v-model="queryParams.status" placeholder="宀椾綅鐘舵��" clearable size="small">
+ <el-select v-model="queryParams.status" placeholder="宀椾綅鐘舵��" clearable style="width: 200px">
<el-option
v-for="dict in sys_normal_disable"
:key="dict.value"
@@ -30,8 +30,8 @@
</el-select>
</el-form-item>
<el-form-item>
- <el-button type="primary" icon="Search" size="mini" @click="handleQuery">鎼滅储</el-button>
- <el-button icon="Refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
+ <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button>
+ <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button>
</el-form-item>
</el-form>
@@ -41,7 +41,6 @@
type="primary"
plain
icon="Plus"
- size="mini"
@click="handleAdd"
v-hasPermi="['system:post:add']"
>鏂板</el-button>
@@ -51,7 +50,6 @@
type="success"
plain
icon="Edit"
- size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:post:edit']"
@@ -62,7 +60,6 @@
type="danger"
plain
icon="Delete"
- size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:post:remove']"
@@ -73,7 +70,6 @@
type="warning"
plain
icon="Download"
- size="mini"
@click="handleExport"
v-hasPermi="['system:post:export']"
>瀵煎嚭</el-button>
@@ -81,7 +77,7 @@
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
- <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
+ <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange" stripe>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="宀椾綅缂栧彿" align="center" prop="postId" />
<el-table-column label="宀椾綅缂栫爜" align="center" prop="postCode" />
@@ -97,22 +93,10 @@
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
- <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
+ <el-table-column label="鎿嶄綔" width="180" align="center" class-name="small-padding fixed-width">
<template #default="scope">
- <el-button
- size="mini"
- type="text"
- icon="Edit"
- @click="handleUpdate(scope.row)"
- v-hasPermi="['system:post:edit']"
- >淇敼</el-button>
- <el-button
- size="mini"
- type="text"
- icon="Delete"
- @click="handleDelete(scope.row)"
- v-hasPermi="['system:post:remove']"
- >鍒犻櫎</el-button>
+ <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:post:edit']">淇敼</el-button>
+ <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:post:remove']">鍒犻櫎</el-button>
</template>
</el-table-column>
</el-table>
@@ -142,7 +126,7 @@
<el-radio
v-for="dict in sys_normal_disable"
:key="dict.value"
- :label="dict.value"
+ :value="dict.value"
>{{ dict.label }}</el-radio>
</el-radio-group>
</el-form-item>
@@ -161,20 +145,21 @@
</template>
<script setup name="Post">
-import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post";
+import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post"
+import {onMounted} from "vue";
-const { proxy } = getCurrentInstance();
-const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
+const { proxy } = getCurrentInstance()
+const { sys_normal_disable } = proxy.useDict("sys_normal_disable")
-const postList = ref([]);
-const open = ref(false);
-const loading = ref(true);
-const showSearch = ref(true);
-const ids = ref([]);
-const single = ref(true);
-const multiple = ref(true);
-const total = ref(0);
-const title = ref("");
+const postList = ref([])
+const open = ref(false)
+const loading = ref(true)
+const showSearch = ref(true)
+const ids = ref([])
+const single = ref(true)
+const multiple = ref(true)
+const total = ref(0)
+const title = ref("")
const data = reactive({
form: {},
@@ -190,24 +175,26 @@
postCode: [{ required: true, message: "宀椾綅缂栫爜涓嶈兘涓虹┖", trigger: "blur" }],
postSort: [{ required: true, message: "宀椾綅椤哄簭涓嶈兘涓虹┖", trigger: "blur" }],
}
-});
+})
-const { queryParams, form, rules } = toRefs(data);
+const { queryParams, form, rules } = toRefs(data)
/** 鏌ヨ宀椾綅鍒楄〃 */
function getList() {
- loading.value = true;
+ loading.value = true
listPost(queryParams.value).then(response => {
- postList.value = response.rows;
- total.value = response.total;
- loading.value = false;
- });
+ postList.value = response.rows
+ total.value = response.total
+ loading.value = false
+ })
}
+
/** 鍙栨秷鎸夐挳 */
function cancel() {
- open.value = false;
- reset();
+ open.value = false
+ reset()
}
+
/** 琛ㄥ崟閲嶇疆 */
function reset() {
form.value = {
@@ -217,77 +204,87 @@
postSort: 0,
status: "0",
remark: undefined
- };
- proxy.resetForm("postRef");
+ }
+ proxy.resetForm("postRef")
}
+
/** 鎼滅储鎸夐挳鎿嶄綔 */
function handleQuery() {
- queryParams.value.pageNum = 1;
- getList();
+ queryParams.value.pageNum = 1
+ getList()
}
+
/** 閲嶇疆鎸夐挳鎿嶄綔 */
function resetQuery() {
- proxy.resetForm("queryRef");
- handleQuery();
+ proxy.resetForm("queryRef")
+ handleQuery()
}
+
/** 澶氶�夋閫変腑鏁版嵁 */
function handleSelectionChange(selection) {
- ids.value = selection.map(item => item.postId);
- single.value = selection.length != 1;
- multiple.value = !selection.length;
+ ids.value = selection.map(item => item.postId)
+ single.value = selection.length != 1
+ multiple.value = !selection.length
}
+
/** 鏂板鎸夐挳鎿嶄綔 */
function handleAdd() {
- reset();
- open.value = true;
- title.value = "娣诲姞宀椾綅";
+ reset()
+ open.value = true
+ title.value = "娣诲姞宀椾綅"
}
+
/** 淇敼鎸夐挳鎿嶄綔 */
function handleUpdate(row) {
- reset();
- const postId = row.postId || ids.value;
+ reset()
+ const postId = row.postId || ids.value
getPost(postId).then(response => {
- form.value = response.data;
- open.value = true;
- title.value = "淇敼宀椾綅";
- });
+ form.value = response.data
+ open.value = true
+ title.value = "淇敼宀椾綅"
+ })
}
+
/** 鎻愪氦鎸夐挳 */
function submitForm() {
proxy.$refs["postRef"].validate(valid => {
if (valid) {
if (form.value.postId != undefined) {
updatePost(form.value).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛");
- open.value = false;
- getList();
- });
+ proxy.$modal.msgSuccess("淇敼鎴愬姛")
+ open.value = false
+ getList()
+ })
} else {
addPost(form.value).then(response => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛");
- open.value = false;
- getList();
- });
+ proxy.$modal.msgSuccess("鏂板鎴愬姛")
+ open.value = false
+ getList()
+ })
}
}
- });
+ })
}
+
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
function handleDelete(row) {
- const postIds = row.postId || ids.value;
+ const postIds = row.postId || ids.value
proxy.$modal.confirm('鏄惁纭鍒犻櫎宀椾綅缂栧彿涓�"' + postIds + '"鐨勬暟鎹」锛�').then(function() {
- return delPost(postIds);
+ return delPost(postIds)
}).then(() => {
- getList();
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- }).catch(() => {});
+ getList()
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
+ }).catch(() => {})
}
+
/** 瀵煎嚭鎸夐挳鎿嶄綔 */
function handleExport() {
proxy.download("system/post/export", {
...queryParams.value
- }, `post_${new Date().getTime()}.xlsx`);
+ }, `post_${new Date().getTime()}.xlsx`)
}
-getList();
+onMounted(() => {
+ getList();
+});
</script>
--
Gitblit v1.9.3