Rap 原分销系统代码Web
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

eb8bfbd819a9ff9bc9243c626ab81eead127cb8b.svn-base 6.3KB

5 månader sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="app-container">
  3. <div>
  4. <el-button type="success" @click="addBtn">新增</el-button>
  5. </div>
  6. <!--搜索-->
  7. <el-form class="mt_15" ref="form" inline size="small">
  8. <el-form-item label="账号">
  9. <el-input v-model="searchParm.account" clearable placeholder='账号'></el-input>
  10. </el-form-item>
  11. <el-form-item label="昵称">
  12. <el-input v-model="searchParm.nickName" clearable></el-input>
  13. </el-form-item>
  14. <el-form-item label="密码">
  15. <el-input v-model="searchParm.pwd" clearable></el-input>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button type="primary" @click="goSearch">搜索</el-button>
  19. <el-button type="warning">重置</el-button>
  20. </el-form-item>
  21. </el-form>
  22. <!--表格渲染-->
  23. <el-table ref="table" border size="small" :data="list">
  24. <el-table-column label="序号" type="index" width="50" />
  25. <el-table-column label="账号" prop="account" />
  26. <el-table-column label="昵称" prop="nickName" />
  27. <el-table-column label="密码" prop="pwd" />
  28. <el-table-column label="创建时间" prop="createdAt" />
  29. <el-table-column label="修改时间" prop="updatedAt" />
  30. <el-table-column label="操作" width="220">
  31. <template slot-scope="scope">
  32. <el-button type="danger" @click="delById(scope.row.id)">删除</el-button>
  33. <el-button type="warning" @click="editById(scope.row)">修改</el-button>
  34. <el-button type="info" @click="getBtnById(scope.row.id)">查看</el-button>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. <!--分页-->
  39. <div class="mt_15">
  40. <el-pagination
  41. @size-change="handleSizeChange"
  42. @current-change="handleCurrentChange"
  43. :current-page="searchParm.page"
  44. :page-sizes="[10, 20, 30, 40, 50]"
  45. :page-size="searchParm.pageSize"
  46. layout="total, sizes, prev, pager, next, jumper"
  47. :total="total">
  48. </el-pagination>
  49. </div>
  50. <!--弹窗-->
  51. <el-dialog :visible.sync="dialogVisible" :title="dialogTitle" center width="45%">
  52. <div class="dialog-content">
  53. <el-form ref="ruleForm" size="small" :model="addParm" :rules="rules" label-width="100px">
  54. <el-form-item label="账号" prop="account">
  55. <el-input v-model="addParm.account" clearable></el-input>
  56. </el-form-item>
  57. <el-form-item label="昵称" prop="nickName">
  58. <el-input v-model="addParm.nickName" clearable></el-input>
  59. </el-form-item>
  60. <el-form-item label="密码" prop="pwd">
  61. <el-input v-model="addParm.pwd" clearable></el-input>
  62. </el-form-item>
  63. </el-form>
  64. </div>
  65. <span v-if="dialogTitle!='查看'" slot="footer">
  66. <el-button type="info" @click="dialogVisible=flase">取消</el-button>
  67. <el-button type="primary" @click="sureEdit">确认</el-button>
  68. </span>
  69. </el-dialog>
  70. </div>
  71. </template>
  72. <script>
  73. import { add, editById, delById, getList, getById } from '@/api/group/buyer'
  74. export default {
  75. // 数据
  76. data() {
  77. return {
  78. searchParm: {
  79. page: 1,
  80. pageSize: 10,
  81. account:null,
  82. sort:'id',
  83. order:'desc',
  84. nickName:null,
  85. pwd:null
  86. },
  87. total:0,
  88. list: [],
  89. dialogVisible: false,
  90. dialogTitle: '新增',
  91. addParm: {
  92. id: null,
  93. nickName:'',
  94. pwd:'',
  95. account: ''
  96. },
  97. rules: {
  98. pwd: [
  99. { required: true, message: '请输入密码', trigger: 'blur' }
  100. ],
  101. nickName: [
  102. { required: true, message: '请输入昵称', trigger: 'blur' }
  103. ],
  104. account: [
  105. { required: true, message: '请输入账号', trigger: 'blur' }
  106. ]
  107. }
  108. }
  109. },
  110. // 调用
  111. created() {
  112. this.goSearch()
  113. },
  114. //方法
  115. methods: {
  116. // 查询
  117. goSearch() {
  118. this.searchParm.page=1
  119. this.getDataList()
  120. },
  121. //重置
  122. // 新增
  123. addBtn(){
  124. this.addParm = {
  125. id: null,
  126. nickName:'',
  127. pwd:'',
  128. account: ''
  129. }
  130. this.dialogTitle='新增'
  131. this.dialogVisible = true
  132. },
  133. // 根据id删除
  134. delById(id){
  135. this.$confirm('确认删除?','提示',{
  136. confirmButtonText: '确定',
  137. cancelButtonText: '取消',
  138. type: 'warning'
  139. }).then(() => {
  140. delById({id}).then(res => {
  141. if(res.code==200) {
  142. this.$message.success('删除成功!')
  143. this.getDataList()
  144. }
  145. }).catch(err => {
  146. console.log(err)
  147. })
  148. }).catch(() => {
  149. this.$message.info('取消删除')
  150. })
  151. },
  152. // 修改
  153. editById(data){
  154. this.dialogTitle = '修改'
  155. getById({id: data.id}).then(res => {
  156. if(res.code==200) {
  157. this.addParm.id = res.data.id;
  158. this.addParm.nickName = res.data.nickName;
  159. this.addParm.pwd = res.data.pwd;
  160. this.addParm.account = res.data.account;
  161. this.dialogVisible = true
  162. this.$refs.ruleForm.clearValidate()
  163. }
  164. }).catch(err => {
  165. console.log(err)
  166. })
  167. },
  168. sureEdit(){
  169. if(this.dialogTitle == '新增'){
  170. add(this.addParm).then(res => {
  171. if(res.code==200) {
  172. this.dialogVisible = false
  173. this.$message.success('新增成功!')
  174. this.getDataList()
  175. }
  176. }).catch(err => {
  177. console.log(err)
  178. })
  179. } else{
  180. editById(this.addParm).then(res => {
  181. if(res.code==200) {
  182. console.log(res)
  183. this.dialogVisible = false
  184. this.$message.success('修改成功!')
  185. this.getDataList()
  186. }
  187. }).catch(err => {
  188. console.log(err)
  189. })
  190. }
  191. },
  192. // 查看根据id
  193. getBtnById(id){
  194. console.log("详情=============");
  195. this.dialogTitle = '详情'
  196. getById({id}).then(res => {
  197. if(res.code==200) {
  198. this.addParm.id = res.data.id;
  199. this.addParm.nickName = res.data.nickName;
  200. this.addParm.pwd = res.data.pwd;
  201. this.addParm.account = res.data.account;
  202. this.dialogVisible = true
  203. this.$refs.ruleForm.clearValidate()
  204. }
  205. }).catch(err => {
  206. console.log(err)
  207. })
  208. },
  209. // 分页获取表格数据
  210. getDataList(){
  211. getList(this.searchParm).then(res => {
  212. console.log(res)
  213. if(res.code==200) {
  214. console.log(res)
  215. this.list = res.data.list;
  216. this.total = res.data.total;
  217. }
  218. }).catch(err => {
  219. console.log(err)
  220. })
  221. },
  222. // 分页
  223. handleSizeChange(val) {
  224. console.log(`每页 ${val} 条`);
  225. this.searchParm.pageSize = val;
  226. this.getDataList();
  227. },
  228. handleCurrentChange(val) {
  229. console.log(`当前页: ${val}`);
  230. this.searchParm.page = val;
  231. this.getDataList();
  232. }
  233. }
  234. }
  235. </script>
  236. <style rel="stylesheet/scss" lang="scss" scoped>
  237. </style>