Buyer.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="adminShop-wrap">
  3. <div class="addShopBtn" @click="toShowAdd"><i class="el-icon-plus"></i><span>添加买家</span></div>
  4. <div class="shopList-wrap">
  5. <h5>买家信息</h5>
  6. <el-table
  7. :data="buyerInfo"
  8. border
  9. style="width: 100%">
  10. <el-table-column
  11. prop="id"
  12. label="编号"
  13. min-width="1">
  14. </el-table-column>
  15. <el-table-column
  16. prop="userName"
  17. label="买家昵称"
  18. min-width="3">
  19. </el-table-column>
  20. <el-table-column
  21. prop="loginId"
  22. label="登陆账号"
  23. min-width="3">
  24. </el-table-column>
  25. <el-table-column
  26. prop="password"
  27. label="登陆密码"
  28. min-width="3">
  29. </el-table-column>
  30. <el-table-column
  31. prop="address"
  32. label="邮寄地址"
  33. min-width="6">
  34. </el-table-column>
  35. <el-table-column label="操作" min-width="6">
  36. <template slot-scope="scope">
  37. <el-button
  38. size="mini"
  39. @click="toShowEdit(scope.row)">编辑</el-button>
  40. <el-button
  41. size="mini"
  42. @click="toDelete(scope.row.id)">删除</el-button>
  43. <el-button
  44. size="mini"
  45. @click="toShowCheck(scope.row)">查看</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <div class="pageblock">
  50. <el-pagination
  51. layout="prev, pager, next"
  52. :page-size="pageSize"
  53. :current-page.sync="currentPage"
  54. :total="total"
  55. @current-change="pagechange">
  56. </el-pagination>
  57. </div>
  58. </div>
  59. <el-dialog :title="dialogTitle" :visible.sync="dialogTableVisible" :show-close="false">
  60. <div class="dialogheader">
  61. <el-form label-position="right" label-width="80px">
  62. <el-form-item label="编号" v-show="dialogTitle=='查看买家'">
  63. <el-input v-model="showItem.id" :disabled="dialogTitle=='查看买家'"></el-input>
  64. </el-form-item>
  65. <el-form-item label="买家昵称">
  66. <el-input v-model="showItem.userName" :disabled="dialogTitle=='查看买家'"></el-input>
  67. </el-form-item>
  68. <el-form-item label="登陆账号">
  69. <el-input v-model="showItem.name" :disabled="dialogTitle=='查看买家'"></el-input>
  70. </el-form-item>
  71. <el-form-item label="登陆密码">
  72. <el-input v-model="showItem.password" :disabled="dialogTitle=='查看买家'"></el-input>
  73. </el-form-item>
  74. <el-form-item label="邮寄地址">
  75. <el-input v-model="showItem.address" :disabled="dialogTitle=='查看买家'"></el-input>
  76. </el-form-item>
  77. <el-form-item>
  78. <el-button type="primary" @click="toAdd" v-show="dialogTitle=='添加买家'">提交</el-button>
  79. <el-button type="primary" @click="toEdit" v-show="dialogTitle=='编辑买家'">提交</el-button>
  80. <el-button @click="toCancel">取消</el-button>
  81. </el-form-item>
  82. </el-form>
  83. </div>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script>
  88. export default{
  89. data(){
  90. return{
  91. buyerInfo:[],
  92. dialogTableVisible:false,
  93. dialogTitle:"",
  94. showItem:{
  95. id:"",
  96. userName:"",
  97. name:"",
  98. password:"",
  99. address:""
  100. },
  101. total:0,
  102. currentPage:1,
  103. pageSize:10,
  104. }
  105. },
  106. mounted(){
  107. this.getShopList();
  108. },
  109. methods:{
  110. getShopList(){
  111. this.axios.post(this.Api.getAccountList,{
  112. type:2
  113. }).then((res)=>{
  114. this.buyerInfo=[];
  115. for(let i=(this.currentPage-1)*10;i<this.currentPage*10;i++){
  116. if(res.data.length-1>=i){
  117. this.buyerInfo.push(res.data[i])
  118. }
  119. }
  120. this.total=parseInt(res.data.length);
  121. }).catch((err)=>{
  122. console.log("getShopList:"+err);
  123. });
  124. },
  125. filterTag(value, row) {
  126. return row.label === value;
  127. },
  128. toShowAdd(){
  129. this.dialogTableVisible=true;
  130. this.dialogTitle="添加买家";
  131. },
  132. toShowEdit(obj){
  133. this.dialogTableVisible=true;
  134. this.dialogTitle="编辑买家";
  135. this.showItem.id=obj.id;
  136. this.showItem.userName=obj.userName;
  137. this.showItem.name=obj.loginId;
  138. this.showItem.password=obj.password;
  139. this.showItem.address=obj.address;
  140. },
  141. toShowCheck(obj){
  142. this.dialogTableVisible=true;
  143. this.dialogTitle="查看买家";
  144. this.showItem.id=obj.id;
  145. this.showItem.userName=obj.userName;
  146. this.showItem.name=obj.loginId;
  147. this.showItem.password=obj.password;
  148. this.showItem.address=obj.address;
  149. },
  150. toCancel(){
  151. this.dialogTableVisible=false;
  152. this.dialogTitle="";
  153. this.showItem={
  154. id:"",
  155. userName:"",
  156. name:"",
  157. password:"",
  158. address:""
  159. }
  160. },
  161. toAdd(){
  162. if(this.showItem.name==""||this.showItem.password==""||this.showItem.userName==""||this.showItem.address==""){
  163. this.$message.error('请填写完整信息');
  164. console.log(this.showItem)
  165. return;
  166. }
  167. let param={
  168. type:2,
  169. handle:"1",
  170. mess:{
  171. name:this.showItem.name,
  172. password:this.showItem.password,
  173. userName:this.showItem.userName,
  174. address:this.showItem.address,
  175. }
  176. }
  177. this.axios.post(this.Api.adminHandle,param).then((res)=>{
  178. console.log(res);
  179. if(res.data.code==200){
  180. this.$message({
  181. message: '添加成功',
  182. type: 'success'
  183. });
  184. this.toCancel();
  185. this.getShopList();
  186. }
  187. }).catch((err)=>{
  188. console.log("toAdd:"+err);
  189. });
  190. },
  191. toEdit(){
  192. if(this.showItem.name==""||this.showItem.password==""||this.showItem.userName==""||this.showItem.address==""){
  193. this.$message.error('请填写完整信息');
  194. console.log(this.showItem)
  195. return;
  196. }
  197. let param={
  198. type:2,
  199. handle:"2",
  200. mess:{
  201. id:this.showItem.id,
  202. name:this.showItem.name,
  203. password:this.showItem.password,
  204. userName:this.showItem.userName,
  205. address:this.showItem.address,
  206. }
  207. }
  208. this.axios.post(this.Api.adminHandle,param).then((res)=>{
  209. console.log(res);
  210. if(res.data.code==200){
  211. this.$message({
  212. message: '编辑成功',
  213. type: 'success'
  214. });
  215. this.toCancel();
  216. this.getShopList();
  217. }
  218. }).catch((err)=>{
  219. console.log("toEdit:"+err);
  220. });
  221. },
  222. toDelete(id){
  223. this.$confirm("确定将该买家删除吗?", '提示', {
  224. confirmButtonText: '确定',
  225. cancelButtonText: '取消',
  226. type: 'warning'
  227. }).then(() => {
  228. let param={
  229. type:2,
  230. handle:"3",
  231. mess:{
  232. id:id,
  233. }
  234. }
  235. this.axios.post(this.Api.adminHandle,param).then((res)=>{
  236. console.log(res);
  237. if(res.data.code==200){
  238. this.$message({
  239. type: 'success',
  240. message: '删除成功!'
  241. });
  242. this.getShopList();
  243. }else{
  244. this.$notify({
  245. title:'提示',
  246. message:'删除失败',
  247. type:'error',
  248. })
  249. }
  250. });
  251. }).catch(() => {
  252. this.$message({
  253. type: 'info',
  254. message: '已取消操作'
  255. });
  256. })
  257. },
  258. pagechange(val){
  259. this.currentPage=val;
  260. this.getShopList();
  261. },
  262. }
  263. }
  264. </script>
  265. <style scoped>
  266. .adminShop-wrap{
  267. width: 100%;
  268. padding: 0 20px;
  269. }
  270. .addShopBtn{
  271. width: 100%;
  272. height: 70px;
  273. background-color: #3eb983;
  274. border: 0;
  275. color: #fff;
  276. margin: 20px 0;
  277. font-size: 16px;
  278. line-height: 70px;
  279. cursor: pointer;
  280. }
  281. .addShopBtn span{
  282. height: 100%;
  283. display: inline-block;
  284. vertical-align: middle;
  285. }
  286. .addShopBtn i{
  287. font-size: 30px;
  288. margin-right: 10px;
  289. display: inline-block;
  290. vertical-align: middle;
  291. }
  292. .shopList-wrap{
  293. background-color: #fff;
  294. padding: 20px;
  295. margin-top: 20px;
  296. }
  297. .shopList-wrap h5{
  298. font-size: 16px;
  299. text-align: left;
  300. margin-bottom: 10px;
  301. }
  302. .shopList-content{
  303. width: 100%;
  304. }
  305. .el-table thead{
  306. background-color: #bcf2db;
  307. height: 32px;
  308. line-height: 32px;
  309. font-size: 12px;
  310. text-align: center;
  311. }
  312. .has-gutter th{
  313. color: #17905c;
  314. padding: 0 4px;
  315. }
  316. .pageblock{
  317. margin-top: 20px;
  318. text-align: right;
  319. }
  320. </style>
  321. <style>
  322. .adminShop-wrap .el-table thead{
  323. background-color: #bcf2db;
  324. height: 32px;
  325. line-height: 32px;
  326. font-size: 12px;
  327. text-align: center;
  328. }
  329. .adminShop-wrap .el-table thead tr{
  330. background-color: #bcf2db;
  331. }
  332. .adminShop-wrap .el-table th{
  333. color: #17905c;
  334. padding: 0;
  335. background-color: #bcf2db;
  336. text-align: center;
  337. }
  338. .adminShop-wrap .el-dialog{
  339. width: 500px;
  340. /*height: 280px;*/
  341. border-radius: 6px;
  342. text-align: left;
  343. }
  344. .adminShop-wrap .el-dialog__header{
  345. padding: 20px 30px 0 40px;
  346. }
  347. .adminShop-wrap .el-dialog__body{
  348. padding: 20px 30px;
  349. }
  350. .adminShop-wrap .dialogheader{
  351. width: 100%;
  352. /*height: 60px;*/
  353. }
  354. .adminShop-wrap .dialogheader p{
  355. width: 360px;
  356. height: 30px;
  357. line-height: 30px;
  358. margin-top: 10px;
  359. border:1px solid #3eb983;
  360. border-radius: 6px;
  361. text-align: left;
  362. padding-left: 10px;
  363. margin-left: 60px;
  364. }
  365. .adminShop-wrap .dialogheader p input{
  366. height: 24px;
  367. line-height: 24px;
  368. border:0;
  369. margin-left: 20px;
  370. }
  371. .adminShop-wrap .dialogheader .button{
  372. background: #3eb983;
  373. color: #fff;
  374. text-align: center;
  375. margin-top: 40px;
  376. cursor: pointer;
  377. }
  378. .adminShop-wrap .dialogheader .el-button{
  379. width: 173px;
  380. padding: 10px 0;
  381. }
  382. .adminShop-wrap .dialogheader .el-form-item{
  383. margin-bottom: 15px;
  384. }
  385. .adminShop-wrap .dialogheader .el-button+.el-button{
  386. margin-left: 0;
  387. }
  388. .adminShop-wrap .dialogheader .el-button--primary{
  389. background-color: #3eb983;
  390. border-color: #3eb983;
  391. }
  392. .adminShop-wrap .dialogheader .el-button--primary:hover{
  393. background-color: #3eb983;
  394. border-color: #3eb983;
  395. }
  396. .adminShop-wrap .dialogheader .el-button--default{
  397. background-color: #bfcbd9;
  398. color: #fff;
  399. }
  400. .adminShop-wrap .dialogheader .el-button--default:hover{
  401. background-color: #bfcbd9;
  402. border-color: #bfcbd9;
  403. color: #fff;
  404. }
  405. .adminShop-wrap .el-message-box button{
  406. display: inline-block;
  407. float: right;
  408. }
  409. .adminShop-wrap .el-message-box .el-message-box__btns{
  410. height: 61px;
  411. }
  412. .adminShop-wrap .el-message-box .el-message-box__btns button:nth-child(1){
  413. margin-left: 10px;
  414. }
  415. .adminShop-wrap .el-message-box .el-message-box__btns .el-button--default{
  416. background-color: #bfcbd9;
  417. color: #fff;
  418. }
  419. .adminShop-wrap .el-message-box .el-message-box__btns .el-button--default:hover{
  420. background-color: #bfcbd9;
  421. border-color: #bfcbd9;
  422. color: #fff;
  423. }
  424. .adminShop-wrap .el-message-box .el-message-box__btns .el-button--primary{
  425. background-color: #3eb983;
  426. border-color: #3eb983;
  427. }
  428. .adminShop-wrap .el-message-box .el-message-box__btns .el-button--primary:hover{
  429. background-color: #3eb983;
  430. border-color: #3eb983;
  431. }
  432. .adminShop-wrap .adminShop-wrap .el-pagination{
  433. font-weight: normal;
  434. padding-right: 0;
  435. }
  436. .adminShop-wrap .adminShop-wrap .el-pagination button{
  437. padding: 0 6px;
  438. min-width: 28px;
  439. }
  440. .adminShop-wrap .adminShop-wrap .el-pagination .btn-next, .el-pagination .btn-prev{
  441. border: 1px solid #d1dbe5;
  442. }
  443. .adminShop-wrap .adminShop-wrap .el-pagination .btn-prev{
  444. padding-right: 6px;
  445. border-right: 0;
  446. border-radius: 2px 0 0 2px;
  447. }
  448. .adminShop-wrap .adminShop-wrap .el-pagination .btn-next{
  449. border-left: 0;
  450. padding-left: 6px;
  451. border-radius: 0 2px 2px 0;
  452. }
  453. .adminShop-wrap .adminShop-wrap .el-pager li{
  454. border: 1px solid #d1dbe5;
  455. border-right: 0;
  456. min-width: 28px;
  457. }
  458. .adminShop-wrap .adminShop-wrap .el-pager li.active{
  459. color: #fff;
  460. }
  461. .adminShop-wrap .adminShop-wrap .pageblock .el-pager li.active{
  462. border-color: #3eb983;
  463. background-color: #3eb983;
  464. }
  465. .adminShop-wrap .el-pager li.active+li{
  466. border-left: 0;
  467. }
  468. .adminShop-wrap .el-pager li:last-child{
  469. border-right: 1px solid #d1dbe5;
  470. }
  471. </style>