activityManage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <!-- 活动管理页面 -->
  3. <div class="container-activity">
  4. <!-- 头部el-card -->
  5. <el-card style="margin-bottom: 20px">
  6. <div class="top-card-box">
  7. <div class="tabs-box">
  8. <span
  9. v-for="(item, index) in listTitle"
  10. :key="item.ChartPermissionId"
  11. @click="tabsBoxBtn(item, index)"
  12. :class="index == tabsPitchon ? 'pitch' : ''"
  13. >{{ item.PermissionName }}</span
  14. >
  15. </div>
  16. <div>
  17. <el-button type="primary" @click="$router.push(routePath=='hongze'?'/addActivity':'/addPurchaserActivity')">添加活动</el-button>
  18. </div>
  19. </div>
  20. </el-card>
  21. <!-- 内容el-card -->
  22. <el-card>
  23. <!-- 选择部分 -->
  24. <div class="screen-box">
  25. <div>
  26. <el-select placeholder="行业" clearable v-model="industry" @change="conditionChange" style="margin-bottom: 20px"
  27. v-if="routePath=='hongze'">
  28. <el-option
  29. v-for="item in chartPermissionList"
  30. :label="item.PermissionName"
  31. :key="item.ChartPermissionId"
  32. :value="item.ChartPermissionId"
  33. ></el-option>
  34. </el-select>
  35. <el-select placeholder="活动类型" clearable v-model="cactivityTypeVal" @change="conditionChange">
  36. <el-option
  37. v-for="item in routePath=='hongze'?cactivityTypeList:
  38. [{ActivityTypeId:11,ActivityTypeName:'专家电话会'},
  39. {ActivityTypeId:21,ActivityTypeName:'专家线下沙龙'},
  40. {ActivityTypeId:31,ActivityTypeName:'公司调研电话会'},
  41. {ActivityTypeId:41,ActivityTypeName:'买方线下交流'}]"
  42. :label="item.ActivityTypeName"
  43. :key="item.ActivityTypeId"
  44. :value="item.ActivityTypeId"
  45. ></el-option>
  46. </el-select>
  47. <el-date-picker
  48. v-model="publishDate"
  49. type="date"
  50. placeholder="发布时间"
  51. format="yyyy 年 MM 月 dd 日"
  52. value-format="yyyy-MM-dd"
  53. @change="conditionChange"
  54. >
  55. </el-date-picker>
  56. <date-picker
  57. style="margin-bottom: 20px"
  58. v-model="issueTime"
  59. type="date"
  60. range
  61. placeholder="活动时间"
  62. value-type="format"
  63. @change="conditionChange"
  64. >
  65. </date-picker>
  66. <el-select placeholder="发布状态" clearable v-model="status" @change="conditionChange" style="margin-bottom: 20px">
  67. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id"></el-option>
  68. </el-select>
  69. <el-input v-model="activityLabel" @input="titleInput" placeholder="请输入活动标签" clearable
  70. style="display: inline-block; width: 220px;margin-bottom: 20px">
  71. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  72. </el-input>
  73. </div>
  74. <div>
  75. <el-input v-model="titleValue" @input="titleInput" placeholder="请输入活动名称" clearable style="display: inline-block; width: 220px">
  76. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  77. </el-input>
  78. </div>
  79. </div>
  80. <!-- 表格部分 -->
  81. <el-table :data="dataList" style="width: 100%" border>
  82. <el-table-column align="center" label="活动名称" min-width="285">
  83. <template slot-scope="{ row }">
  84. <span class="editsty" @click="titleBtnClick(row.ActivityId)">{{ row.ActivityName }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="ChartPermissionName" align="center" label="行业" min-width="90"></el-table-column>
  88. <el-table-column min-width="120" prop="ActivityTypeName" align="center" label="活动类型"></el-table-column>
  89. <el-table-column min-width="120" prop="Label" align="center" label="活动标签"></el-table-column>
  90. <el-table-column min-width="219" prop="ActivityTimeText" align="center" label="活动时间"></el-table-column>
  91. <el-table-column min-width="200" prop="LastUpdatedTime" align="center" label="更新时间"></el-table-column>
  92. <el-table-column align="center" label="发布状态" min-width="100">
  93. <template slot-scope="{ row }">
  94. {{ row.PublishStatus == 0 ? "未发布" : row.PublishStatus == 1 ? "已发布" : "已取消" }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column v-if="tabsPitchon === 2" align="center" label="路演回放" min-width="100">
  98. <template slot-scope="{ row }"> {{ row.IsUpload ? "已上传" : "" }} </template>
  99. </el-table-column>
  100. <el-table-column align="center" width="146" label="操作">
  101. <template slot-scope="{ row }">
  102. <span v-if="row.PublishStatus == 0 && tabsPitchon == 0" class="editsty" @click="operationBtn(row.ActivityId, '发布')">发布</span>
  103. <span v-if="row.PublishStatus == 3 && tabsPitchon == 0" class="editsty" @click="operationBtn(row.ActivityId, '重新发布')">重新发布</span>
  104. <span v-if="row.PublishStatus == 1 && tabsPitchon == 0" class="editsty" @click="operationBtn(row.ActivityId, '取消发布')">取消发布</span>
  105. &nbsp;&nbsp;
  106. <span class="editsty" @click="editBtn(row.ActivityId, row.PublishStatus)">编辑</span>
  107. &nbsp;&nbsp;
  108. <span class="deletesty" v-if="row.PublishStatus == 0 && tabsPitchon == 0" @click="operationBtn(row.ActivityId, '删除')">删除</span>
  109. <span class="editsty" v-if="row.IsShowSigninButton " @click="handleDownLoadImg(row)">下载签到码</span>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <!-- 分页 -->
  114. <el-col :span="24" class="toolbar">
  115. <m-page :total="total" :page_no="page_no" :pageSize="10" @handleCurrentChange="handleCurrentChange" />
  116. </el-col>
  117. </el-card>
  118. <atc-particulars :dialogVisible.sync="dialogVisible" :detailData.sync="detailData" />
  119. </div>
  120. </template>
  121. <script>
  122. import mPage from "@/components/mPage.vue";
  123. import { raiInterface } from "@/api/api.js";
  124. import AtcParticulars from "../components/atcParticulars.vue";
  125. export default {
  126. name: "",
  127. components: { mPage, AtcParticulars },
  128. props: {
  129. Type:{
  130. type:String,
  131. emnu:['hongze','purchaser'], // 弘则,研选
  132. default:'hongze'
  133. }
  134. },
  135. data() {
  136. return {
  137. listTitle: [
  138. {
  139. PermissionName: "未开始",
  140. Id: "NotStarted",
  141. },
  142. {
  143. PermissionName: "进行中",
  144. Id: "HaveInHand",
  145. },
  146. {
  147. PermissionName: "已结束",
  148. Id: "Complete",
  149. },
  150. ],
  151. tabsPitchon: 0, //tabs 默认选中
  152. page_no: sessionStorage.getItem("cativityBack") ? JSON.parse(sessionStorage.getItem("cativityBack")).page_no : 1,
  153. dataList: [], //表格内容
  154. industry: "", //行业
  155. status: "", //状态
  156. issueTime: "", //时间
  157. cactivityTypeVal: "", //活动
  158. options: [
  159. { id: 1, name: "已发布" },
  160. { id: 0, name: "未发布" },
  161. { id: 3, name: "已取消" },
  162. ],
  163. titleValue: "", //标题关键词
  164. total: 0, //条数
  165. PageSize: 10, //每页显示几条
  166. chartPermissionList: [], //行业的数组
  167. cactivityTypeList: [], //活动类型
  168. dialogVisible: false, //弹框
  169. activeStateId: "NotStarted",
  170. detailData: {}, //
  171. activityLabel: "",
  172. publishDate: "",
  173. };
  174. },
  175. computed: {
  176. sta() {
  177. return this.status >= 0 && typeof this.status == "number" ? this.status : 2;
  178. },
  179. // 弘则 研选
  180. routePath(){
  181. return this.$route.path.indexOf("purchaser")!=-1?'purchaser':'hongze'
  182. },
  183. },
  184. created() {},
  185. mounted() {
  186. if (sessionStorage.getItem("cativityBack")) {
  187. const initialize = JSON.parse(sessionStorage.getItem("cativityBack"));
  188. this.titleValue = initialize.keyword;
  189. this.industry = initialize.industry;
  190. this.status = initialize.status;
  191. this.issueTime = initialize.issueTime;
  192. this.cactivityTypeVal = initialize.cactivityTypeVal;
  193. this.activeStateId = initialize.activeStateId;
  194. this.tabsPitchon = initialize.tabsPitchon;
  195. this.activityLabel = initialize.activityLabel;
  196. this.publishDate = initialize.publishDate;
  197. }
  198. this.chartPermission();
  199. this.activityType();
  200. this.getsummaryManageList();
  201. },
  202. methods: {
  203. titleInput() {
  204. this.page_no = 1;
  205. this.init();
  206. this.getsummaryManageList();
  207. },
  208. init() {
  209. this.industry = ""; //行业
  210. this.status = ""; //状态
  211. this.issueTime = ""; //时间
  212. this.cactivityTypeVal = ""; //活动
  213. this.sta = "";
  214. },
  215. //头部tabs
  216. tabsBoxBtn(item, index) {
  217. this.activeStateId = item.Id;
  218. this.tabsPitchon = index;
  219. this.page_no = 1;
  220. this.getsummaryManageList();
  221. },
  222. operationBtn(id, value) {
  223. this.$confirm(`确定${value}该活动吗?`, "提示", {
  224. confirmButtonText: "确定",
  225. cancelButtonText: "取消",
  226. type: "warning",
  227. })
  228. .then(() => {
  229. if (value == "删除") {
  230. raiInterface
  231. .activityDelete({
  232. ActivityId: id,
  233. })
  234. .then((res) => {
  235. if (res.Ret !== 200) return;
  236. this.$message.success("删除成功!");
  237. let page_num = Math.ceil((this.total - 1) / this.PageSize);
  238. if (this.page_no > page_num) {
  239. this.page_no = page_num;
  240. }
  241. this.getsummaryManageList();
  242. });
  243. } else {
  244. raiInterface
  245. .activityPublishAndCancel({
  246. ActivityId: id,
  247. })
  248. .then((res) => {
  249. if (res.Ret !== 200) return;
  250. this.$message.success(value + "成功!");
  251. this.getsummaryManageList();
  252. });
  253. }
  254. })
  255. .catch(() => {
  256. this.$message({
  257. type: "info",
  258. message: `已取消${value}`,
  259. });
  260. });
  261. },
  262. //编辑
  263. editBtn(id, show) {
  264. this.$router.push({
  265. path: this.routePath=='hongze'?'/editActivity':'/editPurchaserActivity',
  266. query: {
  267. id: id,
  268. isShow: show,
  269. },
  270. });
  271. },
  272. //分页
  273. handleCurrentChange(page) {
  274. this.page_no = page;
  275. this.getsummaryManageList();
  276. },
  277. //获取行业
  278. chartPermission() {
  279. raiInterface.chartPermission().then((res) => {
  280. if (res.Ret === 200) {
  281. this.chartPermissionList = res.Data.List;
  282. }
  283. });
  284. },
  285. //活动类型
  286. activityType() {
  287. raiInterface.getActivityType().then((res) => {
  288. if (res.Ret === 200) {
  289. this.cactivityTypeList = res.Data.List;
  290. }
  291. });
  292. },
  293. //列表
  294. getsummaryManageList() {
  295. raiInterface
  296. .getActivityList({
  297. CurrentIndex: this.page_no,
  298. PageSize: this.PageSize,
  299. PublishStatus: this.sta - 0,
  300. ChartPermissionId: this.routePath=="purchaser"?31:this.industry,
  301. StartDate: this.issueTime[0],
  302. EndDate: this.issueTime[1],
  303. KeyWord: this.titleValue,
  304. ActivityTypeId: this.cactivityTypeVal,
  305. ActiveState: this.activeStateId,
  306. ActivityLabel: this.activityLabel,
  307. PublishStartDate: this.publishDate,
  308. })
  309. .then((res) => {
  310. if (res.Ret !== 200) return;
  311. this.dataList = res.Data.List;
  312. this.total = res.Data.Paging.Totals;
  313. });
  314. },
  315. //change事件
  316. conditionChange() {
  317. this.page_no = 1;
  318. this.getsummaryManageList();
  319. },
  320. //点击标题的弹框
  321. titleBtnClick(id) {
  322. raiInterface.activityDetail({ ActivityId: Number(id) }).then((res) => {
  323. if (res.Ret == 200) {
  324. this.detailData = res.Data;
  325. }
  326. });
  327. this.dialogVisible = true;
  328. },
  329. // 下载图片
  330. handleDownLoadImg(row) {
  331. let img = new Image();
  332. img.setAttribute("crossOrigin", "anonymous");
  333. img.src = row.SigninImg;
  334. img.onload = () => {
  335. let canvas = document.createElement("canvas");
  336. canvas.width = img.width;
  337. canvas.height = img.height;
  338. let context = canvas.getContext("2d");
  339. context.drawImage(img, 0, 0, img.width, img.height);
  340. let dataURL = canvas.toDataURL("image/png", 1);
  341. const a = document.createElement("a");
  342. a.setAttribute("download", "签到码.png");
  343. a.style.display = "none";
  344. a.href = dataURL;
  345. document.body.appendChild(a);
  346. a.click();
  347. };
  348. },
  349. },
  350. /* 页面跳转前记录参数 */
  351. beforeRouteLeave(to, form, next) {
  352. let backData = {
  353. page_no: this.page_no,
  354. keyword: this.titleValue,
  355. industry: this.industry, //行业
  356. status: this.status, //状态
  357. issueTime: this.issueTime, //时间
  358. cactivityTypeVal: this.cactivityTypeVal, //活动
  359. activeStateId: this.activeStateId, //
  360. tabsPitchon: this.tabsPitchon,
  361. activityLabel: this.activityLabel,
  362. publishDate: this.publishDate,
  363. };
  364. sessionStorage.setItem("cativityBack", JSON.stringify(backData));
  365. next();
  366. },
  367. /* 页面进入前是否清除参数 */
  368. beforeRouteEnter(to, from, next) {
  369. if (from.path != "/editActivity") {
  370. sessionStorage.removeItem("cativityBack");
  371. }
  372. next();
  373. },
  374. };
  375. </script>
  376. <style lang="scss">
  377. .container-activity {
  378. .top-card-box {
  379. display: flex;
  380. justify-content: space-between;
  381. .tabs-box {
  382. span {
  383. display: inline-block;
  384. padding: 9px 24px;
  385. background-color: #e9f4ff;
  386. border: 1px solid #b3d8ff;
  387. border-radius: 4px;
  388. margin-right: 30px;
  389. color: #409eff;
  390. cursor: pointer;
  391. }
  392. .pitch {
  393. background-color: #409eff;
  394. border: none;
  395. color: #fff;
  396. }
  397. }
  398. }
  399. .screen-box {
  400. display: flex;
  401. justify-content: space-between;
  402. .el-select {
  403. margin-right: 25px;
  404. }
  405. .el-date-picker,
  406. .el-date-editor {
  407. margin-right: 25px;
  408. }
  409. }
  410. .mx-datepicker {
  411. width: 220px !important;
  412. margin-right: 25px;
  413. }
  414. .customWidth {
  415. width: 550px !important;
  416. }
  417. }
  418. </style>