newProject.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. <template>
  2. <div class="newPlan">
  3. <a-form :form="form">
  4. <div class="moduler">
  5. <div class="moduler-title">选择账户</div>
  6. <div>
  7. <div class="row-item">
  8. <div class="hint-item"></div>
  9. <div class="label-item">
  10. <div class="text-item">账户</div>
  11. <div class="required-item"></div>
  12. </div>
  13. <div class="input-item">
  14. <a-tree-select
  15. v-model="accountIds"
  16. show-search
  17. style="width: 600px;height:30px"
  18. :dropdownMatchSelectWidth='true'
  19. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  20. tree-checkable
  21. searchPlaceholder='请输入账户关键字搜索'
  22. :show-checked-strategy="SHOW_PARENT"
  23. placeholder="请选择项目和账户或搜索账户关键字"
  24. treeNodeFilterProp="title"
  25. :allowClear="true"
  26. @change="treeChange"
  27. @search="treeSearch"
  28. @select="treeSelect"
  29. :maxTagCount='1'
  30. :tree-data="treeData"
  31. :filterOption='filterOption'
  32. >
  33. </a-tree-select>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <!-- 投放范围 -->
  39. <div class="moduler">
  40. <div class="moduler-title">请选择投放媒体</div>
  41. <div class="ad-range">
  42. <div class="row-item">
  43. <div class="hint-item"></div>
  44. <div class="label-item">
  45. <div class="text-item">投放媒体</div>
  46. <div class="required-item"></div>
  47. </div>
  48. <div class="input-item">
  49. <a-form-item>
  50. <a-radio-group v-decorator="['deliveryRange', { initialValue:'DEFAULT' }]">
  51. <a-radio-button value="DEFAULT">默认</a-radio-button>
  52. <a-radio-button value="UNION">
  53. 穿山甲
  54. <a-tooltip>
  55. <template slot="title">基于4亿日活跃用户大数据积累,顶尖AI智能推荐技术,今日头条与最广泛的合作伙伴携手打造全新移动生态联盟</template>
  56. <a-icon type="question-circle" />
  57. </a-tooltip>
  58. </a-radio-button>
  59. </a-radio-group>
  60. </a-form-item>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <!-- 推广目的 -->
  66. <div class="moduler">
  67. <div class="moduler-title">请选择推广目的</div>
  68. <div class="row-item">
  69. <div class="hint-item">
  70. <a-tooltip>
  71. <template slot="title">
  72. <span>应用推广:提升应用的下载、安装、激活、付费</span>
  73. <span>销售线索收集:提升销售线索的获取量</span>
  74. </template>
  75. <a-icon type="question-circle" />
  76. </a-tooltip>
  77. </div>
  78. <div class="label-item">
  79. <div class="text-item">推广目的</div>
  80. <div class="required-item"></div>
  81. </div>
  82. <div class="input-item">
  83. <a-form-item >
  84. <a-radio-group v-decorator="['landingType',{initialValue:'APP' }]" @change="landingTypeChange">
  85. <a-radio-button value="APP">应用推广</a-radio-button>
  86. <a-radio-button value="LINK">销售线索收集</a-radio-button>
  87. </a-radio-group>
  88. </a-form-item>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 投放方式 -->
  93. <div class="moduler">
  94. <div class="moduler-title">请选择投放方式</div>
  95. <div class="row-item">
  96. <div class="hint-item">
  97. <a-tooltip>
  98. <template slot="title">
  99. <span>根据您的投放方式,为您提供包括计划启停、预算分配、出价调整、素材优选等一站式解决方案</span>
  100. </template>
  101. <a-icon type="question-circle" />
  102. </a-tooltip>
  103. </div>
  104. <div class="label-item">
  105. <div class="text-item">投放方式</div>
  106. <div class="required-item"></div>
  107. </div>
  108. <div class="input-item">
  109. <a-form-item>
  110. <a-radio-group v-decorator="['adTarget', { initialValue:'CPA' }]">
  111. <a-radio-button value="CPA" >优先成本</a-radio-button>
  112. <a-radio-button value="COST">优先跑量</a-radio-button>
  113. <a-radio-button value="PUSH">激进抢量</a-radio-button>
  114. </a-radio-group>
  115. </a-form-item>
  116. </div>
  117. </div>
  118. </div>
  119. <!-- 基础信息 -->
  120. <div class="moduler">
  121. <div class="moduler-title">请设置基本信息</div>
  122. <div class="row-item">
  123. <div class="hint-item"> </div>
  124. <div class="label-item">
  125. <div class="text-item">项目名称</div>
  126. <div class="required-item"></div>
  127. </div>
  128. <div class="input-item">
  129. <a-form-item>
  130. <a-input v-model="name" allow-clear />
  131. </a-form-item>
  132. </div>
  133. </div>
  134. </div>
  135. <!-- 操作 -->
  136. <div class="moduler">
  137. <!-- <div class="moduler-title">计划名称</div> -->
  138. <div class="opt">
  139. <a-button type="default" style="margin-right:15px" @click="goBack">取消</a-button>
  140. <a-button type="primary" @click="goNext" :loading="goNextloading">下一步</a-button>
  141. </div>
  142. </div>
  143. </a-form>
  144. <div class="infoModal">
  145. <a-modal v-model="visible" title="提示" @ok="handleOk" :keyboard='false' :maskClosable='false'>
  146. <ul>
  147. <li v-for="(item,index) in errorInfo" :key="index">
  148. <span>账户{{LHKaccountInfo[index].title}}:</span>{{item.message || '投放项目创建成功,下一步去设置转化信息'}}
  149. </li>
  150. </ul>
  151. <template slot="footer">
  152. <a-button key="back" @click="handleCancel">
  153. 返回本页
  154. </a-button>
  155. <a-button key="submit" type="primary" @click="handleOk">
  156. 下一步
  157. </a-button>
  158. </template>
  159. </a-modal>
  160. </div>
  161. </div>
  162. </template>
  163. <script>
  164. import moment from 'moment'
  165. import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
  166. import { TreeSelect } from 'ant-design-vue';
  167. import qs from 'qs'
  168. const SHOW_PARENT = TreeSelect.SHOW_PARENT;
  169. // import selectCheckAll from './toutiaoTime'
  170. var str = ""
  171. for (let i = 0; i < 7*48; i++) {
  172. str+='0'
  173. }
  174. export default {
  175. components: {
  176. // selectCheckAll,
  177. // newDirectedPackage,
  178. },
  179. data() {
  180. return {
  181. LHKaccountInfo:{},
  182. treeValue: [],
  183. treeData: [],
  184. SHOW_PARENT,
  185. accountIds:[],
  186. name: '',
  187. form: this.$form.createForm(this),
  188. goNextloading:false,
  189. goPlanShowloading:false,
  190. dateRange: [moment(), moment()],
  191. visible:false,
  192. errorInfo:[],
  193. validationRules: {
  194. url: [
  195. {
  196. required: true,
  197. validator: this.validateURL,
  198. },
  199. ],
  200. name:[{
  201. required: true,
  202. validator: this.validateName,
  203. }],
  204. bid:[{
  205. required: true,
  206. message:'出价信息必须填写',
  207. // validator: this.validateBid,
  208. }],
  209. roi:[{
  210. required: true,
  211. message:'ROI系数必须填写',
  212. // validator: this.validateBid,
  213. }],
  214. },
  215. }
  216. },
  217. watch: {
  218. },
  219. methods: {
  220. // //项目改变后的事件
  221. treeChange(val) {
  222. // console.log(this.treeData)
  223. console.log(val)
  224. this.accountIds = [];
  225. //选择一个后禁用其他
  226. if(val.length==1){
  227. if(val[0]*1){
  228. let selectindex=0
  229. this.treeData.forEach((ele,index)=>{
  230. if(ele.children){
  231. ele.children.map((item,ind)=>{
  232. if(item.value==val[0]){
  233. selectindex=index;
  234. }
  235. })
  236. }
  237. });
  238. // console.log(selectindex)
  239. if(selectindex ||selectindex==0){
  240. this.treeData.forEach((ele,index)=>{
  241. if(index!=selectindex){
  242. ele.disableCheckbox = true;
  243. if(ele.children){
  244. ele.children.map((item,ind)=>{
  245. item.disableCheckbox = true;
  246. })
  247. }
  248. }
  249. })
  250. }
  251. }else{
  252. // console.log(1)
  253. this.treeData.forEach((ele,index)=>{
  254. if(ele.value!=val[0]){
  255. ele.disableCheckbox = true;
  256. if(ele.children){
  257. ele.children.forEach((item,ind)=>{
  258. item.disableCheckbox = true;
  259. })
  260. }
  261. }
  262. })
  263. }
  264. // console.log(this.mediaId)
  265. }
  266. if(val.length==0){
  267. this.treeData.forEach((ele,index)=>{
  268. ele.disableCheckbox = false;
  269. if(ele.children){
  270. ele.children.forEach((item,ind)=>{
  271. item.disableCheckbox = false;
  272. })
  273. }
  274. });
  275. }
  276. if(val){
  277. val.forEach((ele,index)=>{
  278. if(ele*1){
  279. this.accountIds.push(ele)
  280. }else{
  281. let projectArr=this.treeData.filter((item)=>{
  282. return item.value==ele
  283. });
  284. // console.log(projectArr)
  285. projectArr[0].children.forEach((element)=>{
  286. this.accountIds.push(element.value)
  287. })
  288. }
  289. })
  290. }
  291. console.log(this.accountIds);
  292. let LHKaccountInfo=[]
  293. this.accountIds.forEach(item=>{
  294. this.treeData.forEach(element=>{
  295. element.children.forEach(ele=>{
  296. if(item==ele.value){
  297. LHKaccountInfo.push(ele)
  298. }
  299. })
  300. })
  301. })
  302. sessionStorage.setItem('LHKaccountInfo',JSON.stringify(LHKaccountInfo))
  303. },
  304. treeSearch(){
  305. },
  306. treeSelect(){
  307. },
  308. filterOption(input, option){
  309. console.log(input, option)
  310. return (
  311. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  312. );
  313. },
  314. //请求项目和账户内容
  315. accountHttp(){
  316. this.treeData=[];
  317. this.accountIds=[];
  318. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=1', {}).then(res => {
  319. if(res.success){
  320. // console.log(res);
  321. if(res.result){
  322. res.result.forEach((element,index) => {
  323. if(element){
  324. this.treeData.push({});
  325. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  326. this.treeData[index].value='project'+element.project.projectId;
  327. this.treeData[index].key=element.project.projectId;
  328. this.treeData[index].mediaId=element.project.mediaId;
  329. this.treeData[index].children=[];
  330. if(element.account.length){
  331. element.account.forEach((ele,i)=>{
  332. this.treeData[index].children.push({});
  333. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_'+element.project.projectName;
  334. this.treeData[index].children[i].value=ele.accountId;
  335. this.treeData[index].children[i].key=ele.accountId;
  336. })
  337. }
  338. }
  339. });
  340. // console.log(this.treeData)
  341. }
  342. }
  343. })
  344. },
  345. handleOk(e) {
  346. this.visible=false;
  347. this.$router.replace({path:'/LaunchHousekeeper/setProjectConvert'})
  348. },
  349. handleCancel(e) {
  350. this.visible = false;
  351. },
  352. //获取表单的某一个属性值
  353. getFormData(className) {
  354. return this.form.getFieldValue(className)
  355. },
  356. dateChange(date, dateString) {
  357. // console.log(date,dateString)
  358. this.form.getFieldDecorator('startTime')
  359. this.form.getFieldDecorator('endTime')
  360. this.form.setFieldsValue({
  361. startTime: date[0].format('YYYY-MM-DD HH:mm'),
  362. endTime: date[1].format('YYYY-MM-DD HH:mm'),
  363. })
  364. },
  365. //推广目的改变
  366. landingTypeChange(e){
  367. console.log(e.target)
  368. if(e.target.value=='APP'){
  369. this.name=`应用推广_${moment().format('MM_DD_HH:SS')}`
  370. }else if(e.target.value=='LINK'){
  371. this.name=`销售线索收集_${moment().format('MM_DD_HH:SS')}`
  372. }
  373. },
  374. // 验证网址
  375. IsURL(res) {
  376. // var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/
  377. var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+(.+[A-Za-z0-9-~\/])+$/
  378. var re = new RegExp(strRegex)
  379. // console.log(re.test(res))
  380. if (re.test(res)) {
  381. return true
  382. } else {
  383. return false
  384. }
  385. },
  386. validateURL(rule, value, callback) {
  387. // console.log(rule, value, callback);
  388. if (this.IsURL(value)) {
  389. callback()
  390. } else if (value && !this.IsURL(value)) {
  391. callback('链接地址无法访问,请正确输入')
  392. } else {
  393. callback('链接必须填写')
  394. }
  395. },
  396. validateName(rule, value, callback){
  397. // console.log(rule, value, callback);
  398. if (value) {
  399. callback()
  400. } else {
  401. callback('应用包名称必须填写')
  402. }
  403. },
  404. validateBid(rule, value, callback){
  405. // console.log(rule, value, callback);
  406. if (value) {
  407. callback()
  408. } else {
  409. callback('出价必须填写')
  410. }
  411. },
  412. goBack() {
  413. this.$router.replace('/modules/LaunchHousekeeper/LaunchHousekeeperList')
  414. this.$bus.$emit('remove', '/LaunchHousekeeper/newProject')
  415. },
  416. // 保存并新建创意
  417. goNext() {
  418. this.$nextTick(()=>{
  419. if (this.name) {
  420. let LHKaccountInfo=sessionStorage.getItem('LHKaccountInfo');
  421. if(LHKaccountInfo){
  422. this.LHKaccountInfo=JSON.parse(LHKaccountInfo)
  423. }
  424. this.form.validateFields((err, values) => {
  425. if (!err) {
  426. console.log('Received values of form: ', values)
  427. // console.log(this.names)
  428. this.goNextloading=true;
  429. values.accountIds = this.accountIds
  430. values.name=this.name
  431. postAction('/adlab/Project/create', {
  432. ...values,
  433. }).then((res) => {
  434. console.log(res)
  435. if (res.success) {
  436. this.goNextloading=false;
  437. if(res.result){
  438. this.errorInfo=res.result;
  439. this.visible=true;
  440. let projectInfo=[]
  441. res.result.forEach(item=>{
  442. if(item.code==0){
  443. projectInfo.push(item)
  444. }
  445. })
  446. sessionStorage.setItem('projectInfo',JSON.stringify(projectInfo))
  447. }
  448. } else {
  449. this.goNextloading=false;
  450. this.$message.error('网络开小差了,等会再试试')
  451. }
  452. })
  453. }else{
  454. this.$message.error('请正确填写必填项目')
  455. }
  456. })
  457. }else{
  458. this.$message.error('请输入投放项目名称')
  459. }
  460. })
  461. },
  462. },
  463. mounted() {
  464. this.accountHttp()
  465. // this.$bus.$emit('remove', '/modules/BatchCreate/newGroup')
  466. let namepart='';
  467. if(this.getFormData('landingType')=='APP'){
  468. namepart='应用推广'
  469. }else{
  470. namepart='销售线索收集'
  471. }
  472. this.name ='[项目]'+ namepart + moment().format('MM_DD_hh:mm') ;
  473. },
  474. }
  475. </script>
  476. <style lang="scss">
  477. .newPlan{
  478. .ant-btn-danger {
  479. background-color: #ff4d4f !important;
  480. }
  481. }
  482. .ant-tooltip-inner,
  483. .ant-tooltip-arrow::before {
  484. background-color: #fff;
  485. color: #333;
  486. }
  487. .ant-tooltip-inner {
  488. span {
  489. display: block;
  490. }
  491. }
  492. .ant-tooltip {
  493. max-width: 450px;
  494. }
  495. .newPlan {
  496. .ant-radio-button-wrapper {
  497. min-width: 80px;
  498. text-align: center;
  499. }
  500. .ant-form-item {
  501. -webkit-box-sizing: border-box;
  502. box-sizing: border-box;
  503. margin: 0;
  504. padding: 0;
  505. color: rgba(0, 0, 0, 0.65);
  506. font-size: 14px;
  507. font-variant: tabular-nums;
  508. line-height: 1.5;
  509. list-style: none;
  510. -webkit-font-feature-settings: 'tnum';
  511. font-feature-settings: 'tnum';
  512. vertical-align: top;
  513. }
  514. .directedBody {
  515. .ant-form-item {
  516. margin-bottom: 20px;
  517. }
  518. }
  519. }
  520. </style>
  521. <style lang="scss" scoped>
  522. .newPlan {
  523. font-family: PingFangSC-Regular, tahoma, arial, 'Hiragino Sans GB', 'Microsoft yahei', sans-serif;
  524. color: #333;
  525. ul,
  526. li {
  527. margin: 0;
  528. padding: 0;
  529. }
  530. .moduler {
  531. background: #fff;
  532. margin-bottom: 16px;
  533. position: relative;
  534. padding: 32px 24px 48px 32px;
  535. border-radius: 4px;
  536. box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
  537. .moduler-title {
  538. display: flex;
  539. align-items: center;
  540. font-size: 22px;
  541. margin-bottom: 20px;
  542. }
  543. .row-item {
  544. display: flex;
  545. justify-content: flex-start;
  546. align-items: center;
  547. margin-bottom: 32px;
  548. }
  549. .row-item:last-of-type {
  550. margin-bottom: 0;
  551. }
  552. .row-item .hint-item {
  553. width: 24px;
  554. min-width: 24px;
  555. align-self: flex-start;
  556. line-height: 20px;
  557. height: 20px;
  558. margin-top: 9px;
  559. }
  560. .row-item .label-item {
  561. position: relative;
  562. align-items: flex-start;
  563. align-self: flex-start;
  564. line-height: 20px;
  565. height: 20px;
  566. margin-top: 10px;
  567. width: 80px;
  568. min-width: 80px;
  569. .text-item {
  570. font-size: 14px;
  571. width: 60px;
  572. }
  573. }
  574. .row-item .required-item {
  575. width: 4px;
  576. height: 4px;
  577. border-radius: 2px;
  578. background: #f45858;
  579. position: absolute;
  580. right: 10px;
  581. top: 50%;
  582. transform: translateY(-50%);
  583. }
  584. .row-item .input-item {
  585. min-width: 480px;
  586. position: relative;
  587. // height: 35px;
  588. .tip {
  589. font-size: 12px;
  590. color: tomato;
  591. }
  592. }
  593. }
  594. .opt {
  595. text-align: right;
  596. }
  597. }
  598. </style>