createStrategy.vue 15 KB

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