createStrategy.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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. this.marketingGoalHandle(e.target.value)
  176. },
  177. // 验证网址
  178. IsURL(res) {
  179. // var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/
  180. var strRegex = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+(.+[A-Za-z0-9-~\/])+$/
  181. var re = new RegExp(strRegex)
  182. // console.log(re.test(res))
  183. if (re.test(res)) {
  184. return true
  185. } else {
  186. return false
  187. }
  188. },
  189. validateURL(rule, value, callback) {
  190. // console.log(rule, value, callback);
  191. if (this.IsURL(value)) {
  192. callback()
  193. } else if (value && !this.IsURL(value)) {
  194. callback('链接地址无法访问,请正确输入')
  195. } else {
  196. callback('链接必须填写')
  197. }
  198. },
  199. validateName(rule, value, callback){
  200. // console.log(rule, value, callback);
  201. if (value) {
  202. callback()
  203. } else {
  204. callback('应用包名称必须填写')
  205. }
  206. },
  207. validateBid(rule, value, callback){
  208. // console.log(rule, value, callback);
  209. if (value) {
  210. callback()
  211. } else {
  212. callback('出价必须填写')
  213. }
  214. },
  215. goBack() {
  216. this.$router.replace('/autoLaunch/autoLaunchList')
  217. this.$bus.$emit('remove', '/autoLaunch/newStrategy')
  218. },
  219. // 保存并新建创意
  220. goNext() {
  221. this.$nextTick(()=>{
  222. if (this.strategyName) {
  223. this.form.validateFields((err, values) => {
  224. if (!err) {
  225. console.log('Received values of form: ', values)
  226. // console.log(this.strategyNames)
  227. values.accountId = this.accountId
  228. values.strategyName=this.strategyName
  229. this.$parent.strategyInfo=values;
  230. this.$parent.currentTabComponent='setDirectional'
  231. }else{
  232. this.$message.error('请正确填写必填项目')
  233. }
  234. })
  235. }else{
  236. this.$message.error('请输入策略名称')
  237. }
  238. })
  239. },
  240. //请求项目和账户内容
  241. accountHttp(){
  242. this.treeData=[];
  243. this.accountIds=[];
  244. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=2', {}).then(res => {
  245. if(res.success){
  246. // console.log(res);
  247. if(res.result){
  248. res.result.forEach((element,index) => {
  249. if(element){
  250. this.treeData.push({});
  251. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  252. this.treeData[index].value='project'+element.project.projectId;
  253. this.treeData[index].key=element.project.projectId;
  254. this.treeData[index].mediaId=element.project.mediaId;
  255. this.treeData[index].children=[];
  256. if(element.account.length){
  257. element.account.forEach((ele,i)=>{
  258. this.treeData[index].children.push({});
  259. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_'+element.project.projectName;
  260. this.treeData[index].children[i].value=ele.accountId;
  261. this.treeData[index].children[i].key=ele.accountId;
  262. })
  263. }
  264. }
  265. });
  266. // console.log(this.treeData)
  267. }
  268. }
  269. })
  270. },
  271. marketingGoalHandle(val){
  272. let str='';
  273. switch (val) {
  274. case '2':
  275. str='应用安装'
  276. break;
  277. case '3':
  278. str='电商下单'
  279. break;
  280. case '4':
  281. str='推广品牌'
  282. break;
  283. case '5':
  284. str='营销线上'
  285. break;
  286. case '7':
  287. str='应用活跃'
  288. break;
  289. default:
  290. str='转化错误'
  291. break;
  292. }
  293. return str
  294. },
  295. },
  296. mounted() {
  297. this.accountHttp()
  298. // this.$bus.$emit('remove', '/modules/BatchCreate/newGroup')
  299. let strategyNamepart=this.marketingGoalHandle(this.getFormData('marketingGoal'));
  300. this.strategyName ='[策略]_'+ strategyNamepart+'_' + moment().format('MM_DD_hh:mm') ;
  301. },
  302. }
  303. </script>
  304. <style lang="scss">
  305. .newPlan{
  306. .ant-btn-danger {
  307. background-color: #ff4d4f !important;
  308. }
  309. }
  310. .ant-tooltip-inner,
  311. .ant-tooltip,
  312. .ant-tooltip-arrow::before {
  313. background-color: #fff;
  314. color: #333;
  315. }
  316. .ant-tooltip-inner {
  317. span {
  318. display: block;
  319. }
  320. }
  321. .ant-tooltip {
  322. max-width: 450px;
  323. }
  324. .newPlan {
  325. .ant-radio-button-wrapper {
  326. min-width: 80px;
  327. text-align: center;
  328. }
  329. .ant-form-item {
  330. -webkit-box-sizing: border-box;
  331. box-sizing: border-box;
  332. margin: 0;
  333. padding: 0;
  334. color: rgba(0, 0, 0, 0.65);
  335. font-size: 14px;
  336. font-variant: tabular-nums;
  337. line-height: 1.5;
  338. list-style: none;
  339. -webkit-font-feature-settings: 'tnum';
  340. font-feature-settings: 'tnum';
  341. vertical-align: top;
  342. }
  343. .directedBody {
  344. .ant-form-item {
  345. margin-bottom: 20px;
  346. }
  347. }
  348. }
  349. </style>
  350. <style lang="scss" scoped>
  351. .newPlan {
  352. font-family: PingFangSC-Regular, tahoma, arial, 'Hiragino Sans GB', 'Microsoft yahei', sans-serif;
  353. color: #333;
  354. ul,
  355. li {
  356. margin: 0;
  357. padding: 0;
  358. }
  359. .moduler {
  360. background: #fff;
  361. margin-bottom: 16px;
  362. position: relative;
  363. padding: 32px 24px 48px 32px;
  364. border-radius: 4px;
  365. box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
  366. .moduler-title {
  367. display: flex;
  368. align-items: center;
  369. font-size: 22px;
  370. margin-bottom: 20px;
  371. }
  372. .row-item {
  373. display: flex;
  374. justify-content: flex-start;
  375. align-items: center;
  376. margin-bottom: 32px;
  377. }
  378. .row-item:last-of-type {
  379. margin-bottom: 0;
  380. }
  381. .row-item .hint-item {
  382. width: 24px;
  383. min-width: 24px;
  384. align-self: flex-start;
  385. line-height: 20px;
  386. height: 20px;
  387. margin-top: 9px;
  388. }
  389. .row-item .label-item {
  390. position: relative;
  391. align-items: flex-start;
  392. align-self: flex-start;
  393. line-height: 20px;
  394. height: 20px;
  395. margin-top: 10px;
  396. width: 80px;
  397. min-width: 80px;
  398. .text-item {
  399. font-size: 14px;
  400. width: 60px;
  401. }
  402. }
  403. .row-item .required-item {
  404. width: 4px;
  405. height: 4px;
  406. border-radius: 2px;
  407. background: #f45858;
  408. position: absolute;
  409. right: 10px;
  410. top: 50%;
  411. transform: translateY(-50%);
  412. }
  413. .row-item .input-item {
  414. min-width: 480px;
  415. position: relative;
  416. // height: 35px;
  417. .tip {
  418. font-size: 12px;
  419. color: tomato;
  420. }
  421. }
  422. }
  423. .opt {
  424. text-align: right;
  425. }
  426. }
  427. </style>