material.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. <template>
  2. <div class="input-item material-creat">
  3. <a-form-item>
  4. <a-radio-group v-model="materialType" @change="materialTypeChange" style="margin-bottom: 32px;">
  5. <!-- <a-badge :count="HorizontalLargeImageListBig.length" :numberStyle="{backgroundColor: '#52c41a'} ">
  6. <a-radio-button value="CREATIVE_IMAGE_MODE_LARGE">大图横图</a-radio-button>
  7. </a-badge> -->
  8. <a-badge :count="HorizontalLargeImageListShu.length" :numberStyle="{backgroundColor: '#52c41a'} ">
  9. <a-radio-button value="CREATIVE_IMAGE_MODE_VIDEO">横版视频</a-radio-button>
  10. </a-badge>
  11. <a-badge :count="HorizontalLargeImageListHeng.length" :numberStyle="{backgroundColor: '#52c41a'} ">
  12. <a-radio-button value="CREATIVE_IMAGE_MODE_VIDEO_VERTICAL">竖版视频</a-radio-button>
  13. </a-badge>
  14. <!-- <a-badge :count="HorizontalLargeImageListZu.length" :numberStyle="{backgroundColor: '#52c41a'} "
  15. v-if="creativeType=='customCreativity'">
  16. <a-radio-button value="CREATIVE_IMAGE_MODE_GROUP">组图</a-radio-button>
  17. </a-badge> -->
  18. <!-- <a-badge :count="HorizontalLargeImageListSmall.length" :numberStyle="{backgroundColor: '#52c41a'} ">
  19. <a-radio-button value="CREATIVE_IMAGE_MODE_SMALL">小图</a-radio-button>
  20. </a-badge> -->
  21. <!-- <a-badge :count="HorizontalLargeImageListBigShu.length" :numberStyle="{backgroundColor: '#52c41a'} ">
  22. <a-radio-button value="CREATIVE_IMAGE_MODE_LARGE_VERTICAL">大图竖图</a-radio-button>
  23. </a-badge> -->
  24. </a-radio-group>
  25. <div class="bui-tabs-scroll">
  26. <a-layout
  27. :style="{ height: '600px',width:'700px',border:'1px solid #ccc',overflow:'auto',padding:'0 15px 10px'}">
  28. <a-layout-content style="padding:10px;">
  29. <div :style="{ marginBottom: '16px' }">
  30. <a-button @click="addCreative()" :disabled="count&&materialType!=undefined">添加创意</a-button>
  31. <span style="color:black;margin-left:10px"
  32. v-if="creativeType == 'customCreativity'">{{countMany}}/10</span>
  33. <span style="color:black;margin-left:10px" v-else-if="creativeType == 'program'">视频数量:{{vadioMany}}/12
  34. 图片数量:{{imgMany}}/10</span>
  35. </div>
  36. <a-row>
  37. <a-col :span="24" v-for="(item,index) of HorizontalLargeImageList" :key="index">
  38. <a-card title :ref="item">
  39. {{item}}
  40. <a-icon type="close" style="float:right;cursor: pointer;" @click="deleteCreative(index)" />
  41. <div style="clear:both"></div>
  42. <div class="dynamically_add_form_item">
  43. <a-form-item class label="素材选择" :labelCol="labelCol" :wrapperCol="wrapperCol">
  44. <!-- <upload-to-ali v-model="item.vadioUrl" :customDomain="customDomain" preview :region="region"
  45. :bucket="bucket"
  46. :accept="materialType=='CREATIVE_IMAGE_MODE_VIDEO'||materialType=='CREATIVE_IMAGE_MODE_VIDEO_VERTICAL'?acceptVideo:acceptImage"
  47. :size="102400" :accessKeyId="accessKeyId" :accessKeySecret="accessKeySecret"></upload-to-ali> -->
  48. <!-- <uploadFile :value.sync="item.vadioUrl" :fileCount="1"
  49. :uploadType="materialType=='CREATIVE_IMAGE_MODE_VIDEO'||materialType=='CREATIVE_IMAGE_MODE_VIDEO_VERTICAL'?'video':'image'" />
  50. -->
  51. <a
  52. @click="getVideoList(item)">{{materialType=='CREATIVE_IMAGE_MODE_VIDEO'||materialType=='CREATIVE_IMAGE_MODE_VIDEO_VERTICAL'?'选择视频':'选择图片'}}</a>
  53. <div>
  54. <!-- {{materialType}} -->
  55. <video :src="item.videoUrl" style="width:300px" v-show="materialType=='CREATIVE_IMAGE_MODE_VIDEO'&&item.videoUrl"></video>
  56. <video :src="item.videoUrl" style="width:120px" v-show="materialType=='CREATIVE_IMAGE_MODE_VIDEO_VERTICAL'&&item.videoUrl"></video>
  57. </div>
  58. </a-form-item>
  59. <!-- <a-form-item label="封面上传" :labelCol="labelCol" :wrapperCol="wrapperCol"
  60. v-if="(materialType=='CREATIVE_IMAGE_MODE_VIDEO_VERTICAL'||materialType=='CREATIVE_IMAGE_MODE_VIDEO')">
  61. <upload-to-ali v-model="item.imageUrl" :customDomain="customDomain" preview :region="region"
  62. :bucket="bucket" :accept="acceptImage" :size="102400" :accessKeyId="accessKeyId"
  63. :accessKeySecret="accessKeySecret"></upload-to-ali>
  64. <a @click="getImageList(item)">选择图片</a>
  65. </a-form-item> -->
  66. <a-form-item label="创意标题" :labelCol="labelCol" :wrapperCol="wrapperCol"
  67. v-if="creativeType == 'customCreativity'">
  68. <a-input v-model="item.text" style="width:400px" class="rending" @change="judge(item)"></a-input>
  69. </a-form-item>
  70. <a-form-item label="动态词包" :labelCol="labelCol" :wrapperCol="wrapperCol"
  71. v-if="creativeType == 'customCreativity'">
  72. <a-tag v-for="(itemTag,indexTag) of tags" :key="indexTag" v-show="indexTag<item.many"
  73. @click="getChange(item,itemTag,index)">{{itemTag.name}}</a-tag>
  74. <span @click="showElseClick(item)">{{item.showElse?"更多":"收起"}}</span>
  75. </a-form-item>
  76. </div>
  77. </a-card>
  78. </a-col>
  79. </a-row>
  80. </a-layout-content>
  81. </a-layout>
  82. </div>
  83. </a-form-item>
  84. <div v-if="creativeType == 'proceduralCreativity'">
  85. <div style="display:block;font-size: 22px;margin-bottom: 20px;">程序化创意标题</div>
  86. <a-button @click="addTitle" class="row-item">添加创意标题</a-button>
  87. <br />
  88. <div v-for="(item,index) of titleData" :key="index">
  89. <a-input style="width:55%;margin-bottom:20px" v-model="item.text" class="rending-all" @change="judge(item)">
  90. </a-input>
  91. <a-icon type="delete" style="margin-left:20px;cursor: pointer;" v-show="titleData.length>1"
  92. @click="tetleDetele(index)" />
  93. <br />
  94. <a-tag style="margin-bottom:10px" v-for="(itemTag,indexTag) of tags" :key="indexTag"
  95. @click="getChangeAllTitle(item,itemTag,index)">
  96. {{itemTag.name}}</a-tag>
  97. </div>
  98. </div>
  99. <!-- 创建大图横图创意 -->
  100. <a-modal :maskClosable="false" title="选择素材" v-model="visibleMatemal" @ok="handleOkShow" :width="1000">
  101. <a-range-picker name="buildTime" style="width: 400px;margin:10px 0" v-model="time" />
  102. <ul v-if="dataSource.length>0" style="overflow:auto;padding-left:0">
  103. <a-checkbox-group v-model="checkVideo" @change="onChangeVideo" style="width:100%">
  104. <li v-for="(item,index) of dataSource" :key="index" class="chouzhen" style="height:350px;">
  105. <!-- <video class="video" :src="item.url" controls="controls" style="width:100%">
  106. 您的浏览器不支持 video 标签。
  107. </video> -->
  108. <a-checkbox :value="item" style="width:100%;position:absolute;z-index: 100;right:0;top:0;">
  109. <video v-if="materialType == 'CREATIVE_IMAGE_MODE_VIDEO' || materialType ==
  110. 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL'" class="video" :src="item.videoUrl" controls="controls"
  111. style="width:100%;margin-left: -8px;">
  112. 您的浏览器不支持 video 标签。
  113. </video>
  114. <img v-else :src="item.imageUrl" alt="" style="width:100%;margin-left: -8px;">
  115. </a-checkbox>
  116. <!-- <a @click="matemalVideo(item,index)" style="position:absolute;z-index: 100;right:56px;bottom: 5px;">查看视频</a> -->
  117. </li>
  118. </a-checkbox-group>
  119. </ul>
  120. <div v-else style="width:100%;height:400px;display:flex;justify-content: center;align-items: center;">
  121. <img
  122. src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575627350102&di=02972956f2243933bffc0d85099adbfe&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D1095310825%2C1528244349%26fm%3D214%26gp%3D0.jpg"
  123. alt="" v-if="!loadingVideoList" />
  124. <img v-else src="@/views/modules/material/loading.gif" />
  125. </div>
  126. <!-- <ul class="actor-photo-list">
  127. <a-checkbox-group v-model="checkArr" style="width:100%; display: flex;padding-left: 0;"
  128. @change="onChangeCheck">
  129. <li v-for="(item, index) of dataSource" :key="index">
  130. <a-checkbox :value="item" style="position:absolute;z-index:100;padding-right:30px">
  131. </a-checkbox>
  132. </li>
  133. </a-checkbox-group>
  134. </ul> -->
  135. <div style="text-align:right">
  136. <a-pagination size="small" :showTotal="ipagination.showTotal" style="float:right" v-if="dataSource.length > 0"
  137. showQuickJumper :pageSize.sync="ipagination.pageSize" :total="ipagination.total" v-model="ipagination.current"
  138. @change="getDataSource" />
  139. </div>
  140. </a-modal>
  141. <a-modal :maskClosable="false" title="选择素材" v-model="visibleMatemalImage" @ok="handleOkShow" :width="1000">
  142. <a-range-picker name="buildTime" style="width: 400px;margin:10px 0" v-model="time" />
  143. <ul v-if="dataSource.length>0" style="overflow:auto;padding-left:0">
  144. <a-checkbox-group v-model="checkVideo" @change="onChangeVideo" style="width:100%">
  145. <li v-for="(item,index) of dataSource" :key="index" class="chouzhen" style="height:350px;">
  146. <!-- <video class="video" :src="item.url" controls="controls" style="width:100%">
  147. 您的浏览器不支持 video 标签。
  148. </video> -->
  149. <a-checkbox :value="item" style="width:100%;position:absolute;z-index: 100;right:0;top:0;">
  150. <img :src="item.imageUrl" alt="" style="width:100%;margin-left: -8px;">
  151. </a-checkbox>
  152. <!-- <a @click="matemalVideo(item,index)" style="position:absolute;z-index: 100;right:56px;bottom: 5px;">查看视频</a> -->
  153. </li>
  154. </a-checkbox-group>
  155. </ul>
  156. <div v-else style="width:100%;height:400px;display:flex;justify-content: center;align-items: center;">
  157. <img
  158. src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575627350102&di=02972956f2243933bffc0d85099adbfe&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D1095310825%2C1528244349%26fm%3D214%26gp%3D0.jpg"
  159. alt="" v-if="!loadingVideoList" />
  160. <img v-else src="@/views/modules/material/loading.gif" />
  161. </div>
  162. <!-- <ul class="actor-photo-list">
  163. <a-checkbox-group v-model="checkArr" style="width:100%; display: flex;padding-left: 0;"
  164. @change="onChangeCheck">
  165. <li v-for="(item, index) of dataSource" :key="index">
  166. <a-checkbox :value="item" style="position:absolute;z-index:100;padding-right:30px">
  167. </a-checkbox>
  168. </li>
  169. </a-checkbox-group>
  170. </ul> -->
  171. <div style="text-align:right">
  172. <a-pagination size="small" :showTotal="ipagination.showTotal" style="float:right" v-if="dataSource.length > 0"
  173. showQuickJumper :pageSize.sync="ipagination.pageSize" :total="ipagination.total" v-model="ipagination.current"
  174. @change="getDataSource" />
  175. </div>
  176. </a-modal>
  177. <a-modal title="查看视频" v-model="visibleVideo" :width="300" :footer="null">
  178. <video class="video" :src="videoUrlShow" controls="controls" style="width:100%">
  179. 您的浏览器不支持 video 标签。
  180. </video>
  181. </a-modal>
  182. </div>
  183. </template>
  184. <script>
  185. import UploadToAli from '@femessage/upload-to-ali'
  186. import uploadFile from '@/components/uploadFile.vue'
  187. import {
  188. postAction,
  189. getAction,
  190. getPackage
  191. } from '@/api/manage'
  192. import {
  193. stopOtherVideo,
  194. closeAllVideoFun
  195. } from '@/utils/videoControl' // 停止除当前外的其他视频播放,及停止所有视频播放的方法
  196. import moment from 'moment'
  197. import AFormItem from 'ant-design-vue/es/form/FormItem'
  198. import $ from 'jquery'
  199. import qs from 'qs'
  200. export default {
  201. name: 'BaseForm',
  202. props: {
  203. accountId: {
  204. default () {
  205. return ''
  206. }
  207. },
  208. creativeType: {
  209. type: String,
  210. default () {
  211. return 'customCreativity'
  212. }
  213. }
  214. },
  215. components: {
  216. AFormItem,
  217. // UploadToAli,
  218. uploadFile
  219. },
  220. data() {
  221. return {
  222. visibleMatemal: false,
  223. visibleVideo: false,
  224. videoUrlShow: "",
  225. dataSource: [],
  226. loadingVideoList: false,
  227. time: [],
  228. checkVideo: [],
  229. labelCol: {
  230. xs: {
  231. span: 24
  232. },
  233. sm: {
  234. span: 5
  235. }
  236. },
  237. wrapperCol: {
  238. xs: {
  239. span: 24
  240. },
  241. sm: {
  242. span: 16
  243. }
  244. },
  245. visibleMatemalImage:false,
  246. accessKeyId: 'LTAIbNbqWzSOklQV',
  247. accessKeySecret: '1rkPz7JNoXk8sJevPaeYHWqfkQXBGh',
  248. bucket: 'ctop-media',
  249. region: 'oss-cn-beijing',
  250. acceptImage: 'image/jpeg,image/png',
  251. acceptVideo: 'video/mpeg,video/mp4',
  252. customDomain: '',
  253. form: this.$form.createForm(this),
  254. url: {
  255. userAllocationList: '/template/allocation/list',
  256. insertUrl: '/template/creative/insert',
  257. industryListUrl: '/template/bytedance/industry/list',
  258. campaignListUrl: '/template/campaign/list',
  259. budgetTemplateListUrl: '/template/budget/list',
  260. deliverytargetTemplateListUrl: '/template/deliverytarget/list',
  261. userorentationTemplateListUrl: '/template/userorentation/list',
  262. deliverytargetTemplateGetUrl: '/template/deliveryTarget/get',
  263. convertList: 'template/convert/list'
  264. },
  265. materialType: 'CREATIVE_IMAGE_MODE_VIDEO',
  266. // 创建大图横图创意
  267. createLargeImageCreativeCon: true,
  268. HorizontalLargeImageList: [],
  269. HorizontalLargeImageListBig: [],
  270. HorizontalLargeImageListHeng: [],
  271. HorizontalLargeImageListShu: [],
  272. HorizontalLargeImageListZu: [],
  273. HorizontalLargeImageListSmall: [],
  274. HorizontalLargeImageListBigShu: [],
  275. horizonImageUrlColl: [], // 大图横图图片素材集合
  276. horizonImageCreativeTextColl: [], // 创意标题集合
  277. itemIndex: null,
  278. tags: [],
  279. range: null,
  280. countTag: 0,
  281. titleData: [{
  282. text: '',
  283. showElse: true,
  284. titleMany: 0
  285. }],
  286. nowItem: null,
  287. ipagination: {
  288. current: 1,
  289. pageSize: 5,
  290. // pageSizeOptions: ['10', '20', '30'],
  291. showTotal: (total, range) => {
  292. return range[0] + '-' + range[1] + ' 共' + total + '条'
  293. },
  294. showQuickJumper: true,
  295. // showSizeChanger: true,
  296. total: 0,
  297. onChange: current => {
  298. // 切换分页时的回调,
  299. // 当在页面定义change事件时,切记要把此处的事件清除,因为这两个事件重叠了,可能到时候会导致一些莫名的bug
  300. this.ipagination.current = current
  301. }
  302. },
  303. }
  304. },
  305. methods: {
  306. getDataSource(page, pageSize) {
  307. this.ipagination.current = page
  308. var params = {}
  309. params.accountId = "1649600126891015"
  310. params.pageSize = this.ipagination.pageSize
  311. params.pageNo = page
  312. if (this.time.length > 0) {
  313. params.startDate = moment(this.time[0]).format('YYYY-MM-DD')
  314. params.endDate = moment(this.time[1]).format('YYYY-MM-DD')
  315. }
  316. if (this.materialType == 'CREATIVE_IMAGE_MODE_VIDEO' || this.materialType ==
  317. 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL') {
  318. this.showVideoList('/bytedance/batch/getVideoList', params)
  319. } else {
  320. this.showVideoList('/bytedance/batch/getImageList', params)
  321. }
  322. },
  323. getImageList(item) {
  324. this.checkVideo = []
  325. this.nowItem = item
  326. this.visibleMatemal = true
  327. this.ipagination.current = 1
  328. var params = {}
  329. params.accountId = '1649600126891015'
  330. params.pageSize = this.ipagination.pageSize
  331. params.pageNo = this.ipagination.current
  332. if (this.time.length > 0) {
  333. params.startDate = moment(this.time[0]).format('YYYY-MM-DD')
  334. params.endDate = moment(this.time[1]).format('YYYY-MM-DD')
  335. }
  336. this.showVideoList('/bytedance/batch/getImageList', params)
  337. },
  338. onChangeVideo() {
  339. if (this.checkVideo.length > 1) {
  340. this.checkVideo.shift()
  341. }
  342. },
  343. matemalVideo(item, index) {
  344. this.visibleVideo = true
  345. this.videoUrlShow = item.url
  346. },
  347. handleOkShow() {
  348. this.visibleMatemal = false
  349. if (this.materialType == 'CREATIVE_IMAGE_MODE_VIDEO' || this.materialType ==
  350. 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL') {
  351. this.nowItem.videoId = this.checkVideo[0].id
  352. this.nowItem.videoUrl = this.checkVideo[0].videoUrl
  353. } else {
  354. this.nowItem.imageId = this.checkVideo[0].id
  355. this.nowItem.imageUrl = this.checkVideo[0].imageUrl
  356. }
  357. },
  358. getVideoList(item) {
  359. this.checkVideo = []
  360. this.nowItem = item
  361. this.visibleMatemal = true
  362. this.ipagination.current = 1
  363. var params = {}
  364. params.accountId = '1649600126891015'
  365. params.pageSize = this.ipagination.pageSize
  366. params.pageNo = this.ipagination.current
  367. if (this.time.length > 0) {
  368. params.startDate = moment(this.time[0]).format('YYYY-MM-DD')
  369. params.endDate = moment(this.time[1]).format('YYYY-MM-DD')
  370. }
  371. if (this.materialType == 'CREATIVE_IMAGE_MODE_VIDEO' || this.materialType ==
  372. 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL') {
  373. this.showVideoList('/bytedance/batch/getVideoList', params)
  374. } else {
  375. this.showVideoList('/bytedance/batch/getImageList', params)
  376. }
  377. },
  378. showVideoList(url, params) {
  379. this.dataSource = []
  380. this.loadingVideoList = true
  381. getAction(url, params).then(res => {
  382. if (res.success) {
  383. this.dataSource = res.result.records
  384. this.ipagination.total = res.result.total
  385. this.loadingVideoList = false
  386. } else {
  387. this.loadingVideoList = false
  388. }
  389. })
  390. },
  391. judge(item) {
  392. var re = /{(.*?)}/g
  393. var array = []
  394. var temp
  395. while ((temp = re.exec(item.text))) {
  396. array.push(temp[1])
  397. }
  398. console.log(array)
  399. item.countTag = array.length
  400. },
  401. getChange(item, tag, index) {
  402. this.judge(item)
  403. if (item.text == '') {
  404. item.countTag = 0
  405. }
  406. if (item.countTag >= 2) {
  407. this.$message.error('最多插入两条词包')
  408. // item.countTag = 2
  409. return
  410. }
  411. var node = document.getElementsByClassName('rending')[index]
  412. var v = '{' + tag.name + '}'
  413. if (document.selection) {
  414. //IE
  415. node.focus()
  416. var sel = document.selection.createRange()
  417. sel.text = v
  418. sel.select()
  419. item.creativeWordIds.push(tag.creative_word_id)
  420. } else if (node.selectionStart || node.selectionStart == '0') {
  421. //MOZILLA/GOOGLE
  422. var startPos = node.selectionStart
  423. var endPos = node.selectionEnd
  424. var restoreTop = node.scrollTop
  425. node.value = node.value.substring(0, startPos) + v + node.value.substring(endPos, node.value.length)
  426. if (restoreTop > 0) {
  427. node.scrollTop = restoreTop
  428. }
  429. item.text = node.value
  430. item.creativeWordIds.push(tag.creative_word_id)
  431. node.focus()
  432. node.selectionStart = startPos + v.length
  433. node.selectionEnd = startPos + v.length
  434. } else {
  435. //OTHER
  436. node.value += v
  437. item.creativeWordIds.push(tag.creative_word_id)
  438. item.text = node.value
  439. node.focus()
  440. }
  441. },
  442. getChangeAllTitle(item, tag, index) {
  443. this.judge(item)
  444. if (item.text == '') {
  445. item.countTag = 0
  446. }
  447. if (item.countTag >= 2) {
  448. this.$message.error('最多插入两条词包')
  449. // item.countTag = 2
  450. return
  451. }
  452. var node = document.getElementsByClassName('rending-all')[index]
  453. var v = '{' + tag.name + '}'
  454. item.creativeWordIds.push(tag.name)
  455. if (document.selection) {
  456. //IE
  457. node.focus()
  458. var sel = document.selection.createRange()
  459. sel.text = v
  460. sel.select()
  461. } else if (node.selectionStart || node.selectionStart == '0') {
  462. //MOZILLA/GOOGLE
  463. var startPos = node.selectionStart
  464. var endPos = node.selectionEnd
  465. var restoreTop = node.scrollTop
  466. node.value = node.value.substring(0, startPos) + v + node.value.substring(endPos, node.value.length)
  467. if (restoreTop > 0) {
  468. node.scrollTop = restoreTop
  469. }
  470. item.text = node.value
  471. node.focus()
  472. node.selectionStart = startPos + v.length
  473. node.selectionEnd = startPos + v.length
  474. } else {
  475. //OTHER
  476. node.value += v
  477. item.text = node.value
  478. node.focus()
  479. }
  480. },
  481. showElseClick(item) {
  482. item.showElse = !item.showElse
  483. if (!item.showElse) {
  484. item.many = this.tags.length
  485. } else {
  486. item.many = 3
  487. }
  488. },
  489. materialTypeChange() {
  490. let type = this.materialType
  491. if (type === 'CREATIVE_IMAGE_MODE_SMALL') {
  492. // this.createLargeImageCreativeCon = false
  493. this.showLargeImage = false
  494. this.showLargeVerticalImage = false
  495. this.showHorizonVideo = false
  496. this.showVerticalVideo = false
  497. this.showGroupImage = false
  498. this.showSmallImage = true
  499. this.HorizontalLargeImageList = this.HorizontalLargeImageListSmall
  500. }
  501. if (type === 'CREATIVE_IMAGE_MODE_LARGE') {
  502. // this.createLargeImageCreativeCon = true
  503. this.showLargeImage = false
  504. this.showLargeVerticalImage = false
  505. this.showHorizonVideo = false
  506. this.showVerticalVideo = false
  507. this.showGroupImage = false
  508. this.showSmallImage = false
  509. this.HorizontalLargeImageList = this.HorizontalLargeImageListBig
  510. }
  511. if (type === 'CREATIVE_IMAGE_MODE_GROUP') {
  512. // this.createLargeImageCreativeCon = false
  513. this.showLargeImage = false
  514. this.showLargeVerticalImage = false
  515. this.showHorizonVideo = false
  516. this.showVerticalVideo = false
  517. this.showGroupImage = true
  518. this.showSmallImage = false
  519. this.HorizontalLargeImageList = this.HorizontalLargeImageListZu
  520. }
  521. if (type === 'CREATIVE_IMAGE_MODE_VIDEO') {
  522. // this.createLargeImageCreativeCon = false
  523. this.showLargeImage = false
  524. this.showLargeVerticalImage = false
  525. this.showHorizonVideo = true
  526. this.showVerticalVideo = false
  527. this.showGroupImage = false
  528. this.showSmallImage = false
  529. this.HorizontalLargeImageList = this.HorizontalLargeImageListShu
  530. }
  531. if (type === 'CREATIVE_IMAGE_MODE_LARGE_VERTICAL') {
  532. // this.createLargeImageCreativeCon = false
  533. this.showLargeImage = false
  534. this.showLargeVerticalImage = true
  535. this.showHorizonVideo = false
  536. this.showVerticalVideo = false
  537. this.showGroupImage = false
  538. this.showSmallImage = false
  539. this.HorizontalLargeImageList = this.HorizontalLargeImageListBigShu
  540. }
  541. if (type === 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL') {
  542. // this.createLargeImageCreativeCon = false
  543. this.showLargeImage = false
  544. this.showLargeVerticalImage = false
  545. this.showHorizonVideo = false
  546. this.showVerticalVideo = true
  547. this.showGroupImage = false
  548. this.showSmallImage = false
  549. this.HorizontalLargeImageList = this.HorizontalLargeImageListHeng
  550. }
  551. },
  552. // 创建大图横图创意
  553. addCreative() {
  554. let type = this.materialType
  555. this.getTags()
  556. if (type === 'CREATIVE_IMAGE_MODE_SMALL') {
  557. this.HorizontalLargeImageListSmall.push({
  558. ImageMode: type,
  559. imageUrl: '',
  560. imageId: '',
  561. text: '',
  562. creativeWordIds: [],
  563. vadioUrl: '',
  564. videoId: '',
  565. multiple: [],
  566. countTag: 0,
  567. many: 3,
  568. showElse: true
  569. })
  570. this.HorizontalLargeImageList = this.HorizontalLargeImageListSmall
  571. }
  572. if (type === 'CREATIVE_IMAGE_MODE_LARGE') {
  573. this.HorizontalLargeImageListBig.push({
  574. imageMode: type,
  575. imageUrl: '',
  576. imageId: '',
  577. text: '',
  578. creativeWordIds: [],
  579. vadioUrl: '',
  580. videoId: '',
  581. multiple: [],
  582. countTag: 0,
  583. many: 3,
  584. showElse: true
  585. })
  586. this.HorizontalLargeImageList = this.HorizontalLargeImageListBig
  587. }
  588. if (type === 'CREATIVE_IMAGE_MODE_GROUP') {
  589. this.HorizontalLargeImageListZu.push({
  590. creativeType: this.creativeType,
  591. imageMode: type,
  592. imageUrl: '',
  593. imageId: '',
  594. text: '',
  595. creativeWordIds: [],
  596. vadioUrl: '',
  597. videoId: '',
  598. multiple: [],
  599. countTag: 0,
  600. many: 3,
  601. showElse: true
  602. })
  603. this.HorizontalLargeImageList = this.HorizontalLargeImageListZu
  604. }
  605. if (type === 'CREATIVE_IMAGE_MODE_VIDEO') {
  606. this.HorizontalLargeImageListShu.push({
  607. creativeType: this.creativeType,
  608. imageMode: type,
  609. imageUrl: '',
  610. imageId: '',
  611. text: '',
  612. creativeWordIds: [],
  613. vadioUrl: '',
  614. videoId: '',
  615. multiple: [],
  616. countTag: 0,
  617. many: 3,
  618. showElse: true
  619. })
  620. this.HorizontalLargeImageList = this.HorizontalLargeImageListShu
  621. }
  622. if (type === 'CREATIVE_IMAGE_MODE_LARGE_VERTICAL') {
  623. this.HorizontalLargeImageListBigShu.push({
  624. creativeType: this.creativeType,
  625. imageMode: type,
  626. imageUrl: '',
  627. imageId: '',
  628. text: '',
  629. creativeWordIds: [],
  630. vadioUrl: '',
  631. videoId: '',
  632. multiple: [],
  633. countTag: 0,
  634. many: 3,
  635. showElse: true
  636. })
  637. this.HorizontalLargeImageList = this.HorizontalLargeImageListBigShu
  638. }
  639. if (type === 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL') {
  640. this.HorizontalLargeImageListHeng.push({
  641. creativeType: this.creativeType,
  642. imageMode: type,
  643. imageUrl: '',
  644. imageId: '',
  645. text: '',
  646. creativeWordIds: [],
  647. vadioUrl: '',
  648. videoId: '',
  649. multiple: [],
  650. countTag: 0,
  651. many: 3,
  652. showElse: true
  653. })
  654. this.HorizontalLargeImageList = this.HorizontalLargeImageListHeng
  655. }
  656. },
  657. deleteCreative(index) {
  658. console.log(index)
  659. console.log(this.HorizontalLargeImageList)
  660. this.HorizontalLargeImageList.splice(index, 1)
  661. },
  662. getTags() {
  663. // let accountInfo = localStorage.getItem('accountInfo')
  664. // console.log(groupInfo)
  665. getAction('/bytedance/batch/creative/words/get', {
  666. accountId: '1649600126891015'
  667. }).then(res => {
  668. if (res.code == '0') {
  669. this.tags = res.creative_word
  670. } else {
  671. this.tags = []
  672. }
  673. })
  674. },
  675. addTitle() {
  676. this.titleData.push({
  677. text: '',
  678. titleMany: 0,
  679. creativeWordIds: []
  680. })
  681. },
  682. tetleDetele(index) {
  683. this.titleData.splice(index, 1)
  684. }
  685. },
  686. created: function () {
  687. this.$nextTick(() => {
  688. this.getTags()
  689. })
  690. },
  691. watch: {
  692. creativeType: function (n, o) {
  693. console.log(n, o)
  694. this.HorizontalLargeImageListBig = []
  695. this.HorizontalLargeImageListHeng = []
  696. this.HorizontalLargeImageListShu = []
  697. this.HorizontalLargeImageListZu = []
  698. this.HorizontalLargeImageListSmall = []
  699. this.HorizontalLargeImageListBigShu = []
  700. this.HorizontalLargeImageList = []
  701. },
  702. materialType: function (n, o) {
  703. this.materialTypeChange()
  704. },
  705. visibleVideo(n, o) {
  706. if (!n) {
  707. closeAllVideoFun()
  708. }
  709. },
  710. time(n, o) {
  711. console.log(n)
  712. if (n.length > 0) {
  713. var params = {}
  714. params.accountId = "1649600126891015"
  715. params.pageSize = this.ipagination.pageSize
  716. params.pageNo = 1
  717. params.startDate = moment(n[0]).format('YYYY-MM-DD')
  718. params.endDate = moment(n[1]).format('YYYY-MM-DD')
  719. this.showVideoList('/bytedance/batch/getVideoList', params)
  720. } else {
  721. var params = {}
  722. params.accountId = "1649600126891015"
  723. params.pageSize = this.ipagination.pageSize
  724. params.pageNo = 1
  725. this.ipagination.current = 1
  726. this.showVideoList('/bytedance/batch/getVideoList', params)
  727. }
  728. },
  729. },
  730. computed: {
  731. count: function () {
  732. var bool
  733. if (this.creativeType == 'customCreativity') {
  734. bool =
  735. this.HorizontalLargeImageListBig.length +
  736. this.HorizontalLargeImageListHeng.length +
  737. this.HorizontalLargeImageListShu.length +
  738. this.HorizontalLargeImageListZu.length +
  739. this.HorizontalLargeImageListSmall.length +
  740. this.HorizontalLargeImageListBigShu.length >=
  741. 10 ?
  742. true :
  743. false
  744. } else {
  745. if (
  746. this.materialType == 'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL' ||
  747. this.materialType == 'CREATIVE_IMAGE_MODE_VIDEO'
  748. ) {
  749. bool = this.HorizontalLargeImageListHeng.length + this.HorizontalLargeImageListShu.length >= 12 ? true :
  750. false
  751. } else {
  752. bool =
  753. this.HorizontalLargeImageListBig.length +
  754. this.HorizontalLargeImageListZu.length +
  755. this.HorizontalLargeImageListSmall.length +
  756. this.HorizontalLargeImageListBigShu.length >=
  757. 10 ?
  758. true :
  759. false
  760. }
  761. }
  762. return bool
  763. },
  764. countMany: function () {
  765. var bool =
  766. this.HorizontalLargeImageListBig.length +
  767. this.HorizontalLargeImageListHeng.length +
  768. this.HorizontalLargeImageListShu.length +
  769. this.HorizontalLargeImageListZu.length +
  770. this.HorizontalLargeImageListSmall.length +
  771. this.HorizontalLargeImageListBigShu.length
  772. return bool
  773. },
  774. vadioMany: function () {
  775. var bool = this.HorizontalLargeImageListHeng.length + this.HorizontalLargeImageListShu.length
  776. return bool
  777. },
  778. imgMany: function () {
  779. var bool =
  780. this.HorizontalLargeImageListBig.length +
  781. this.HorizontalLargeImageListZu.length +
  782. this.HorizontalLargeImageListSmall.length +
  783. this.HorizontalLargeImageListBigShu.length
  784. return bool
  785. }
  786. }
  787. }
  788. </script>
  789. <style lang="scss">
  790. .material-creat {
  791. .ant-layout {
  792. background: white;
  793. }
  794. .ant-scroll-number {
  795. z-index: 1000;
  796. }
  797. }
  798. .dynamically_add_form_item {
  799. .ant-form-item-label {
  800. width: auto !important;
  801. }
  802. .ant-form-item-control-wrapper {
  803. width: auto !important;
  804. }
  805. }
  806. </style>
  807. <style lang="scss" scoped>
  808. ul,
  809. li {
  810. margin: 0;
  811. padding: 0;
  812. }
  813. .moduler {
  814. background: #fff;
  815. margin-bottom: 16px;
  816. position: relative;
  817. padding: 32px 24px 48px 32px;
  818. border-radius: 4px;
  819. box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
  820. .moduler-title {
  821. display: flex;
  822. align-items: center;
  823. font-size: 22px;
  824. margin-bottom: 20px;
  825. }
  826. .row-item {
  827. display: flex;
  828. justify-content: flex-start;
  829. align-items: center;
  830. margin-bottom: 32px;
  831. }
  832. .row-item:last-of-type {
  833. margin-bottom: 0;
  834. }
  835. .row-item .hint-item {
  836. width: 24px;
  837. min-width: 24px;
  838. align-self: flex-start;
  839. line-height: 20px;
  840. height: 20px;
  841. margin-top: 5px;
  842. }
  843. .row-item .label-item {
  844. position: relative;
  845. align-items: flex-start;
  846. align-self: flex-start;
  847. line-height: 20px;
  848. height: 20px;
  849. margin-top: 7px;
  850. width: 80px;
  851. min-width: 80px;
  852. .text-item {
  853. font-size: 14px;
  854. width: 60px;
  855. }
  856. }
  857. .row-item .required-item {
  858. width: 4px;
  859. height: 4px;
  860. border-radius: 2px;
  861. background: #f45858;
  862. position: absolute;
  863. right: 10px;
  864. top: 50%;
  865. transform: translateY(-50%);
  866. }
  867. .row-item .input-item {
  868. min-width: 480px;
  869. position: relative;
  870. // height: 35px;
  871. .tip {
  872. font-size: 12px;
  873. color: tomato;
  874. }
  875. .inventory-tags-lists-header {
  876. background-color: #F8F9FA;
  877. border: 1px solid #E4E9ED;
  878. height: 36px;
  879. line-height: 33px;
  880. border-radius: 4px 4px 0 0;
  881. font-weight: bold;
  882. display: flex;
  883. }
  884. .inventory-tags-lists-container {
  885. border: 1px solid #E4E9ED;
  886. margin-top: -1px;
  887. height: 100%;
  888. padding: 4px 0px;
  889. border-radius: 0 0 4px 4px;
  890. }
  891. .inventory-tags-lists-item {
  892. width: 100%;
  893. height: 37px;
  894. line-height: 37px;
  895. padding-left: 12px;
  896. padding-right: 12px;
  897. display: flex;
  898. font-size: 14px;
  899. color: #333;
  900. }
  901. }
  902. }
  903. .opt {
  904. text-align: right;
  905. }
  906. .chouzhen {
  907. border-style: solid;
  908. border-width: 1px;
  909. border-color: #e4e4e4;
  910. width: calc(20% - 10px);
  911. padding: 10px;
  912. margin-right: 10px;
  913. margin-bottom: 10px;
  914. display: flex;
  915. align-items: center;
  916. background: #fff;
  917. position: relative;
  918. z-index: 99;
  919. float: left
  920. }
  921. </style>