Shop.vue 13 KB

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