copy-library.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. <template>
  2. <div class="copy-library-content">
  3. <div class="control-con-header">
  4. <a-form
  5. class="grid-form"
  6. layout="inline"
  7. :form="form"
  8. hide-required-mark
  9. >
  10. <a-row>
  11. <a-form-item
  12. v-if="controlTypeModel === '1'"
  13. class="grid-form-item"
  14. label="账户:"
  15. :colon="false"
  16. >
  17. <acount-search
  18. class="acount-search-class"
  19. :appId.sync="configForm.acountId"
  20. :multiple="false"
  21. request="1,3"
  22. >
  23. </acount-search>
  24. </a-form-item>
  25. <a-form-model-item v-if="controlTypeModel === '2'" label="项目:">
  26. <a-select
  27. class="common-input-long"
  28. show-search
  29. v-model="configForm.adConvertId"
  30. :filter-option="filterOption"
  31. allowClear
  32. placeholder="请选择项目"
  33. >
  34. <a-select-option
  35. v-for="(item, index) in optimizationOption"
  36. :key="index"
  37. :value="item.projectId"
  38. >
  39. {{ item.projectName }}
  40. </a-select-option>
  41. </a-select>
  42. </a-form-model-item>
  43. </a-row>
  44. <a-row class="grid-form-options">
  45. <a-form-item
  46. class="grid-form-item"
  47. label="关键词:"
  48. :colon="false"
  49. >
  50. <a-input v-model="configForm.num" placeholder="请输入关键词"/>
  51. </a-form-item>
  52. <a-form-item
  53. class="grid-form-item"
  54. label="选择时间:"
  55. :colon="false"
  56. >
  57. <a-range-picker
  58. v-model="configForm.launchDateRange"
  59. format="YYYY-MM-DD"
  60. :disabled-date="disabledDate"
  61. @change="handleLaunchData"
  62. />
  63. </a-form-item>
  64. <a-form-item class="form-handle-btn">
  65. <a-button type="default" class="reset-class" @click="handleResetList">重置</a-button>
  66. <a-button type="primary" @click="handleQueryList">查询</a-button>
  67. </a-form-item>
  68. </a-row>
  69. </a-form>
  70. </div>
  71. <div class="control-con-table">
  72. <a-button type="primary" class="upload-person" @click="handleAddAccountConfig">新增文案</a-button>
  73. <a-tabs v-model="controlTypeModel" @change="handleTabsChange">
  74. <a-tab-pane key="1" tab="通用">
  75. <a-table
  76. ref="table"
  77. size="middle"
  78. bordered
  79. :columns="currencyColumns"
  80. :dataSource="currencyData"
  81. :pagination="false"
  82. :scroll="{x: 1500}"
  83. >
  84. </a-table>
  85. <a-pagination
  86. class="pagin-table-class"
  87. v-model="currencyPag.page"
  88. :page-size="currencyPag.size"
  89. :total="currencyTotalAll"
  90. :show-total="total => `共 ${currencyTotalAll} 条`"
  91. size="small"
  92. show-size-changer
  93. show-quick-jumper
  94. @change="handleCurrentPage"
  95. @showSizeChange="handleCurrentPage"
  96. />
  97. </a-tab-pane>
  98. <a-tab-pane key="2" tab="指定">
  99. <a-table
  100. ref="table"
  101. size="middle"
  102. bordered
  103. :columns="appointColumns"
  104. :dataSource="appointData"
  105. :pagination="false"
  106. :scroll="{x: 1500}"
  107. >
  108. </a-table>
  109. <a-pagination
  110. class="pagin-table-class"
  111. v-model="appointPag.page"
  112. :page-size="appointPag.size"
  113. :total="appointTotalAll"
  114. :show-total="total => `共 ${appointTotalAll} 条`"
  115. size="small"
  116. show-size-changer
  117. show-quick-jumper
  118. @change="handleAppointPage"
  119. @showSizeChange="handleAppointPage"
  120. />
  121. </a-tab-pane>
  122. </a-tabs>
  123. </div>
  124. <a-modal
  125. v-if="causeVisible"
  126. title="新建文案"
  127. dialog-class="copywrit-modal"
  128. :visible="causeVisible"
  129. @ok="handleCauseSure"
  130. @cancel="handleCauseCancel"
  131. >
  132. <div>
  133. <div class="acount-title">
  134. <div class="acount-title-left">文案类型</div>
  135. <div class="acount-title-right">
  136. <div class="only-title-mater">
  137. <a-radio-group v-model="copywrittypeName" button-style="solid" @change="handleFormLayoutChange">
  138. <a-radio-button value="horizontal">通用</a-radio-button>
  139. <a-radio-button value="vertical">指定素材</a-radio-button>
  140. </a-radio-group>
  141. </div>
  142. </div>
  143. </div>
  144. <div v-if="copywrittypeName === 'horizontal'" class="acount-title">
  145. <div class="acount-title-left">广告账户</div>
  146. <div class="acount-title-right">
  147. <div class="only-title-mater">
  148. <acount-search :appId.sync="advertisingAccount" request="1,3"></acount-search>
  149. </div>
  150. </div>
  151. </div>
  152. <div v-if="copywrittypeName === 'horizontal'" class="acount-title">
  153. <div class="acount-title-left">文件上传</div>
  154. <div class="acount-title-right">
  155. <div class="only-title-mater">
  156. <a-upload
  157. name="file"
  158. :file-list="fileList"
  159. :customRequest="customRequest"
  160. :remove="handleRemoveUpload"
  161. >
  162. <a-button><a-icon type="upload"/>文件上传</a-button>
  163. </a-upload>
  164. </div>
  165. </div>
  166. </div>
  167. <div v-if="copywrittypeName === 'vertical'" class="acount-title">
  168. <div class="acount-title-left">选择素材</div>
  169. <div class="acount-title-right">
  170. <div class="only-title-mater">
  171. <div><a @click="handleSelectMaterial">选择素材</a></div>
  172. <div class="title-mater-list">
  173. <p
  174. class="mater-list-name"
  175. v-for="item in modalSelectMaterial"
  176. :key="item.id"
  177. >
  178. <span class="mater-list-show">{{ item.materialName }}</span>
  179. <span class="mater-list-icon" @click="handleDelAlone(item)"><a-icon type="close"/></span>
  180. </p>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. <div v-if="copywrittypeName === 'vertical'" class="acount-title push-plate">
  186. <div class="acount-title-left">创意标题</div>
  187. <div class="acount-title-right">
  188. <a-button type="primary" @click="handleAddOrigin"><a-icon type="plus" />创意标题</a-button>
  189. <span style="margin-left: 20px;">已填:{{ titleFiledResult.length || 0 }}</span>
  190. </div>
  191. </div>
  192. <div v-if="copywrittypeName === 'vertical'" class="acount-title">
  193. <div class="acount-title-left"></div>
  194. <div class="acount-title-right">
  195. <a-form :form="examinForm">
  196. <a-form-item
  197. v-for="item in defaultFormList"
  198. :key="item.id"
  199. class="examin-form-model"
  200. :label-col="labelCol"
  201. :wrapper-col="wrapperCol"
  202. label=""
  203. >
  204. <a-input
  205. v-decorator="[
  206. item.name,
  207. {rules: [
  208. {validator: validatePass, trigger: 'blur'}
  209. ]}
  210. ]"
  211. class="examin-form-input"
  212. :id="item.name"
  213. placeholder="请输入"
  214. @change="handleFormInputChang($event, item.name, item.id)"
  215. />
  216. <span class="examin-form-num">{{ item.lenSize }}/30</span>
  217. <a-icon class="examin-form-icon" type="delete" @click="handleDelOrigin(item)"/>
  218. <div class="ad-name-tags-class">
  219. <div v-if="item.tabStatus === 'alone'" class="name-tags-left">
  220. <a-tag
  221. v-for="val in item.updateTagsList"
  222. :key="val.id"
  223. color="#1890ff"
  224. @click="handleGetChangeAll(val.name, item.name, item.id)"
  225. >
  226. + {{ val.name }}
  227. </a-tag>
  228. </div>
  229. <div v-if="item.tabStatus === 'all'" class="name-tags-left">
  230. <a-tag
  231. v-for="val in item.defaultTagsList"
  232. :key="val.id"
  233. color="#1890ff"
  234. @click="handleGetChangeAll(val.name, item.name, item.id)"
  235. >
  236. + {{ val.name }}
  237. </a-tag>
  238. </div>
  239. <div v-if="item.tabStatus === 'alone'">
  240. <a @click="handleMoreTagsShow(item.id, 'more')">更多</a>
  241. </div>
  242. <div v-if="item.tabStatus === 'all'">
  243. <a @click="handleMoreTagsShow(item.id, 'little')">收起</a>
  244. </div>
  245. </div>
  246. </a-form-item>
  247. </a-form>
  248. </div>
  249. </div>
  250. </div>
  251. </a-modal>
  252. <a-modal
  253. v-if="visibleMatemal"
  254. title="选择素材"
  255. :visible="visibleMatemal"
  256. dialog-class="select-matermal-modal"
  257. @ok="handleOkShow"
  258. @cancel="handleCancelAll"
  259. >
  260. <div class="mater-viedo-content">
  261. <div class="viedo-header-class">
  262. <div></div>
  263. <div>
  264. 当前选择数量 {{ viedoCheckValue.length }}/{{ materTotalAll }}
  265. <a-button type="primary" class="refush-btn-mat" @click="handleRefreshMaster">刷新素材</a-button>
  266. </div>
  267. </div>
  268. <a-row class="viedo-serach-class" :gutter="24">
  269. <a-col :span="9">
  270. <a-form-item label="项目" :labelCol="labelCol" :wrapperCol="wrapperCol">
  271. <a-select
  272. class="common-input-long"
  273. show-search
  274. v-model="projectModelValue"
  275. placeholder="请选择"
  276. :filter-option="filterOption"
  277. allowClear
  278. >
  279. <a-select-option
  280. v-for="(item, index) in optimizationOption"
  281. :key="index"
  282. :value="item.projectId"
  283. >
  284. {{ item.projectName }}
  285. </a-select-option>
  286. </a-select>
  287. </a-form-item>
  288. </a-col>
  289. <a-col :span="9">
  290. <a-form-item label="日期选择" :labelCol="modalCol" :wrapperCol="modalWrapper">
  291. <a-range-picker
  292. v-model="masterTimes"
  293. format="YYYY-MM-DD"
  294. @change="handleSelectTimeChange"
  295. />
  296. </a-form-item>
  297. </a-col>
  298. <a-col :span="4">
  299. <a-button style="position: relative;top: 4px;" @click="handleAllChecked">全选</a-button>
  300. <a-button type="primary" style="position: relative;top: 4px;margin-left:5px" @click="handleSearchMaster">搜索</a-button>
  301. </a-col>
  302. </a-row>
  303. <div class="viedo-content-class">
  304. <a-checkbox-group class="viedo-content-group" v-model="viedoCheckValue">
  305. <li class="content-modal-li" v-for="(item, index) in viedoDefaultList" :key="index">
  306. <a-checkbox
  307. class="viedo-content-checkbox"
  308. :value="item.id"
  309. >
  310. </a-checkbox>
  311. <img :src="item.coverUrl"/>
  312. <div class="checkbox-select-time">时间:{{ item.createTime }}</div>
  313. </li>
  314. </a-checkbox-group>
  315. <a-pagination
  316. class="pagin-table-class"
  317. v-model="masterPag.page"
  318. :page-size="masterPag.size"
  319. :total="materTotalAll"
  320. :show-total="total => `共 ${materTotalAll} 条`"
  321. size="small"
  322. show-size-changer
  323. show-quick-jumper
  324. @change="handleMasterPageChange"
  325. @showSizeChange="handleMasterPageChange"
  326. />
  327. </div>
  328. </div>
  329. </a-modal>
  330. </div>
  331. </template>
  332. <script>
  333. import AcountSearch from '@/views/modules/Statistics/components/Treeselect.vue';
  334. import moment from 'moment';
  335. import {getAction, postFileAction, postAction} from '@/api/manage';
  336. import {mapGetters} from 'vuex';
  337. import {urlAcount} from './copy-library-server.js';
  338. let COS = require('cos-js-sdk-v5');
  339. let cos = new COS({
  340. SecretId: 'AKIDE6IpMi8fJQRCg1iuWzFajjRs43kbbets',
  341. SecretKey: 'tXzuwMfplTTK3c9GFUyETilasvQfePu9'
  342. });
  343. export default {
  344. name: 'copy-library',
  345. components: {
  346. AcountSearch
  347. },
  348. data() {
  349. return {
  350. moment,
  351. projectModelValue: '',
  352. optimizationOption: [], // 账户option
  353. controlTypeModel: '1',
  354. fileList: [],
  355. modalSelectMaterial: [],
  356. materTotalAll: 0,
  357. viedoCheckValue: [],
  358. viedoDefaultList: [
  359. {
  360. name: '北京市',
  361. id: 1,
  362. statDate: '2019-08-08'
  363. },
  364. {
  365. name: '上海市',
  366. id: 2,
  367. statDate: '2019-08-08'
  368. },
  369. {
  370. name: '天津市',
  371. id: 3,
  372. statDate: '2019-08-08'
  373. },
  374. {
  375. name: '武汉市',
  376. id: 4,
  377. statDate: '2019-08-08'
  378. },
  379. {
  380. name: '贵州市',
  381. id: 5,
  382. statDate: '2019-08-08'
  383. },
  384. {
  385. name: '太原市',
  386. id: 6,
  387. statDate: '2019-08-08'
  388. },
  389. {
  390. name: '大同市',
  391. id: 7,
  392. statDate: '2019-08-08'
  393. }
  394. ],
  395. visibleMatemal: false,
  396. advertisingAccount: [],
  397. copywrittypeName: 'horizontal',
  398. adNameTags: [],
  399. causeVisible: false,
  400. labelCol: {span: 4},
  401. wrapperCol: {span: 14},
  402. modalCol: {
  403. lg: {span: 6},
  404. sm: {span: 6},
  405. xs: {span: 6},
  406. md: {span: 6}
  407. },
  408. modalWrapper: {
  409. lg: {span: 18},
  410. sm: {span: 18},
  411. xs: {span: 14},
  412. md: {span: 14}
  413. },
  414. configForm: {
  415. acountId: '',
  416. num: '',
  417. adConvertId: undefined,
  418. launchDateRange: []
  419. },
  420. currencyPag: {
  421. page: 1,
  422. size: 10
  423. },
  424. currencyData: [],
  425. currencyTotalAll: 0,
  426. currencyColumns: [
  427. {
  428. title: '文案',
  429. align: 'center',
  430. width: 200,
  431. dataIndex: 'textCopywriter'
  432. },
  433. {
  434. title: '相关创意',
  435. align: 'center',
  436. width: 150,
  437. dataIndex: 'count'
  438. },
  439. {
  440. title: '花费(元)',
  441. align: 'center',
  442. width: 150,
  443. dataIndex: 'cost',
  444. sorter: (a, b) => a.cost - b.cost
  445. },
  446. {
  447. title: '展示数',
  448. dataIndex: 'showNum',
  449. width: 150,
  450. align: 'center',
  451. sorter: (a, b) => a.showNum - b.showNum
  452. },
  453. {
  454. title: '平均千次展现费用',
  455. dataIndex: 'costPerThousandShow',
  456. align: 'center',
  457. width: 200,
  458. sorter: (a, b) => a.costPerThousandShow - b.costPerThousandShow
  459. },
  460. {
  461. title: '点击数',
  462. dataIndex: 'click',
  463. width: 150,
  464. align: 'center',
  465. sorter: (a, b) => a.click - b.click
  466. },
  467. {
  468. title: '平均点击单价',
  469. dataIndex: 'costPerClick',
  470. width: 150,
  471. align: 'center',
  472. sorter: (a, b) => a.costPerClick - b.costPerClick
  473. },
  474. {
  475. title: '点击率',
  476. dataIndex: 'clickRate',
  477. align: 'center',
  478. width: 150,
  479. sorter: (a, b) => a.clickRate - b.clickRate
  480. },
  481. {
  482. title: '转化数',
  483. dataIndex: 'convertNum',
  484. align: 'center',
  485. width: 150,
  486. sorter: (a, b) => a.convertNum - b.convertNum
  487. },
  488. {
  489. title: '转化率',
  490. dataIndex: 'convertRate',
  491. align: 'center',
  492. width: 150,
  493. sorter: (a, b) => a.convertRate - b.convertRate
  494. },
  495. {
  496. title: '转化成本',
  497. dataIndex: 'costConvert',
  498. align: 'center',
  499. width: 150,
  500. sorter: (a, b) => a.costConvert - b.costConvert
  501. }
  502. ],
  503. appointColumns: [
  504. {
  505. title: '文案',
  506. align: 'center',
  507. width: 200,
  508. dataIndex: 'slogan'
  509. },
  510. {
  511. title: '相关创意',
  512. align: 'center',
  513. width: 150,
  514. dataIndex: 'count'
  515. },
  516. {
  517. title: '花费(元)',
  518. align: 'center',
  519. width: 150,
  520. dataIndex: 'cost',
  521. sorter: (a, b) => a.cost - b.cost
  522. },
  523. {
  524. title: '展示数',
  525. dataIndex: 'showNum',
  526. width: 150,
  527. align: 'center',
  528. sorter: (a, b) => a.showNum - b.showNum
  529. },
  530. {
  531. title: '平均千次展现费用',
  532. dataIndex: 'costPerThousandShow',
  533. align: 'center',
  534. width: 200,
  535. sorter: (a, b) => a.costPerThousandShow - b.costPerThousandShow
  536. },
  537. {
  538. title: '点击数',
  539. dataIndex: 'click',
  540. width: 150,
  541. align: 'center',
  542. sorter: (a, b) => a.click - b.click
  543. },
  544. {
  545. title: '平均点击单价',
  546. dataIndex: 'costPerClick',
  547. width: 150,
  548. align: 'center',
  549. sorter: (a, b) => a.costPerClick - b.costPerClick
  550. },
  551. {
  552. title: '点击率',
  553. dataIndex: 'clickRate',
  554. align: 'center',
  555. width: 150,
  556. sorter: (a, b) => a.clickRate - b.clickRate
  557. },
  558. {
  559. title: '转化数',
  560. dataIndex: 'convertNum',
  561. align: 'center',
  562. width: 150,
  563. sorter: (a, b) => a.convertNum - b.convertNum
  564. },
  565. {
  566. title: '转化率',
  567. dataIndex: 'convertRate',
  568. align: 'center',
  569. width: 150,
  570. sorter: (a, b) => a.convertRate - b.convertRate
  571. },
  572. {
  573. title: '转化成本',
  574. dataIndex: 'costConvert',
  575. align: 'center',
  576. width: 150,
  577. sorter: (a, b) => a.costConvert - b.costConvert
  578. }
  579. ],
  580. appointData: [],
  581. appointTotalAll: 0,
  582. appointPag: {
  583. page: 1,
  584. size: 10
  585. },
  586. masterPag: {
  587. page: 1,
  588. size: 10
  589. },
  590. defaultFormList: [],
  591. titleFiledResult: 0,
  592. examinForm: this.$form.createForm(this),
  593. changeShowmasterData: [],
  594. masterTimes: [] // 选择素材的时间选择
  595. };
  596. },
  597. watch: {
  598. defaultFormList: {
  599. deep: true,
  600. handler(n, o) {
  601. const result = [];
  602. this.defaultFormList = n;
  603. this.$nextTick(() => {
  604. this.defaultFormList.forEach(item => {
  605. if (item.value) {
  606. result.push(item.value);
  607. }
  608. this.examinForm.setFieldsValue({[item.name]: item.value});
  609. });
  610. this.titleFiledResult = result;
  611. });
  612. }
  613. }
  614. },
  615. created() {
  616. this.form = this.$form.createForm(this);
  617. },
  618. mounted() {
  619. this.handleGetCurrencyList();
  620. this.handleGetProjectList();
  621. this.handleGetCreativeWord();
  622. },
  623. methods: {
  624. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  625. disabledDate(current) {
  626. return current > moment().subtract(1, 'day');
  627. },
  628. handleRefreshMaster() {
  629. this.projectModelValue = '';
  630. this.masterTimes = [];
  631. this.viedoCheckValue = [];
  632. this.hendleMaterialInfo();
  633. },
  634. handleAllChecked() {
  635. this.viedoCheckValue = this.viedoDefaultList.map(item => item.id);
  636. },
  637. filterOption(input, option) {
  638. return (
  639. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  640. );
  641. },
  642. handleGetProjectList() {
  643. getAction('/ctop/projectMember/bytedanceProjectParticipateInList').then(result => {
  644. if (result.code === 0) {
  645. this.optimizationOption = result.result;
  646. }
  647. else {
  648. this.$message.error(result.message);
  649. }
  650. }).catch(error => {
  651. console.log(error, 'eeee');
  652. });
  653. },
  654. hendleMaterialInfo() {
  655. const paramsData = {
  656. projectId: this.projectModelValue,
  657. startDate: this.masterTimes[0],
  658. endDate: this.masterTimes[1],
  659. offlineFlag: 0,
  660. pageNo: this.masterPag.page,
  661. pageSize: this.masterPag.size
  662. };
  663. getAction('/ctop/materialInfo/listV2', paramsData).then(result => {
  664. if (result.code === 0) {
  665. this.viedoDefaultList = result.data.list;
  666. this.materTotalAll = result.data.total;
  667. }
  668. else {
  669. this.$message.error(result.message);
  670. }
  671. }).catch(error => {
  672. console.log(error, 'eeee');
  673. });
  674. },
  675. handleTabsChange(e) {
  676. const page = {
  677. page: 1,
  678. size: 10
  679. };
  680. this.currencyPag = page;
  681. this.appointPag = page;
  682. this.configForm = {
  683. acountId: '',
  684. num: '',
  685. adConvertId: undefined,
  686. launchDateRange: []
  687. };
  688. if (e === '1') {
  689. this.handleGetCurrencyList();
  690. }
  691. else if (e === '2') {
  692. this.handleGetAppointList();
  693. }
  694. },
  695. handleGetCurrencyList() {
  696. let paramsData = {
  697. accountId: this.configForm.acountId,
  698. keyWord: this.configForm.num,
  699. userId: this.userInfo().id,
  700. startTime: this.configForm.launchDateRange[0],
  701. endTime: this.configForm.launchDateRange[0],
  702. pageNo: this.currencyPag.page,
  703. pageSize: this.currencyPag.size
  704. };
  705. getAction(urlAcount + '/bytedance-api/advertiser/bytedanceGeneralCopywriter/queryPageListByText', paramsData).then(result => {
  706. if (result.code === 0) {
  707. this.currencyData = result.result.list;
  708. this.currencyTotalAll = result.result.total || 0;
  709. }
  710. else {
  711. this.currencyData = [];
  712. this.currencyTotalAll = 0;
  713. this.$message.error(result.message);
  714. }
  715. }).catch(error => {
  716. console.log(error, 'eeee');
  717. });
  718. },
  719. handleGetAppointList() {
  720. let paramsData = {
  721. projectId: this.configForm.adConvertId,
  722. userId: this.userInfo().id,
  723. keyWord: this.configForm.num,
  724. startTime: this.configForm.launchDateRange[0],
  725. endTime: this.configForm.launchDateRange[0],
  726. pageNo: this.appointPag.page,
  727. pageSize: this.appointPag.size
  728. };
  729. getAction(urlAcount + '/bytedance-api/ctop/bytedanceVideoSlogenInfo/queryPageListByText', paramsData).then(result => {
  730. if (result.code === 0) {
  731. this.appointData = result.result.list;
  732. this.appointTotalAll = result.result.total || 0;
  733. }
  734. else {
  735. this.appointData = [];
  736. this.appointTotalAll = 0;
  737. this.$message.error(result.message);
  738. }
  739. }).catch(error => {
  740. console.log(error, 'eeee');
  741. });
  742. },
  743. customRequest(info) {
  744. const isZip = info.file.name.indexOf('xlsx') !== -1 || info.file.name.indexOf('xls') !== -1;
  745. if (!isZip) {
  746. this.$message.error('上传模板只能是 xls、xlsx格式!');
  747. return;
  748. }
  749. this.fileList = [];
  750. this.$nextTick(() => {
  751. this.fileList.push(info.file);
  752. });
  753. },
  754. handleRemoveUpload(data) {
  755. let index = this.fileList.indexOf(data);
  756. let newUploadFile = this.fileList;
  757. newUploadFile.splice(index, 1);
  758. this.fileList = newUploadFile;
  759. },
  760. // handleChange(info) {
  761. // const isZip = info.file.name.indexOf('xlsx') !== -1 || info.file.name.indexOf('xls') !== -1;
  762. // if (!isZip) {
  763. // this.$message.error('上传模板只能是 xls、xlsx格式!');
  764. // return;
  765. // }
  766. // this.fileList = info.fileList;
  767. // },
  768. handleSearchMaster() {
  769. this.hendleMaterialInfo();
  770. },
  771. handleSelectTimeChange(date, dateString) {
  772. this.masterTimes = dateString;
  773. },
  774. handleDelAlone(data) {
  775. this.modalSelectMaterial = this.modalSelectMaterial.filter(item => item.id !== data.id);
  776. },
  777. handleMasterPageChange(current, pageSize) {
  778. this.masterPag = {
  779. page: current = pageSize !== this.masterPag.size ? 1 : current,
  780. size: pageSize
  781. };
  782. this.hendleMaterialInfo();
  783. },
  784. handleSelectMaterial() {
  785. this.masterPag = {
  786. page: 1,
  787. size: 10
  788. };
  789. this.handleRefreshMaster();
  790. this.visibleMatemal = true;
  791. },
  792. // 选择素材的取消按钮
  793. handleCancelAll() {
  794. this.projectModelValue = '';
  795. this.masterTimes = [];
  796. this.viedoCheckValue = [];
  797. this.visibleMatemal = false;
  798. },
  799. // 选择素材的确认按钮
  800. handleOkShow() {
  801. const defaultList = this.viedoDefaultList;
  802. const defaultCheckValue = this.viedoCheckValue;
  803. let changeSelectMaterData = defaultList.filter(item => {
  804. if (defaultCheckValue.includes(item.id)) {
  805. return item;
  806. }
  807. });
  808. if (this.modalSelectMaterial.length) {
  809. this.changeShowmasterData = [...this.modalSelectMaterial];
  810. this.changeShowmasterData = this.changeShowmasterData.concat(changeSelectMaterData);
  811. let temp = {}; // 用于id判断
  812. let result = []; // 最后的新数组
  813. this.changeShowmasterData.map(item => {
  814. if (!temp[item.id]) {
  815. result.push(item);
  816. temp[item.id] = true;
  817. }
  818. });
  819. if (result.length > 10) {
  820. this.$message.error('最多上传10个素材');
  821. return;
  822. }
  823. this.modalSelectMaterial = [...result];
  824. }
  825. else {
  826. if (changeSelectMaterData.length > 10) {
  827. this.$message.error('最多上传10个素材');
  828. return;
  829. }
  830. this.modalSelectMaterial = [...changeSelectMaterData];
  831. }
  832. this.handleCancelAll();
  833. },
  834. handleFormLayoutChange(e) {
  835. const defaultValue = e.target.value;
  836. this.copywrittypeName = defaultValue;
  837. if (defaultValue === 'horizontal') {
  838. this.modalSelectMaterial = [];
  839. this.defaultFormList = [];
  840. }
  841. else if (defaultValue === 'vertical') {
  842. this.advertisingAccount = [];
  843. this.fileList = [];
  844. const defaultList = this.adNameTags;
  845. for (let i = 0; i < 3; i++) {
  846. const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
  847. this.defaultFormList.push({
  848. id: randomNum,
  849. name: 'username' + randomNum,
  850. value: '',
  851. lenSize: 0,
  852. tabStatus: 'alone',
  853. defaultTagsList: defaultList,
  854. updateTagsList: defaultList.slice(0, 4)
  855. });
  856. }
  857. }
  858. },
  859. handleExportRules(value) {
  860. let cnReg = /([\u4e00-\u9fa5]|[\u3000-\u303F]|[\uFF00-\uFF60])/;
  861. let length = 0;
  862. let strArr = value.split('');
  863. strArr.forEach(item => {
  864. if (cnReg.test(item)) {
  865. length += 1;
  866. }
  867. else {
  868. length += 0.5;
  869. }
  870. });
  871. return Math.ceil(length);
  872. },
  873. handleFormInputChang(e, field, formId) {
  874. const changeFiled = [];
  875. this.defaultFormList.forEach(item => {
  876. if (item.id === formId) {
  877. item.value = e.target.value;
  878. }
  879. });
  880. this.defaultFormList.forEach(item => {
  881. if (item.value) {
  882. changeFiled.push(item.value);
  883. }
  884. });
  885. this.$nextTick(() => {
  886. const dynamicWordPackIds = [];
  887. let finallyLenList = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
  888. let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
  889. const inputDefaultLen = this.handleExportRules(this.defaultFormList.filter(item => item.id === formId)[0].value);
  890. let tagsLen = updateFinallyResult.length * 2;
  891. let tagsSureLen = 0;
  892. let resultSelectSize = 0;
  893. this.adNameTags.forEach(item => {
  894. updateFinallyResult.forEach(val => {
  895. if (item.name === val) {
  896. tagsSureLen += item.maxWordLen;
  897. dynamicWordPackIds.push(item.creativeWordId);
  898. }
  899. });
  900. });
  901. updateFinallyResult.forEach(item => {
  902. tagsLen += item.length;
  903. });
  904. resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen + updateFinallyResult.length;
  905. this.defaultFormList.forEach(item => {
  906. if (item.id === formId) {
  907. item.lenSize = resultSelectSize;
  908. item.wordPackId = dynamicWordPackIds;
  909. }
  910. });
  911. this.titleFiledResult = changeFiled;
  912. });
  913. },
  914. handleJudgeExec(item) {
  915. let re = /\{(.+?)\}/g;
  916. let array = [];
  917. let temp;
  918. while ((temp = re.exec(item))) {
  919. array.push(temp[1]);
  920. };
  921. return array;
  922. },
  923. // 点击获取光标位置进行字段插入
  924. handleGetChangeAll(item, field, formId) {
  925. let node = document.getElementById(field);
  926. let startPos = node.selectionStart; // input 第0个字符到选中的字符
  927. let endPos = node.selectionEnd; // 选中的字符到最后的字符
  928. let txt = node.value;
  929. this.$nextTick(() => {
  930. let finallyLenList = this.handleJudgeExec(txt);
  931. let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
  932. if (updateFinallyResult.length >= 2) {
  933. this.$message.error('最多选择两个词包');
  934. return;
  935. }
  936. if (startPos === 0 || endPos === 0) {
  937. txt += '{' + item + '}';
  938. this.examinForm.setFieldsValue({[field]: txt});
  939. }
  940. else {
  941. this.examinForm.setFieldsValue({[field]: txt.substring(0, startPos) + '{' + item + '}' + txt.substring(endPos)});
  942. node.selectionStart = startPos + item.length + 6;
  943. node.selectionEnd = startPos + item.length + 6;
  944. }
  945. node.focus();
  946. node.blur();
  947. });
  948. this.$nextTick(() => {
  949. const dynamicWordPackIds = [];
  950. let changeData = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
  951. let updateChangeData = this.adNameTags.filter(item => changeData.includes(item.name)).map(val => val.name);
  952. const inputDefaultLen = this.handleExportRules(this.examinForm.getFieldsValue()[field]);
  953. let tagsLen = updateChangeData.length * 2;
  954. let tagsSureLen = 0;
  955. let resultSelectSize = 0;
  956. this.adNameTags.forEach(item => {
  957. updateChangeData.forEach(val => {
  958. if (item.name === val) {
  959. tagsSureLen += item.maxWordLen;
  960. dynamicWordPackIds.push(item.creativeWordId);
  961. }
  962. });
  963. });
  964. updateChangeData.forEach(item => {
  965. tagsLen += item.length;
  966. });
  967. resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen + updateChangeData.length;
  968. this.defaultFormList.forEach(item => {
  969. if (item.id === formId) {
  970. item.lenSize = resultSelectSize;
  971. item.value = this.examinForm.getFieldsValue()[field];
  972. item.wordPackId = dynamicWordPackIds;
  973. }
  974. });
  975. });
  976. },
  977. validatePass(rule, value, callback) {
  978. this.$nextTick(() => {
  979. let finallyLenList = this.handleJudgeExec(value);
  980. let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
  981. let resultSelectSize = 0;
  982. if (updateFinallyResult.length) {
  983. const inputDefaultLen = this.handleExportRules(value);
  984. let tagsLen = updateFinallyResult.length * 2;
  985. let tagsSureLen = 0;
  986. this.adNameTags.forEach(item => {
  987. updateFinallyResult.forEach(val => {
  988. if (item.name === val) {
  989. tagsSureLen += item.maxWordLen;
  990. }
  991. });
  992. });
  993. updateFinallyResult.forEach(item => {
  994. tagsLen += item.length;
  995. });
  996. resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen + updateFinallyResult.length;
  997. }
  998. else {
  999. resultSelectSize = this.handleExportRules(value);
  1000. }
  1001. if (resultSelectSize === 0) {
  1002. callback(new Error('请输入'));
  1003. }
  1004. else if (resultSelectSize > 30 || resultSelectSize < 5) {
  1005. callback(new Error('创意标题5-30个字'));
  1006. }
  1007. else if (updateFinallyResult.length > 2) {
  1008. callback(new Error('最多选择两个词包'));
  1009. }
  1010. else {
  1011. callback();
  1012. }
  1013. });
  1014. },
  1015. handleMoreTagsShow(val, type) {
  1016. if (type === 'more') {
  1017. this.defaultFormList.forEach(item => {
  1018. if (item.id === val) {
  1019. item.tabStatus = 'all';
  1020. }
  1021. });
  1022. }
  1023. else if (type === 'little') {
  1024. this.defaultFormList.forEach(item => {
  1025. if (item.id === val) {
  1026. item.tabStatus = 'alone';
  1027. }
  1028. });
  1029. }
  1030. },
  1031. handleUploadWxecl() {
  1032. if (!this.advertisingAccount.length) {
  1033. this.$message.error('请选择账户');
  1034. return;
  1035. }
  1036. if (!this.fileList.length) {
  1037. this.$message.error('请上传文件');
  1038. return;
  1039. }
  1040. let paramsData = new FormData();
  1041. paramsData.append('accountId', this.advertisingAccount);
  1042. paramsData.append('excelFile', this.fileList[0]);
  1043. postFileAction(urlAcount + '/bytedance-api/advertiser/bytedanceGeneralCopywriter/loadExcel', paramsData, {
  1044. headers: {
  1045. 'Content-Type': 'multipart/form-data'
  1046. }
  1047. }).then(result => {
  1048. if (result.code === 0) {
  1049. this.$message.success(result.message);
  1050. this.controlTypeModel = '1';
  1051. this.handleCauseCancel();
  1052. this.handleGetCurrencyList();
  1053. }
  1054. else {
  1055. this.$message.error(result.message);
  1056. }
  1057. }).catch(error => {
  1058. console.log(error, 'eeee');
  1059. });
  1060. },
  1061. handleVerticalAdd() {
  1062. if (!this.modalSelectMaterial.length) {
  1063. this.$message.error('请选择素材');
  1064. return;
  1065. }
  1066. if (this.defaultFormList && this.defaultFormList.length < 3) {
  1067. this.$message.error('请至少输入3条标题');
  1068. return;
  1069. }
  1070. let changeSlogan = this.defaultFormList;
  1071. changeSlogan.forEach(item => {
  1072. item.title = item.value;
  1073. item.creative_word_ids = item.wordPackId;
  1074. });
  1075. let paramsData = {
  1076. materialIds: this.modalSelectMaterial.map(item => item.id),
  1077. userId: this.userInfo().id,
  1078. slogans: changeSlogan
  1079. };
  1080. this.examinForm.validateFields(err => {
  1081. if (!err) {
  1082. postAction(urlAcount + '/bytedance-api/ctop/bytedanceVideoSlogenInfo/addList', paramsData).then(result => {
  1083. if (result.code === 0) {
  1084. this.$message.success(result.message);
  1085. this.controlTypeModel = '1';
  1086. this.modalSelectMaterial = [];
  1087. this.handleCauseCancel();
  1088. this.handleGetCurrencyList();
  1089. }
  1090. else {
  1091. this.$message.error(result.message);
  1092. }
  1093. }).catch(error => {
  1094. console.log(error, 'eeee');
  1095. });
  1096. }
  1097. });
  1098. },
  1099. handleCauseSure() {
  1100. if (this.copywrittypeName === 'horizontal') {
  1101. this.handleUploadWxecl();
  1102. }
  1103. else if (this.copywrittypeName === 'vertical') {
  1104. this.handleVerticalAdd();
  1105. }
  1106. },
  1107. handleCauseCancel() {
  1108. this.copywrittypeName = 'horizontal';
  1109. this.advertisingAccount = [];
  1110. this.fileList = [];
  1111. this.causeVisible = false;
  1112. this.defaultFormList = [];
  1113. this.modalSelectMaterial = [];
  1114. },
  1115. handleGetCreativeWord() {
  1116. getAction('/ctop/ByteDanceCreativeWordPackage/list').then(result => {
  1117. if (result.code === 0) {
  1118. this.adNameTags = result.result.records;
  1119. }
  1120. else {
  1121. this.$message.error(result.message);
  1122. }
  1123. }).catch(error => {
  1124. console.log(error, 'eeee');
  1125. });
  1126. },
  1127. handleAddOrigin() {
  1128. const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
  1129. this.defaultFormList.push({
  1130. id: randomNum,
  1131. name: 'username' + randomNum,
  1132. value: '',
  1133. lenSize: 0,
  1134. tabStatus: 'alone',
  1135. defaultTagsList: this.adNameTags,
  1136. updateTagsList: this.adNameTags.slice(0, 4)
  1137. });
  1138. },
  1139. handleDelOrigin(list) {
  1140. let formData = this.defaultFormList;
  1141. this.defaultFormList = formData.filter(item => list.id !== item.id);
  1142. },
  1143. handleAddAccountConfig() {
  1144. this.causeVisible = true;
  1145. },
  1146. handleLaunchData(date, dateString) {
  1147. this.configForm.launchDateRange = dateString;
  1148. },
  1149. handleQueryList() {
  1150. const page = {
  1151. page: 1,
  1152. size: 10
  1153. };
  1154. this.currencyPag = page;
  1155. this.appointPag = page;
  1156. if (this.controlTypeModel === '1') {
  1157. this.handleGetCurrencyList();
  1158. }
  1159. else if (this.controlTypeModel === '2') {
  1160. this.handleGetAppointList();
  1161. }
  1162. },
  1163. handleResetList() {
  1164. this.configForm = {
  1165. acountId: '',
  1166. num: '',
  1167. adConvertId: undefined,
  1168. launchDateRange: []
  1169. };
  1170. const page = {
  1171. page: 1,
  1172. size: 10
  1173. };
  1174. this.currencyPag = page;
  1175. this.appointPag = page;
  1176. if (this.controlTypeModel === '1') {
  1177. this.handleGetCurrencyList();
  1178. }
  1179. else if (this.controlTypeModel === '2') {
  1180. this.handleGetAppointList();
  1181. }
  1182. },
  1183. handleCurrentPage(current, pageSize) {
  1184. this.currencyPag = {
  1185. page: current = pageSize !== this.currencyPag.size ? 1 : current,
  1186. size: pageSize
  1187. };
  1188. this.handleGetCurrencyList();
  1189. },
  1190. handleAppointPage(current, pageSize) {
  1191. this.appointPag = {
  1192. page: current = pageSize !== this.appointPag.size ? 1 : current,
  1193. size: pageSize
  1194. };
  1195. this.handleGetAppointList();
  1196. }
  1197. }
  1198. };
  1199. </script>
  1200. <style lang="less" scoped>
  1201. @import "copy-library";
  1202. </style>