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 | 127 +++++++++++++++++++++++-------------------
1 files changed, 70 insertions(+), 57 deletions(-)
diff --git a/src/views/system/post/index.vue b/src/views/system/post/index.vue
index aee6034..39f807f 100644
--- a/src/views/system/post/index.vue
+++ b/src/views/system/post/index.vue
@@ -77,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" />
@@ -126,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>
@@ -145,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: {},
@@ -174,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 = {
@@ -201,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