elementui-table分页+增删改查实例

柔光的暖阳◎ 2022-04-13 08:27 548阅读 0赞
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>团队表</title>
  5. <#include "/header.html">
  6. <!-- 文件上传 -->
  7. <link rel="stylesheet" href="${request.contextPath}/statics/plugins/oss/style.css">
  8. <script type="text/javascript" src="${request.contextPath}/statics/plugins/oss/js/plupload.full.min.js"></script>
  9. <script type="text/javascript" src="${request.contextPath}/statics/plugins/oss/ziyun_library.js"></script>
  10. <!-- 图片预览 -->
  11. <link rel="stylesheet" href="${request.contextPath}/statics/plugins/viewer/viewer.min.css">
  12. <script src="${request.contextPath}/statics/plugins/viewer/viewer.min.js"></script>
  13. </head>
  14. <body>
  15. <div id="app">
  16. <div>
  17. <el-form :inline="true" v-model="q">
  18. <el-button type="primary" size="medium" icon="el-icon-search" @click="search"></el-button>
  19. <el-button type="primary" size="medium" @click="rest">重置</el-button>
  20. <el-form-item>
  21. <el-input v-model="q.teamName" placeholder="团队名"></el-input>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-input v-model="q.mobile" placeholder="手机号码"></el-input>
  25. </el-form-item>
  26. <el-select v-model="q.sourceType" placeholder="分销类型">
  27. <el-option label="一企推" value="together"></el-option>
  28. <el-option label="代理点二级分销" value="agent"></el-option>
  29. <el-option label="微信朋友圈推广" value="wechat"></el-option>
  30. </el-select>
  31. <el-select v-model="q.auditStatus" placeholder="审核状态">
  32. <el-option label="待审核" value=0></el-option>
  33. <el-option label="审核通过" value=1></el-option>
  34. <el-option label="已拒绝" value=2></el-option>
  35. </el-select>
  36. </el-form>
  37. <el-table ref="testTable" :data="tableData" style="width:100%" border highlight-current-row class="tb-edit"
  38. :default-sort="{prop: 'updatetime', order: 'descending'}" @selection-change="handleSelectionChange" @row-click="handleclick">
  39. <el-table-column prop="teamId" label="团队ID" sortable show-overflow-tooltip></el-table-column>
  40. <el-table-column prop="teamName" label="团队名" sortable show-overflow-tooltip></el-table-column>
  41. <el-table-column prop="userId" label="团长ID" sortable show-overflow-tooltip></el-table-column>
  42. <el-table-column prop="mobile" label="手机号码" sortable show-overflow-tooltip></el-table-column>
  43. <el-table-column prop="createtime" label="创建时间" sortable show-overflow-tooltip></el-table-column>
  44. <el-table-column prop="remark" label="团队备注" sortable show-overflow-tooltip></el-table-column>
  45. <el-table-column prop="sourceType" label="团队分销类型" sortable show-overflow-tooltip :formatter="sourceTypeFormatter"></el-table-column>
  46. <el-table-column prop="updatetime" label="更新时间" sortable show-overflow-tooltip></el-table-column>
  47. <el-table-column prop="auditStatus" label="审核状态" sortable show-overflow-tooltip :formatter="auditStatusFormatter"></el-table-column>
  48. <el-table-column label="操作">
  49. <template scope="scope">
  50. <!--<el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>-->
  51. <el-button size="small" type="primary" @click="handleAudit(scope.$index, scope.row)">审核</el-button>
  52. </template>
  53. </el-table-column>
  54. <el-table-column v-if="false" prop="businessUrl" label="营业执照url" sortable show-overflow-tooltip></el-table-column>
  55. <el-table-column v-if="false" prop="idCardUrls" label="身份证url" sortable show-overflow-tooltip></el-table-column>
  56. <el-table-column v-if="false" prop="refuseReason" label="拒绝理由" sortable show-overflow-tooltip></el-table-column>
  57. </el-table>
  58. <div align="center">
  59. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
  60. :page-sizes="[20, 50, 80, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="totalCount"
  61. background>
  62. </el-pagination>
  63. </div>
  64. </div>
  65. <el-dialog title="团队审核" :visible.sync="dialogFormVisible" width="60%">
  66. <el-form :inline="true">
  67. <el-row>
  68. <el-col :span="8">
  69. <el-form-item label="团队名">
  70. <el-input v-model="curRowData.teamName" readonly></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="8">
  74. <el-form-item label="手机号码">
  75. <el-input v-model="curRowData.mobile" readonly></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="8">
  79. <el-form-item label="团队分销类型">
  80. <el-input v-if="curRowData.sourceType=='together'" value="一企推" readonly></el-input>
  81. <el-input v-if="curRowData.sourceType=='agent'" value="代理点二级分销" readonly></el-input>
  82. <el-input v-if="curRowData.sourceType=='wechat'" value="微信朋友圈推广" readonly></el-input>
  83. <el-input v-if="curRowData.sourceType=='second'" value="二级分销(不审)" readonly></el-input>
  84. </el-form-item>
  85. </el-col>
  86. <div id="view">
  87. <el-col :span="8">
  88. <el-form-item label="营业执照">
  89. <img :src="'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/'+curRowData.businessUrl" style="width: 200px">
  90. <!--<br><a class="btn btn-info btn-sm" id="uploadImage1">上传图片</a>-->
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="8">
  94. <el-form-item label="身份证图片">
  95. <img :src="'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/'+idCardImgs[0]" style="width: 200px">
  96. <!--<a class="btn btn-info btn-sm" id="uploadImage2">上传图片</a>-->
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="8">
  100. <el-form-item label="身份证图片">
  101. <img :src="'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/'+idCardImgs[1]" style="width: 200px">
  102. <!--<a class="btn btn-info btn-sm" id="uploadImage2">上传图片</a>-->
  103. </el-form-item>
  104. </el-col>
  105. </div>
  106. </el-row>
  107. <el-row>
  108. <el-col :span="8">
  109. <el-form-item label="拒绝理由">
  110. <el-input v-model="curRowData.refuseReason" style="width: 260%"></el-input>
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. </el-form>
  115. <div slot="footer" class="dialog-footer">
  116. <el-button type="primary" size="medium" @click="pass" :disabled="curRowData.auditStatus!=0">拒绝</el-button>
  117. <el-button type="primary" size="medium" @click="audit" :disabled="curRowData.auditStatus!=0">通过</el-button>
  118. </div>
  119. </el-dialog>
  120. </div>
  121. <script src="${request.contextPath}/statics/js/modules/userTeam/userteama.js?_${.now?long}"></script>
  122. <style>
  123. /* 设置当前选中行的背景颜色 */
  124. .el-table__body tr.current-row>td {
  125. background: #c9eff5 !important;
  126. }
  127. /* 设置表主体的高度 */
  128. .el-table__body td,.el-table__body th{
  129. padding:3px;
  130. }
  131. /* 设置表头的高度 */
  132. .el-table__header td,.el-table__header th{
  133. padding:6px 0px;
  134. }
  135. </style>
  136. </body>
  137. </html>
  138. const vm = new Vue({
  139. el: '#app',
  140. data: {
  141. tableData: [],//表格当前页数据
  142. criteria: '',
  143. select: '',//下拉菜单选项
  144. pagesize: 20,//默认每页数据量
  145. curRowData: {}, //当前选择行数据
  146. currentPage: 1,//当前页码
  147. start: 1, //查询的页码
  148. totalCount: '',//默认数据总数
  149. multipleSelection: [],//多选数组
  150. dialogFormVisible:false,//编辑框
  151. q:{//搜索条件
  152. teamName:'',
  153. mobile:'',
  154. sourceType:'',
  155. auditStatus:''
  156. },
  157. idCardImgs:[],//身份证正反面url
  158. },
  159. created () {
  160. Vue.nextTick(()=>{
  161. //载入数据
  162. vm.loadData(vm.currentPage, vm.pagesize);
  163. });
  164. },
  165. methods: {
  166. //从后台获取数据
  167. loadData: function (page, limit) {
  168. let {teamName,mobile,sourceType,auditStatus} = vm.q
  169. const params = {page,limit,teamName,mobile,sourceType,auditStatus}
  170. $.ajax({
  171. type: "POST",
  172. url: baseURL + "userTeam/userteam/list",
  173. contentType: "application/json",
  174. data: JSON.stringify(params),
  175. success: function(r){
  176. if(r.code === 0){
  177. vm.tableData = r.page.list
  178. vm.totalCount = r.page.totalCount
  179. }else{
  180. alert(r.msg);
  181. }
  182. }
  183. });
  184. },
  185. //多选响应
  186. handleSelectionChange: function(val) {
  187. vm.multipleSelection = val;
  188. console.log(vm.multipleSelection)
  189. },
  190. //点击行响应
  191. handleclick: function(row, event, column){
  192. vm.curRowData = JSON.parse(JSON.stringify(row));//深克隆
  193. },
  194. //弹出编辑框
  195. handleEdit: function(index, row) {
  196. vm.curRowData = JSON.parse(JSON.stringify(row));//深克隆
  197. vm.dialogFormVisible = true
  198. },
  199. //提交编辑
  200. edit() {
  201. $.ajax({
  202. type: "POST",
  203. url: baseURL + "userTeam/userteam/update",
  204. contentType: "application/json",
  205. data: JSON.stringify(vm.curRowData),
  206. success: function(r){
  207. if(r.code === 0){
  208. vm.loadData(vm.currentPage, vm.pagesize);//刷新后页面在当前页
  209. //vm.loadData(vm.currentPage=1, vm.pagesize);刷新后页面回到首页
  210. vm.dialogFormVisible = false
  211. }else{
  212. alert(r.msg);
  213. }
  214. }
  215. });
  216. },
  217. //弹出审核框
  218. handleAudit: function(index, row) {
  219. vm.curRowData = JSON.parse(JSON.stringify(row));//深克隆
  220. if (vm.curRowData.idCardUrls) {
  221. vm.idCardImgs=vm.curRowData.idCardUrls.split(',')
  222. }
  223. vm.dialogFormVisible = true;
  224. Vue.nextTick(function () {
  225. // 图片预览初始化
  226. $('#view').viewer();
  227. /* oss上传 */
  228. $.files_up_oss({
  229. id: ["uploadImage1"],//按钮id
  230. url: "/sys/oss/getSignature",
  231. dir: "config/couponucenter/",
  232. file_type: "jpg,png,gif,psd,ai,cdr,eps,ppt,word,excel,pdf,tiff,rar,zip,7z,gif,AVI,WMV,RM,RMVB,MPEG1,MPEG2,MPEG4,3GP,ASF,SWF,VOB,DAT,MOV,M4V,FLV,F4V,MKV,TIF",
  233. size: "100mb",//mb
  234. view_url: "https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/"
  235. }, function (index_number, json) {
  236. if (json.Status == 'OK') {
  237. Vue.set(vm.curRowData, 'businessUrl', json.filename);
  238. }
  239. })
  240. });
  241. },
  242. //审核通过
  243. audit() {
  244. $.ajax({
  245. type: "POST",
  246. url: baseURL + "userTeam/userteam/audit",
  247. contentType: "application/json",
  248. data: JSON.stringify(vm.curRowData),
  249. success: function(r){
  250. if(r.code === 0){
  251. alert('审核通过')
  252. vm.dialogFormVisible = false
  253. vm.loadData(vm.currentPage=1, vm.pagesize);//刷新后页面回到首页
  254. }else{
  255. alert(r.msg);
  256. }
  257. }
  258. });
  259. },
  260. //审核拒绝
  261. pass() {
  262. $.ajax({
  263. type: "POST",
  264. url: baseURL + "userTeam/userteam/pass",
  265. contentType: "application/json",
  266. data: JSON.stringify(vm.curRowData),
  267. success: function(r){
  268. if(r.code === 0){
  269. alert('拒绝成功')
  270. vm.dialogFormVisible = false
  271. vm.loadData(vm.currentPage=1, vm.pagesize);//刷新后页面回到首页
  272. }else{
  273. alert(r.msg);
  274. }
  275. }
  276. });
  277. },
  278. //单行删除
  279. handleDelete: function(index, row) {
  280. $.ajax({
  281. type: "POST",
  282. url: baseURL + "userTeam/userteam/delete",
  283. contentType: "application/json",
  284. data: JSON.stringify(row),
  285. success: function(r){
  286. if(r.code === 0){
  287. alert('删除成功')
  288. vm.loadData(vm.currentPage, vm.pagesize);//刷新后页面在当前页
  289. //vm.loadData(vm.currentPage=1, vm.pagesize);刷新后页面回到首页
  290. }else{
  291. alert(r.msg);
  292. }
  293. }
  294. });
  295. },
  296. //搜索
  297. search: function(){
  298. vm.loadData(vm.currentPage, vm.pagesize);
  299. },
  300. //重置
  301. rest() {
  302. vm.q.teamName=''
  303. vm.q.mobile=''
  304. vm.q.sourceType=''
  305. vm.q.auditStatus=''
  306. vm.loadData(vm.currentPage, vm.pagesize);
  307. },
  308. add() {
  309. },
  310. //每页显示数据量变更
  311. handleSizeChange: function(val) {
  312. vm.pagesize = val;
  313. vm.loadData(vm.currentPage, vm.pagesize);
  314. },
  315. //页码变更
  316. handleCurrentChange: function(val) {
  317. vm.currentPage = val;
  318. vm.loadData(vm.currentPage, vm.pagesize);
  319. },
  320. //together:一企推,agent:代理点二级分销,wechat:微信朋友圈推广, second:二级分销(不审)
  321. sourceTypeFormatter(val) {
  322. if(val.sourceType == 'together')
  323. {return "一企推"}
  324. else if (val.sourceType == 'agent')
  325. {return "代理点二级分销"}
  326. else if (val.sourceType == 'wechat')
  327. {return "微信朋友圈推广"}
  328. else if (val.sourceType == 'second')
  329. {return "二级分销(不审)"}
  330. else
  331. {return ""}
  332. },
  333. //审核状态 0:待审核 1:审核通过 2:已拒绝
  334. auditStatusFormatter(val) {
  335. if(val.auditStatus == 0)
  336. {return "待审核"}
  337. else if (val.auditStatus == 1)
  338. {return "审核通过"}
  339. else if (val.auditStatus == 2)
  340. {return "已拒绝"}
  341. else
  342. {return ""}
  343. },
  344. }
  345. });
  346. @Override
  347. public PageUtils list(Map<String, Object> params) {
  348. Page<UserTeamVo> page = new Page<>();
  349. page.setCurrent(Integer.valueOf(params.get("page").toString()));
  350. page.setSize(Integer.valueOf(params.get("limit").toString()));
  351. List<UserTeamVo> list = this.baseMapper.list(page, params);
  352. page.setRecords(list);
  353. return new PageUtils(page);
  354. }

发表评论

表情:
评论列表 (有 0 条评论,548人围观)

还没有评论,来说两句吧...

相关阅读