templateModal.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. </style>
  24. <template>
  25. <a-modal v-model="visible" title="定向模板" :width="1100" v-if="visible">
  26. <a-spin :spinning="spinning">
  27. <a-form @submit="handleSubmit" :form="form">
  28. <a-form-item
  29. label="模板名称"
  30. :labelCol="{ lg: { span: 7 }, sm: { span: 7 } }"
  31. :wrapperCol="{ lg: { span: 17 }, sm: { span: 17 } }"
  32. >
  33. <a-input
  34. v-decorator="['templateName', { rules: [{ required: true, message: '模板名称必填' }] }]"
  35. :disabled="type == 'look'"
  36. ></a-input>
  37. </a-form-item>
  38. <targeted-population ref="population" :populationData.sync="populationData" />
  39. </a-form>
  40. </a-spin>
  41. <template slot="footer">
  42. <!-- <a-button type="primary" @click="handleSubmit" :loading="loading"> 确定 </a-button> -->
  43. <a-button type="default" @click="()=>{this.visible=false}" > 取消 </a-button>
  44. <a-button type="primary" @click="handleSubmit" :loading="loading"> {{this.type=='add'?'确定':'修改'}} </a-button>
  45. </template>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { getAction, postAction, deleteAction, putAction } from '@/api/manage'
  50. import moment from 'moment'
  51. import { mapGetters } from 'vuex'
  52. import jq from 'jquery'
  53. import targetedPopulation from '@/views/modules/kuaishouapp/account/stepForm/stepModule/targetedPopulation.vue'
  54. import pick from 'lodash.pick'
  55. export default {
  56. name: 'new-mould',
  57. components: {
  58. targetedPopulation,
  59. },
  60. data() {
  61. return {
  62. visible: false,
  63. spinning: false,
  64. form: this.$form.createForm(this),
  65. populationData: {},
  66. accountId: '',
  67. templateId:undefined,
  68. type: 'add',
  69. loading: false,
  70. }
  71. },
  72. computed: {},
  73. methods: {
  74. create(accountId, type) {
  75. this.spinning = false
  76. this.visible = true
  77. this.type = type
  78. this.populationData = {checkApp:'none'}
  79. this.accountId = accountId
  80. },
  81. handleOk(accountId, templateId, type) {
  82. this.spinning = true
  83. this.visible = true
  84. this.type = type
  85. var params = {}
  86. params.templateId = templateId
  87. this.templateId=templateId;
  88. this.accountId = accountId
  89. getAction('/batch/kuaishouTemplateTarget/getDetailByTemplateId', params).then((res) => {
  90. if (res.success) {
  91. var dataJson = {
  92. ...res.result.base,
  93. ...res.result.detail,
  94. }
  95. this.populationData = dataJson
  96. this.populationData.population = dataJson.population ? JSON.parse(dataJson.population) : null
  97. this.populationData.excludePopulation = dataJson.excludePopulation
  98. ? JSON.parse(dataJson.excludePopulation)
  99. : null
  100. this.populationData.devicePrice = dataJson.devicePrice ? JSON.parse(dataJson.devicePrice) : null
  101. this.populationData.appInterest = dataJson.appInterest ? JSON.parse(dataJson.appInterest) : null
  102. this.populationData.businessInterest = dataJson.businessInterest
  103. ? JSON.parse(dataJson.businessInterest)
  104. : null
  105. this.populationData.fansStar = dataJson.fansStar ? JSON.parse(dataJson.fansStar) : null
  106. this.populationData.interestVideo = dataJson.interestVideo ? JSON.parse(dataJson.interestVideo) : null
  107. this.populationData.deviceBrand = dataJson.deviceBrand ? JSON.parse(dataJson.deviceBrand) : null
  108. this.populationData.age = dataJson.min ? [dataJson.min, dataJson.max] : []
  109. this.populationData.agesRange = dataJson.agesRange ? JSON.parse(dataJson.agesRange) : []
  110. this.populationData.devicePrice = dataJson.devicePrice ? dataJson.devicePrice : null
  111. this.populationData.allForm = {}
  112. this.populationData.allForm.regionType =
  113. dataJson.region && JSON.parse(dataJson.region).length > 0 ? 'limit' : 'noLimit'
  114. this.populationData.allForm.region = dataJson.region
  115. // postAction('/kuaishou/batch/getRegionDetail', {
  116. // regionArr: dataJson.region
  117. // }).then(res => {
  118. // console.log(res, 11111)
  119. // if (res.success) {
  120. // this.populationData.allForm.region = res.result
  121. // }
  122. // })
  123. this.populationData.allForm.ageType =
  124. dataJson.agesRange.length > 0 ? 'ageLimit' : dataJson.min ? 'ageCustom' : 'noLimit'
  125. this.populationData.allForm.device = dataJson.deviceBrand ? '1' : '0'
  126. this.populationData.allForm.price = dataJson.devicePrice ? '1' : '0'
  127. this.populationData.allForm.appType = dataJson.appInterest ? '1' : dataJson.appIds ? '2' : '0'
  128. this.populationData.allForm.fansStar = dataJson.fansStar ? '1' : '0'
  129. this.populationData.allForm.interestVideo = dataJson.interestVideo ? '1' : '0'
  130. this.populationData.allForm.platform_os = dataJson.platformOs
  131. this.populationData.allForm.businessInterestType = dataJson.businessInterest ? 2 : 0
  132. this.populationData.allForm.isOpen = dataJson.isOpen
  133. this.populationData.allForm.noAgeBreak = dataJson.noAgeBreak + ''
  134. this.populationData.allForm.noGenderBreak = dataJson.noGenderBreak + ''
  135. this.populationData.allForm.noAreaBreak = dataJson.noAreaBreak + ''
  136. this.populationData.allForm.checkArr =
  137. this.populationData.allForm.appType == '2' ? JSON.parse(dataJson.appIds) : []
  138. this.populationData.checkApp = 'none'
  139. this.$nextTick(() => {
  140. console.log(dataJson)
  141. this.form.setFieldsValue(pick(dataJson, ['templateName']))
  142. this.spinning = false
  143. })
  144. }
  145. })
  146. },
  147. handleCancel(e) {
  148. this.visible = false
  149. },
  150. handleSubmit(e) {
  151. // this.$refs.population.handleSubmit()
  152. e.preventDefault()
  153. this.$refs.population.handleSubmit()
  154. this.form.validateFieldsAndScroll((err, values) => {
  155. if (!err) {
  156. // this.loading = true
  157. var params = {
  158. ...this.populationData,
  159. templateName: values.templateName,
  160. accountId: this.accountId,
  161. }
  162. console.log(params)
  163. if (this.type == 'add') {
  164. postAction('/batch/kuaishouTemplate/createTemplate', params).then((res) => {
  165. if (res.success) {
  166. this.visible = false
  167. this.loading = false
  168. getAction('/batch/kuaishouTemplate/getTemplateByAccountId', {
  169. accountId: this.accountId,
  170. }).then((res) => {
  171. if (res.success) {
  172. this.$emit('getData', this.accountId)
  173. }
  174. })
  175. } else {
  176. this.loading = false
  177. this.$message.error(res.result.message)
  178. }
  179. })
  180. } else if (this.type == 'look') {
  181. params.templateId=this.templateId
  182. postAction('/batch/kuaishouTemplate/updateTemplate', params).then((res) => {
  183. this.visible = false
  184. if (res.success) {
  185. this.loading = false
  186. getAction('/batch/kuaishouTemplate/getTemplateByAccountId', {
  187. accountId: this.accountId,
  188. }).then((res) => {
  189. if (res.success) {
  190. this.$emit('getData', this.accountId)
  191. }
  192. })
  193. } else {
  194. this.loading = false
  195. this.$message.error(res.result.message)
  196. }
  197. })
  198. }
  199. }
  200. })
  201. },
  202. },
  203. }
  204. </script>