index.blade.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', trans('素材管理'))
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}" />
  5. <style>
  6. .vue-main .el-form-item .el-form-item__label{
  7. padding: 0 20px 0 0 !important;
  8. }
  9. </style>
  10. <div id="app">
  11. <div class="all">
  12. <div class="vue-head">
  13. <div class="vue-main-title">
  14. <div class="vue-main-title-left"></div>
  15. <div class="vue-main-title-content">条件筛选</div>
  16. <div class="vue-main-title-right"><el-button style="margin-top:10px;color: #29ba9c;" @click="addTemp"> <i class="el-icon-plus"></i> 添加素材</el-button></div>
  17. </div>
  18. <div class="vue-search">
  19. <el-form :inline="true" :model="search" class="demo-form-inline">
  20. <el-form-item label="">
  21. <el-input v-model="search.keyword" placeholder="标题"></el-input>
  22. </el-form-item>
  23. <el-form-item label="">
  24. <el-select v-model="search.is_show" placeholder="请选择显示状态" clearable>
  25. <el-option :key="1" label="显示" :value="1"></el-option>
  26. <el-option :key="2" label="不显示" :value="2"></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="">
  30. <el-date-picker v-model="search.is_time" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="timestamp">
  31. </el-date-picker>
  32. </el-form-item>
  33. <el-form-item label="">
  34. <el-button type="primary" @click="handleSearch">搜索</el-button>
  35. </el-form-item>
  36. </el-form>
  37. </div>
  38. </div>
  39. <div class="vue-head">
  40. <div class="vue-main-title">
  41. <div class="vue-main-title-left"></div>
  42. <div class="vue-main-title-content">素材列表</div>
  43. </div>
  44. <el-table :data="tableData" style="width: 100%">
  45. <el-table-column prop="id" label="ID" align="center">
  46. </el-table-column>
  47. <el-table-column prop="created_at" label="创建时间" align="center">
  48. </el-table-column>
  49. <el-table-column prop="title" label="标题" align="center">
  50. </el-table-column>
  51. <el-table-column prop="goods.title" label="商品名称" align="center">
  52. </el-table-column>
  53. <el-table-column prop="share" label="图片分享数" align="center">
  54. </el-table-column>
  55. <el-table-column label="显示状态" align="center">
  56. <template slot-scope="scope">
  57. <el-switch v-model="scope.row.is_show" active-color="#29BA9C" inactive-color="#ff4949" :active-value=1 :inactive-value=0 @change="(value) => statusChange(value,scope.row.id)">
  58. </el-switch>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="操作" align="center">
  62. <template slot-scope="scope">
  63. <i class="el-icon-edit-outline" style="font-size:18px;cursor:pointer" @click="edit(scope.row.id)"></i>
  64. <i class="el-icon-delete-solid" style="font-size:18px;cursor:pointer" @click="deleteMaterial(scope.row.id)"></i>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. </div>
  69. <div class="vue-page">
  70. <el-row>
  71. <el-col align="right">
  72. <el-pagination layout="prev, pager, next,jumper" @current-change="search1" :total="total" :page-size="per_page" :current-page="current_page" background></el-pagination>
  73. </el-col>
  74. </el-row>
  75. </div>
  76. </div>
  77. </div>
  78. <script language='javascript'>
  79. //vue
  80. var app = new Vue({
  81. el: "#app",
  82. delimiters: ['[[', ']]'],
  83. data() {
  84. return {
  85. options: [{
  86. label: '显示',
  87. value: 1
  88. },
  89. {
  90. label: '不显示',
  91. value: 0
  92. }
  93. ],
  94. page: 1,
  95. tableData: [],
  96. current_page: 1,
  97. total: 1,
  98. per_page: 15,
  99. search: {
  100. keyword: '',
  101. is_time: [],
  102. is_show: ''
  103. }
  104. }
  105. },
  106. computed: {
  107. },
  108. mounted() {
  109. this.getTempList()
  110. },
  111. methods: {
  112. //获取模板列表数据
  113. getTempList() {
  114. this.$http.post("{!! yzWebFullUrl('plugin.material-center.admin.material.index') !!}", {
  115. }).then(res => {
  116. if (res.data.result) {
  117. this.tableData = res.data.data.list.data
  118. this.current_page = res.data.data.list.current_page
  119. this.total = res.data.data.list.total
  120. this.per_page = res.data.data.list.per_page
  121. } else {
  122. this.$message.error(res.data.msg);
  123. }
  124. })
  125. },
  126. //编辑模板
  127. edit(id) {
  128. let url = "{!! yzWebUrl('plugin.material-center.admin.material.add') !!}&id=" + id
  129. window.location.href = url
  130. },
  131. addTemp() {
  132. let url = "{!! yzWebUrl('plugin.material-center.admin.material.add') !!}"
  133. window.location.href = url
  134. },
  135. deleteMaterial(id) {
  136. this.$confirm('确定删除嘛', '提示', {
  137. confirmButtonText: '确定',
  138. cancelButtonText: '取消',
  139. type: 'warning'
  140. }).then(() => {
  141. this.$http.post("{!! yzWebFullUrl('plugin.material-center.admin.material.delete') !!}&id=" + id, {
  142. id
  143. }).then(res => {
  144. if (res.data.result) {
  145. this.$message.success(res.data.msg);
  146. this.getTempList()
  147. } else {
  148. this.$message.error(res.data.msg);
  149. }
  150. })
  151. }).catch(() => {
  152. this.$message({
  153. type: 'info',
  154. message: '已取消删除'
  155. });
  156. });
  157. },
  158. // 搜索
  159. search1(page) {
  160. this.current_page = page
  161. this.getTempList(page)
  162. },
  163. handleSearch() {
  164. this.$http.post("{!! yzWebFullUrl('plugin.material-center.admin.material.index') !!}", {
  165. search:{...this.search}
  166. }).then(res => {
  167. this.tableData = res.data.data.list.data
  168. this.current_page = res.data.data.list.current_page
  169. this.total = res.data.data.list.total
  170. this.per_page = res.data.data.list.per_page
  171. if (res.data.result) {
  172. } else {
  173. this.$message.error(res.data.msg);
  174. }
  175. })
  176. },
  177. statusChange(status,id){
  178. this.$http.post('{!! yzWebFullUrl("plugin.material-center.admin.material.changeStatus") !!}', {
  179. is_show:status,
  180. id:id
  181. }).then(({
  182. data
  183. }) => {
  184. if (data.result) {
  185. this.$message.success(data.msg)
  186. } else {
  187. this.$message.error(data.msg);
  188. }
  189. }, (response) => {
  190. console.log(response);
  191. });
  192. }
  193. },
  194. })
  195. </script>
  196. @endsection