index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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="templateId">
  5. <el-select v-model="queryParams.templateId" @change="accountChange" placeholder="请选择模板">
  6. <el-option
  7. v-for="item in templateList"
  8. :key="item.id"
  9. :label="item.name"
  10. :value="item.id"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="媒体类型" prop="type">
  15. <el-select v-model="queryParams.type" placeholder="请选择媒体类型" clearable size="small">
  16. <el-option
  17. v-for="item in typeOptions"
  18. :key="item.dictValue"
  19. :label="item.dictLabel"
  20. :value="item.dictValue"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <!-- <el-form-item label="账号ID" prop="accountId">-->
  25. <!-- <el-input-->
  26. <!-- v-model="queryParams.accountId"-->
  27. <!-- placeholder="请输入账号ID"-->
  28. <!-- clearable-->
  29. <!-- size="small"-->
  30. <!-- @keyup.enter.native="handleQuery"-->
  31. <!-- />-->
  32. <!-- </el-form-item>-->
  33. <el-form-item>
  34. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  35. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  36. </el-form-item>
  37. </el-form>
  38. <el-row :gutter="10" class="mb8">
  39. <el-col :span="1.5">
  40. <el-button
  41. type="primary"
  42. plain
  43. icon="el-icon-plus"
  44. size="mini"
  45. @click="handleAdd"
  46. v-hasPermi="['ad:adSite:add']"
  47. >新增</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="success"
  52. plain
  53. icon="el-icon-edit"
  54. size="mini"
  55. :disabled="single"
  56. @click="handleUpdate"
  57. v-hasPermi="['ad:adSite:edit']"
  58. >修改</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['ad:adSite:remove']"
  69. >删除</el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. type="warning"
  74. plain
  75. icon="el-icon-download"
  76. size="mini"
  77. :loading="exportLoading"
  78. @click="handleExport"
  79. v-hasPermi="['ad:adSite:export']"
  80. >导出</el-button>
  81. </el-col>
  82. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  83. </el-row>
  84. <el-table border v-loading="loading" :data="adSiteList" @selection-change="handleSelectionChange">
  85. <el-table-column type="selection" width="55" align="center" />
  86. <el-table-column label="id" align="center" prop="id" />
  87. <el-table-column label="获客连接" align="center" prop="linkName" />
  88. <el-table-column label="媒体类型" align="center" prop="type">
  89. <template slot-scope="scope">
  90. <el-tag prop="type" v-for="(item, index) in typeOptions" v-if="scope.row.type==item.dictValue">{{item.dictLabel}}</el-tag>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="账号" align="center" prop="accountName" />
  94. <el-table-column label="链接" align="center">
  95. <template slot-scope="scope">
  96. <el-tooltip class="item" effect="dark" content="复制链接" placement="top-start">
  97. <el-link type="primary" @click="copyUrl(scope.row.url)">{{scope.row.url}}</el-link>
  98. </el-tooltip>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="备注" align="center" prop="remark" />
  102. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  103. <template slot-scope="scope">
  104. <el-button
  105. size="mini"
  106. type="text"
  107. icon="el-icon-edit"
  108. @click="handleUpdate(scope.row)"
  109. v-hasPermi="['ad:adSite:edit']"
  110. >修改</el-button>
  111. <!-- <el-button-->
  112. <!-- size="mini"-->
  113. <!-- type="text"-->
  114. <!-- icon="el-icon-delete"-->
  115. <!-- @click="handleDelete(scope.row)"-->
  116. <!-- v-hasPermi="['ad:adSite:remove']"-->
  117. <!-- >删除</el-button>-->
  118. </template>
  119. </el-table-column>
  120. </el-table>
  121. <pagination
  122. v-show="total>0"
  123. :total="total"
  124. :page.sync="queryParams.pageNum"
  125. :limit.sync="queryParams.pageSize"
  126. @pagination="getList"
  127. />
  128. <!-- 添加或修改站点管理对话框 -->
  129. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  130. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  131. <el-form-item label="名称" prop="name">
  132. <el-input v-model="form.name" placeholder="请输入名称" />
  133. </el-form-item>
  134. <el-form-item label="模板" prop="templateId">
  135. <el-select v-model="form.templateId" placeholder="请选择模板">
  136. <el-option
  137. v-for="item in templateList"
  138. :key="item.id"
  139. :label="item.name"
  140. :value="item.id"
  141. />
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="媒体类型" prop="type">
  145. <el-select v-model="form.type" @change="accountChange" placeholder="请选择媒体类型">
  146. <el-option
  147. v-for="item in typeOptions"
  148. :key="item.dictValue"
  149. :label="item.dictLabel"
  150. :value="Number(item.dictValue)"
  151. />
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="账号" prop="accountId" v-if="form.type != 99">
  155. <el-select v-model="form.accountId" filterable v-loading="accountLoading">
  156. <el-option v-for="item in accountList" :value="item.id" :key="item.id" :label="item.name" />
  157. </el-select>
  158. </el-form-item>
  159. <el-form-item label="域名" prop="domainId">
  160. <el-select v-model="form.domainId" filterable>
  161. <el-option v-for="item in domainList" :value="item.id" :key="item.id" :label="item.domain" />
  162. </el-select>
  163. </el-form-item>
  164. <el-form-item label="获客链接" prop="workId">
  165. <el-select v-model="form.workId" filterable>
  166. <el-option v-for="item in workList" :value="item.id" :key="item.id" :label="item.linkName" />
  167. </el-select>
  168. </el-form-item>
  169. <el-form-item label="备注" prop="remark">
  170. <el-input v-model="form.remark" placeholder="请输入备注" />
  171. </el-form-item>
  172. </el-form>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button type="primary" @click="submitForm">确 定</el-button>
  175. <el-button @click="cancel">取 消</el-button>
  176. </div>
  177. </el-dialog>
  178. </div>
  179. </template>
  180. <script>
  181. import { listAdSite, getAdSite, delAdSite, addAdSite, updateAdSite, exportAdSite } from "@/api/ad/adSite";
  182. import {listAll as templateListAll} from "@/api/ad/htmlTemplate";
  183. import {listAll as domainListAll} from "@/api/ad/adDomain";
  184. import {listAll as accountListAll} from "@/api/ad/adAccount";
  185. import {listAll as workUrlListAll} from '@/api/qw/workLink'
  186. export default {
  187. name: "AdSite",
  188. data() {
  189. return {
  190. // 遮罩层
  191. loading: true,
  192. // 导出遮罩层
  193. exportLoading: false,
  194. accountLoading: false,
  195. // 选中数组
  196. ids: [],
  197. // 非单个禁用
  198. single: true,
  199. // 非多个禁用
  200. multiple: true,
  201. // 显示搜索条件
  202. showSearch: true,
  203. // 总条数
  204. total: 0,
  205. // 站点管理表格数据
  206. adSiteList: [],
  207. accountList: [],
  208. accountAllList: [],
  209. typeOptions: [],
  210. templateList: [],
  211. domainList: [],
  212. // 弹出层标题
  213. title: "",
  214. // 是否显示弹出层
  215. open: false,
  216. // 查询参数
  217. queryParams: {
  218. pageNum: 1,
  219. pageSize: 10,
  220. templateId: null,
  221. type: null,
  222. accountId: null,
  223. url: null,
  224. },
  225. // 表单参数
  226. form: {},
  227. workList: [],
  228. // 表单校验
  229. rules: {
  230. }
  231. };
  232. },
  233. created() {
  234. this.getDicts("ad_type").then((response) => {
  235. this.typeOptions = response.data;
  236. });
  237. templateListAll().then(e => {
  238. this.templateList = e.data;
  239. })
  240. domainListAll().then(e => {
  241. this.domainList = e.data;
  242. })
  243. accountListAll().then(e => {
  244. this.accountAllList = e.data;
  245. })
  246. workUrlListAll().then(e => {
  247. this.workList = e.data;
  248. })
  249. this.getList();
  250. },
  251. methods: {
  252. /** 查询站点管理列表 */
  253. getList() {
  254. this.loading = true;
  255. listAdSite(this.queryParams).then(response => {
  256. this.adSiteList = response.rows;
  257. this.total = response.total;
  258. this.loading = false;
  259. });
  260. },
  261. // 取消按钮
  262. cancel() {
  263. this.open = false;
  264. this.reset();
  265. },
  266. // 表单重置
  267. reset() {
  268. this.form = {
  269. id: null,
  270. templateId: null,
  271. type: null,
  272. accountId: null,
  273. url: null,
  274. createTime: null,
  275. createBy: null,
  276. updateBy: null,
  277. updateTime: null,
  278. remark: null
  279. };
  280. this.resetForm("form");
  281. },
  282. /** 搜索按钮操作 */
  283. handleQuery() {
  284. this.queryParams.pageNum = 1;
  285. this.getList();
  286. },
  287. /** 重置按钮操作 */
  288. resetQuery() {
  289. this.resetForm("queryForm");
  290. this.handleQuery();
  291. },
  292. // 多选框选中数据
  293. handleSelectionChange(selection) {
  294. this.ids = selection.map(item => item.id)
  295. this.single = selection.length!==1
  296. this.multiple = !selection.length
  297. },
  298. copyUrl(url){
  299. navigator.clipboard.writeText(url)
  300. .then(() => {
  301. this.msgSuccess("复制成功");
  302. })
  303. .catch(err => {
  304. this.msgError("复制失败");
  305. });
  306. },
  307. /** 新增按钮操作 */
  308. handleAdd() {
  309. this.reset();
  310. this.open = true;
  311. this.title = "添加站点管理";
  312. },
  313. /** 修改按钮操作 */
  314. handleUpdate(row) {
  315. this.reset();
  316. const id = row.id || this.ids
  317. getAdSite(id).then(response => {
  318. this.form = response.data;
  319. this.accountList = this.accountAllList.filter(item => item.type == this.form.type);
  320. this.open = true;
  321. this.title = "修改站点管理";
  322. });
  323. },
  324. /** 提交按钮 */
  325. submitForm() {
  326. this.$refs["form"].validate(valid => {
  327. if (valid) {
  328. if (this.form.id != null) {
  329. updateAdSite(this.form).then(response => {
  330. this.msgSuccess("修改成功");
  331. this.open = false;
  332. this.getList();
  333. });
  334. } else {
  335. addAdSite(this.form).then(response => {
  336. this.msgSuccess("新增成功");
  337. this.open = false;
  338. this.getList();
  339. });
  340. }
  341. }
  342. });
  343. },
  344. /** 删除按钮操作 */
  345. handleDelete(row) {
  346. const ids = row.id || this.ids;
  347. this.$confirm('是否确认删除站点管理编号为"' + ids + '"的数据项?', "警告", {
  348. confirmButtonText: "确定",
  349. cancelButtonText: "取消",
  350. type: "warning"
  351. }).then(function() {
  352. return delAdSite(ids);
  353. }).then(() => {
  354. this.getList();
  355. this.msgSuccess("删除成功");
  356. }).catch(() => {});
  357. },
  358. /** 导出按钮操作 */
  359. handleExport() {
  360. const queryParams = this.queryParams;
  361. this.$confirm('是否确认导出所有站点管理数据项?', "警告", {
  362. confirmButtonText: "确定",
  363. cancelButtonText: "取消",
  364. type: "warning"
  365. }).then(() => {
  366. this.exportLoading = true;
  367. return exportAdSite(queryParams);
  368. }).then(response => {
  369. this.download(response.msg);
  370. this.exportLoading = false;
  371. }).catch(() => {});
  372. },
  373. accountChange(){
  374. let type = this.form.type;
  375. this.form.accountId = undefined;
  376. this.accountList = this.accountAllList.filter(item => item.type == type);
  377. },
  378. }
  379. };
  380. </script>