index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <!-- 活动管理ß -->
  2. <template>
  3. <div class="app-container">
  4. <!-- 搜索 -->
  5. <el-form inline size="mini">
  6. <el-form-item label="活动名称:">
  7. <el-input v-model="form.name" placeholder="请输入活动名称" clearable />
  8. </el-form-item>
  9. <el-form-item label="当前状态:">
  10. <el-select
  11. v-model="form.activityState"
  12. placeholder="请选择当前状态"
  13. clearable
  14. >
  15. <el-option
  16. v-for="item in currentOptions"
  17. :key="item.value"
  18. :value="item.value"
  19. :label="item.label"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="上下架状态:">
  24. <el-select
  25. v-model="form.status"
  26. placeholder="请选择上下架状态"
  27. clearable
  28. >
  29. <el-option
  30. v-for="item in disabledOptions"
  31. :key="item.value"
  32. :value="item.value"
  33. :label="item.label"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="primary" icon="el-icon-search" @click="getSearch"
  39. >搜索</el-button
  40. >
  41. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  42. <el-button
  43. type="primary"
  44. icon="el-icon-plus"
  45. plain
  46. @click="showDialog"
  47. v-hasPermi="['operation:activity:add']"
  48. >新增赠送流量</el-button
  49. >
  50. <el-button
  51. type="primary"
  52. icon="el-icon-plus"
  53. plain
  54. @click="getDetail"
  55. v-hasPermi="['operation:activity:add']"
  56. >新增活动</el-button
  57. >
  58. </el-form-item>
  59. </el-form>
  60. <!-- 列表 -->
  61. <el-table :data="tableData" v-loading="loading">
  62. <el-table-column label="序号" align="center" type="index" />
  63. <el-table-column
  64. label="活动id"
  65. align="center"
  66. prop="id"
  67. show-overflow-tooltip
  68. />
  69. <el-table-column
  70. label="活动名称"
  71. align="center"
  72. prop="name"
  73. show-overflow-tooltip
  74. />
  75. <el-table-column label="活动图片" align="center" width="100px">
  76. <template slot-scope="scope">
  77. <el-image :src="scope.row.pic" />
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="创建时间" align="center" prop="createTime" />
  81. <el-table-column label="有效时间" align="center" show-overflow-tooltip>
  82. <template slot-scope="scope">
  83. {{ scope.row.timeList.join(" - ") }}
  84. </template>
  85. </el-table-column>
  86. <el-table-column
  87. label="当前状态"
  88. align="center"
  89. :formatter="activityFormatter"
  90. width="150px"
  91. />
  92. <el-table-column
  93. label="上下架状态"
  94. align="center"
  95. :formatter="statusFormatter"
  96. width="150px"
  97. />
  98. <el-table-column label="操作" align="center">
  99. <template slot-scope="scope">
  100. <el-button type="text" @click="getDetail(scope.row, true)"
  101. >查看</el-button
  102. >
  103. <el-button
  104. type="text"
  105. v-if="scope.row.status === 0"
  106. @click="getChange(scope.row.id, 1, '下架')"
  107. v-hasPermi="['operation:activity:down']"
  108. >下架</el-button
  109. >
  110. <span v-else style="margin: 0 10px">
  111. <el-button
  112. v-if="scope.row.activityState !== 2"
  113. type="text"
  114. @click="getDetail(scope.row)"
  115. v-hasPermi="['operation:activity:edit']"
  116. >编辑</el-button
  117. >
  118. <el-button
  119. v-if="scope.row.activityState !== 2"
  120. type="text"
  121. @click="getChange(scope.row.id, 0, '上架')"
  122. v-hasPermi="['operation:activity:up']"
  123. >上架</el-button
  124. >
  125. <el-button
  126. type="delete"
  127. @click="getDelete(scope.row)"
  128. v-hasPermi="['operation:activity:delete']"
  129. >删除</el-button
  130. >
  131. </span>
  132. <el-button
  133. type="text"
  134. v-clipboard:copy="scope.row.copyUrl"
  135. v-clipboard:success="getCopy"
  136. v-hasPermi="['operation:activity:copy']"
  137. >复制链接</el-button
  138. >
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <pagination
  143. v-show="total > 0"
  144. :total="total"
  145. :page.sync="form.pageNum"
  146. :limit.sync="form.pageSize"
  147. @pagination="getList"
  148. />
  149. <el-dialog
  150. :visible.sync="dialogVisible"
  151. :title="dialogTitle"
  152. width="1000px"
  153. :before-close="getDialogClose"
  154. >
  155. <!-- :rules="[
  156. {
  157. required: true,
  158. message: '请输入要赠送设备的ICCID号',
  159. trigger: 'blur',
  160. },
  161. { max: 30, message: '不可超过30个字符', trigger: 'blur' },
  162. ]" -->
  163. <el-form :model="dialogData" ref="dialogData" label-width="auto">
  164. <!-- ICCID号 -->
  165. <el-form-item label="ICCID号:" prop="iccid">
  166. <el-input
  167. v-model="dialogData.iccid"
  168. placeholder="请输入要赠送设备的ICCID号"
  169. />
  170. </el-form-item>
  171. <!-- 关联活动ID -->
  172. <el-form-item label="关联活动ID:">
  173. <el-select
  174. v-model="dialogData.activityId"
  175. placeholder="请选择关联活动"
  176. >
  177. <el-option
  178. v-for="item in dialogAcitivityIds"
  179. :key="item.id"
  180. :value="item.id"
  181. :label="item.name"
  182. />
  183. </el-select>
  184. </el-form-item>
  185. <!-- 设备型号 -->
  186. <el-form-item label="设备型号:">
  187. <el-select v-model="dialogData.deviceId" placeholder="请选择设备型号">
  188. <el-option
  189. v-for="item in devOptions"
  190. :key="item.value"
  191. :value="item.value"
  192. :label="item.label"
  193. />
  194. </el-select>
  195. </el-form-item>
  196. </el-form>
  197. <div slot="footer">
  198. <el-button @click="getDialogClose">取消</el-button>
  199. <el-button type="primary" @click="getDialogSubmit">确定</el-button>
  200. </div>
  201. </el-dialog>
  202. </div>
  203. </template>
  204. <script>
  205. import {
  206. allNoDeleteList,
  207. change,
  208. doExchange,
  209. list,
  210. } from "@/api/operation/activity";
  211. import { currentMixin, devMixin, disabledMixin } from "@/mixin/index";
  212. export default {
  213. mixins: [devMixin, currentMixin, disabledMixin],
  214. data() {
  215. return {
  216. dialogVisible: false,
  217. dialogTitle: "新增赠送流量",
  218. dialogAcitivityIds: [],
  219. dialogData: {},
  220. // 遮罩层
  221. loading: false,
  222. // 表单
  223. form: {
  224. pageNum: 1,
  225. pageSize: 10,
  226. },
  227. // 总数据
  228. total: 0,
  229. // 列表
  230. tableData: [],
  231. };
  232. },
  233. mounted() {
  234. this.getList();
  235. this.getAllNoDeleteList();
  236. this.getDevList();
  237. },
  238. methods: {
  239. // 弹窗
  240. async showDialog() {
  241. this.dialogVisible = true;
  242. this.dialogData = {};
  243. if (this.dialogAcitivityIds.length == 0) {
  244. this.getAllNoDeleteList();
  245. }
  246. if (this.devOptions.length == 0) {
  247. this.getList();
  248. }
  249. },
  250. // 提交分类表单
  251. getDialogSubmit() {
  252. var iccid = this.dialogData.iccid;
  253. var activityId = this.dialogData.activityId;
  254. var deviceId = this.dialogData.deviceId;
  255. var param = {
  256. iccid: iccid,
  257. activityId: activityId,
  258. deviceId: deviceId,
  259. };
  260. console.log("操作参数==" + JSON.stringify(param));
  261. doExchange(param).then((res) => {
  262. // 89860624650085884202
  263. console.log("操作结果=" + JSON.stringify(param));
  264. if (res.code === 0) {
  265. this.dialogVisible = false;
  266. this.dialogData = {};
  267. this.$refs.dialogData.resetFields();
  268. this.$message.success("操作成功!");
  269. }
  270. });
  271. },
  272. // 取消
  273. getDialogClose() {
  274. this.dialogVisible = false;
  275. this.dialogData = {};
  276. this.$refs.dialogData.resetFields();
  277. },
  278. getAllNoDeleteList() {
  279. // 平台ID:灵活配置多个平台的 0-vip会员 1-联通
  280. var param = { platformId: 1 };
  281. allNoDeleteList(param).then((res) => {
  282. if (res.code === 0) {
  283. this.dialogAcitivityIds = res.data;
  284. }
  285. });
  286. },
  287. // 列表
  288. getList() {
  289. this.loading = true;
  290. list(this.form).then((res) => {
  291. console.log("操作结果dasd发==00=" + JSON.stringify(res));
  292. if (res.code === 0) {
  293. this.tableData = res.data.records;
  294. this.total = res.data.total;
  295. this.loading = false;
  296. }
  297. });
  298. },
  299. // 搜索
  300. getSearch() {
  301. this.form.pageNum = 1;
  302. this.getList();
  303. },
  304. // 重置
  305. getRefresh() {
  306. this.form = {
  307. pageNum: 1,
  308. pageSize: 10,
  309. };
  310. this.getList();
  311. },
  312. // 详情
  313. getDetail(row, boolean) {
  314. this.$router.push({
  315. path: `/operation/activity/detail`,
  316. query: {
  317. id: row.id,
  318. boolean: boolean,
  319. activityState: row.activityState,
  320. },
  321. });
  322. },
  323. // 上下架
  324. getChange(id, status, title) {
  325. change(id, status).then((res) => {
  326. if (res.code === 0) {
  327. this.$message.success(`${title}成功!`);
  328. this.getList();
  329. }
  330. });
  331. },
  332. // 删除
  333. getDelete(row) {
  334. this.$confirm(`是否删除${row.name}?`, "提示", {
  335. type: "warning",
  336. }).then(() => {
  337. change(row.id, 2).then((res) => {
  338. if (res.code === 0) {
  339. this.$message.success("删除成功!");
  340. this.getList();
  341. }
  342. });
  343. });
  344. },
  345. // 复制链接
  346. getCopy() {
  347. this.$message.success("复制成功!");
  348. },
  349. // 字典翻译
  350. activityFormatter(row) {
  351. return this.selectDictLabel(this.currentOptions, row.activityState);
  352. },
  353. statusFormatter(row) {
  354. return this.selectDictLabel(this.disabledOptions, row.status);
  355. },
  356. },
  357. };
  358. </script>