index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="activityManage 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-select
  13. v-model="query.activityType"
  14. size="small"
  15. class="item-width-200 ml10"
  16. placeholder="请选择活动类型"
  17. clearable
  18. >
  19. <el-option
  20. v-for="item in options"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value"
  24. >
  25. </el-option>
  26. </el-select>
  27. <el-select
  28. v-model="query.state"
  29. size="small"
  30. class="item-width-200 ml10"
  31. placeholder="请选择活动状态"
  32. clearable
  33. >
  34. <el-option
  35. v-for="item in options1"
  36. :key="item.value"
  37. :label="item.label"
  38. :value="item.value"
  39. >
  40. </el-option>
  41. </el-select>
  42. <el-button
  43. class="ml10"
  44. type="primary"
  45. size="small"
  46. icon="el-icon-search"
  47. @click="handleSearch"
  48. >
  49. 搜索
  50. </el-button>
  51. </div>
  52. <el-button
  53. type="primary"
  54. size="small"
  55. @click="handleAdd"
  56. >
  57. 添加
  58. </el-button>
  59. </div>
  60. <el-table
  61. :data="tableData"
  62. tooltip-effect="dark"
  63. border
  64. v-loading="loading"
  65. style="width: 100%"
  66. >
  67. <el-table-column
  68. align="center"
  69. label="活动名称"
  70. prop="activityName"
  71. show-overflow-tooltip
  72. >
  73. </el-table-column>
  74. <el-table-column
  75. align="center"
  76. label="活动时间"
  77. prop="orderNo"
  78. show-overflow-tooltip
  79. >
  80. <template slot-scope="scope">
  81. {{scope.row.activityStartTime}} 至 {{scope.row.activityEndTime}}
  82. </template>
  83. </el-table-column>
  84. <el-table-column
  85. align="center"
  86. label="活动类型"
  87. prop="activityType"
  88. show-overflow-tooltip
  89. >
  90. <template slot-scope="scope">
  91. {{scope.row.activityType == 1?'海报':'报名'}}
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. align="center"
  96. label="活动状态"
  97. prop="status"
  98. show-overflow-tooltip
  99. >
  100. </el-table-column>
  101. <el-table-column prop="address" align="center" label="操作">
  102. <template slot-scope="scope">
  103. <el-button type="text" size="small" @click="handleData(scope.row.id)">数据</el-button>
  104. <el-button type="text" size="small" v-if="scope.row.status != '已结束'" @click="handleShare(scope.row)">分享</el-button>
  105. <el-button type="text" size="small" @click="handleDetail(scope.row, scope.row.status != '已结束'?'edit':'detail')">{{scope.row.status != '已结束'?'编辑':'查看'}}</el-button>
  106. <el-button type="text" size="small" v-if="scope.row.status != '已结束'" @click="handleStop(scope.row.id)">停止</el-button>
  107. <el-button type="text" size="small" @click="handleDel(scope.row.id)">删除</el-button>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <div class="page-box">
  112. <el-pagination
  113. @size-change="handleSizeChange"
  114. @current-change="handleCurrentChange"
  115. background
  116. :current-page="query.currentPage"
  117. :page-sizes="[10, 20, 30, 40]"
  118. :page-size="query.pageSize"
  119. layout="total, sizes, prev, pager, next, jumper"
  120. :total="total"
  121. >
  122. </el-pagination>
  123. </div>
  124. <el-dialog
  125. :visible.sync="showCode"
  126. width="400px"
  127. center>
  128. <div v-loading="codeLoading">
  129. <img style="width:300px;height:300px;margin:0 auto;display:block" :src="codeImg" alt="">
  130. </div>
  131. <span slot="footer" class="dialog-footer">
  132. <a id="downBtn" v-show="false" :download="downName" :href="codeImg" >下载</a>
  133. <el-button @click="download">下载</el-button>
  134. <el-button @click="refresh">刷新二维码</el-button>
  135. </span>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import {debounce} from '@/utils/index'
  141. import {activityList,activityDel,activityStop} from '@/api/activity'
  142. import {timeFormat} from '@/utils/index'
  143. import {BASE_URL} from '@/utils/config'
  144. import axios from 'axios'
  145. import {clear} from '@/api/common'
  146. export default {
  147. name: "activityManage",
  148. data() {
  149. return {
  150. options:[
  151. {
  152. value:1,
  153. label:'海报'
  154. },
  155. {
  156. value:2,
  157. label:'报名'
  158. },
  159. ],
  160. options1:[
  161. {
  162. value:1,
  163. label:'未开始'
  164. },
  165. {
  166. value:1,
  167. label:'进行中'
  168. },
  169. {
  170. value:1,
  171. label:'已结束'
  172. }
  173. ],
  174. tableData: [],
  175. loading: false,
  176. codeLoading: false,
  177. showCode: false,
  178. codeImg:'',//收款码
  179. downName:'',//下载名称
  180. query: {
  181. "activityType":null,
  182. "state":'',
  183. "currentPage": 1,
  184. "pageSize": 10,
  185. shopId: 0,
  186. },
  187. title: "",
  188. total: 0,
  189. id:''
  190. };
  191. },
  192. methods: {
  193. handleShare(item){
  194. this.showCode = true
  195. this.codeLoading = true
  196. this.downName = item.activityName + "活动码"
  197. this.id = item.id
  198. const platformType = localStorage.getItem('platformType')
  199. axios(
  200. {
  201. url: BASE_URL+'zswl-cloud-bdb/promotion/qrcode',
  202. method: 'post',
  203. responseType: "arraybuffer",
  204. data:{
  205. "page": "signUp/index",
  206. "scene": item.id,
  207. "platformType" : platformType
  208. }
  209. }).then(res=>{
  210. console.log(res);
  211. this.codeLoading = false
  212. let blob = new Blob([res.data], { type: "image/png" });
  213. this.codeImg = (window.URL || window.webkitURL).createObjectURL(blob);
  214. })
  215. },
  216. refresh(){
  217. this.codeLoading = true
  218. clear({type:1}).then(res=>{
  219. if(res.state == 'Success'){
  220. axios(
  221. {
  222. url: BASE_URL+'zswl-cloud-bdb/promotion/qrcode',
  223. method: 'post',
  224. responseType: "arraybuffer",
  225. data:{
  226. "page": "signUp/index",
  227. "scene": this.id
  228. }
  229. }).then(res=>{
  230. console.log(res);
  231. this.codeLoading = false
  232. let blob = new Blob([res.data], { type: "image/png" });
  233. this.codeImg = (window.URL || window.webkitURL).createObjectURL(blob);
  234. })
  235. }
  236. })
  237. },
  238. // 下载
  239. download(){
  240. document.getElementById('downBtn').click()
  241. },
  242. handleAdd(){
  243. this.$router.push({
  244. path:'/operationManage/activityManage/addActivity',
  245. query:{
  246. mode:'add',
  247. }
  248. })
  249. },
  250. handleSearch(){
  251. this.query.currentPage = 1
  252. this.activityList();
  253. },
  254. timeFormat(val){
  255. return timeFormat(val)
  256. },
  257. handleData(id){
  258. this.$router.push({
  259. path:'/operationManage/activityManage/dataList',
  260. query:{
  261. id
  262. }
  263. })
  264. },
  265. handleDetail(row,mode){
  266. this.$router.push({
  267. path:'/operationManage/activityManage/addActivity',
  268. query:{
  269. mode,
  270. id:row.id,
  271. status:row.status
  272. }
  273. })
  274. },
  275. handleDel(id){
  276. this.$confirm(`此操作将删除该活动, 是否继续?`, "提示", {
  277. confirmButtonText: "确定",
  278. cancelButtonText: "取消",
  279. type: "warning",
  280. }).then(() => {
  281. activityDel({id}).then(res=>{
  282. if(res.state == 'Success'){
  283. this.$notify({
  284. title: "成功",
  285. message: "操作成功",
  286. type: "success",
  287. });
  288. this.handleSearch()
  289. }
  290. })
  291. })
  292. },
  293. handleStop(id){
  294. this.$confirm(`此操作将停止该活动, 是否继续?`, "提示", {
  295. confirmButtonText: "确定",
  296. cancelButtonText: "取消",
  297. type: "warning",
  298. }).then(() => {
  299. activityStop({id}).then(res=>{
  300. if(res.state == 'Success'){
  301. this.$notify({
  302. title: "成功",
  303. message: "操作成功",
  304. type: "success",
  305. });
  306. this.handleSearch()
  307. }
  308. })
  309. })
  310. },
  311. handleSizeChange(val) {
  312. this.query.currentPage = 1;
  313. this.query.pageSize = val;
  314. this.activityList()
  315. },
  316. handleCurrentChange(val) {
  317. this.query.currentPage = val;
  318. this.activityList()
  319. },
  320. activityList(){
  321. this.loading = true
  322. activityList(this.query).then(res=>{
  323. this.loading = false
  324. if(res.state == 'Success'){
  325. this.tableData = res.content.records
  326. this.total = res.content.total
  327. }
  328. })
  329. }
  330. },
  331. created() {
  332. this.activityList()
  333. },
  334. };
  335. </script>
  336. <style lang="scss" >
  337. .activityManage {
  338. }
  339. </style>