当前位置:   article > 正文

ElementUI+VUE案例,demo_vue element ui demo

vue element ui demo
  1. <template>
  2. <div id="app" style="margin-top: 20px;" v-cloak>
  3. <el-col>
  4. <el-form ref="form" :model="form" label-width="100px" :inline="true">
  5. <el-form-item label="阿啊实打实达">
  6. <el-input v-model="form.md_typeName" size="mini" maxlength="20"></el-input>
  7. </el-form-item>
  8. <el-form-item label="发大股东非">
  9. <el-input v-model="form.md_typeName" size="mini" maxlength="20"></el-input>
  10. </el-form-item>
  11. <el-button style="margin-left: 20px" type="primary" @click="search" icon="el-icon-search">查询</el-button>
  12. <el-button type="danger" @click="showAddDialog" icon="el-icon-plus">添加</el-button>
  13. </el-form>
  14. <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
  15. &lt;!&ndash; <el-table-column type="selection" ></el-table-column>&ndash;&gt;
  16. <el-table-column type="index"></el-table-column>
  17. <el-table-column prop="id" label="胜多负少的" show-overflow-tooltip>
  18. </el-table-column>
  19. <el-table-column prop="b" label="阿达" show-overflow-tooltip>
  20. </el-table-column>
  21. <el-table-column prop="c" label="胜多负少" show-overflow-tooltip>
  22. </el-table-column>
  23. <el-table-column prop="d" label="苟富贵" show-overflow-tooltip>
  24. </el-table-column>
  25. <el-table-column prop="e" label="二维" show-overflow-tooltip>
  26. </el-table-column>
  27. <el-table-column prop="f" label="操作" show-overflow-tooltip>
  28. <template slot-scope="scope">
  29. <el-button type="primary" size="mini" @click="showEditDialog(scope.row.id)">编辑</el-button>
  30. <el-button type="warning" size="mini" @click="deleteInfo(scope.row.id)">删除</el-button>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[2, 4, 8, 10]" :page-size="2" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
  35. </el-col>
  36. <el-dialog
  37. title="修改"
  38. :visible.sync="EditdialogVisible"
  39. width="60%" >
  40. <el-form :model="eidtForm" :ref="eidtFormRef" label-width="70px" class="demo-ruleForm">
  41. <el-form-item label="地方">
  42. <el-input v-model="eidtForm.id"></el-input>
  43. </el-form-item>
  44. <el-form-item label="阿达">
  45. <el-input v-model="eidtForm.b"></el-input>
  46. </el-form-item>
  47. <el-form-item label="地方">
  48. <el-input v-model="eidtForm.c"></el-input>
  49. </el-form-item>
  50. <el-form-item label="胜多负少">
  51. <el-input v-model="eidtForm.d"></el-input>
  52. </el-form-item>
  53. <el-form-item label="给对方" >
  54. <el-input v-model="eidtForm.e"></el-input>
  55. </el-form-item>
  56. <el-form-item label="二维">
  57. <el-input v-model="eidtForm.f"></el-input>
  58. </el-form-item>
  59. </el-form>
  60. <span slot="footer" class="dialog-footer">
  61. <el-button @click="EditCanel">取 消</el-button>
  62. <el-button type="primary" @click="EditInfo">确 定</el-button>
  63. </span>
  64. </el-dialog>
  65. <el-dialog
  66. title="添加"
  67. :visible.sync="AddDialogVisible"
  68. width="60%" >
  69. <el-form :model="addForm" :ref="addForm" label-width="70px" class="demo-ruleForm">
  70. <el-form-item label="规划局">
  71. <el-input v-model="addForm.id"></el-input>
  72. </el-form-item>
  73. <el-form-item label="都是废话">
  74. <el-input v-model="addForm.b"></el-input>
  75. </el-form-item>
  76. <el-form-item label="关乎">
  77. <el-input v-model="addForm.c"></el-input>
  78. </el-form-item>
  79. <el-form-item label="师范">
  80. <el-input v-model="addForm.d"></el-input>
  81. </el-form-item>
  82. <el-form-item label="返回" >
  83. <el-input v-model="addForm.e"></el-input>
  84. </el-form-item>
  85. <el-form-item label="发过火">
  86. <el-input v-model="addForm.f"></el-input>
  87. </el-form-item>
  88. </el-form>
  89. <span slot="footer" class="dialog-footer">
  90. <el-button @click="AddCanel">取 消</el-button>
  91. <el-button type="primary" @click="addinfo">确 定</el-button>
  92. </span>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. export default {
  98. name: "index",
  99. data: function() {
  100. return {
  101. total: 3,
  102. showDiv: false,
  103. EditdialogVisible:false,
  104. AddDialogVisible:false,
  105. form: {
  106. md_typeId: '',
  107. md_typeName: '',
  108. md_ptName:'',
  109. pageSize: 2,
  110. pageIndex: 1
  111. },
  112. addForm:{},
  113. eidtForm:{
  114. id: '1111111',
  115. b: '王小虎',
  116. c: '上海市普陀区金沙江路 1518 弄',
  117. d:2,
  118. e:3,
  119. f:4
  120. },
  121. tableData: [{
  122. id: '1111111',
  123. b: '王小虎',
  124. c: '上海市普陀区金沙江路 1518 弄',
  125. d:2,
  126. e:3,
  127. f:4
  128. }, {
  129. id: '22222222',
  130. b: '王小虎',
  131. c: '上海市普陀区金沙江路 1518 弄',
  132. d:2,
  133. e:3,
  134. f:4
  135. }, {
  136. id: '333333',
  137. b: '王小虎',
  138. c: '上海市普陀区金沙江路 1518 弄',
  139. d:2,
  140. e:3,
  141. f:4
  142. }],
  143. multipleSelection: [],
  144. currentPage: 1,
  145. loading: false,
  146. message:''
  147. }
  148. },
  149. mounted: function() {
  150. //初始化
  151. this.search();
  152. },
  153. methods: {
  154. handleSelectionChange: function(val) {
  155. this.multipleSelection = val;
  156. },
  157. handleSizeChange: function(val) {
  158. this.form.pageSize = val;
  159. this.search();
  160. },
  161. handleCurrentChange: function(val) {
  162. this.form.pageIndex = val;
  163. this.search();
  164. },
  165. showEditDialog(id){
  166. this.EditdialogVisible=true;
  167. getObj(id)
  168. .then(response => {
  169. this.eidtForm = response.data;
  170. })
  171. },
  172. EditCanel(eidtForm){
  173. this.EditdialogVisible=false;
  174. this.$refs[eidtForm].resetFields();
  175. },
  176. EditInfo(){
  177. //关闭对话框 之后写里面
  178. this.EditdialogVisible=false;
  179. putObj(this.eidtForm.id,this.eidtForm)
  180. .then(response => {
  181. this.message = response.bodyText;
  182. //提示成功
  183. this.$message({
  184. showClose: true,
  185. message: this.message,
  186. type: 'success'
  187. });
  188. // 刷新页面
  189. this.search();
  190. })
  191. },
  192. deleteInfo(id){
  193. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  194. confirmButtonText: '确定',
  195. cancelButtonText: '取消',
  196. type: 'warning'
  197. }).then(() => {
  198. delObj(id)
  199. .then(() => {
  200. this.$notify({
  201. title: '成功',
  202. message: '删除成功',
  203. type: 'success',
  204. duration: 2000
  205. });
  206. });
  207. });
  208. },
  209. showAddDialog(){
  210. this.AddDialogVisible=true;
  211. },
  212. addinfo(){
  213. const set = this.$refs;
  214. set[addForm].validate(valid => {
  215. if (valid) {
  216. addObj(this.addForm)
  217. .then(() => {
  218. this.AddDialogVisible = false;
  219. this.getList();
  220. this.$notify({
  221. title: '成功',
  222. message: '创建成功',
  223. type: 'success',
  224. duration: 2000
  225. });
  226. })
  227. } else {
  228. return false;
  229. }
  230. });
  231. },
  232. AddCanel(){
  233. this.AddDialogVisible=false;
  234. this.$refs[addForm].resetFields();
  235. },
  236. search(){
  237. var vm = this;
  238. vm.loading=true;
  239. vm.$http.post(path + '/soft_TypeList', encrypt(vm.form)).then(function(response) {
  240. var objData = decrypt(response.bodyText);
  241. vm.tableData = objData.result.list;
  242. /* vm.total = objData.result.total*/
  243. vm.loading = false;
  244. }, function(response) {
  245. vm.loading = false;
  246. this.$message({
  247. showClose: true,
  248. message: '获取信息查询失败',
  249. type: 'error'
  250. });
  251. });
  252. }
  253. }
  254. }
  255. </script>
  256. <style scoped>
  257. html{
  258. background: #ffffff;
  259. }
  260. .el-form-item {
  261. margin-bottom: 10px;
  262. }
  263. .el-table th {
  264. background-color: #f0f0f0;
  265. }
  266. .el-table thead {
  267. color: #4f4f4f;
  268. }
  269. .el-pagination{
  270. text-align: center;
  271. }
  272. </style>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/300062
推荐阅读