瀏覽代碼

常用功能可拖动

wgl 4 年之前
父節點
當前提交
7c2943497d
共有 4 個文件被更改,包括 59 次插入30 次删除
  1. 1 0
      package.json
  2. 23 15
      src/projects/business/views/Master/EditFun.vue
  3. 23 15
      src/projects/pension/views/Master/EditFun.vue
  4. 12 0
      yarn.lock

+ 1 - 0
package.json

@@ -23,6 +23,7 @@
 		"vue-cropper": "^0.5.5",
 		"vue-directive-image-previewer": "^2.2.2",
 		"vue-router": "^3.2.0",
+		"vuedraggable": "^2.24.3",
 		"vuex": "^3.4.0",
 		"weixin-js-sdk": "^1.6.0"
 	},

+ 23 - 15
src/projects/business/views/Master/EditFun.vue

@@ -9,13 +9,15 @@
 			<div class="vongi-all">
 				<h4 class="vongi-center">您可以将常用的应用添加到主页</h4>
 				<ul class="mui-table-view mui-grid-view mui-grid-9">
-					<li draggable="true" v-for="(item,index) in menu_list" class="mui-table-view-cell mui-media mui-col-xs-3">
-						<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
-						<img :src="requirePic(item.iconPic)" />
-						<div class="mui-media-body" v-text="item.iconName"></div>
-						<!-- </router-link> -->
-						<span @click="del(item.id,index)" class="mui-icon mui-icon-closeempty vongi-close"></span>
-					</li>
+					<draggable element="ul" v-model="menuList" :options="{draggable:'.mui-table-view-cell'}">
+						<li draggable="true" v-for="(item,index) in menuList" class="mui-table-view-cell mui-media mui-col-xs-3">
+							<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
+							<img :src="requirePic(item.iconPic)" />
+							<div class="mui-media-body" v-text="item.iconName"></div>
+							<!-- </router-link> -->
+							<span @click="del(item.id,index)" class="mui-icon mui-icon-closeempty vongi-close"></span>
+						</li>
+					</draggable>
 				</ul>
 			</div>
 			<div class="vongi-all">
@@ -40,6 +42,7 @@
 </template>
 
 <script>
+	import draggable from 'vuedraggable'
 	import * as API_User from '$project/apis/user'
 	import Common from '$project/components/Common.vue'
 	import Loading from '$project/components/Loading.vue'
@@ -55,7 +58,8 @@
 			Common,
 			Loading,
 			TopHeader,
-			NavMenu
+			NavMenu,
+			draggable,
 		},
 		data() {
 			return {
@@ -76,6 +80,7 @@
 			}
 		},
 		created() {
+			this.menuList = this.menu_list;
 			this.resetIdList();
 		},
 		methods: {
@@ -117,23 +122,23 @@
 			},
 			resetIdList() {
 				var list = [];
-				for (var i = 0; i < this.menu_list.length; i++) {
-					list.push(this.menu_list[i]['id']);
+				for (var i = 0; i < this.menuList.length; i++) {
+					list.push(this.menuList[i]['id']);
 				}
 				this.idList = list;
 			},
 			//添加图标
 			add(indy, index) {
-				this.menu_list.push(this.allFunList[indy]['list'][index])
+				this.menuList.push(this.allFunList[indy]['list'][index])
 				this.allFunList[indy]['list'][index]['is_show'] = 0;
 				this.allFunList[indy]['cun_num']--;
 			},
 			//减少图标
 			del(id, index) {
 
-				for (var i = 0; i < this.menu_list.length; i++) {
-					if (this.menu_list[i]['id'] == id) {
-						this.menu_list.splice(i, 1);
+				for (var i = 0; i < this.menuList.length; i++) {
+					if (this.menuList[i]['id'] == id) {
+						this.menuList.splice(i, 1);
 					}
 				}
 
@@ -186,5 +191,8 @@
 <style src="$project/assets/css/iconfont.css"></style>
 <style scoped src="$project/assets/css/xpgj.css"></style>
 <style scoped src="$project/assets/css/xpwyfyy.css"></style>
-<style>
+<style scoped>
+	.mui-table-view ul {
+		padding-left: 0;
+	}
 </style>

+ 23 - 15
src/projects/pension/views/Master/EditFun.vue

@@ -9,13 +9,15 @@
 			<div class="vongi-all">
 				<h4 class="vongi-center">您可以将常用的应用添加到主页</h4>
 				<ul class="mui-table-view mui-grid-view mui-grid-9">
-					<li draggable="true" v-for="(item,index) in menu_list" class="mui-table-view-cell mui-media mui-col-xs-3">
-						<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
-						<img :src="requirePic(item.iconPic)" />
-						<div class="mui-media-body" v-text="item.iconName"></div>
-						<!-- </router-link> -->
-						<span @click="del(item.id,index)" class="mui-icon mui-icon-closeempty vongi-close"></span>
-					</li>
+					<draggable element="ul" v-model="menuList" :options="{draggable:'.mui-table-view-cell'}">
+						<li draggable="true" v-for="(item,index) in menuList" class="mui-table-view-cell mui-media mui-col-xs-3">
+							<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
+							<img :src="requirePic(item.iconPic)" />
+							<div class="mui-media-body" v-text="item.iconName"></div>
+							<!-- </router-link> -->
+							<span @click="del(item.id,index)" class="mui-icon mui-icon-closeempty vongi-close"></span>
+						</li>
+					</draggable>
 				</ul>
 			</div>
 			<div class="vongi-all">
@@ -40,6 +42,7 @@
 </template>
 
 <script>
+	import draggable from 'vuedraggable'
 	import * as API_User from '$project/apis/user'
 	import Common from '$project/components/Common.vue'
 	import Loading from '$project/components/Loading.vue'
@@ -55,7 +58,8 @@
 			Common,
 			Loading,
 			TopHeader,
-			NavMenu
+			NavMenu,
+			draggable,
 		},
 		data() {
 			return {
@@ -76,6 +80,7 @@
 			}
 		},
 		created() {
+			this.menuList = this.menu_list;
 			this.resetIdList();
 		},
 		methods: {
@@ -117,23 +122,23 @@
 			},
 			resetIdList() {
 				var list = [];
-				for (var i = 0; i < this.menu_list.length; i++) {
-					list.push(this.menu_list[i]['id']);
+				for (var i = 0; i < this.menuList.length; i++) {
+					list.push(this.menuList[i]['id']);
 				}
 				this.idList = list;
 			},
 			//添加图标
 			add(indy, index) {
-				this.menu_list.push(this.allFunList[indy]['list'][index])
+				this.menuList.push(this.allFunList[indy]['list'][index])
 				this.allFunList[indy]['list'][index]['is_show'] = 0;
 				this.allFunList[indy]['cun_num']--;
 			},
 			//减少图标
 			del(id, index) {
 
-				for (var i = 0; i < this.menu_list.length; i++) {
-					if (this.menu_list[i]['id'] == id) {
-						this.menu_list.splice(i, 1);
+				for (var i = 0; i < this.menuList.length; i++) {
+					if (this.menuList[i]['id'] == id) {
+						this.menuList.splice(i, 1);
 					}
 				}
 
@@ -186,5 +191,8 @@
 <style src="$project/assets/css/iconfont.css"></style>
 <style scoped src="$project/assets/css/xpgj.css"></style>
 <style scoped src="$project/assets/css/xpwyfyy.css"></style>
-<style>
+<style scoped>
+	.mui-table-view ul {
+		padding-left: 0;
+	}
 </style>

+ 12 - 0
yarn.lock

@@ -7303,6 +7303,11 @@ sort-keys@^1.0.0:
   dependencies:
     is-plain-obj "^1.0.0"
 
+sortablejs@1.10.2:
+  version "1.10.2"
+  resolved "https://registry.npm.taobao.org/sortablejs/download/sortablejs-1.10.2.tgz#6e40364d913f98b85a14f6678f92b5c1221f5290"
+  integrity sha1-bkA2TZE/mLhaFPZnj5K1wSIfUpA=
+
 source-list-map@^2.0.0:
   version "2.0.1"
   resolved "https://registry.npm.taobao.org/source-list-map/download/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
@@ -8254,6 +8259,13 @@ vue@^2.4.2, vue@^2.6.11:
   resolved "https://registry.npm.taobao.org/vue/download/vue-2.6.12.tgz?cache=0&sync_timestamp=1600441238751&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-2.6.12.tgz#f5ebd4fa6bd2869403e29a896aed4904456c9123"
   integrity sha1-9evU+mvShpQD4pqJau1JBEVskSM=
 
+vuedraggable@^2.24.3:
+  version "2.24.3"
+  resolved "https://registry.npm.taobao.org/vuedraggable/download/vuedraggable-2.24.3.tgz?cache=0&sync_timestamp=1603589683626&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvuedraggable%2Fdownload%2Fvuedraggable-2.24.3.tgz#43c93849b746a24ce503e123d5b259c701ba0d19"
+  integrity sha1-Q8k4SbdGokzlA+Ej1bJZxwG6DRk=
+  dependencies:
+    sortablejs "1.10.2"
+
 vuex@^3.4.0:
   version "3.5.1"
   resolved "https://registry.npm.taobao.org/vuex/download/vuex-3.5.1.tgz#f1b8dcea649bc25254cf4f4358081dbf5da18b3d"