templateModal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <style>
  2. #table_time_selected1 tr {
  3. border: 1px solid rgb(102, 162, 243);
  4. }
  5. .plug-timer-grid th {
  6. line-height: 25px;
  7. }
  8. .group-creat .ant-form-item-required::before {
  9. display: inline-block;
  10. margin-right: 4px;
  11. color: #f5222d;
  12. font-size: 14px;
  13. font-family: SimSun, sans-serif;
  14. line-height: 1;
  15. content: '';
  16. }
  17. .else-label .ant-form-item-label label::after {
  18. content: '';
  19. position: relative;
  20. top: -0.5px;
  21. margin: 0 8px 0 2px;
  22. }
  23. .ant-form-item-required::before {
  24. display: inline-block;
  25. margin-right: 4px;
  26. color: #f5222d;
  27. font-size: 14px;
  28. font-family: SimSun, sans-serif;
  29. line-height: 1;
  30. content: '*';
  31. }
  32. </style>
  33. <style lang="scss" scoped>
  34. .require-check {
  35. /deep/ .ant-form-item-label {
  36. label::before {
  37. display: inline-block;
  38. margin-right: 4px;
  39. color: #f5222d;
  40. font-size: 14px;
  41. font-family: SimSun, sans-serif;
  42. line-height: 1;
  43. content: '*';
  44. }
  45. }
  46. }
  47. </style>
  48. <template>
  49. <a-modal v-model="visible" :title="type === 'add' ? '新建定向包' : '修改定向包'" :width="1100" v-if="visible">
  50. <a-spin :spinning="spinning">
  51. <a-form @submit="handleSubmit" :form="form">
  52. <a-row :gutter="24">
  53. <a-col :md="24" :sm="24" :xxl="24">
  54. <a-form-item
  55. label="账户ID"
  56. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  57. :wrapperCol="{ lg: { span: 12 }, sm: { span: 12 } }"
  58. class="require-check"
  59. >
  60. <!-- <a-input v-model="accountId" :disabled="disabled"></a-input> -->
  61. {{ accountId }}
  62. </a-form-item>
  63. </a-col>
  64. </a-row>
  65. <a-form-item
  66. label="定向包名称"
  67. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  68. :wrapperCol="{ lg: { span: 12 }, sm: { span: 12 } }"
  69. >
  70. <a-input
  71. v-decorator="[
  72. 'templateName',
  73. {
  74. rules: [
  75. { required: true, message: '模板名称必填' },
  76. { min: 1, max: 30, message: '请输入1-30个字', trigger: 'blur' }
  77. ]
  78. }
  79. ]"
  80. ></a-input>
  81. </a-form-item>
  82. <targeted-population
  83. ref="population"
  84. :populationData.sync="populationData"
  85. :accountId.sync="accountId"
  86. />
  87. </a-form>
  88. </a-spin>
  89. <template slot="footer">
  90. <!-- <a-button type="primary" @click="handleSubmit" :loading="loading"> 确定 </a-button> -->
  91. <a-button
  92. type="default"
  93. @click="
  94. () => {
  95. this.visible = false
  96. }
  97. "
  98. >
  99. 取消
  100. </a-button>
  101. <a-button type="primary" @click="handleSubmit" :loading="loading">
  102. {{ type == 'add' ? '确定' : '修改' }}
  103. </a-button>
  104. </template>
  105. </a-modal>
  106. </template>
  107. <script>
  108. import { getAction, postAction, deleteAction, putAction } from '@/api/manage'
  109. import moment from 'moment'
  110. import { mapGetters } from 'vuex'
  111. import jq from 'jquery'
  112. import selectTable from '@/views/modules/Statistics/components/selectPagination.vue'
  113. import targetedPopulation from './targetedPopulation.vue'
  114. import pick from 'lodash.pick'
  115. export default {
  116. name: 'new-mould',
  117. components: {
  118. targetedPopulation,
  119. selectTable
  120. },
  121. data() {
  122. return {
  123. visible: false,
  124. spinning: false,
  125. projectName: '',
  126. form: this.$form.createForm(this),
  127. projectId: '',
  128. populationData: {},
  129. accountId: '',
  130. templateId: undefined,
  131. type: 'add',
  132. loading: false,
  133. labelCol: { lg: { span: 7 }, sm: { span: 7 } },
  134. disabled: false
  135. }
  136. },
  137. computed: {},
  138. methods: {
  139. create(accountId, type) {
  140. this.disabled = false
  141. this.spinning = false
  142. this.visible = true
  143. this.type = type
  144. this.populationData = {}
  145. this.accountId = accountId
  146. localStorage.setItem('createLaunch', accountId)
  147. },
  148. handleOk(item, type) {
  149. this.spinning = true
  150. this.visible = true
  151. this.type = type
  152. var params = {}
  153. params.id = item.id
  154. this.accountId = item.accountId
  155. this.templateId = item.id
  156. getAction('/auto/aiKuaishouAccountAutoTarget/queryById', params).then(res => {
  157. if (res.success) {
  158. var dataJson = {
  159. ...res.result,
  160. templateName: res.result.targetName
  161. }
  162. this.populationData = dataJson
  163. this.populationData.devicePrice = dataJson.devicePrice ? JSON.parse(dataJson.devicePrice) : null
  164. this.populationData.appInterest = dataJson.appInterest ? JSON.parse(dataJson.appInterest) : null
  165. this.populationData.businessInterest = dataJson.businessInterest
  166. ? JSON.parse(dataJson.businessInterest)
  167. : null
  168. this.populationData.fansStar = dataJson.fansStar ? JSON.parse(dataJson.fansStar) : null
  169. this.populationData.interestVideo = dataJson.interestVideo
  170. ? JSON.parse(dataJson.interestVideo)
  171. : null
  172. this.populationData.deviceBrand = dataJson.deviceBrand ? JSON.parse(dataJson.deviceBrand) : null
  173. this.populationData.age = dataJson.min ? [dataJson.min, dataJson.max] : []
  174. this.populationData.agesRange = dataJson.agesRange ? JSON.parse(dataJson.agesRange) : []
  175. this.populationData.devicePrice = dataJson.devicePrice ? dataJson.devicePrice : null
  176. // this.populationData.behavior = dataJson.label
  177. // this.populationData.interest = dataJson.interestLabel
  178. // this.populationData.sceneType = dataJson.sceneType ? JSON.parse(dataJson.sceneType) : []
  179. this.populationData.allForm = {}
  180. var population = dataJson.population ? JSON.parse(dataJson.population) : null
  181. var excludePopulation = dataJson.excludePopulation ? JSON.parse(dataJson.excludePopulation) : null
  182. this.populationData.allForm.people =
  183. population && excludePopulation && excludePopulation.length > 0 && population.length > 0
  184. ? '3'
  185. : population &&
  186. population.length > 0 &&
  187. (!excludePopulation || excludePopulation.length == 0)
  188. ? '1'
  189. : (!population || population.length == 0) &&
  190. excludePopulation &&
  191. excludePopulation.length > 0
  192. ? '2'
  193. : (!population || population.length == 0) &&
  194. (!excludePopulation || excludePopulation.length == 0)
  195. ? '0'
  196. : '0'
  197. this.populationData.allForm.tabKey =
  198. this.populationData.allForm.people == '0'
  199. ? '1'
  200. : this.populationData.allForm.people == '1'
  201. ? '1'
  202. : this.populationData.allForm.people == '2'
  203. ? '2'
  204. : '1'
  205. this.populationData.allForm.incluedSelectedRowKeys =
  206. dataJson.population && dataJson.population.length > 0 ? dataJson.population : []
  207. this.populationData.allForm.incluedSelectedKeys =
  208. dataJson.population && dataJson.population.length > 0 ? dataJson.population : []
  209. this.populationData.allForm.excludeSelectedKeys =
  210. dataJson.excludePopulation && dataJson.excludePopulation.length > 0
  211. ? dataJson.excludePopulation
  212. : []
  213. this.populationData.allForm.excludeSelectedRowKeys =
  214. dataJson.excludePopulation && dataJson.excludePopulation.length > 0
  215. ? dataJson.excludePopulation
  216. : []
  217. this.populationData.allForm.regionType =
  218. dataJson.region && JSON.parse(dataJson.region).length > 0 ? 'limit' : 'noLimit'
  219. this.populationData.allForm.region = dataJson.region
  220. // postAction('/kuaishou/batch/getRegionDetail', {
  221. // regionArr: dataJson.region
  222. // }).then(res => {
  223. // console.log(res, 11111)
  224. // if (res.success) {
  225. // this.populationData.allForm.region = res.result
  226. // }
  227. // })
  228. this.populationData.allForm.ageType =
  229. dataJson.agesRange.length > 0 ? 'ageLimit' : dataJson.min > 0 ? 'ageCustom' : 'noLimit'
  230. this.populationData.allForm.device =
  231. dataJson.deviceBrand && eval(dataJson.deviceBrand).length > 0 ? '1' : '0'
  232. this.populationData.allForm.price =
  233. dataJson.devicePrice && eval(dataJson.devicePrice).length > 0 ? '1' : '0'
  234. this.populationData.allForm.appType =
  235. dataJson.appInterest && eval(dataJson.appInterest).length > 0
  236. ? '1'
  237. : dataJson.appIds && eval(dataJson.appIds).length > 0
  238. ? '2'
  239. : '0'
  240. this.populationData.allForm.fansStar =
  241. dataJson.fansStar && eval(dataJson.fansStar).length > 0 ? '1' : '0'
  242. this.populationData.allForm.interestVideo =
  243. dataJson.interestVideo && eval(dataJson.interestVideo).length > 0 ? '1' : '0'
  244. this.populationData.allForm.platform_os = dataJson.platformOs
  245. this.populationData.allForm.businessInterestType = dataJson.businessInterestType
  246. this.populationData.allForm.isOpen = dataJson.isOpen
  247. this.populationData.allForm.noAgeBreak = dataJson.noAgeBreak + ''
  248. this.populationData.allForm.noGenderBreak = dataJson.noGenderBreak + ''
  249. this.populationData.allForm.noAreaBreak = dataJson.noAreaBreak + ''
  250. // this.populationData.allForm.behaviorInterest = dataJson.label && dataJson.label != '[]' ? '1' : '0'
  251. this.populationData.allForm.checkArr =
  252. this.populationData.allForm.appType == '2' ? JSON.parse(dataJson.appIds) : []
  253. this.populationData.projectId = dataJson.projectId + ''
  254. this.disabled = true
  255. this.$nextTick(() => {
  256. console.log(dataJson)
  257. this.form.setFieldsValue(pick(dataJson, ['templateName']))
  258. this.spinning = false
  259. })
  260. }
  261. })
  262. },
  263. handleCancel(e) {
  264. this.visible = false
  265. },
  266. handleSubmit(e) {
  267. // this.$refs.population.handleSubmit()
  268. e.preventDefault()
  269. this.$refs.population.handleSubmit()
  270. this.$refs.population.formAll.validateFields((err, value) => {
  271. if (this.populationData.allForm.appType == '2') {
  272. if (this.populationData.appIds.length == 0) {
  273. this.$message.error('APP名称未选择')
  274. }
  275. }
  276. if (!err) {
  277. this.form.validateFieldsAndScroll((err, values) => {
  278. if (!err) {
  279. // this.loading = true
  280. if (this.accountId) {
  281. var params = {
  282. ...this.populationData,
  283. targetName: values.templateName,
  284. accountId: this.accountId
  285. }
  286. // params.label = params.behavior ? JSON.stringify(params.behavior) : '[]'
  287. // params.interestLabel = params.interest ? JSON.stringify(params.interest) : '[]'
  288. if (this.type == 'add') {
  289. postAction('/auto/aiKuaishouAccountAutoTarget/addLocalTarget', params).then(res => {
  290. if (res.success) {
  291. this.visible = false
  292. this.loading = false
  293. this.$emit('getData')
  294. } else {
  295. this.loading = false
  296. this.$message.error(res.message)
  297. }
  298. })
  299. } else if (this.type == 'edit') {
  300. params.id = this.templateId
  301. postAction('/auto/aiKuaishouAccountAutoTarget/updateLocalTarget', params).then(
  302. res => {
  303. this.loading = false
  304. if (res.success) {
  305. this.visible = false
  306. this.$emit('getData')
  307. } else {
  308. // this.loading = false
  309. this.$message.error(res.message)
  310. }
  311. }
  312. )
  313. }
  314. } else {
  315. this.$message.error('请选择项目')
  316. }
  317. }
  318. })
  319. }
  320. })
  321. }
  322. }
  323. }
  324. </script>