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. 否
  141. </div>
  142. <div v-else>
  143. 是
  144. </div>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="添加时间" prop="created_at" align="center">
  148. <template slot-scope="scope">
  149. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  150. </template>
  151. </el-table-column>
  152. <el-table-column prop="status" align="center" label="状态" align="center">
  153. <template slot-scope="scope">
  154. <div v-if="scope.row.status == 0">
  155. 禁用
  156. </div>
  157. <div v-else>
  158. 启用
  159. </div>
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="操作" align="center">
  163. <template slot-scope="scope">
  164. <el-button size="small" type="text" @click="$navigate({r: 'mall/goods-template/edit', id:scope.row.id})" circle>
  165. 编辑
  166. </el-button>
  167. <el-button size="small" type="text" @click="switchRow(scope.row)">
  168. <span v-if="scope.row.status == 1">禁用</span>
  169. <span v-else>启用</span>
  170. </el-button>
  171. <el-button size="small" type="text" @click="copy(scope.row)">
  172. 复制
  173. </el-button>
  174. <el-button size="small" type="text" @click="destroy(scope.row)">
  175. 删除
  176. </el-button>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. <div style="text-align: right;margin: 20px 0;">
  181. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  182. </div>
  183. </div>
  184. </el-card>
  185. </div>
  186. <script>
  187. const app = new Vue({
  188. el: '#app',
  189. data() {
  190. return {
  191. form: [],
  192. pageCount: 0,
  193. pageCount: 0,
  194. listLoading: false,
  195. page: 1,
  196. btnLoading: false,
  197. dialogImg: false,
  198. multipleSelection: [],
  199. dialogVisible: false,
  200. activeName: '1',
  201. dialogPageCount: 0,
  202. dialogPage: 1,
  203. dialogList: [],
  204. template: null,
  205. templateVisible: false,
  206. status: '',
  207. id: '',
  208. name: '',
  209. };
  210. },
  211. methods: {
  212. addTemplateVisible() {
  213. this.templateVisible = true;
  214. },
  215. pagination(currentPage) {
  216. this.page = currentPage;
  217. this.search();
  218. },
  219. change() {
  220. this.page = 1;
  221. this.search();
  222. },
  223. search() {
  224. this.listLoading = true;
  225. request({
  226. params: {
  227. r: 'mall/goods-template/index',
  228. page: this.page,
  229. id: this.id,
  230. name: this.name,
  231. status: this.status,
  232. },
  233. }).then(e => {
  234. if (e.data.code === 0) {
  235. this.form = e.data.data.list;
  236. this.pageCount = e.data.data.page_count;
  237. } else {
  238. this.$message.error(e.data.msg);
  239. }
  240. this.listLoading = false;
  241. }).catch(e => {
  242. this.listLoading = false;
  243. });
  244. },
  245. //删除
  246. destroy: function(column) {
  247. this.$confirm('确认删除该记录吗?', '提示', {
  248. type: 'warning'
  249. }).then(() => {
  250. this.listLoading = true;
  251. request({
  252. params: {
  253. r: 'mall/goods-template/delete'
  254. },
  255. data: {
  256. id: column.id
  257. },
  258. method: 'post'
  259. }).then(e => {
  260. location.reload();
  261. this.listLoading = false;
  262. }).catch(e => {
  263. this.listLoading = false;
  264. });
  265. });
  266. },
  267. switchRow: function(row) {
  268. let self = this;
  269. request({
  270. params: {
  271. r: 'mall/goods-template/switch',
  272. },
  273. method: 'post',
  274. data: {
  275. id: row.id
  276. }
  277. }).then(e => {
  278. if (e.data.code === 0) {
  279. self.$message.success(e.data.msg);
  280. } else {
  281. self.$message.error(e.data.msg);
  282. }
  283. location.reload();
  284. });
  285. },
  286. copy: function(row) {
  287. let self = this;
  288. request({
  289. params: {
  290. r: 'mall/goods-template/copy-template',
  291. },
  292. method: 'post',
  293. data: {
  294. id: row.id
  295. }
  296. }).then(e => {
  297. if (e.data.code === 0) {
  298. self.$message.success(e.data.msg);
  299. } else {
  300. self.$message.error(e.data.msg);
  301. }
  302. location.reload();
  303. });
  304. },
  305. handleSelectionChange(val) {
  306. this.multipleSelection = val;
  307. },
  308. radioChange(row) {
  309. this.templateId = row.id;
  310. },
  311. openDialog(template) {
  312. this.template = template;
  313. },
  314. dialogClose() {
  315. this.templateVisible = false;
  316. },
  317. },
  318. mounted: function() {
  319. this.search();
  320. }
  321. });
  322. </script>