123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- <template>
- <div class="newPlan">
- <a-form :form="form">
- <!-- 投放范围 -->
- <div class="moduler">
- <div class="moduler-title">请选择策略创建场景</div>
- <div class="ad-range">
- <div class="row-item">
- <div class="hint-item"></div>
- <div class="label-item">
- <div class="text-item">创建场景</div>
- <div class="required-item"></div>
- </div>
- <div class="input-item">
- <a-form-item>
- <a-radio-group v-decorator="['scenes', { initialValue:'2' }]">
- <a-radio-button value="1">素材+出价</a-radio-button>
- <a-radio-button value="2">素材+定向</a-radio-button>
- <a-radio-button value="3">时间+出价</a-radio-button>
- </a-radio-group>
- </a-form-item>
- </div>
- </div>
- </div>
- </div>
- <div class="moduler">
- <div class="moduler-title">选择账户</div>
- <div>
- <div class="row-item">
- <div class="hint-item"></div>
- <div class="label-item">
- <div class="text-item">账户</div>
- <div class="required-item"></div>
- </div>
- <div class="input-item">
- <a-tree-select
- v-model="accountId"
- show-search
- style="width: 600px;height:30px"
- :dropdownMatchSelectWidth='true'
- :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
- tree-checkable
- searchPlaceholder='请输入账户关键字搜索'
- :show-checked-strategy="SHOW_PARENT"
- placeholder="请选择项目和账户或搜索账户关键字"
- treeNodeFilterProp="title"
- :allowClear="true"
- @change="treeChange"
- @search="treeSearch"
- @select="treeSelect"
- :maxTagCount='1'
- :tree-data="treeData"
- :filterOption='filterOption'
- >
-
- </a-tree-select>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 推广目的 -->
- <div class="moduler">
- <div class="moduler-title">请选择营销目标</div>
-
- <div class="row-item">
- <div class="hint-item">
- </div>
- <div class="label-item">
- <div class="text-item"></div>
- <div class="required-item"></div>
- </div>
- <div class="input-item">
- <a-form-item >
- <a-radio-group v-decorator="['marketingGoal',{initialValue:'1' }]" @change="marketingGoalChange">
- <a-radio-button value="1">提升应用安装</a-radio-button>
- <a-radio-button value="2">获取电商下单</a-radio-button>
- <a-radio-button value="3">推广品牌活动</a-radio-button>
- <a-radio-button value="4">收集销售线索</a-radio-button>
- <a-radio-button value="5">提高应用活跃</a-radio-button>
- </a-radio-group>
- </a-form-item>
- </div>
- </div>
-
- </div>
-
- <!-- 基础信息 -->
- <div class="moduler">
- <div class="moduler-title">请设置基本信息</div>
-
- <div class="row-item">
- <div class="hint-item"> </div>
- <div class="label-item">
- <div class="text-item">策略名称</div>
- <div class="required-item"></div>
- </div>
- <div class="input-item">
- <a-form-item>
- <a-input v-model="strategyName" allow-clear />
- </a-form-item>
- </div>
- </div>
-
- </div>
-
- <div class="moduler">
- <div class="opt">
- <a-button type="default" style="margin-right:15px" @click="goBack">取消</a-button>
-
- <a-button type="primary" @click="goNext" :loading="goNextloading">下一步</a-button>
- </div>
- </div>
- </a-form>
- <div class="infoModal">
- <a-modal v-model="visible" title="提示" @ok="handleOk" :keyboard='false' :maskClosable='false'>
- <ul>
- <li v-for="(item,index) in errorInfo" :key="index">
- <span>账户{{LHKaccountInfo[index].title}}:</span>{{item.message || '投放项目创建成功'}}
- </li>
- </ul>
- <template slot="footer">
- <a-button key="back" @click="handleCancel">
- 返回本页
- </a-button>
- <a-button key="submit" type="primary" @click="handleOk">
- 下一步
- </a-button>
- </template>
- </a-modal>
- </div>
- </div>
- </template>
- <script>
- import moment from 'moment'
- import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
- import { TreeSelect } from 'ant-design-vue';
- import qs from 'qs'
- const SHOW_PARENT = TreeSelect.SHOW_PARENT;
- // import selectCheckAll from './toutiaoTime'
- var str = ""
- for (let i = 0; i < 7*48; i++) {
- str+='0'
-
- }
- export default {
- components: {
- // selectCheckAll,
- // newDirectedPackage,
- },
- data() {
- return {
- LHKaccountInfo:{},
- treeValue: [],
- treeData: [],
- SHOW_PARENT,
- accountId:[],
- strategyName: '',
- form: this.$form.createForm(this),
- goNextloading:false,
- goPlanShowloading:false,
-
-
- dateRange: [moment(), moment()],
- visible:false,
- errorInfo:[],
-
- validationRules: {
- url: [
- {
- required: true,
- validator: this.validateURL,
- },
- ],
- strategyName:[{
- required: true,
- validator: this.validateName,
- }],
- bid:[{
- required: true,
- message:'出价信息必须填写',
- // validator: this.validateBid,
- }],
- roi:[{
- required: true,
- message:'ROI系数必须填写',
- // validator: this.validateBid,
- }],
- },
-
- }
- },
- watch: {
-
- },
- methods: {
- // //项目改变后的事件
- treeChange(val) {
- // console.log(this.treeData)
- console.log(val)
- this.accountId = [];
- //选择一个后禁用其他
- if(val.length==1){
- if(val[0]*1){
- let selectindex=0
- this.treeData.forEach((ele,index)=>{
- if(ele.children){
- ele.children.map((item,ind)=>{
- if(item.value==val[0]){
- selectindex=index;
- }
- })
- }
- });
- // console.log(selectindex)
- if(selectindex ||selectindex==0){
- this.treeData.forEach((ele,index)=>{
- if(index!=selectindex){
- ele.disableCheckbox = true;
- if(ele.children){
- ele.children.map((item,ind)=>{
- item.disableCheckbox = true;
- })
- }
- }
- })
- }
-
- }else{
- // console.log(1)
- this.treeData.forEach((ele,index)=>{
- if(ele.value!=val[0]){
- ele.disableCheckbox = true;
-
- if(ele.children){
- ele.children.forEach((item,ind)=>{
- item.disableCheckbox = true;
- })
- }
- }
-
- })
- }
- // console.log(this.mediaId)
-
- }
- if(val.length==0){
- this.treeData.forEach((ele,index)=>{
- ele.disableCheckbox = false;
-
- if(ele.children){
- ele.children.forEach((item,ind)=>{
- item.disableCheckbox = false;
- })
- }
-
- });
-
- }
- if(val){
- val.forEach((ele,index)=>{
- if(ele*1){
- this.accountId.push(ele)
- }else{
- let projectArr=this.treeData.filter((item)=>{
- return item.value==ele
- });
- // console.log(projectArr)
- projectArr[0].children.forEach((element)=>{
- this.accountId.push(element.value)
- })
- }
- })
- }
-
- console.log(this.accountId);
- let LHKaccountInfo=[]
- this.accountId.forEach(item=>{
- this.treeData.forEach(element=>{
- element.children.forEach(ele=>{
- if(item==ele.value){
- LHKaccountInfo.push(ele)
- }
- })
- })
- })
- sessionStorage.setItem('LHKaccountInfo',JSON.stringify(LHKaccountInfo))
- },
- treeSearch(){
- },
- treeSelect(){
- },
-
- filterOption(input, option){
- console.log(input, option)
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- );
- },
-
- //请求项目和账户内容
- accountHttp(){
- this.treeData=[];
- this.accountId=[];
- getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=1', {}).then(res => {
- if(res.success){
- // console.log(res);
- if(res.result){
- res.result.forEach((element,index) => {
- if(element){
- this.treeData.push({});
- this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
- this.treeData[index].value='project'+element.project.projectId;
- this.treeData[index].key=element.project.projectId;
- this.treeData[index].mediaId=element.project.mediaId;
- this.treeData[index].children=[];
-
- if(element.account.length){
- element.account.forEach((ele,i)=>{
- this.treeData[index].children.push({});
- this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_'+element.project.projectName;
- this.treeData[index].children[i].value=ele.accountId;
- this.treeData[index].children[i].key=ele.accountId;
- })
-
- }
- }
- });
- // console.log(this.treeData)
-
- }
- }
- })
- },
-
- handleOk(e) {
- this.visible=false;
- this.$router.replace({path:'/LaunchHousekeeper/setProjectConvert'})
-
-
- },
- handleCancel(e) {
- this.visible = false;
- },
-
-
- //获取表单的某一个属性值
- getFormData(className) {
- return this.form.getFieldValue(className)
- },
- dateChange(date, dateString) {
- // console.log(date,dateString)
- this.form.getFieldDecorator('startTime')
- this.form.getFieldDecorator('endTime')
- this.form.setFieldsValue({
- startTime: date[0].format('YYYY-MM-DD HH:mm'),
- endTime: date[1].format('YYYY-MM-DD HH:mm'),
- })
- },
-
- //推广目的改变
- marketingGoalChange(e){
- console.log(e.target)
- this.marketingGoalHandle(e.target.value)
- },
-
- // 验证网址
- IsURL(res) {
- // var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/
- var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+(.+[A-Za-z0-9-~\/])+$/
- var re = new RegExp(strRegex)
- // console.log(re.test(res))
- if (re.test(res)) {
- return true
- } else {
- return false
- }
- },
- validateURL(rule, value, callback) {
- // console.log(rule, value, callback);
- if (this.IsURL(value)) {
- callback()
- } else if (value && !this.IsURL(value)) {
- callback('链接地址无法访问,请正确输入')
- } else {
- callback('链接必须填写')
- }
- },
- validateName(rule, value, callback){
- // console.log(rule, value, callback);
- if (value) {
- callback()
- } else {
- callback('应用包名称必须填写')
- }
- },
- validateBid(rule, value, callback){
- // console.log(rule, value, callback);
- if (value) {
- callback()
- } else {
- callback('出价必须填写')
- }
- },
-
-
- goBack() {
- this.$router.replace('/modules/LaunchHousekeeper/LaunchHousekeeperList')
- this.$bus.$emit('remove', '/LaunchHousekeeper/newProject')
- },
-
- // 保存并新建创意
- goNext() {
- this.$nextTick(()=>{
- if (this.strategyName) {
- let LHKaccountInfo=sessionStorage.getItem('LHKaccountInfo');
- if(LHKaccountInfo){
- this.LHKaccountInfo=JSON.parse(LHKaccountInfo)
- }
- this.form.validateFields((err, values) => {
- if (!err) {
- console.log('Received values of form: ', values)
- // console.log(this.strategyNames)
- this.goNextloading=true;
- values.accountId = this.accountId
- values.strategyName=this.strategyName
- postAction('/adlab/Project/create', {
- ...values,
- }).then((res) => {
- console.log(res)
- if (res.success) {
- this.goNextloading=false;
-
- if(res.result){
- this.errorInfo=res.result;
- this.visible=true;
- let projectInfo=[]
- res.result.forEach(item=>{
- if(item.code==0){
- projectInfo.push(item)
- }
- })
- sessionStorage.setItem('projectInfo',JSON.stringify(projectInfo))
- }
-
- } else {
- this.goNextloading=false;
- this.$message.error('网络开小差了,等会再试试')
- }
- })
- }else{
- this.$message.error('请正确填写必填项目')
- }
- })
- }else{
- this.$message.error('请输入策略名称')
- }
- })
-
- },
-
-
- },
- marketingGoalHandle(val){
- let str='';
- switch (val) {
- case '1':
- str='应用安装'
- break;
- case '2':
- str='电商下单'
- break;
- case '3':
- str='推广品牌'
- break;
- case '4':
- str='营销线上'
- break;
- case '5':
- str='应用活跃'
- break;
-
- default:
- str='转化错误'
- break;
- }
- return str
- },
- mounted() {
- this.accountHttp()
- // this.$bus.$emit('remove', '/modules/BatchCreate/newGroup')
- let strategyNamepart=this.marketingGoalHandle(this.getFormData('marketingGoal'));
-
-
- this.strategyName ='[策略]'+ strategyNamepart + moment().format('MM_DD_hh:mm') ;
-
- },
- }
- </script>
- <style lang="scss">
- .newPlan{
- .ant-btn-danger {
- background-color: #ff4d4f !important;
- }
- }
- .ant-tooltip-inner,
- .ant-tooltip,
- .ant-tooltip-arrow::before {
- background-color: #fff;
- color: #333;
- }
- .ant-tooltip-inner {
- span {
- display: block;
- }
- }
- .ant-tooltip {
- max-width: 450px;
- }
- .newPlan {
- .ant-radio-button-wrapper {
- min-width: 80px;
- text-align: center;
- }
- .ant-form-item {
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- color: rgba(0, 0, 0, 0.65);
- font-size: 14px;
- font-variant: tabular-nums;
- line-height: 1.5;
- list-style: none;
- -webkit-font-feature-settings: 'tnum';
- font-feature-settings: 'tnum';
- vertical-align: top;
- }
- .directedBody {
- .ant-form-item {
- margin-bottom: 20px;
- }
- }
- }
- </style>
- <style lang="scss" scoped>
- .newPlan {
- font-family: PingFangSC-Regular, tahoma, arial, 'Hiragino Sans GB', 'Microsoft yahei', sans-serif;
- color: #333;
- ul,
- li {
- margin: 0;
- padding: 0;
- }
- .moduler {
- background: #fff;
- margin-bottom: 16px;
- position: relative;
- padding: 32px 24px 48px 32px;
- border-radius: 4px;
- box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
- .moduler-title {
- display: flex;
- align-items: center;
- font-size: 22px;
- margin-bottom: 20px;
- }
- .row-item {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- margin-bottom: 32px;
- }
- .row-item:last-of-type {
- margin-bottom: 0;
- }
- .row-item .hint-item {
- width: 24px;
- min-width: 24px;
- align-self: flex-start;
- line-height: 20px;
- height: 20px;
- margin-top: 9px;
- }
- .row-item .label-item {
- position: relative;
- align-items: flex-start;
- align-self: flex-start;
- line-height: 20px;
- height: 20px;
- margin-top: 10px;
- width: 80px;
- min-width: 80px;
- .text-item {
- font-size: 14px;
- width: 60px;
- }
- }
- .row-item .required-item {
- width: 4px;
- height: 4px;
- border-radius: 2px;
- background: #f45858;
- position: absolute;
- right: 10px;
- top: 50%;
- transform: translateY(-50%);
- }
- .row-item .input-item {
- min-width: 480px;
- position: relative;
- // height: 35px;
- .tip {
- font-size: 12px;
- color: tomato;
- }
- }
- }
- .opt {
- text-align: right;
- }
- }
- </style>
|