123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182 |
- <template>
- <div class="copy-library-content">
- <div class="control-con-header">
- <a-form
- class="grid-form"
- layout="inline"
- :form="form"
- hide-required-mark
- >
- <a-row>
- <a-form-item
- v-if="controlTypeModel === '1'"
- class="grid-form-item"
- label="账户:"
- :colon="false"
- >
- <acount-search
- class="acount-search-class"
- :appId.sync="configForm.acountId"
- :multiple="false"
- request="1,3"
- >
- </acount-search>
- </a-form-item>
- <a-form-model-item v-if="controlTypeModel === '2'" label="项目:">
- <a-select
- class="common-input-long"
- show-search
- v-model="configForm.adConvertId"
- :filter-option="filterOption"
- allowClear
- placeholder="请选择项目"
- >
- <a-select-option
- v-for="(item, index) in optimizationOption"
- :key="index"
- :value="item.projectId"
- >
- {{ item.projectName }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- </a-row>
- <a-row class="grid-form-options">
- <a-form-item
- class="grid-form-item"
- label="关键词:"
- :colon="false"
- >
- <a-input v-model="configForm.num" placeholder="请输入关键词"/>
- </a-form-item>
- <a-form-item
- class="grid-form-item"
- label="选择时间:"
- :colon="false"
- >
- <a-range-picker
- v-model="configForm.launchDateRange"
- format="YYYY-MM-DD"
- :disabled-date="disabledDate"
- @change="handleLaunchData"
- />
- </a-form-item>
- <a-form-item class="form-handle-btn">
- <a-button type="default" class="reset-class" @click="handleResetList">重置</a-button>
- <a-button type="primary" @click="handleQueryList">查询</a-button>
- </a-form-item>
- </a-row>
- </a-form>
- </div>
- <div class="control-con-table">
- <a-button type="primary" class="upload-person" @click="handleAddAccountConfig">新增文案</a-button>
- <a-tabs v-model="controlTypeModel" @change="handleTabsChange">
- <a-tab-pane key="1" tab="通用">
- <a-table
- ref="table"
- size="middle"
- bordered
- :columns="currencyColumns"
- :dataSource="currencyData"
- :pagination="false"
- :scroll="{x: 1500}"
- >
- </a-table>
- <a-pagination
- class="pagin-table-class"
- v-model="currencyPag.page"
- :page-size="currencyPag.size"
- :total="currencyTotalAll"
- :show-total="total => `共 ${currencyTotalAll} 条`"
- size="small"
- show-size-changer
- show-quick-jumper
- @change="handleCurrentPage"
- @showSizeChange="handleCurrentPage"
- />
- </a-tab-pane>
- <a-tab-pane key="2" tab="指定">
- <a-table
- ref="table"
- size="middle"
- bordered
- :columns="appointColumns"
- :dataSource="appointData"
- :pagination="false"
- :scroll="{x: 1500}"
- >
- </a-table>
- <a-pagination
- class="pagin-table-class"
- v-model="appointPag.page"
- :page-size="appointPag.size"
- :total="appointTotalAll"
- :show-total="total => `共 ${appointTotalAll} 条`"
- size="small"
- show-size-changer
- show-quick-jumper
- @change="handleAppointPage"
- @showSizeChange="handleAppointPage"
- />
- </a-tab-pane>
- </a-tabs>
- </div>
- <a-modal
- v-if="causeVisible"
- title="新建文案"
- dialog-class="copywrit-modal"
- :visible="causeVisible"
- @ok="handleCauseSure"
- @cancel="handleCauseCancel"
- >
- <div>
- <div class="acount-title">
- <div class="acount-title-left">文案类型</div>
- <div class="acount-title-right">
- <div class="only-title-mater">
- <a-radio-group v-model="copywrittypeName" button-style="solid" @change="handleFormLayoutChange">
- <a-radio-button value="horizontal">通用</a-radio-button>
- <a-radio-button value="vertical">指定素材</a-radio-button>
- </a-radio-group>
- </div>
- </div>
- </div>
- <div v-if="copywrittypeName === 'horizontal'" class="acount-title">
- <div class="acount-title-left">广告账户</div>
- <div class="acount-title-right">
- <div class="only-title-mater">
- <acount-search :appId.sync="advertisingAccount" request="1,3"></acount-search>
- </div>
- </div>
- </div>
- <div v-if="copywrittypeName === 'horizontal'" class="acount-title">
- <div class="acount-title-left">文件上传</div>
- <div class="acount-title-right">
- <div class="only-title-mater">
- <a-upload
- name="file"
- action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
- :file-list="fileList"
- @change="handleChange"
- >
- <a-button><a-icon type="upload"/>文件上传</a-button>
- </a-upload>
- </div>
- </div>
- </div>
- <div v-if="copywrittypeName === 'vertical'" class="acount-title">
- <div class="acount-title-left">选择素材</div>
- <div class="acount-title-right">
- <div class="only-title-mater">
- <div><a @click="handleSelectMaterial">选择素材</a></div>
- <div class="title-mater-list">
- <p
- class="mater-list-name"
- v-for="item in modalSelectMaterial"
- :key="item.id"
- >
- <span class="mater-list-show">{{ item.materialName }}</span>
- <span class="mater-list-icon" @click="handleDelAlone(item)"><a-icon type="close"/></span>
- </p>
- </div>
- </div>
- </div>
- </div>
- <div v-if="copywrittypeName === 'vertical'" class="acount-title push-plate">
- <div class="acount-title-left">创意标题</div>
- <div class="acount-title-right">
- <a-button type="primary" @click="handleAddOrigin"><a-icon type="plus" />创意标题</a-button>
- <span style="margin-left: 20px;">已填:{{ titleFiledResult.length || 0 }}</span>
- </div>
- </div>
- <div v-if="copywrittypeName === 'vertical'" class="acount-title">
- <div class="acount-title-left"></div>
- <div class="acount-title-right">
- <a-form :form="examinForm">
- <a-form-item
- v-for="item in defaultFormList"
- :key="item.id"
- class="examin-form-model"
- :label-col="labelCol"
- :wrapper-col="wrapperCol"
- label=""
- >
- <a-input
- v-decorator="[
- item.name,
- {rules: [
- {validator: validatePass, trigger: 'blur'}
- ]}
- ]"
- class="examin-form-input"
- :id="item.name"
- placeholder="请输入"
- @change="handleFormInputChang($event, item.name, item.id)"
- />
- <span class="examin-form-num">{{ item.lenSize }}/30</span>
- <a-icon class="examin-form-icon" type="delete" @click="handleDelOrigin(item)"/>
- <div class="ad-name-tags-class">
- <div v-if="item.tabStatus === 'alone'" class="name-tags-left">
- <a-tag
- v-for="val in item.updateTagsList"
- :key="val.id"
- color="#1890ff"
- @click="handleGetChangeAll(val.name, item.name, item.id)"
- >
- + {{ val.name }}
- </a-tag>
- </div>
- <div v-if="item.tabStatus === 'all'" class="name-tags-left">
- <a-tag
- v-for="val in item.defaultTagsList"
- :key="val.id"
- color="#1890ff"
- @click="handleGetChangeAll(val.name, item.name, item.id)"
- >
- + {{ val.name }}
- </a-tag>
- </div>
- <div v-if="item.tabStatus === 'alone'">
- <a @click="handleMoreTagsShow(item.id, 'more')">更多</a>
- </div>
- <div v-if="item.tabStatus === 'all'">
- <a @click="handleMoreTagsShow(item.id, 'little')">收起</a>
- </div>
- </div>
- </a-form-item>
- </a-form>
- </div>
- </div>
- </div>
- </a-modal>
- <a-modal
- v-if="visibleMatemal"
- title="选择素材"
- :visible="visibleMatemal"
- dialog-class="select-matermal-modal"
- @ok="handleOkShow"
- @cancel="handleCancelAll"
- >
- <div class="mater-viedo-content">
- <div class="viedo-header-class">
- <div></div>
- <div>
- 当前选择数量 {{ viedoCheckValue.length }}/{{ materTotalAll }}
- <a-button type="primary" class="refush-btn-mat" @click="handleRefreshMaster">刷新素材</a-button>
- </div>
- </div>
- <a-row class="viedo-serach-class" :gutter="24">
- <a-col :span="9">
- <a-form-item label="项目" :labelCol="labelCol" :wrapperCol="wrapperCol">
- <a-select
- class="common-input-long"
- show-search
- v-model="projectModelValue"
- placeholder="请选择"
- :filter-option="filterOption"
- allowClear
- >
- <a-select-option
- v-for="(item, index) in optimizationOption"
- :key="index"
- :value="item.projectId"
- >
- {{ item.projectName }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :span="9">
- <a-form-item label="日期选择" :labelCol="modalCol" :wrapperCol="modalWrapper">
- <a-range-picker
- v-model="masterTimes"
- format="YYYY-MM-DD"
- @change="handleSelectTimeChange"
- />
- </a-form-item>
- </a-col>
- <a-col :span="4">
- <a-button style="position: relative;top: 4px;" @click="handleAllChecked">全选</a-button>
- <a-button type="primary" style="position: relative;top: 4px;margin-left:5px" @click="handleSearchMaster">搜索</a-button>
- </a-col>
- </a-row>
- <div class="viedo-content-class">
- <a-checkbox-group class="viedo-content-group" v-model="viedoCheckValue">
- <li class="content-modal-li" v-for="(item, index) in viedoDefaultList" :key="index">
- <a-checkbox
- class="viedo-content-checkbox"
- :value="item.id"
- >
- </a-checkbox>
- <img :src="item.coverUrl"/>
- <div class="checkbox-select-time">时间:{{ item.createTime }}</div>
- </li>
- </a-checkbox-group>
- <a-pagination
- class="pagin-table-class"
- v-model="masterPag.page"
- :page-size="masterPag.size"
- :total="materTotalAll"
- :show-total="total => `共 ${materTotalAll} 条`"
- size="small"
- show-size-changer
- show-quick-jumper
- @change="handleMasterPageChange"
- @showSizeChange="handleMasterPageChange"
- />
- </div>
- </div>
- </a-modal>
- </div>
- </template>
- <script>
- import AcountSearch from '@/views/modules/Statistics/components/Treeselect.vue';
- import moment from 'moment';
- import {getAction, postFileAction, postAction} from '@/api/manage';
- import {mapGetters} from 'vuex';
- import {urlAcount} from './copy-library-server.js';
- export default {
- name: 'copy-library',
- components: {
- AcountSearch
- },
- data() {
- return {
- moment,
- projectModelValue: '',
- optimizationOption: [], // 账户option
- controlTypeModel: '1',
- fileList: [],
- modalSelectMaterial: [],
- materTotalAll: 0,
- viedoCheckValue: [],
- viedoDefaultList: [
- {
- name: '北京市',
- id: 1,
- statDate: '2019-08-08'
- },
- {
- name: '上海市',
- id: 2,
- statDate: '2019-08-08'
- },
- {
- name: '天津市',
- id: 3,
- statDate: '2019-08-08'
- },
- {
- name: '武汉市',
- id: 4,
- statDate: '2019-08-08'
- },
- {
- name: '贵州市',
- id: 5,
- statDate: '2019-08-08'
- },
- {
- name: '太原市',
- id: 6,
- statDate: '2019-08-08'
- },
- {
- name: '大同市',
- id: 7,
- statDate: '2019-08-08'
- }
- ],
- visibleMatemal: false,
- advertisingAccount: [],
- copywrittypeName: 'horizontal',
- adNameTags: [],
- causeVisible: false,
- labelCol: {span: 4},
- wrapperCol: {span: 14},
- modalCol: {
- lg: {span: 6},
- sm: {span: 6},
- xs: {span: 6},
- md: {span: 6}
- },
- modalWrapper: {
- lg: {span: 18},
- sm: {span: 18},
- xs: {span: 14},
- md: {span: 14}
- },
- configForm: {
- acountId: '',
- num: '',
- adConvertId: undefined,
- launchDateRange: []
- },
- currencyPag: {
- page: 1,
- size: 10
- },
- currencyData: [],
- currencyTotalAll: 0,
- currencyColumns: [
- {
- title: '文案',
- align: 'center',
- width: 200,
- dataIndex: 'textCopywriter'
- },
- {
- title: '相关创意',
- align: 'center',
- width: 150,
- dataIndex: 'count'
- },
- {
- title: '花费(元)',
- align: 'center',
- width: 150,
- dataIndex: 'cost',
- sorter: (a, b) => a.cost - b.cost
- },
- {
- title: '展示数',
- dataIndex: 'showNum',
- width: 150,
- align: 'center',
- sorter: (a, b) => a.showNum - b.showNum
- },
- {
- title: '平均千次展现费用',
- dataIndex: 'costPerThousandShow',
- align: 'center',
- width: 200,
- sorter: (a, b) => a.costPerThousandShow - b.costPerThousandShow
- },
- {
- title: '点击数',
- dataIndex: 'click',
- width: 150,
- align: 'center',
- sorter: (a, b) => a.click - b.click
- },
- {
- title: '平均点击单价',
- dataIndex: 'costPerClick',
- width: 150,
- align: 'center',
- sorter: (a, b) => a.costPerClick - b.costPerClick
- },
- {
- title: '点击率',
- dataIndex: 'clickRate',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.clickRate - b.clickRate
- },
- {
- title: '转化数',
- dataIndex: 'convertNum',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.convertNum - b.convertNum
- },
- {
- title: '转化率',
- dataIndex: 'convertRate',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.convertRate - b.convertRate
- },
- {
- title: '转化成本',
- dataIndex: 'costConvert',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.costConvert - b.costConvert
- }
- ],
- appointColumns: [
- {
- title: '文案',
- align: 'center',
- width: 200,
- dataIndex: 'slogan'
- },
- {
- title: '相关创意',
- align: 'center',
- width: 150,
- dataIndex: 'count'
- },
- {
- title: '花费(元)',
- align: 'center',
- width: 150,
- dataIndex: 'cost',
- sorter: (a, b) => a.cost - b.cost
- },
- {
- title: '展示数',
- dataIndex: 'showNum',
- width: 150,
- align: 'center',
- sorter: (a, b) => a.showNum - b.showNum
- },
- {
- title: '平均千次展现费用',
- dataIndex: 'costPerThousandShow',
- align: 'center',
- width: 200,
- sorter: (a, b) => a.costPerThousandShow - b.costPerThousandShow
- },
- {
- title: '点击数',
- dataIndex: 'click',
- width: 150,
- align: 'center',
- sorter: (a, b) => a.click - b.click
- },
- {
- title: '平均点击单价',
- dataIndex: 'costPerClick',
- width: 150,
- align: 'center',
- sorter: (a, b) => a.costPerClick - b.costPerClick
- },
- {
- title: '点击率',
- dataIndex: 'clickRate',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.clickRate - b.clickRate
- },
- {
- title: '转化数',
- dataIndex: 'convertNum',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.convertNum - b.convertNum
- },
- {
- title: '转化率',
- dataIndex: 'convertRate',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.convertRate - b.convertRate
- },
- {
- title: '转化成本',
- dataIndex: 'costConvert',
- align: 'center',
- width: 150,
- sorter: (a, b) => a.costConvert - b.costConvert
- }
- ],
- appointData: [],
- appointTotalAll: 0,
- appointPag: {
- page: 1,
- size: 10
- },
- masterPag: {
- page: 1,
- size: 10
- },
- defaultFormList: [],
- titleFiledResult: 0,
- examinForm: this.$form.createForm(this),
- changeShowmasterData: [],
- masterTimes: [] // 选择素材的时间选择
- };
- },
- watch: {
- defaultFormList: {
- deep: true,
- handler(n, o) {
- const result = [];
- this.defaultFormList = n;
- this.$nextTick(() => {
- this.defaultFormList.forEach(item => {
- if (item.value) {
- result.push(item.value);
- }
- this.examinForm.setFieldsValue({[item.name]: item.value});
- });
- this.titleFiledResult = result;
- });
- }
- }
- },
- created() {
- this.form = this.$form.createForm(this);
- },
- mounted() {
- this.handleGetCurrencyList();
- this.handleGetProjectList();
- this.handleGetCreativeWord();
- },
- methods: {
- ...mapGetters(['nickname', 'avatar', 'userInfo']),
- disabledDate(current) {
- return current > moment().subtract(1, 'day');
- },
- handleRefreshMaster() {
- this.projectModelValue = '';
- this.masterTimes = [];
- this.viedoCheckValue = [];
- this.hendleMaterialInfo();
- },
- handleAllChecked() {
- this.viedoCheckValue = this.viedoDefaultList.map(item => item.id);
- },
- filterOption(input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- );
- },
- handleGetProjectList() {
- getAction('/ctop/projectMember/bytedanceProjectParticipateInList').then(result => {
- if (result.code === 0) {
- this.optimizationOption = result.result;
- }
- else {
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- },
- hendleMaterialInfo() {
- const paramsData = {
- projectId: this.projectModelValue,
- startDate: this.masterTimes[0],
- endDate: this.masterTimes[1],
- offlineFlag: 0,
- pageNo: this.masterPag.page,
- pageSize: this.masterPag.size
- };
- getAction('/ctop/materialInfo/listV2', paramsData).then(result => {
- if (result.code === 0) {
- this.viedoDefaultList = result.data.list;
- this.materTotalAll = result.data.total;
- }
- else {
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- },
- handleTabsChange(e) {
- const page = {
- page: 1,
- size: 10
- };
- this.currencyPag = page;
- this.appointPag = page;
- this.configForm = {
- acountId: '',
- num: '',
- adConvertId: undefined,
- launchDateRange: []
- };
- if (e === '1') {
- this.handleGetCurrencyList();
- }
- else if (e === '2') {
- this.handleGetAppointList();
- }
- },
- handleGetCurrencyList() {
- let paramsData = {
- accountId: this.configForm.acountId,
- keyWord: this.configForm.num,
- userId: this.userInfo().id,
- startTime: this.configForm.launchDateRange[0],
- endTime: this.configForm.launchDateRange[0],
- pageNo: this.currencyPag.page,
- pageSize: this.currencyPag.size
- };
- getAction(urlAcount + '/bytedance-api/advertiser/bytedanceGeneralCopywriter/queryPageListByText', paramsData).then(result => {
- if (result.code === 0) {
- this.currencyData = result.result.list;
- this.currencyTotalAll = result.result.total;
- }
- else {
- this.currencyData = [];
- this.currencyTotalAll = 0;
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- },
- handleGetAppointList() {
- let paramsData = {
- projectId: this.configForm.adConvertId,
- userId: this.userInfo().id,
- keyWord: this.configForm.num,
- startTime: this.configForm.launchDateRange[0],
- endTime: this.configForm.launchDateRange[0],
- pageNo: this.appointPag.page,
- pageSize: this.appointPag.size
- };
- getAction(urlAcount + '/bytedance-api/ctop/bytedanceVideoSlogenInfo/queryPageListByText', paramsData).then(result => {
- if (result.code === 0) {
- this.appointData = result.result.list;
- this.appointTotalAll = result.result.total;
- }
- else {
- this.appointData = [];
- this.appointTotalAll = [];
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- },
- handleChange(info) {
- const isZip = info.file.name.indexOf('xlsx') !== -1 || info.file.name.indexOf('xls') !== -1;
- if (!isZip) {
- this.$message.error('上传模板只能是 xls、xlsx格式!');
- return;
- }
- this.fileList = info.fileList;
- },
- handleSearchMaster() {
- this.hendleMaterialInfo();
- },
- handleSelectTimeChange(date, dateString) {
- this.masterTimes = dateString;
- },
- handleDelAlone(data) {
- this.modalSelectMaterial = this.modalSelectMaterial.filter(item => item.id !== data.id);
- },
- handleMasterPageChange(current, pageSize) {
- this.masterPag = {
- page: current = pageSize !== this.masterPag.size ? 1 : current,
- size: pageSize
- };
- this.hendleMaterialInfo();
- },
- handleSelectMaterial() {
- this.masterPag = {
- page: 1,
- size: 10
- };
- this.handleRefreshMaster();
- this.visibleMatemal = true;
- },
- // 选择素材的取消按钮
- handleCancelAll() {
- this.projectModelValue = '';
- this.masterTimes = [];
- this.viedoCheckValue = [];
- this.visibleMatemal = false;
- },
- // 选择素材的确认按钮
- handleOkShow() {
- const defaultList = this.viedoDefaultList;
- const defaultCheckValue = this.viedoCheckValue;
- let changeSelectMaterData = defaultList.filter(item => {
- if (defaultCheckValue.includes(item.id)) {
- return item;
- }
- });
- if (this.modalSelectMaterial.length) {
- this.changeShowmasterData = [...this.modalSelectMaterial];
- this.changeShowmasterData = this.changeShowmasterData.concat(changeSelectMaterData);
- let temp = {}; // 用于id判断
- let result = []; // 最后的新数组
- this.changeShowmasterData.map(item => {
- if (!temp[item.id]) {
- result.push(item);
- temp[item.id] = true;
- }
- });
- if (result.length > 10) {
- this.$message.error('最多上传10个素材');
- return;
- }
- this.modalSelectMaterial = [...result];
- }
- else {
- if (changeSelectMaterData.length > 10) {
- this.$message.error('最多上传10个素材');
- return;
- }
- this.modalSelectMaterial = [...changeSelectMaterData];
- }
- this.handleCancelAll();
- },
- handleFormLayoutChange(e) {
- const defaultValue = e.target.value;
- this.copywrittypeName = defaultValue;
- if (defaultValue === 'horizontal') {
- this.modalSelectMaterial = [];
- this.defaultFormList = [];
- }
- else if (defaultValue === 'vertical') {
- this.advertisingAccount = [];
- this.fileList = [];
- const defaultList = this.adNameTags;
- for (let i = 0; i < 3; i++) {
- const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
- this.defaultFormList.push({
- id: randomNum,
- name: 'username' + randomNum,
- value: '',
- lenSize: 0,
- tabStatus: 'alone',
- defaultTagsList: defaultList,
- updateTagsList: defaultList.slice(0, 4)
- });
- }
- }
- },
- handleExportRules(value) {
- let cnReg = /([\u4e00-\u9fa5]|[\u3000-\u303F]|[\uFF00-\uFF60])/;
- let length = 0;
- let strArr = value.split('');
- strArr.forEach(item => {
- if (cnReg.test(item)) {
- length += 1;
- }
- else {
- length += 0.5;
- }
- });
- return Math.ceil(length);
- },
- handleFormInputChang(e, field, formId) {
- const changeFiled = [];
- this.defaultFormList.forEach(item => {
- if (item.id === formId) {
- item.value = e.target.value;
- }
- });
- this.defaultFormList.forEach(item => {
- if (item.value) {
- changeFiled.push(item.value);
- }
- });
- this.$nextTick(() => {
- const dynamicWordPackIds = [];
- let finallyLenList = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
- let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
- const inputDefaultLen = this.handleExportRules(this.defaultFormList.filter(item => item.id === formId)[0].value);
- let tagsLen = updateFinallyResult.length * 2;
- let tagsSureLen = 0;
- let resultSelectSize = 0;
- this.adNameTags.forEach(item => {
- updateFinallyResult.forEach(val => {
- if (item.name === val) {
- tagsSureLen += item.maxWordLen;
- dynamicWordPackIds.push(item.creativeWordId);
- }
- });
- });
- updateFinallyResult.forEach(item => {
- tagsLen += item.length;
- });
- resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen + updateFinallyResult.length;
- this.defaultFormList.forEach(item => {
- if (item.id === formId) {
- item.lenSize = resultSelectSize;
- item.wordPackId = dynamicWordPackIds;
- }
- });
- this.titleFiledResult = changeFiled;
- });
- },
- handleJudgeExec(item) {
- let re = /\{(.+?)\}/g;
- let array = [];
- let temp;
- while ((temp = re.exec(item))) {
- array.push(temp[1]);
- };
- return array;
- },
- // 点击获取光标位置进行字段插入
- handleGetChangeAll(item, field, formId) {
- let node = document.getElementById(field);
- let startPos = node.selectionStart; // input 第0个字符到选中的字符
- let endPos = node.selectionEnd; // 选中的字符到最后的字符
- let txt = node.value;
- this.$nextTick(() => {
- let finallyLenList = this.handleJudgeExec(txt);
- let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
- if (updateFinallyResult.length >= 2) {
- this.$message.error('最多选择两个词包');
- return;
- }
- if (startPos === 0 || endPos === 0) {
- txt += '{' + item + '}';
- this.examinForm.setFieldsValue({[field]: txt});
- }
- else {
- this.examinForm.setFieldsValue({[field]: txt.substring(0, startPos) + '{' + item + '}' + txt.substring(endPos)});
- node.selectionStart = startPos + item.length + 6;
- node.selectionEnd = startPos + item.length + 6;
- }
- node.focus();
- node.blur();
- });
- this.$nextTick(() => {
- const dynamicWordPackIds = [];
- let changeData = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
- let updateChangeData = this.adNameTags.filter(item => changeData.includes(item.name)).map(val => val.name);
- const inputDefaultLen = this.handleExportRules(this.examinForm.getFieldsValue()[field]);
- let tagsLen = updateChangeData.length * 2;
- let tagsSureLen = 0;
- let resultSelectSize = 0;
- this.adNameTags.forEach(item => {
- updateChangeData.forEach(val => {
- if (item.name === val) {
- tagsSureLen += item.maxWordLen;
- dynamicWordPackIds.push(item.creativeWordId);
- }
- });
- });
- updateChangeData.forEach(item => {
- tagsLen += item.length;
- });
- resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen + updateChangeData.length;
- this.defaultFormList.forEach(item => {
- if (item.id === formId) {
- item.lenSize = resultSelectSize;
- item.value = this.examinForm.getFieldsValue()[field];
- item.wordPackId = dynamicWordPackIds;
- }
- });
- });
- },
- validatePass(rule, value, callback) {
- this.$nextTick(() => {
- let finallyLenList = this.handleJudgeExec(value);
- let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
- let resultSelectSize = 0;
- if (updateFinallyResult.length) {
- const inputDefaultLen = this.handleExportRules(value);
- let tagsLen = updateFinallyResult.length * 2;
- let tagsSureLen = 0;
- this.adNameTags.forEach(item => {
- updateFinallyResult.forEach(val => {
- if (item.name === val) {
- tagsSureLen += item.maxWordLen;
- }
- });
- });
- updateFinallyResult.forEach(item => {
- tagsLen += item.length;
- });
- resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen + updateFinallyResult.length;
- }
- else {
- resultSelectSize = this.handleExportRules(value);
- }
- if (resultSelectSize === 0) {
- callback(new Error('请输入'));
- }
- else if (resultSelectSize > 30 || resultSelectSize < 5) {
- callback(new Error('创意标题5-30个字'));
- }
- else if (updateFinallyResult.length > 2) {
- callback(new Error('最多选择两个词包'));
- }
- else {
- callback();
- }
- });
- },
- handleMoreTagsShow(val, type) {
- if (type === 'more') {
- this.defaultFormList.forEach(item => {
- if (item.id === val) {
- item.tabStatus = 'all';
- }
- });
- }
- else if (type === 'little') {
- this.defaultFormList.forEach(item => {
- if (item.id === val) {
- item.tabStatus = 'alone';
- }
- });
- }
- },
- handleUploadWxecl() {
- if (!this.advertisingAccount.length) {
- this.$message.error('请选择账户');
- return;
- }
- if (!this.fileList.length) {
- this.$message.error('请上传文件');
- return;
- }
- let paramsData = new FormData();
- paramsData.append('accountId', this.advertisingAccount);
- paramsData.append('excelFile', this.fileList[0].originFileObj);
- postFileAction(urlAcount + '/bytedance-api/advertiser/bytedanceGeneralCopywriter/loadExcel', paramsData, {
- headers: {
- 'Content-Type': 'multipart/form-data'
- }
- }).then(result => {
- if (result.code === 0) {
- this.$message.success(result.message);
- this.controlTypeModel = '1';
- this.handleCauseCancel();
- this.handleGetCurrencyList();
- }
- else {
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- },
- handleVerticalAdd() {
- if (!this.modalSelectMaterial.length) {
- this.$message.error('请选择素材');
- return;
- }
- if (this.defaultFormList && this.defaultFormList.length < 3) {
- this.$message.error('请至少输入3条标题');
- return;
- }
- let changeSlogan = this.defaultFormList;
- changeSlogan.forEach(item => {
- item.title = item.value;
- item.creative_word_ids = item.wordPackId;
- });
- let paramsData = {
- materialIds: this.modalSelectMaterial.map(item => item.id),
- userId: this.userInfo().id,
- slogans: changeSlogan
- };
- this.examinForm.validateFields(err => {
- if (!err) {
- postAction(urlAcount + '/bytedance-api/ctop/bytedanceVideoSlogenInfo/addList', paramsData).then(result => {
- if (result.code === 0) {
- this.$message.success(result.message);
- this.controlTypeModel = '1';
- this.modalSelectMaterial = [];
- this.handleCauseCancel();
- this.handleGetCurrencyList();
- }
- else {
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- }
- });
- },
- handleCauseSure() {
- if (this.copywrittypeName === 'horizontal') {
- this.handleUploadWxecl();
- }
- else if (this.copywrittypeName === 'vertical') {
- this.handleVerticalAdd();
- }
- },
- handleCauseCancel() {
- this.copywrittypeName = 'horizontal';
- this.advertisingAccount = [];
- this.fileList = [];
- this.causeVisible = false;
- this.defaultFormList = [];
- this.modalSelectMaterial = [];
- },
- handleGetCreativeWord() {
- getAction('/ctop/ByteDanceCreativeWordPackage/list').then(result => {
- if (result.code === 0) {
- this.adNameTags = result.result.records;
- }
- else {
- this.$message.error(result.message);
- }
- }).catch(error => {
- console.log(error, 'eeee');
- });
- },
- handleAddOrigin() {
- const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
- this.defaultFormList.push({
- id: randomNum,
- name: 'username' + randomNum,
- value: '',
- lenSize: 0,
- tabStatus: 'alone',
- defaultTagsList: this.adNameTags,
- updateTagsList: this.adNameTags.slice(0, 4)
- });
- },
- handleDelOrigin(list) {
- let formData = this.defaultFormList;
- this.defaultFormList = formData.filter(item => list.id !== item.id);
- },
- handleAddAccountConfig() {
- this.causeVisible = true;
- },
- handleLaunchData(date, dateString) {
- this.configForm.launchDateRange = dateString;
- },
- handleQueryList() {
- const page = {
- page: 1,
- size: 10
- };
- this.currencyPag = page;
- this.appointPag = page;
- if (this.controlTypeModel === '1') {
- this.handleGetCurrencyList();
- }
- else if (this.controlTypeModel === '2') {
- this.handleGetAppointList();
- }
- },
- handleResetList() {
- this.configForm = {
- acountId: '',
- num: '',
- adConvertId: undefined,
- launchDateRange: []
- };
- const page = {
- page: 1,
- size: 10
- };
- this.currencyPag = page;
- this.appointPag = page;
- if (this.controlTypeModel === '1') {
- this.handleGetCurrencyList();
- }
- else if (this.controlTypeModel === '2') {
- this.handleGetAppointList();
- }
- },
- handleCurrentPage(current, pageSize) {
- this.currencyPag = {
- page: current = pageSize !== this.currencyPag.size ? 1 : current,
- size: pageSize
- };
- this.handleGetCurrencyList();
- },
- handleAppointPage(current, pageSize) {
- this.appointPag = {
- page: current = pageSize !== this.appointPag.size ? 1 : current,
- size: pageSize
- };
- this.handleGetAppointList();
- }
- }
- };
- </script>
- <style lang="less" scoped>
- @import "copy-library";
- </style>
|