crowd-control.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <style lang="less" scoped>
  2. @import "crowd-control";
  3. </style>
  4. <template>
  5. <div class="crowd-control-content">
  6. <div class="control-con-header">
  7. <a-form
  8. class="grid-form" layout="inline"
  9. :form="form"
  10. hide-required-mark @submit="handleQueryList"
  11. >
  12. <a-row class="grid-form-options">
  13. <a-form-item
  14. class="grid-form-item" label="名称"
  15. :colon="false"
  16. >
  17. <a-input
  18. v-decorator="['name']" type="text"
  19. placeholder="请输入"
  20. />
  21. </a-form-item>
  22. <a-form-item
  23. class="grid-form-item" label="账户"
  24. :colon="false"
  25. >
  26. <a-select
  27. v-decorator="['acount']"
  28. placeholder="请选择"
  29. mode="multiple"
  30. :max-tag-count="1"
  31. :max-tag-text-length="3"
  32. allow-clear :options="acountTasks"
  33. show-arrow
  34. />
  35. </a-form-item>
  36. <a-form-item
  37. class="grid-form-item grid-form-type" label="状态"
  38. :colon="false"
  39. >
  40. <a-select
  41. v-decorator="['status']"
  42. placeholder="请选择"
  43. mode="multiple"
  44. :max-tag-count="1"
  45. :max-tag-text-length="3"
  46. allow-clear :options="statusTasks"
  47. show-arrow
  48. />
  49. </a-form-item>
  50. <a-form-item class="form-handle-btn">
  51. <a-button type="default" class="resetClass" @click="handleResetForm">重置</a-button>
  52. <a-button type="primary" html-type="submit">查询</a-button>
  53. </a-form-item>
  54. </a-row>
  55. </a-form>
  56. <a-button type="primary" class="upload-person" @click="handleUploadPerson">上传人群包</a-button>
  57. </div>
  58. <div class="control-con-table">
  59. <a-table
  60. ref="table"
  61. size="middle"
  62. bordered
  63. rowKey="id"
  64. :columns="columns"
  65. :dataSource="dataSource"
  66. :pagination="ipagination"
  67. :loading="loading"
  68. @change="handleTableChange"
  69. >
  70. <span slot="action" slot-scope="text, record">
  71. <a @click="handleEdit(record)">推送</a>
  72. <a-divider type="vertical" />
  73. <a @click="handleDelete(record)">删除</a>
  74. </span>
  75. <span slot="cause" slot-scope="text, record">
  76. <span class="cause-text-class" @click="handleCause">{{ text }}</span>
  77. </span>
  78. <span slot="depRelax" slot-scope="text, record">
  79. <a @click="handleAcountRelax('dep', record)">{{ text }}</a>
  80. </span>
  81. <span slot="acountRelax" slot-scope="text, record">
  82. <a @click="handleAcountRelax('acount', record)">{{ text }}</a>
  83. </span>
  84. </a-table>
  85. </div>
  86. <a-modal
  87. v-if="personVisible"
  88. title="上传人群包"
  89. class="person-modal"
  90. :visible="personVisible"
  91. :confirm-loading="confirmLoading"
  92. @ok="handleOk"
  93. @cancel="handleCancel"
  94. >
  95. <div>
  96. <a-form-model
  97. ref="ruleForm"
  98. :model="personForm"
  99. :rules="personRules"
  100. :label-col="labelCol"
  101. :wrapper-col="wrapperCol"
  102. >
  103. <a-form-model-item label="匹配类型" prop="resource">
  104. <a-radio-group v-model="personForm.resource">
  105. <a-radio v-for="item in resourceOption" :key="item.id" :value="item.id">{{ item.value }}</a-radio>
  106. </a-radio-group>
  107. </a-form-model-item>
  108. <a-form-model-item ref="name" label="人群包名称" prop="name">
  109. <a-input
  110. v-model="personForm.name"
  111. placeholder="请输入人群包名称"
  112. />
  113. </a-form-model-item>
  114. <a-form-model-item label="选择账户" prop="region">
  115. <a-select v-model="personForm.region" placeholder="请选择广告账户">
  116. <a-select-option value="shanghai">
  117. Zone one
  118. </a-select-option>
  119. <a-select-option value="beijing">
  120. Zone two
  121. </a-select-option>
  122. </a-select>
  123. </a-form-model-item>
  124. <a-form-model-item label="上传人群包">
  125. <a-upload
  126. name="file"
  127. :file-list="fileList"
  128. :before-upload="beforeUpload"
  129. >
  130. <a-button> <a-icon type="upload" />文件上传</a-button>
  131. </a-upload>
  132. <p class="upload-txt-rules">1、文件格式:支持上传*.txt(utf-8)文本;也支持将单个/多个*.txt文件经过Zip格式压缩上传</p>
  133. <p class="upload-txt-rules">2、文件大小:单个文件大小不能超过1G</p>
  134. <p class="upload-txt-rules">3、内容编排:每行一条记录</p>
  135. </a-form-model-item>
  136. </a-form-model>
  137. </div>
  138. </a-modal>
  139. <a-modal
  140. title="推送账户"
  141. v-if="pushVisible"
  142. :visible="pushVisible"
  143. :confirm-loading="pushConfirmLoading"
  144. dialogClass="push-modal"
  145. @ok="handlePushSure"
  146. @cancel="handlePushCancel"
  147. >
  148. <div>
  149. <div class="acount-title">
  150. <div class="acount-title-left">已选人群包</div>
  151. <div class="acount-title-right">推送平台</div>
  152. </div>
  153. <div class="acount-title push-plate">
  154. <div class="acount-title-left">推送平台</div>
  155. <div class="acount-title-right">
  156. <a-radio-group default-value="a" button-style="solid">
  157. <a-radio-button value="a">效果</a-radio-button>
  158. </a-radio-group>
  159. </div>
  160. </div>
  161. <tree-select @applyType="handleApplyType"></tree-select>
  162. </div>
  163. </a-modal>
  164. <a-modal
  165. title="相关项目"
  166. v-if="causeVisible"
  167. :visible="causeVisible"
  168. :confirm-loading="causeConfirmLoading"
  169. dialogClass="cause-modal"
  170. @ok="handleCauseSure"
  171. @cancel="handleCauseCancel"
  172. >
  173. <div>
  174. <a-table :columns="causeColumns" :data-source="causeData" bordered>
  175. <template>
  176. {{ text }}
  177. </template>
  178. </a-table>
  179. </div>
  180. </a-modal>
  181. <a-modal
  182. title="相关项目"
  183. v-if="relaxVisible"
  184. :visible="relaxVisible"
  185. :confirm-loading="relaxConfirmLoading"
  186. dialogClass="relax-modal"
  187. @ok="handleRelaxSure"
  188. @cancel="handleRelaxCancel"
  189. >
  190. <div>
  191. <div class="acount-title">
  192. <div class="acount-title-left">人群包名称</div>
  193. <div class="acount-title-right">推送平台</div>
  194. </div>
  195. <div class="acount-title push-plate">
  196. <div class="acount-title-left">目标账户</div>
  197. <div class="acount-title-right">推送平台</div>
  198. </div>
  199. <template v-if="relaxStatus === 'dep'">
  200. <a-table :columns="depColumns" :data-source="causeData" bordered>
  201. <template>
  202. {{ text }}
  203. </template>
  204. </a-table>
  205. </template>
  206. <template v-if="relaxStatus === 'acount'">
  207. <a-table :columns="acountColumns" :data-source="causeData" bordered>
  208. <template>
  209. {{ text }}
  210. </template>
  211. </a-table>
  212. </template>
  213. </div>
  214. </a-modal>
  215. </div>
  216. </template>
  217. <script>
  218. import { JeecgListMixin } from '@/mixins/JeecgListMixin';
  219. import TreeSelect from './components/tree-select';
  220. export default {
  221. name: 'crowd-control',
  222. mixins: [JeecgListMixin],
  223. components: {
  224. TreeSelect
  225. },
  226. data() {
  227. return {
  228. resourceOption: [
  229. {
  230. id: 1,
  231. value: '北京'
  232. },
  233. {
  234. id: 2,
  235. value: '上海'
  236. }
  237. ],
  238. fileList: [],
  239. relaxVisible: false,
  240. relaxConfirmLoading: false,
  241. pushVisible: false,
  242. pushConfirmLoading: false,
  243. causeVisible: false,
  244. causeConfirmLoading: false,
  245. labelCol: { span: 4 },
  246. wrapperCol: { span: 14 },
  247. personVisible: false,
  248. confirmLoading: false,
  249. statusTasks: [],
  250. acountTasks: [],
  251. url: {
  252. list: "/sys/role/list",
  253. delete: "/sys/role/delete",
  254. deleteBatch: "/sys/role/deleteBatch",
  255. exportXlsUrl: "/sys/role/exportXls",
  256. importExcelUrl: "sys/role/importExcel",
  257. },
  258. relaxStatus: '',
  259. causeData: [
  260. {
  261. name: '1111',
  262. age: '222',
  263. address: '33333'
  264. }
  265. ],
  266. depData: [], // table 相关项目点击数据
  267. countData: [], // table相关账户点击数据
  268. acountColumns: [
  269. {
  270. title: '项目名称',
  271. dataIndex: 'name',
  272. width: '25%'
  273. },
  274. {
  275. title: '所属项目',
  276. dataIndex: 'age',
  277. width: '15%'
  278. },
  279. {
  280. title: '人群包数量',
  281. dataIndex: 'address',
  282. width: '40%'
  283. }
  284. ],
  285. depColumns: [
  286. {
  287. title: '项目名称',
  288. dataIndex: 'name',
  289. width: '25%'
  290. },
  291. {
  292. title: '账户数量',
  293. dataIndex: 'age',
  294. width: '15%'
  295. },
  296. {
  297. title: '人群包数量',
  298. dataIndex: 'address',
  299. width: '40%'
  300. }
  301. ],
  302. causeColumns: [
  303. {
  304. title: '项目名称',
  305. dataIndex: 'name',
  306. width: '25%'
  307. },
  308. {
  309. title: '账户名称',
  310. dataIndex: 'age',
  311. width: '15%'
  312. },
  313. {
  314. title: '原因',
  315. dataIndex: 'address',
  316. width: '40%'
  317. }
  318. ],
  319. columns: [
  320. {
  321. title: '人群包名称',
  322. align:"center",
  323. dataIndex: 'roleName'
  324. },
  325. {
  326. title: '人群包类型',
  327. align:"center",
  328. dataIndex: 'roleCode'
  329. },
  330. {
  331. title: '匹配类型',
  332. align:"center",
  333. dataIndex: 'description'
  334. },
  335. {
  336. title: '上传时间',
  337. dataIndex: 'createTime',
  338. align:"center"
  339. },
  340. {
  341. title: '覆盖数量',
  342. dataIndex: 'updateTime',
  343. align:"center"
  344. },
  345. {
  346. title: '状态',
  347. dataIndex: 'updateTime1',
  348. align:"center"
  349. },
  350. {
  351. title: '原因',
  352. dataIndex: 'roleName1',
  353. align: 'center',
  354. scopedSlots: { customRender: 'cause' }
  355. },
  356. {
  357. title: '目标账户',
  358. dataIndex: 'updateTime2',
  359. align: 'center'
  360. },
  361. {
  362. title: '相关项目',
  363. dataIndex: 'roleName',
  364. align: 'center',
  365. scopedSlots: { customRender: 'depRelax' }
  366. },
  367. {
  368. title: '相关账户',
  369. dataIndex: 'roleName',
  370. align: 'center',
  371. scopedSlots: { customRender: 'acountRelax' }
  372. },
  373. {
  374. title: '操作',
  375. dataIndex: 'action',
  376. align: 'center',
  377. scopedSlots: { customRender: 'action' }
  378. }
  379. ],
  380. personForm: {
  381. name: '',
  382. region: undefined,
  383. resource: ''
  384. },
  385. personRules: {
  386. name: [
  387. { required: true, message: 'Please input Activity name', trigger: 'blur' },
  388. { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  389. ],
  390. region: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
  391. resource: [
  392. { required: true, message: 'Please select activity resource', trigger: 'change' },
  393. ]
  394. }
  395. }
  396. },
  397. created() {
  398. this.form = this.$form.createForm(this);
  399. },
  400. methods: {
  401. handleDelete(data) {
  402. this.$confirm({
  403. title: '删除提示',
  404. content: '确定要删除这一条吗?',
  405. onOk() {
  406. return new Promise((resolve, reject) => {
  407. setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
  408. }).catch(() => console.log('Oops errors!'));
  409. },
  410. onCancel() {},
  411. });
  412. },
  413. handleAcountRelax(txt, recd) {
  414. if (txt === 'dep') {
  415. this.relaxStatus = 'dep';
  416. }
  417. else if (txt === 'acount') {
  418. this.relaxStatus = 'acount';
  419. }
  420. this.relaxVisible = true;
  421. },
  422. handleRelaxCancel() {
  423. console.log('相关项目关闭弹窗');
  424. this.relaxVisible = false;
  425. },
  426. handleRelaxSure() {
  427. console.log('相关项目确认弹窗');
  428. },
  429. handleCause() {
  430. console.log('错误原因的弹窗');
  431. this.causeVisible = true;
  432. },
  433. handleApplyType(list) {
  434. console.log(list, '最后的tree-select的右侧数据');
  435. },
  436. handleEdit(val) {
  437. console.log(val, 'val');
  438. this.pushVisible = true;
  439. },
  440. handleCauseSure() {
  441. console.log('错误原因确认按钮');
  442. },
  443. handleCauseCancel() {
  444. console.log('错误原因取消按钮');
  445. this.causeVisible = false;
  446. },
  447. handlePushSure() {
  448. console.log('推送确认按钮');
  449. },
  450. handlePushCancel() {
  451. console.log('推送取消按钮');
  452. this.pushVisible = false;
  453. },
  454. beforeUpload(file) {
  455. this.fileList = [...this.fileList, file];
  456. this.fileList = this.fileList.slice(-1);
  457. console.log(this.fileList, '8888888');
  458. const isZip = file.type.includes('zip') || file.type.includes('text');
  459. if (!isZip) {
  460. this.fileList = [];
  461. this.$message.error('只能上传zip格式的文件或者txt文件 ');
  462. }
  463. return false;
  464. },
  465. handleQueryList(event) {
  466. event.preventDefault();
  467. const paramsData = this.form.getFieldsValue();
  468. console.log(paramsData, 'paramsData');
  469. },
  470. handleResetForm() {
  471. this.form.resetFields();
  472. },
  473. handleUploadPerson() {
  474. console.log('上传人群包');
  475. this.personVisible = true;
  476. },
  477. handleCancel() {
  478. this.personVisible = false;
  479. },
  480. handleOk() {
  481. console.log('弹窗确认');
  482. this.$refs.ruleForm.validate(valid => {
  483. console.log(4444);
  484. if (valid) {
  485. alert('submit!');
  486. } else {
  487. console.log('error submit!!');
  488. return false;
  489. }
  490. });
  491. },
  492. handleCancel() {
  493. console.log('弹窗关闭');
  494. this.personVisible = false;
  495. this.$refs.ruleForm.resetFields();
  496. }
  497. }
  498. };
  499. </script>