index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="媒体类型" prop="type">
  14. <el-select v-model="queryParams.type" placeholder="请选择媒体类型" clearable size="small">
  15. <el-option label="请选择字典生成" value="" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="关联ID" prop="linkId">
  19. <el-input
  20. v-model="queryParams.linkId"
  21. placeholder="请输入关联ID"
  22. clearable
  23. size="small"
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="primary"
  36. plain
  37. icon="el-icon-plus"
  38. size="mini"
  39. @click="handleAdd"
  40. v-hasPermi="['ad:adAccount:add']"
  41. >新增</el-button>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button
  45. type="success"
  46. plain
  47. icon="el-icon-edit"
  48. size="mini"
  49. :disabled="single"
  50. @click="handleUpdate"
  51. v-hasPermi="['ad:adAccount:edit']"
  52. >修改</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="danger"
  57. plain
  58. icon="el-icon-delete"
  59. size="mini"
  60. :disabled="multiple"
  61. @click="handleDelete"
  62. v-hasPermi="['ad:adAccount:remove']"
  63. >删除</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="warning"
  68. plain
  69. icon="el-icon-download"
  70. size="mini"
  71. :loading="exportLoading"
  72. @click="handleExport"
  73. v-hasPermi="['ad:adAccount:export']"
  74. >导出</el-button>
  75. </el-col>
  76. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  77. </el-row>
  78. <el-table border v-loading="loading" :data="adAccountList" @selection-change="handleSelectionChange">
  79. <el-table-column type="selection" width="55" align="center" />
  80. <el-table-column label="id" align="center" prop="id" />
  81. <el-table-column label="名称" align="center" prop="name" />
  82. <el-table-column label="媒体类型" align="center" prop="type" />
  83. <el-table-column label="关联ID" align="center" prop="linkId" />
  84. <el-table-column label="备注" align="center" prop="remark" />
  85. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  86. <template slot-scope="scope">
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-edit"
  91. @click="handleUpdate(scope.row)"
  92. v-hasPermi="['ad:adAccount:edit']"
  93. >修改</el-button>
  94. <el-button
  95. size="mini"
  96. type="text"
  97. icon="el-icon-delete"
  98. @click="handleDelete(scope.row)"
  99. v-hasPermi="['ad:adAccount:remove']"
  100. >删除</el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination
  105. v-show="total>0"
  106. :total="total"
  107. :page.sync="queryParams.pageNum"
  108. :limit.sync="queryParams.pageSize"
  109. @pagination="getList"
  110. />
  111. <!-- 添加或修改推广账户对话框 -->
  112. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  113. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  114. <el-form-item label="名称" prop="name">
  115. <el-input v-model="form.name" placeholder="请输入名称" />
  116. </el-form-item>
  117. <el-form-item label="媒体类型" prop="type">
  118. <el-select v-model="form.type" placeholder="请选择媒体类型">
  119. <el-option label="请选择字典生成" value="" />
  120. </el-select>
  121. </el-form-item>
  122. <el-form-item label="关联ID" prop="linkId">
  123. <el-input v-model="form.linkId" placeholder="请输入关联ID" />
  124. </el-form-item>
  125. <el-form-item label="备注" prop="remark">
  126. <el-input v-model="form.remark" placeholder="请输入备注" />
  127. </el-form-item>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="submitForm">确 定</el-button>
  131. <el-button @click="cancel">取 消</el-button>
  132. </div>
  133. </el-dialog>
  134. </div>
  135. </template>
  136. <script>
  137. import { listAdAccount, getAdAccount, delAdAccount, addAdAccount, updateAdAccount, exportAdAccount } from "@/api/ad/adAccount";
  138. export default {
  139. name: "AdAccount",
  140. data() {
  141. return {
  142. // 遮罩层
  143. loading: true,
  144. // 导出遮罩层
  145. exportLoading: false,
  146. // 选中数组
  147. ids: [],
  148. // 非单个禁用
  149. single: true,
  150. // 非多个禁用
  151. multiple: true,
  152. // 显示搜索条件
  153. showSearch: true,
  154. // 总条数
  155. total: 0,
  156. // 推广账户表格数据
  157. adAccountList: [],
  158. // 弹出层标题
  159. title: "",
  160. // 是否显示弹出层
  161. open: false,
  162. // 查询参数
  163. queryParams: {
  164. pageNum: 1,
  165. pageSize: 10,
  166. name: null,
  167. type: null,
  168. linkId: null,
  169. },
  170. // 表单参数
  171. form: {},
  172. // 表单校验
  173. rules: {
  174. }
  175. };
  176. },
  177. created() {
  178. this.getList();
  179. },
  180. methods: {
  181. /** 查询推广账户列表 */
  182. getList() {
  183. this.loading = true;
  184. listAdAccount(this.queryParams).then(response => {
  185. this.adAccountList = response.rows;
  186. this.total = response.total;
  187. this.loading = false;
  188. });
  189. },
  190. // 取消按钮
  191. cancel() {
  192. this.open = false;
  193. this.reset();
  194. },
  195. // 表单重置
  196. reset() {
  197. this.form = {
  198. id: null,
  199. name: null,
  200. type: null,
  201. linkId: null,
  202. createTime: null,
  203. createBy: null,
  204. updateBy: null,
  205. updateTime: null,
  206. remark: null
  207. };
  208. this.resetForm("form");
  209. },
  210. /** 搜索按钮操作 */
  211. handleQuery() {
  212. this.queryParams.pageNum = 1;
  213. this.getList();
  214. },
  215. /** 重置按钮操作 */
  216. resetQuery() {
  217. this.resetForm("queryForm");
  218. this.handleQuery();
  219. },
  220. // 多选框选中数据
  221. handleSelectionChange(selection) {
  222. this.ids = selection.map(item => item.id)
  223. this.single = selection.length!==1
  224. this.multiple = !selection.length
  225. },
  226. /** 新增按钮操作 */
  227. handleAdd() {
  228. this.reset();
  229. this.open = true;
  230. this.title = "添加推广账户";
  231. },
  232. /** 修改按钮操作 */
  233. handleUpdate(row) {
  234. this.reset();
  235. const id = row.id || this.ids
  236. getAdAccount(id).then(response => {
  237. this.form = response.data;
  238. this.open = true;
  239. this.title = "修改推广账户";
  240. });
  241. },
  242. /** 提交按钮 */
  243. submitForm() {
  244. this.$refs["form"].validate(valid => {
  245. if (valid) {
  246. if (this.form.id != null) {
  247. updateAdAccount(this.form).then(response => {
  248. this.msgSuccess("修改成功");
  249. this.open = false;
  250. this.getList();
  251. });
  252. } else {
  253. addAdAccount(this.form).then(response => {
  254. this.msgSuccess("新增成功");
  255. this.open = false;
  256. this.getList();
  257. });
  258. }
  259. }
  260. });
  261. },
  262. /** 删除按钮操作 */
  263. handleDelete(row) {
  264. const ids = row.id || this.ids;
  265. this.$confirm('是否确认删除推广账户编号为"' + ids + '"的数据项?', "警告", {
  266. confirmButtonText: "确定",
  267. cancelButtonText: "取消",
  268. type: "warning"
  269. }).then(function() {
  270. return delAdAccount(ids);
  271. }).then(() => {
  272. this.getList();
  273. this.msgSuccess("删除成功");
  274. }).catch(() => {});
  275. },
  276. /** 导出按钮操作 */
  277. handleExport() {
  278. const queryParams = this.queryParams;
  279. this.$confirm('是否确认导出所有推广账户数据项?', "警告", {
  280. confirmButtonText: "确定",
  281. cancelButtonText: "取消",
  282. type: "warning"
  283. }).then(() => {
  284. this.exportLoading = true;
  285. return exportAdAccount(queryParams);
  286. }).then(response => {
  287. this.download(response.msg);
  288. this.exportLoading = false;
  289. }).catch(() => {});
  290. }
  291. }
  292. };
  293. </script>