index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="templateManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-input
  6. v-model="query.name"
  7. size="small"
  8. clearable
  9. placeholder="请输入模板名称"
  10. class="item-width-200 "
  11. ></el-input>
  12. <el-button
  13. class="ml10"
  14. type="primary"
  15. size="small"
  16. icon="el-icon-search"
  17. @click="handleSearch"
  18. >
  19. 搜索
  20. </el-button>
  21. </div>
  22. <el-button
  23. type="primary"
  24. size="small"
  25. v-if="btnAuthObj.addTemplate"
  26. @click="handleAdd"
  27. >
  28. 添加
  29. </el-button>
  30. </div>
  31. <el-table
  32. :data="tableData"
  33. tooltip-effect="dark"
  34. border
  35. v-loading="loading"
  36. style="width: 100%"
  37. >
  38. <el-table-column
  39. align="center"
  40. label="模板名称"
  41. prop="dataCollectName"
  42. show-overflow-tooltip
  43. >
  44. </el-table-column>
  45. <el-table-column
  46. align="center"
  47. label="状态"
  48. prop="status"
  49. show-overflow-tooltip
  50. >
  51. <template slot-scope="scope">
  52. {{scope.row.status == 1?"启用":"停用"}}
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="address" align="center" label="操作">
  56. <template slot-scope="scope">
  57. <el-button type="text" size="small" v-if="btnAuthObj.templateDetail" @click="handleDetail(scope.row.id,'edit')">编辑</el-button>
  58. <el-button type="text" size="small" v-if="btnAuthObj.copyTemplate" @click="handleCopy(scope.row.id)">复制</el-button>
  59. <el-button type="text" size="small" v-if="btnAuthObj.stopTemplate" @click="handleOperate(scope.row.id,scope.row.status == 1?2:1)">{{scope.row.status == 1?'停用':'启用'}}</el-button>
  60. <el-button type="text" class="red" size="small" v-if="btnAuthObj.delTemplate" @click="handleOperate(scope.row.id,3)">删除</el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <div class="page-box">
  65. <el-pagination
  66. @size-change="handleSizeChange"
  67. @current-change="handleCurrentChange"
  68. background
  69. :current-page="query.currentPage"
  70. :page-sizes="[10, 20, 30, 40]"
  71. :page-size="query.pageSize"
  72. layout="total, sizes, prev, pager, next, jumper"
  73. :total="total"
  74. >
  75. </el-pagination>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import {debounce} from '@/utils/index'
  81. import {dataTemplate,operate} from '@/api/activity'
  82. import {timeFormat} from '@/utils/index'
  83. export default {
  84. name: "templateManage",
  85. data() {
  86. return {
  87. tableData: [],
  88. loading: false,
  89. query: {
  90. "name": "",
  91. "currentPage": 1,
  92. "pageSize": 10,
  93. shopId: 0,
  94. },
  95. title: "",
  96. total: 0,
  97. };
  98. },
  99. methods: {
  100. handleAdd(){
  101. this.$router.push({
  102. path:'/operationManage/templateManage/addTemplate',
  103. query:{
  104. mode:'add',
  105. }
  106. })
  107. },
  108. handleSearch(){
  109. this.query.currentPage = 1
  110. this.dataTemplate();
  111. },
  112. timeFormat(val){
  113. return timeFormat(val)
  114. },
  115. handleCopy(id){
  116. this.$router.push({
  117. path:'/operationManage/templateManage/addTemplate',
  118. query:{
  119. mode:'copy',
  120. id
  121. }
  122. })
  123. },
  124. handleDetail(id,mode){
  125. this.$router.push({
  126. path:'/operationManage/templateManage/addTemplate',
  127. query:{
  128. mode,
  129. id
  130. }
  131. })
  132. },
  133. handleOperate(id,type){
  134. let msg
  135. if(type == 1){
  136. msg = '启用'
  137. }else if(type == 2){
  138. msg = '禁用'
  139. }else if(type == 3){
  140. msg = '删除'
  141. }
  142. this.$confirm(`此操作将${msg}该活动, 是否继续?`, "提示", {
  143. confirmButtonText: "确定",
  144. cancelButtonText: "取消",
  145. type: "warning",
  146. }).then(() => {
  147. operate({id,type}).then(res=>{
  148. if(res.state == 'Success'){
  149. this.$notify({
  150. title: '成功',
  151. message: '操作成功',
  152. type: 'success'
  153. });
  154. this.handleSearch()
  155. }
  156. })
  157. })
  158. },
  159. handleSizeChange(val) {
  160. this.query.currentPage = 1;
  161. this.query.pageSize = val;
  162. this.dataTemplate()
  163. },
  164. handleCurrentChange(val) {
  165. this.query.currentPage = val;
  166. this.dataTemplate()
  167. },
  168. dataTemplate(){
  169. this.loading = true
  170. dataTemplate(this.query).then(res=>{
  171. this.loading = false
  172. if(res.state == 'Success'){
  173. this.tableData = res.content.records
  174. this.total = res.content.total
  175. }
  176. })
  177. }
  178. },
  179. created() {
  180. this.dataTemplate()
  181. },
  182. };
  183. </script>
  184. <style lang="scss" >
  185. .templateManage {
  186. }
  187. </style>