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 |  147 ++++++++++++++++++++++--------------------------
 1 files changed, 67 insertions(+), 80 deletions(-)

diff --git a/src/views/system/point/index.vue b/src/views/system/point/index.vue
index 8f50e49..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,14 +116,14 @@
       @pagination="getList"
     />
 
-    <!-- 娣诲姞鎴栦慨鏀硅繍缁寸偣浣嶅璇濇 -->
+    <!-- 娣诲姞杩愮淮鐐逛綅瀵硅瘽妗� -->
     <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
-      <el-form ref="form" :model="tempForm" :rules="rules" label-width="120px">
+      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
         <el-form-item label="鐐逛綅鍚嶇О" prop="pointName">
-          <el-input v-model="tempForm.pointName" placeholder="璇疯緭鍏ョ偣浣嶅悕绉�" />
+          <el-input v-model="form.pointName" placeholder="璇疯緭鍏ョ偣浣嶅悕绉�" />
         </el-form-item>
         <el-form-item label="杩愮淮鍗曚綅" prop="unitId">
-          <el-select v-model="tempForm.unitId"  placeholder="杩愮淮鍗曚綅">
+          <el-select :disabled="title === '淇敼杩愮淮鐐逛綅'" v-model="form.unitId"  placeholder="杩愮淮鍗曚綅">
             <el-option
               v-for="item in unitList"
               :key="item.id"
@@ -139,8 +134,9 @@
         </el-form-item>
         <el-form-item label="鐐逛綅鏃跺尯" prop="timezone">
           <el-date-picker
+            :disabled="title === '淇敼杩愮淮鐐逛綅'"
             @change="dateChange"
-            v-model="tempForm.timezone"
+            v-model="form.timezone"
             type="daterange"
             align="right"
             unlink-panels
@@ -152,58 +148,39 @@
         </el-form-item>
         <el-form-item>
           <div style="display: flex;flex-direction: row-reverse">
-            <el-button @click="nextAdd" type="primary" plain>缁х画娣诲姞</el-button>
+            <el-button @click="nextAdd" type="primary" plain>娣诲姞鐐逛綅</el-button>
           </div>
         </el-form-item>
-          <div class="point-row" v-for="(point,index) in tempFormList">
-            <div class="row-item">
-              <el-input :disabled="editingIndex!==index" v-model="point.pointName" placeholder="鐐逛綅鍚嶇О"></el-input>
+        <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 class="row-item">
-              <el-select :disabled="editingIndex!==index" v-model="point.unitId"  placeholder="杩愮淮鍗曚綅">
-                <el-option
-                  v-for="item in unitList"
-                  :key="item.id"
-                  :label="item.value"
-                  :value="item.id">
-                </el-option>
-              </el-select>
+            <div v-if="title === '淇敼杩愮淮鐐逛綅'">
+              <el-button @click="removeRegion(point)" type="danger" icon="el-icon-delete" circle></el-button>
             </div>
-            <div class="row-item">
-              <el-date-picker
-                :disabled="editingIndex!==index"
-                v-model="point.timezone"
-                type="daterange"
-                align="right"
-                unlink-panels
-                range-separator="鑷�"
-                start-placeholder="寮�濮嬫棩鏈�"
-                end-placeholder="缁撴潫鏃ユ湡"
-              >
-              </el-date-picker>
-            </div>
-            <div  class="row-item">
-              <el-button v-show="editingIndex!==index" @click="editPointItem(index)" type="danger" size="small" plain>淇敼</el-button>
-              <el-button v-show="editingIndex===index" @click="editFinishItem(index)" type="success" size="small" plain>瀹屾垚</el-button>
-            </div>
-          </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, 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,
       // 閬僵灞�
@@ -224,6 +201,8 @@
       title: "",
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
+      // 淇敼寮圭獥
+      editOpen: false,
       // 杩愮淮鍗曚綅
       unitList: [],
       // 杩愮淮鏃跺尯
@@ -263,8 +242,18 @@
   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;
@@ -289,9 +278,9 @@
     },
     // 缁х画娣诲姞鐐逛綅
     nextAdd() {
-      this.formList.push(this.tempForm);
-      this.tempFormList.push(this.tempForm);
-      this.tempForm = {};
+      let item = {}
+      // this.formList.push(item);
+      this.tempFormList.push(item);
     },
     getUnitSelect() {
       // 杩愮淮鍗曚綅涓嬫媺鍒楄〃
@@ -313,6 +302,10 @@
       this.open = false;
       this.reset();
     },
+    updateCancel() {
+      this.editOpen = false;
+      this.reset();
+    },
     // 琛ㄥ崟閲嶇疆
     reset() {
       this.form = {
@@ -325,7 +318,8 @@
         remark: null,
         createTime: null,
         updateTime: null,
-        deleted: null
+        deleted: null,
+        pointDetail: ""
       };
       this.resetForm("form");
     },
@@ -342,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
     },
     /** 鏂板鎸夐挳鎿嶄綔 */
@@ -357,35 +351,32 @@
       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() {
-      if (this.formList.length > 0) {
-        // 鎵归噺澧炲姞
-        if (this.formList.every(item => !item.hasOwnProperty("id"))) {
-          addPointBatch(this.formList).then(response => {
-            this.$modal.msgSuccess("鏂板鎴愬姛");
-            this.open = false;
-            this.getList();
-          });
-        }
-      }else {
-        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();
+        });
       }
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
@@ -396,7 +387,8 @@
       }).then(() => {
         this.getList();
         this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-      }).catch(() => {});
+      }).catch(() => {
+      });
     },
     /** 瀵煎嚭鎸夐挳鎿嶄綔 */
     handleExport() {
@@ -409,16 +401,11 @@
 </script>
 
 <style scoped>
-.point-row {
+.col-item {
+  margin: 5px 0;
   display: flex;
   flex-direction: row;
+  align-content: center;
   justify-content: center;
-  align-items: center;
-}
-.row-item {
-  margin-right: 5px;
-}
-.row-item:nth-last-child {
-  margin-right: 0;
 }
 </style>

--
Gitblit v1.8.0