activityManage.vue 16 KB

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