createStrategy.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <div class="newPlan">
  3. <a-form :form="form">
  4. <!-- 投放范围 -->
  5. <div class="moduler">
  6. <div class="moduler-title">请选择策略创建场景</div>
  7. <div class="ad-range">
  8. <div class="row-item">
  9. <div class="hint-item"></div>
  10. <div class="label-item">
  11. <div class="text-item">创建场景</div>
  12. <div class="required-item"></div>
  13. </div>
  14. <div class="input-item">
  15. <a-form-item>
  16. <a-radio-group v-decorator="['scenes', { initialValue:'2' }]">
  17. <a-radio-button value="1">素材+出价</a-radio-button>
  18. <a-radio-button value="2">素材+定向</a-radio-button>
  19. <a-radio-button value="3">时间+出价</a-radio-button>
  20. </a-radio-group>
  21. </a-form-item>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="moduler">
  27. <div class="moduler-title">选择账户</div>
  28. <div>
  29. <div class="row-item">
  30. <div class="hint-item"></div>
  31. <div class="label-item">
  32. <div class="text-item">账户</div>
  33. <div class="required-item"></div>
  34. </div>
  35. <div class="input-item">
  36. <Treeselect :appId.sync="accountId" :multiple="false" request="2" reqUrl='/ctop/projectMember/getProjectAccountByUserId' ref="treeSelect" style="margin-bottom:8px;width:580px " />
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 推广目的 -->
  42. <div class="moduler">
  43. <div class="moduler-title">请选择营销目标</div>
  44. <div class="row-item">
  45. <div class="hint-item">
  46. </div>
  47. <div class="label-item">
  48. <div class="text-item">营销目标</div>
  49. <div class="required-item"></div>
  50. </div>
  51. <div class="input-item">
  52. <a-form-item >
  53. <a-radio-group v-decorator="['marketingGoal',{initialValue:'2' }]" @change="marketingGoalChange">
  54. <a-radio-button value="2">提升应用安装</a-radio-button>
  55. <a-radio-button value="3">获取电商下单</a-radio-button>
  56. <a-radio-button value="4">推广品牌活动</a-radio-button>
  57. <a-radio-button value="5">收集销售线索</a-radio-button>
  58. <a-radio-button value="7">提高应用活跃</a-radio-button>
  59. </a-radio-group>
  60. </a-form-item>
  61. </div>
  62. </div>
  63. </div>
  64. <!-- 基础信息 -->
  65. <div class="moduler">
  66. <div class="moduler-title">请设置基本信息</div>
  67. <div class="row-item">
  68. <div class="hint-item"> </div>
  69. <div class="label-item">
  70. <div class="text-item">策略名称</div>
  71. <div class="required-item"></div>
  72. </div>
  73. <div class="input-item">
  74. <a-form-item>
  75. <a-input v-model="strategyName" allow-clear />
  76. </a-form-item>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="moduler">
  81. <div class="opt">
  82. <a-button type="default" style="margin-right:15px" @click="goBack">取消</a-button>
  83. <a-button type="primary" @click="goNext" :loading="goNextloading">下一步</a-button>
  84. </div>
  85. </div>
  86. </a-form>
  87. </div>
  88. </template>
  89. <script>
  90. import moment from 'moment'
  91. import {mapGetters} from 'vuex';
  92. import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
  93. import Treeselect from '@/views/modules/Statistics/components/Treeselect.vue'
  94. import { TreeSelect } from 'ant-design-vue';
  95. import qs from 'qs'
  96. const SHOW_PARENT = TreeSelect.SHOW_PARENT;
  97. // import selectCheckAll from './toutiaoTime'
  98. var str = ""
  99. for (let i = 0; i < 7*48; i++) {
  100. str+='0'
  101. }
  102. export default {
  103. components: {
  104. // selectCheckAll,
  105. // newDirectedPackage,
  106. Treeselect
  107. },
  108. data() {
  109. return {
  110. treeData:[],
  111. accountId:undefined,
  112. strategyName: '',
  113. form: this.$form.createForm(this),
  114. goNextloading:false,
  115. goPlanShowloading:false,
  116. dateRange: [moment(), moment()],
  117. visible:false,
  118. errorInfo:[],
  119. validationRules: {
  120. url: [
  121. {
  122. required: true,
  123. validator: this.validateURL,
  124. },
  125. ],
  126. strategyName:[{
  127. required: true,
  128. validator: this.validateName,
  129. }],
  130. bid:[{
  131. required: true,
  132. message:'出价信息必须填写',
  133. // validator: this.validateBid,
  134. }],
  135. roi:[{
  136. required: true,
  137. message:'ROI系数必须填写',
  138. // validator: this.validateBid,
  139. }],
  140. },
  141. }
  142. },
  143. watch: {
  144. accountId(newValue,oldValue){
  145. if(newValue){
  146. this.treeData.forEach(item=>{
  147. if(item.children){
  148. item.children.forEach(ele=>{
  149. if(ele.value==newValue){
  150. this.$parent.accountInfo=ele
  151. }
  152. })
  153. }
  154. })
  155. console.log(this.$parent.accountInfo)
  156. }
  157. }
  158. },
  159. methods: {
  160. ...mapGetters(['userInfo']),
  161. //获取表单的某一个属性值
  162. getFormData(className) {
  163. return this.form.getFieldValue(className)
  164. },
  165. dateChange(date, dateString) {
  166. // console.log(date,dateString)
  167. this.form.getFieldDecorator('startTime')
  168. this.form.getFieldDecorator('endTime')
  169. this.form.setFieldsValue({
  170. startTime: date[0].format('YYYY-MM-DD HH:mm'),
  171. endTime: date[1].format('YYYY-MM-DD HH:mm'),
  172. })
  173. },
  174. //推广目的改变
  175. marketingGoalChange(e){
  176. console.log(e.target)
  177. let strategyNamepart=this.marketingGoalHandle(e.target.value);
  178. this.strategyName ='[策略]_'+ strategyNamepart+'_' + moment().format('MM_DD_hh:mm') ;
  179. },
  180. // 验证网址
  181. IsURL(res) {
  182. // var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/
  183. var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+(.+[A-Za-z0-9-~\/])+$/
  184. var re = new RegExp(strRegex)
  185. // console.log(re.test(res))
  186. if (re.test(res)) {
  187. return true
  188. } else {
  189. return false
  190. }
  191. },
  192. validateURL(rule, value, callback) {
  193. // console.log(rule, value, callback);
  194. if (this.IsURL(value)) {
  195. callback()
  196. } else if (value && !this.IsURL(value)) {
  197. callback('链接地址无法访问,请正确输入')
  198. } else {
  199. callback('链接必须填写')
  200. }
  201. },
  202. validateName(rule, value, callback){
  203. // console.log(rule, value, callback);
  204. if (value) {
  205. callback()
  206. } else {
  207. callback('应用包名称必须填写')
  208. }
  209. },
  210. validateBid(rule, value, callback){
  211. // console.log(rule, value, callback);
  212. if (value) {
  213. callback()
  214. } else {
  215. callback('出价必须填写')
  216. }
  217. },
  218. goBack() {
  219. this.$router.replace('/autoLaunch/autoLaunchList')
  220. this.$bus.$emit('remove', '/autoLaunch/newStrategy')
  221. },
  222. // 保存并新建创意
  223. goNext() {
  224. this.$nextTick(()=>{
  225. if (this.strategyName) {
  226. this.form.validateFields((err, values) => {
  227. if (!err) {
  228. console.log('Received values of form: ', values)
  229. // console.log(this.strategyNames)
  230. values.accountId = this.accountId
  231. values.strategyName=this.strategyName
  232. this.$parent.strategyInfo=values;
  233. this.$parent.currentTabComponent='setDirectional'
  234. }else{
  235. this.$message.error('请正确填写必填项目')
  236. }
  237. })
  238. }else{
  239. this.$message.error('请输入策略名称')
  240. }
  241. })
  242. },
  243. //请求项目和账户内容
  244. accountHttp(){
  245. this.treeData=[];
  246. this.accountIds=[];
  247. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=2&userId=' + this.userInfo().id, {}).then(res => {
  248. if(res.success){
  249. // console.log(res);
  250. if(res.result){
  251. res.result.forEach((element,index) => {
  252. if(element){
  253. this.treeData.push({});
  254. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  255. this.treeData[index].value='project'+element.project.projectId;
  256. this.treeData[index].key=element.project.projectId;
  257. this.treeData[index].mediaId=element.project.mediaId;
  258. this.treeData[index].children=[];
  259. if(element.account.length){
  260. element.account.forEach((ele,i)=>{
  261. this.treeData[index].children.push({});
  262. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_'+element.project.projectName;
  263. this.treeData[index].children[i].value=ele.accountId;
  264. this.treeData[index].children[i].key=ele.accountId;
  265. })
  266. }
  267. }
  268. });
  269. // console.log(this.treeData)
  270. }
  271. }
  272. })
  273. },
  274. marketingGoalHandle(val){
  275. let str='';
  276. switch (val) {
  277. case '2':
  278. str='应用安装'
  279. break;
  280. case '3':
  281. str='电商下单'
  282. break;
  283. case '4':
  284. str='推广品牌'
  285. break;
  286. case '5':
  287. str='营销线索'
  288. break;
  289. case '7':
  290. str='应用活跃'
  291. break;
  292. default:
  293. str='转化错误'
  294. break;
  295. }
  296. return str
  297. },
  298. },
  299. mounted() {
  300. this.accountHttp()
  301. // this.$bus.$emit('remove', '/modules/BatchCreate/newGroup')
  302. let strategyNamepart=this.marketingGoalHandle(this.getFormData('marketingGoal'));
  303. this.strategyName ='[策略]_'+ strategyNamepart+'_' + moment().format('MM_DD_hh:mm') ;
  304. this.$nextTick(()=>{
  305. if(this.$parent.strategyInfo.accountId){
  306. this.form.setFieldsValue(
  307. {
  308. ...this.$parent.strategyInfo
  309. }
  310. )
  311. this.accountId=this.$parent.strategyInfo.accountId
  312. this.strategyName=this.$parent.strategyInfo.strategyName
  313. }
  314. })
  315. },
  316. }
  317. </script>
  318. <style lang="scss">
  319. .newPlan{
  320. .ant-btn-danger {
  321. background-color: #ff4d4f !important;
  322. }
  323. }
  324. .ant-tooltip-inner,
  325. .ant-tooltip-arrow::before {
  326. background-color: #fff;
  327. color: #333;
  328. }
  329. .ant-tooltip-inner {
  330. span {
  331. display: block;
  332. }
  333. }
  334. .ant-tooltip {
  335. max-width: 450px;
  336. }
  337. .newPlan {
  338. .ant-radio-button-wrapper {
  339. min-width: 80px;
  340. text-align: center;
  341. }
  342. .ant-form-item {
  343. -webkit-box-sizing: border-box;
  344. box-sizing: border-box;
  345. margin: 0;
  346. padding: 0;
  347. color: rgba(0, 0, 0, 0.65);
  348. font-size: 14px;
  349. font-variant: tabular-nums;
  350. line-height: 1.5;
  351. list-style: none;
  352. -webkit-font-feature-settings: 'tnum';
  353. font-feature-settings: 'tnum';
  354. vertical-align: top;
  355. }
  356. .directedBody {
  357. .ant-form-item {
  358. margin-bottom: 20px;
  359. }
  360. }
  361. }
  362. </style>
  363. <style lang="scss" scoped>
  364. .newPlan {
  365. font-family: PingFangSC-Regular, tahoma, arial, 'Hiragino Sans GB', 'Microsoft yahei', sans-serif;
  366. color: #333;
  367. ul,
  368. li {
  369. margin: 0;
  370. padding: 0;
  371. }
  372. .moduler {
  373. background: #fff;
  374. margin-bottom: 16px;
  375. position: relative;
  376. padding: 32px 24px 48px 32px;
  377. border-radius: 4px;
  378. box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
  379. .moduler-title {
  380. display: flex;
  381. align-items: center;
  382. font-size: 22px;
  383. margin-bottom: 20px;
  384. }
  385. .row-item {
  386. display: flex;
  387. justify-content: flex-start;
  388. align-items: center;
  389. margin-bottom: 32px;
  390. }
  391. .row-item:last-of-type {
  392. margin-bottom: 0;
  393. }
  394. .row-item .hint-item {
  395. width: 24px;
  396. min-width: 24px;
  397. align-self: flex-start;
  398. line-height: 20px;
  399. height: 20px;
  400. margin-top: 9px;
  401. }
  402. .row-item .label-item {
  403. position: relative;
  404. align-items: flex-start;
  405. align-self: flex-start;
  406. line-height: 20px;
  407. height: 20px;
  408. margin-top: 10px;
  409. width: 80px;
  410. min-width: 80px;
  411. .text-item {
  412. font-size: 14px;
  413. width: 60px;
  414. }
  415. }
  416. .row-item .required-item {
  417. width: 4px;
  418. height: 4px;
  419. border-radius: 2px;
  420. background: #f45858;
  421. position: absolute;
  422. right: 10px;
  423. top: 50%;
  424. transform: translateY(-50%);
  425. }
  426. .row-item .input-item {
  427. min-width: 480px;
  428. position: relative;
  429. // height: 35px;
  430. .tip {
  431. font-size: 12px;
  432. color: tomato;
  433. }
  434. }
  435. }
  436. .opt {
  437. text-align: right;
  438. }
  439. }
  440. </style>