index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="active pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 10px 80px">
  27. <el-col :span="6" style="width: 303px">
  28. <period-date-picker
  29. :type="1"
  30. :width="'135px'"
  31. :size="searchSize"
  32. :start="parmValue.starttime"
  33. :end="parmValue.endtime"
  34. @timeReturned="handleTime"
  35. />
  36. </el-col>
  37. <el-col :span="6" style="width: 250px; padding: 0 0 0 10px"> 所属平台 platform_code</el-col>
  38. <el-col :span="4" style="width: 160px">
  39. <el-select
  40. v-model="parmValue.status"
  41. filterable
  42. clearable
  43. :size="searchSize"
  44. placeholder="活动状态"
  45. style="width: 100%"
  46. @change="
  47. pageInfo.curr = 1;
  48. parmValue.page = 1;
  49. searchList();
  50. "
  51. >
  52. <el-option
  53. v-for="item in statusList"
  54. :key="'status' + item.code"
  55. :label="item.name"
  56. :value="item.code"
  57. />
  58. </el-select>
  59. </el-col>
  60. <el-col
  61. :span="3"
  62. class="fr"
  63. style="width: 66px; padding: 0 0 0 10px"
  64. >
  65. <el-button type="primary" :size="searchSize" @click="searchList">
  66. 刷新
  67. </el-button>
  68. </el-col>
  69. <el-col
  70. :span="3"
  71. class="fr"
  72. style="width: 66px; padding: 0 0 0 10px"
  73. >
  74. <el-button type="warning" :size="searchSize" @click="restSearch">
  75. 重置
  76. </el-button>
  77. </el-col>
  78. </el-row>
  79. <el-row>
  80. <el-col :span="4" style="width: 373px">
  81. <el-input
  82. :size="searchSize"
  83. v-model="parmValue.activity_name"
  84. :maxlength="40"
  85. @blur="
  86. pageInfo.curr = 1;
  87. parmValue.page = 1;
  88. searchList();
  89. "
  90. placeholder="活动名称"
  91. ></el-input>
  92. </el-col>
  93. <el-col :span="6" style="width: 250px; padding: 0 0 0 10px">
  94. <el-input
  95. :size="searchSize"
  96. v-model="parmValue.activity_code"
  97. :maxlength="40"
  98. @blur="
  99. pageInfo.curr = 1;
  100. parmValue.page = 1;
  101. searchList();
  102. "
  103. placeholder="活动编号"
  104. ></el-input>
  105. </el-col>
  106. <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
  107. <el-input
  108. :size="searchSize"
  109. v-model="parmValue.creater"
  110. :maxlength="40"
  111. @change="
  112. pageInfo.curr = 1;
  113. parmValue.page = 1;
  114. searchList();
  115. "
  116. placeholder="创建人"
  117. ></el-input>
  118. </el-col>
  119. <el-col
  120. :span="3"
  121. class="fr"
  122. style="width: 66px; padding: 0 0 0 10px"
  123. v-if="powers.some((item) => item == '003')"
  124. >
  125. <el-button
  126. :size="searchSize"
  127. type="success"
  128. style="float: right"
  129. @click="routeGoto('activeAdd', {})"
  130. >
  131. 添加
  132. </el-button>
  133. </el-col>
  134. </el-row>
  135. </div></template
  136. >
  137. <template #status="{ scope }">
  138. <el-tag
  139. :size="tablebtnSize"
  140. :type="scope.row.status == '1' ? 'warning' : ''"
  141. v-text="
  142. (statusOptions.find((item) => item.id == scope.row.status) || {})
  143. .label || '--'
  144. "
  145. ></el-tag>
  146. </template>
  147. <template #operation="{ scope }">
  148. <el-tooltip
  149. v-if="powers.some((item) => item == '007')"
  150. effect="dark"
  151. content="详情"
  152. placement="top"
  153. >
  154. <i
  155. class="el-icon-view tb-icon"
  156. @click="openModal(scope.row, '007')"
  157. ></i>
  158. </el-tooltip>
  159. <el-tooltip
  160. v-if="powers.some((item) => item == '005')"
  161. effect="dark"
  162. content="修改"
  163. placement="top"
  164. >
  165. <i
  166. class="el-icon-edit tb-icon"
  167. @click="openModal(scope.row, '005')"
  168. ></i>
  169. </el-tooltip>
  170. <el-tooltip
  171. v-if="
  172. powers.some((item) => item == '004') && scope.row.status === '0'
  173. "
  174. effect="dark"
  175. content="禁用"
  176. placement="top"
  177. >
  178. <i
  179. class="el-icon-video-pause tb-icon"
  180. @click="changeStatus(scope.row.id, scope.row.status)"
  181. ></i>
  182. </el-tooltip>
  183. <el-tooltip
  184. v-if="
  185. powers.some((item) => item == '004') && scope.row.status === '1'
  186. "
  187. effect="dark"
  188. content="启用"
  189. placement="top"
  190. >
  191. <i
  192. class="el-icon-video-play tb-icon"
  193. @click="changeStatus(scope.row.id, scope.row.status)"
  194. ></i>
  195. </el-tooltip>
  196. <el-tooltip
  197. v-if="powers.some((item) => item == '006')"
  198. effect="dark"
  199. content="删除"
  200. placement="top"
  201. >
  202. <i
  203. class="el-icon-delete tb-icon"
  204. @click="deleteItem(scope.row.id)"
  205. ></i>
  206. </el-tooltip>
  207. </template>
  208. </ex-table>
  209. <no-auth v-else></no-auth>
  210. <!-- 弹窗 新增/修改 -->
  211. <add-edit
  212. :id="modelId"
  213. :show-model="showModel"
  214. :sitem="sitem"
  215. @refresh="searchList"
  216. @cancel="showModel = false"
  217. />
  218. </div>
  219. </template>
  220. <script>
  221. import asyncRequest from "@/apis/service/activity/active";
  222. import statusList from "@/assets/js/statusList";
  223. import roleLevel from "@/assets/js/roleLevel";
  224. import mixinPage from "@/mixins/elPaginationHandle";
  225. import { mapGetters } from "vuex";
  226. import resToken from "@/mixins/resToken";
  227. export default {
  228. name: "active",
  229. mixins: [mixinPage, resToken],
  230. computed: {
  231. //组件SIZE设置
  232. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  233. powers() {
  234. let tran =
  235. this.$store.getters.btnList.find(
  236. (item) => item.menu_route == "active"
  237. ) || {};
  238. if (tran && tran.action && tran.action.length > 0) {
  239. return tran.action;
  240. } else {
  241. return [];
  242. }
  243. },
  244. },
  245. data() {
  246. return {
  247. statusList: statusList,
  248. roleLevel: roleLevel,
  249. loading: false,
  250. showModel: false,
  251. modelId: "000",
  252. sitem: {},
  253. parmValue: {
  254. page: 1, // 页码
  255. size: 15, // 每页显示条数
  256. starttime: "",
  257. endtime: "",
  258. status: "",
  259. creater: "",
  260. },
  261. // 状态
  262. statusOptions: [
  263. { id: "1", label: "禁用" },
  264. { id: "0", label: "启用" },
  265. ],
  266. // 表格 - 数据
  267. tableData: [],
  268. // 表格 - 参数
  269. table: {
  270. stripe: true,
  271. border: true,
  272. _defaultHeader_: ["setcol"],
  273. },
  274. // 表格 - 分页
  275. pageInfo: {
  276. size: 15,
  277. curr: 1,
  278. total: 0,
  279. },
  280. // 表格 - 列参数
  281. columns: [
  282. {
  283. prop: "id",
  284. label: "ID",
  285. },
  286. {
  287. prop: "active",
  288. label: "活动名称",
  289. },
  290. {
  291. prop: "status",
  292. label: "状态",
  293. sortable: true,
  294. _slot_: "status",
  295. },
  296. {
  297. prop: "creater",
  298. label: "创建人",
  299. },
  300. {
  301. prop: "addtime",
  302. label: "创建时间",
  303. sortable: true,
  304. },
  305. {
  306. prop: "",
  307. label: "操作",
  308. fixed: "right",
  309. _noset_: true,
  310. _slot_: "operation",
  311. },
  312. ],
  313. };
  314. },
  315. mounted() {
  316. // this.searchList();
  317. },
  318. methods: {
  319. restSearch() {
  320. // 表格 - 分页
  321. this.pageInfo = {
  322. size: 15,
  323. curr: 1,
  324. total: 0,
  325. };
  326. this.parmValue = {
  327. page: 1, // 页码
  328. size: 15, // 每页显示条数
  329. starttime: "",
  330. endtime: "",
  331. status: "",
  332. creater: "",
  333. };
  334. this.searchList();
  335. },
  336. // 新建/编辑/详情
  337. openModal(row, type) {
  338. this.sitem = row;
  339. this.modelId = type;
  340. this.showModel = true;
  341. },
  342. // 时间
  343. async handleTime(e) {
  344. this.parmValue.starttime = e.startTime || "";
  345. this.parmValue.endtime = e.endTime || "";
  346. if (
  347. (this.parmValue.starttime !== "" && this.parmValue.endtime !== "") ||
  348. (this.parmValue.starttime === "" && this.parmValue.endtime === "")
  349. ) {
  350. this.pageInfo.curr = 1;
  351. this.parmValue.page = 1;
  352. await this.searchList();
  353. }
  354. },
  355. /**
  356. * 启用/禁用
  357. * @param {String} id id
  358. * @param {String} status 0-禁用 1-启用
  359. */
  360. async changeStatus(id, status) {
  361. await this.$confirm(`确定要改为${status === "0" ? "禁用" : "启用"}?`, {
  362. confirmButtonText: "确定",
  363. cancelButtonText: "取消",
  364. type: "warning",
  365. })
  366. .then(async () => {
  367. this.loading = true;
  368. const model = {
  369. id: id,
  370. status: status === "1" ? "0" : "1",
  371. };
  372. const res = await asyncRequest.status(model);
  373. if (res && res.code === 0) {
  374. this.loading = false;
  375. this.$notify.success({
  376. title: "状态修改成功!",
  377. message: "",
  378. });
  379. await this.searchList();
  380. } else if (res && res.code >= 100 && res.code <= 104) {
  381. await this.logout();
  382. } else {
  383. this.loading = false;
  384. this.$message.warning(res.message);
  385. }
  386. })
  387. .catch(() => {
  388. console.log("取消");
  389. });
  390. },
  391. async deleteItem(id) {
  392. await this.$confirm("确定要删除?", {
  393. confirmButtonText: "确定",
  394. cancelButtonText: "取消",
  395. type: "warning",
  396. })
  397. .then(async () => {
  398. const model = {
  399. id: id,
  400. };
  401. const res = await asyncRequest.delete(model);
  402. if (res && res.code === 0) {
  403. this.$notify.success({
  404. title: "删除成功",
  405. message: "",
  406. });
  407. this.searchList();
  408. } else if (res && res.code >= 100 && res.code <= 104) {
  409. await this.logout();
  410. } else {
  411. this.$message.warning(res.message);
  412. }
  413. })
  414. .catch(() => {
  415. console.log("取消");
  416. });
  417. },
  418. // 刷新表格
  419. async searchList() {
  420. this.loading = true;
  421. const res = await asyncRequest.list(this.parmValue);
  422. if (res && res.code === 0 && res.data) {
  423. this.tableData = res.data.list;
  424. this.pageInfo.total = Number(res.data.count);
  425. } else if (res && res.code >= 100 && res.code <= 104) {
  426. await this.logout();
  427. } else {
  428. this.tableData = [];
  429. this.pageInfo.total = 0;
  430. }
  431. this.loading = false;
  432. },
  433. },
  434. };
  435. </script>
  436. <style lang="scss" scoped>
  437. </style>