index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <?php
  2. ?>
  3. <style>
  4. .table-body {
  5. padding: 20px;
  6. background-color: #fff;
  7. }
  8. .input-item {
  9. display: inline-block;
  10. /* width: 350px; */
  11. /* margin: 0 0 20px; */
  12. margin-right: 10px;
  13. }
  14. .input-item .el-input-group__prepend {
  15. background-color: #fff;
  16. }
  17. .input-item .el-input__inner {
  18. /* border-right: 0; */
  19. }
  20. .input-item .el-input__inner:hover {
  21. border: 1px solid #dcdfe6;
  22. border-right: 0;
  23. outline: 0;
  24. }
  25. .input-item .el-input__inner:focus {
  26. border: 1px solid #dcdfe6;
  27. border-right: 0;
  28. outline: 0;
  29. }
  30. .input-item .el-input-group__append {
  31. background-color: #fff;
  32. border-left: 0;
  33. width: 10%;
  34. padding: 0;
  35. }
  36. .input-item .el-input-group__append .el-button {
  37. padding: 15px;
  38. }
  39. .select {
  40. float: left;
  41. width: 100px;
  42. margin-right: 10px;
  43. }
  44. .el-table .cell .el-button {
  45. padding: 0 !important;
  46. border: 0;
  47. margin: 0 5px;
  48. }
  49. .open-img .el-dialog {
  50. margin-top: 0 !important;
  51. }
  52. .click-img {
  53. width: 100%;
  54. }
  55. .input-item .el-input-group__append .el-button {
  56. padding: 0;
  57. }
  58. .input-item .el-input-group__append .el-button {
  59. margin: 0;
  60. }
  61. .label-text {
  62. height: 32px;
  63. margin-right: 10px;
  64. }
  65. /*弹出框表格样式 start*/
  66. .el-dialog__body {
  67. padding: 5px 20px;
  68. }
  69. .card-box {
  70. padding: 10px;
  71. border: 1px solid #E3E3E3;
  72. }
  73. .table-box {
  74. border-top: 1px solid #E3E3E3;
  75. border-left: 1px solid #E3E3E3;
  76. }
  77. .table-item {
  78. border-bottom: 1px solid #E3E3E3;
  79. border-right: 1px solid #E3E3E3;
  80. height: 50px;
  81. padding-left: 5px;
  82. }
  83. .table-item .el-radio__label {
  84. display: none;
  85. }
  86. .select-type-box {
  87. padding: 25px 0;
  88. height: 40px;
  89. }
  90. /*弹出框表格样式 end*/
  91. .el-table th>.cell {
  92. color: #333;
  93. font-weight: bold;
  94. font-size: 14px;
  95. }
  96. .el-table__footer-wrapper,
  97. .el-table__header-wrapper {
  98. border-bottom: 1.4px solid #D6D6D6;
  99. }
  100. </style>
  101. <div id="app" v-cloak>
  102. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  103. <div slot="header">
  104. <div flex="cross:center box:first">
  105. <div>广告位模版用于“商品详情页的推荐商品、商详图下房的轮播图和猜你喜欢”模块,可配置商品推荐或广告图展示。</div>
  106. <div flex="dir:right">
  107. <div>
  108. <el-button type="primary" size="small" @click="$navigate({r:'mall/goods-template/edit'})">添加广告模板
  109. </el-button>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <div class="table table-body">
  115. <div flex="dir:left">
  116. <div class="input-item">
  117. <el-input @keyup.enter.native="change" size="small" placeholder="请输入模版编号" v-model="id" clearable @clear="search">
  118. </el-input>
  119. </div>
  120. <div class="input-item">
  121. <el-input @keyup.enter.native="change" size="small" placeholder="请输入模版名称" v-model="name" clearable @clear="search">
  122. </el-input>
  123. </div>
  124. <div flex="input-item">
  125. <div class="label-text" flex="cross:center">状态</div>
  126. <el-select size="small" v-model="status" class="select" @change="change">
  127. <el-option key="" label="请选择" value=""></el-option>
  128. <el-option key="1" label="启用" value="1"></el-option>
  129. <el-option key="0" label="禁用" value="0"></el-option>
  130. </el-select>
  131. </div>
  132. </div>
  133. <el-table :data="form" stripe style="width: 100%" v-loading="listLoading" @selection-change="handleSelectionChange">
  134. <el-table-column prop="id" label="模版编号" width="80" align="center"></el-table-column>
  135. <el-table-column prop="name" label="模版名称" align="center">
  136. </el-table-column>
  137. <el-table-column prop="is_default" align="center" label="是否为默认模版" align="center">
  138. <template slot-scope="scope">
  139. <div v-if="scope.row.is_default == 0">
  140. </div>
  141. <div v-else>
  142. </div>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="添加时间" prop="created_at" align="center">
  146. <template slot-scope="scope">
  147. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="status" align="center" label="状态" align="center">
  151. <template slot-scope="scope">
  152. <div v-if="scope.row.status == 0">
  153. 禁用
  154. </div>
  155. <div v-else>
  156. 启用
  157. </div>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="操作" align="center">
  161. <template slot-scope="scope">
  162. <el-button size="small" type="text" @click="$navigate({r: 'mall/goods-template/edit', id:scope.row.id})" circle>
  163. 编辑
  164. </el-button>
  165. <el-button size="small" type="text" @click="switchRow(scope.row)">
  166. <span v-if="scope.row.status == 1">禁用</span>
  167. <span v-else>启用</span>
  168. </el-button>
  169. <el-button size="small" type="text" @click="copy(scope.row)">
  170. 复制
  171. </el-button>
  172. <el-button size="small" type="text" @click="destroy(scope.row)">
  173. 删除
  174. </el-button>
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <div style="text-align: right;margin: 20px 0;">
  179. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  180. </div>
  181. </div>
  182. </el-card>
  183. </div>
  184. <script>
  185. const app = new Vue({
  186. el: '#app',
  187. data() {
  188. return {
  189. form: [],
  190. pageCount: 0,
  191. pageCount: 0,
  192. listLoading: false,
  193. page: 1,
  194. btnLoading: false,
  195. dialogImg: false,
  196. multipleSelection: [],
  197. dialogVisible: false,
  198. activeName: '1',
  199. dialogPageCount: 0,
  200. dialogPage: 1,
  201. dialogList: [],
  202. template: null,
  203. templateVisible: false,
  204. status: '',
  205. id: '',
  206. name: '',
  207. };
  208. },
  209. methods: {
  210. addTemplateVisible() {
  211. this.templateVisible = true;
  212. },
  213. pagination(currentPage) {
  214. this.page = currentPage;
  215. this.search();
  216. },
  217. change() {
  218. this.page = 1;
  219. this.search();
  220. },
  221. search() {
  222. this.listLoading = true;
  223. request({
  224. params: {
  225. r: 'mall/goods-template/index',
  226. page: this.page,
  227. id: this.id,
  228. name: this.name,
  229. status: this.status,
  230. },
  231. }).then(e => {
  232. if (e.data.code === 0) {
  233. this.form = e.data.data.list;
  234. this.pageCount = e.data.data.page_count;
  235. } else {
  236. this.$message.error(e.data.msg);
  237. }
  238. this.listLoading = false;
  239. }).catch(e => {
  240. this.listLoading = false;
  241. });
  242. },
  243. //删除
  244. destroy: function(column) {
  245. this.$confirm('确认删除该记录吗?', '提示', {
  246. type: 'warning'
  247. }).then(() => {
  248. this.listLoading = true;
  249. request({
  250. params: {
  251. r: 'mall/goods-template/delete'
  252. },
  253. data: {
  254. id: column.id
  255. },
  256. method: 'post'
  257. }).then(e => {
  258. location.reload();
  259. this.listLoading = false;
  260. }).catch(e => {
  261. this.listLoading = false;
  262. });
  263. });
  264. },
  265. switchRow: function(row) {
  266. let self = this;
  267. request({
  268. params: {
  269. r: 'mall/goods-template/switch',
  270. },
  271. method: 'post',
  272. data: {
  273. id: row.id
  274. }
  275. }).then(e => {
  276. if (e.data.code === 0) {
  277. self.$message.success(e.data.msg);
  278. } else {
  279. self.$message.error(e.data.msg);
  280. }
  281. location.reload();
  282. });
  283. },
  284. copy: function(row) {
  285. let self = this;
  286. request({
  287. params: {
  288. r: 'mall/goods-template/copy-template',
  289. },
  290. method: 'post',
  291. data: {
  292. id: row.id
  293. }
  294. }).then(e => {
  295. if (e.data.code === 0) {
  296. self.$message.success(e.data.msg);
  297. } else {
  298. self.$message.error(e.data.msg);
  299. }
  300. location.reload();
  301. });
  302. },
  303. handleSelectionChange(val) {
  304. this.multipleSelection = val;
  305. },
  306. radioChange(row) {
  307. this.templateId = row.id;
  308. },
  309. openDialog(template) {
  310. this.template = template;
  311. },
  312. dialogClose() {
  313. this.templateVisible = false;
  314. },
  315. },
  316. mounted: function() {
  317. this.search();
  318. }
  319. });
  320. </script>