From 2d6ec7162f446b64fe395a7e77894277b9385d96 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期三, 13 三月 2024 10:57:06 +0800
Subject: [PATCH] feat:添加数据缓动效果
---
src/views/system/point/index.vue | 201 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 148 insertions(+), 53 deletions(-)
diff --git a/src/views/system/point/index.vue b/src/views/system/point/index.vue
index a0aa54e..d12157b 100644
--- a/src/views/system/point/index.vue
+++ b/src/views/system/point/index.vue
@@ -1,6 +1,6 @@
<template>
<div class="app-container">
- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="鐐逛綅鍚嶇О" prop="pointName">
<el-input
v-model="queryParams.pointName"
@@ -39,7 +39,6 @@
icon="el-icon-plus"
size="mini"
@click="handleAdd"
- v-hasPermi="['x:point:add']"
>鏂板</el-button>
</el-col>
<el-col :span="1.5">
@@ -50,7 +49,6 @@
size="mini"
:disabled="single"
@click="handleUpdate"
- v-hasPermi="['x:point:edit']"
>淇敼</el-button>
</el-col>
<el-col :span="1.5">
@@ -61,7 +59,6 @@
size="mini"
:disabled="multiple"
@click="handleDelete"
- v-hasPermi="['x:point:remove']"
>鍒犻櫎</el-button>
</el-col>
<el-col :span="1.5">
@@ -90,7 +87,7 @@
<span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
- <el-table-column label="杩愮淮鍗曚綅" align="center" prop="unitId" />
+ <el-table-column label="杩愮淮鍗曚綅" align="center" prop="unitName" />
<el-table-column label="杩愮淮鐘舵��" align="center" prop="status" />
<el-table-column label="澶囨敞" align="center" prop="remark" />
<el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
@@ -100,14 +97,12 @@
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
- v-hasPermi="['x:point:edit']"
>淇敼</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
- v-hasPermi="['x:point:remove']"
>鍒犻櫎</el-button>
</template>
</el-table-column>
@@ -121,47 +116,73 @@
@pagination="getList"
/>
- <!-- 娣诲姞鎴栦慨鏀硅繍缁寸偣浣嶅璇濇 -->
- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+ <!-- 娣诲姞杩愮淮鐐逛綅瀵硅瘽妗� -->
+ <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
+ <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="鐐逛綅鍚嶇О" prop="pointName">
<el-input v-model="form.pointName" placeholder="璇疯緭鍏ョ偣浣嶅悕绉�" />
</el-form-item>
- <el-form-item label="鐐逛綅寮�濮嬫椂闂�" prop="startTime">
- <el-date-picker clearable
- v-model="form.startTime"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="璇烽�夋嫨鐐逛綅寮�濮嬫椂闂�">
+ <el-form-item label="杩愮淮鍗曚綅" prop="unitId">
+ <el-select :disabled="title === '淇敼杩愮淮鐐逛綅'" v-model="form.unitId" placeholder="杩愮淮鍗曚綅">
+ <el-option
+ v-for="item in unitList"
+ :key="item.id"
+ :label="item.value"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鐐逛綅鏃跺尯" prop="timezone">
+ <el-date-picker
+ :disabled="title === '淇敼杩愮淮鐐逛綅'"
+ @change="dateChange"
+ v-model="form.timezone"
+ type="daterange"
+ align="right"
+ unlink-panels
+ range-separator="鑷�"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ >
</el-date-picker>
</el-form-item>
- <el-form-item label="鐐逛綅缁撴潫鏃堕棿" prop="endTime">
- <el-date-picker clearable
- v-model="form.endTime"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="璇烽�夋嫨鐐逛綅缁撴潫鏃堕棿">
- </el-date-picker>
+ <el-form-item>
+ <div style="display: flex;flex-direction: row-reverse">
+ <el-button @click="nextAdd" type="primary" plain>娣诲姞鐐逛綅</el-button>
+ </div>
</el-form-item>
- <el-form-item label="澶囨敞" prop="remark">
- <el-input v-model="form.remark" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" />
- </el-form-item>
+ <el-row style="min-height: 200px;max-height: 400px; overflow-y: auto">
+ <el-col class="col-item" v-for="(point) in tempFormList" :span="8">
+ <div style="margin-right: 5px">
+ <el-cascader v-model="point.region" :options="regionList" placeholder="璇烽�夋嫨鍖哄煙" :show-all-levels="false"></el-cascader>
+ </div>
+ <div v-if="title === '淇敼杩愮淮鐐逛綅'">
+ <el-button @click="removeRegion(point)" type="danger" icon="el-icon-delete" circle></el-button>
+ </div>
+ </el-col>
+ </el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
<el-button @click="cancel">鍙� 娑�</el-button>
</div>
</el-dialog>
+
</div>
</template>
<script>
-import { listPoint, getPoint, delPoint, addPoint, updatePoint } from "@/api/platform/point";
+import { listPoint, getPoint, delPoint, addPoint, addPointBatch, updatePoint } from "@/api/platform/point";
+import { unitSelect } from "@/api/platform/unit";
+import { getCascader } from '../../../api/platform/region'
export default {
name: "Point",
data() {
return {
+ regionList: [],
+ // 姝e湪淇敼绗嚑涓�
+ editingIndex: null,
// 閬僵灞�
loading: true,
// 閫変腑鏁扮粍
@@ -180,6 +201,12 @@
title: "",
// 鏄惁鏄剧ず寮瑰嚭灞�
open: false,
+ // 淇敼寮圭獥
+ editOpen: false,
+ // 杩愮淮鍗曚綅
+ unitList: [],
+ // 杩愮淮鏃跺尯
+ timezone:[],
// 鏌ヨ鍙傛暟
queryParams: {
pageNum: 1,
@@ -192,16 +219,19 @@
},
// 琛ㄥ崟鍙傛暟
form: {},
+ // 鎵归噺琛ㄥ崟鍐呭
+ formList:[],
+ // 涓存椂琛ㄥ崟鏁版嵁
+ tempForm: {},
+ // 涓存椂琛ㄥ崟鏁版嵁鍒楄〃
+ tempFormList: [],
// 琛ㄥ崟鏍¢獙
rules: {
pointName: [
{ required: true, message: "鐐逛綅鍚嶇О涓嶈兘涓虹┖", trigger: "blur" }
],
- startTime: [
- { required: true, message: "鐐逛綅寮�濮嬫椂闂翠笉鑳戒负绌�", trigger: "blur" }
- ],
- endTime: [
- { required: true, message: "鐐逛綅缁撴潫鏃堕棿涓嶈兘涓虹┖", trigger: "blur" }
+ timezone: [
+ { required: true, message: "鐐逛綅鏃跺尯涓嶈兘涓虹┖", trigger: "blur" }
],
unitId: [
{ required: true, message: "杩愮淮鍗曚綅涓嶈兘涓虹┖", trigger: "change" }
@@ -211,13 +241,58 @@
},
created() {
this.getList();
+ this.getUnitSelect();
+ this.getCascader();
},
methods: {
+ removeRegion(item) {
+ this.tempFormList = this.tempFormList.filter(data => data !== item)
+ },
+ // 鑾峰彇鍖哄幙绾ц仈
+ getCascader() {
+ getCascader().then(res => {
+ this.regionList = res.data;
+ })
+ },
+ // 鐐逛綅椤逛慨鏀瑰畬鎴�
+ editFinishItem(index) {
+ this.editingIndex = null;
+ let form = this.tempFormList[index];
+ form.startTime = form.timezone[0];
+ form.endTime = form.timezone[1];
+ this.formList[index] = form;
+ },
+ // 鐐逛綅椤逛慨鏀�
+ editPointItem(index) {
+ if (this.editingIndex !== index && this.editingIndex !== null) {
+ this.$modal.msgWarning("璇峰厛瀹屾垚涓婁竴涓慨鏀�");
+ } else {
+ this.editingIndex = index;
+ this.tempFormList[index] = this.formList[index];
+ }
+ },
+ // 鏃堕棿閫夋嫨鍙戠敓鍙樺寲
+ dateChange() {
+ this.tempForm.startTime = this.tempForm.timezone[0];
+ this.tempForm.endTime = this.tempForm.timezone[1];
+ },
+ // 缁х画娣诲姞鐐逛綅
+ nextAdd() {
+ let item = {}
+ // this.formList.push(item);
+ this.tempFormList.push(item);
+ },
+ getUnitSelect() {
+ // 杩愮淮鍗曚綅涓嬫媺鍒楄〃
+ unitSelect().then((res) => {
+ this.unitList = res.data;
+ })
+ },
/** 鏌ヨ杩愮淮鐐逛綅鍒楄〃 */
getList() {
this.loading = true;
listPoint(this.queryParams).then(response => {
- this.pointList = response.rows;
+ this.pointList = response.data;
this.total = response.total;
this.loading = false;
});
@@ -225,6 +300,10 @@
// 鍙栨秷鎸夐挳
cancel() {
this.open = false;
+ this.reset();
+ },
+ updateCancel() {
+ this.editOpen = false;
this.reset();
},
// 琛ㄥ崟閲嶇疆
@@ -239,7 +318,8 @@
remark: null,
createTime: null,
updateTime: null,
- deleted: null
+ deleted: null,
+ pointDetail: ""
};
this.resetForm("form");
},
@@ -256,7 +336,7 @@
// 澶氶�夋閫変腑鏁版嵁
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
- this.single = selection.length!==1
+ this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 鏂板鎸夐挳鎿嶄綔 */
@@ -271,29 +351,33 @@
const id = row.id || this.ids
getPoint(id).then(response => {
this.form = response.data;
+ this.form.timezone = [this.form.startTime, this.form.endTime]
+ if (this.form.pointDetail) {
+ this.tempFormList = JSON.parse(this.form.pointDetail)
+ }
this.open = true;
this.title = "淇敼杩愮淮鐐逛綅";
});
},
/** 鎻愪氦鎸夐挳 */
submitForm() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- if (this.form.id != null) {
- updatePoint(this.form).then(response => {
- this.$modal.msgSuccess("淇敼鎴愬姛");
- this.open = false;
- this.getList();
- });
- } else {
- addPoint(this.form).then(response => {
- this.$modal.msgSuccess("鏂板鎴愬姛");
- this.open = false;
- this.getList();
- });
- }
- }
- });
+ if (this.tempFormList) {
+ this.form.pointDetail = JSON.stringify(this.tempFormList)
+ }
+ if (this.form.id != null) {
+ updatePoint(this.form).then(response => {
+ this.$modal.msgSuccess("淇敼鎴愬姛");
+ this.open = false;
+ this.getList();
+ });
+ } else {
+ addPoint(this.form).then(response => {
+ this.$modal.msgSuccess("鏂板鎴愬姛");
+ this.open = false;
+ this.reset()
+ this.getList();
+ });
+ }
},
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
handleDelete(row) {
@@ -303,7 +387,8 @@
}).then(() => {
this.getList();
this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- }).catch(() => {});
+ }).catch(() => {
+ });
},
/** 瀵煎嚭鎸夐挳鎿嶄綔 */
handleExport() {
@@ -314,3 +399,13 @@
}
};
</script>
+
+<style scoped>
+.col-item {
+ margin: 5px 0;
+ display: flex;
+ flex-direction: row;
+ align-content: center;
+ justify-content: center;
+}
+</style>
--
Gitblit v1.8.0