directedPackage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div class="directionalPackage">
  3. <!-- <div class="topOptions">
  4. <span class="OptinItem topOpt">
  5. <a-tree-select
  6. show-search
  7. allow-clear
  8. dropdownMatchSelectWidth
  9. v-model="accountID"
  10. style="width: 60%"
  11. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  12. :tree-data="treeData"
  13. placeholder="请选择具体账户"
  14. :filterOption='filterOption'
  15. treeNodeFilterProp='title'
  16. @change='accountIDChange'
  17. >
  18. </a-tree-select>
  19. </span>
  20. <span class="timepcik">
  21. </span>
  22. <span class="optionBtn">
  23. <a-button type='primary' @click="search" class="searchBtn">查询</a-button>
  24. </span>
  25. </div> -->
  26. <div class="tableBOX">
  27. <div class="newOpt">
  28. <a-button class="search" type='primary' @click="openDirectionalPackage">新建定向包</a-button>
  29. </div>
  30. <div class="tableArea">
  31. <a-table
  32. :columns="columns"
  33. :data-source="dataSource"
  34. :pagination="ipagination"
  35. bordered
  36. @change="sort"
  37. size='middle'
  38. >
  39. <span slot="landingType" slot-scope="text">
  40. <span v-if="text=='EXTERNAL'">落地页</span>
  41. <span v-if="text=='APP_ANDROID'">应用下载-安卓</span>
  42. <span v-if="text=='APP_IOS'">应用下载-IOS</span>
  43. <span v-if="text=='AWEME'">抖音推广</span>
  44. </span>
  45. <span slot="deliveryRange" slot-scope="text">
  46. <span v-if="text=='DEFAULT'">默认</span>
  47. <span v-if="text=='UNION'">穿山甲</span>
  48. </span>
  49. <span slot="operation" slot-scope="text,record">
  50. <a href="javascript:;" style="margin-right:10px" @click="editDirectedPackage(record.id)">编辑</a>
  51. <a-popconfirm
  52. v-if="dataSource.length"
  53. title="确定要删除吗?"
  54. @confirm="() => onDelete(record)"
  55. >
  56. <a href="javascript:;">删除</a>
  57. </a-popconfirm>
  58. </span>
  59. <span slot="parentGroup" slot-scope="text">
  60. <a href="javascript:;" >{{text}}</a>
  61. </span>
  62. <span slot="parentPlan" slot-scope="text">
  63. <a href="javascript:;" >{{text}}</a>
  64. </span>
  65. <span slot="cost" slot-scope="cost">
  66. {{cost | formatCurrency }}
  67. </span>
  68. </a-table>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import moment from 'moment';
  75. import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
  76. import { JeecgListMixin } from '@/mixins/ipagination'
  77. import qs from 'qs'
  78. const columns = [
  79. {
  80. title: '定向包名称',
  81. dataIndex: 'name',
  82. align: 'center',
  83. key:'name',
  84. scopedSlots: { customRender: 'name' }
  85. },
  86. {
  87. title: '定向描述',
  88. dataIndex: 'description',
  89. align: 'center',
  90. key: 'description',
  91. scopedSlots: { customRender: 'description' }
  92. },
  93. {
  94. title: '定向包类型',
  95. dataIndex: 'landingType',
  96. align: 'center',
  97. key: 'landingType',
  98. scopedSlots: { customRender: 'landingType' }
  99. },
  100. {
  101. title: '投放范围',
  102. dataIndex: 'deliveryRange',
  103. align: 'center',
  104. scopedSlots: { customRender: 'deliveryRange' },
  105. },
  106. // {
  107. // title: '关联计划',
  108. // dataIndex: 'accountName',
  109. // align: 'center',
  110. // scopedSlots: { customRender: 'accountName' },
  111. // },
  112. {
  113. title: '操作',
  114. dataIndex: 'operation',
  115. align: 'center',
  116. scopedSlots: { customRender: 'operation' },
  117. }
  118. ]
  119. export default {
  120. mixins: [JeecgListMixin],
  121. data() {
  122. return {
  123. //主页的表格
  124. dataSource:[],
  125. columns,
  126. accountID:undefined,
  127. treeData:[],
  128. userId:''
  129. }
  130. },
  131. methods: {
  132. openDirectionalPackage(){
  133. this.$router.push({path:'/BatchCreate/newDirectedPackage'})
  134. },
  135. filterOption(input, option){
  136. console.log(input, option)
  137. return (
  138. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  139. );
  140. },
  141. accountIDChange(val){
  142. console.log(val);
  143. let currentData=this.treeData.filter((item)=>{
  144. return item.value==val
  145. })
  146. console.log(currentData);
  147. if(currentData.length>0){
  148. this.accountID=undefined;
  149. this.openID=val
  150. }
  151. },
  152. //请求项目和账户内容
  153. accountHttp(){
  154. this.treeData=[];
  155. this.accountID=undefined;
  156. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=1', {}).then(res => {
  157. if(res.success){
  158. // console.log(res);
  159. if(res.result){
  160. res.result.forEach((element,index) => {
  161. if(element){
  162. this.treeData.push({});
  163. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  164. this.treeData[index].value='project'+element.project.projectId;
  165. this.treeData[index].key=element.project.projectId;
  166. this.treeData[index].mediaId=element.project.mediaId;
  167. this.treeData[index].children=[];
  168. if(element.account.length){
  169. element.account.forEach((ele,i)=>{
  170. this.treeData[index].children.push({});
  171. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName;
  172. this.treeData[index].children[i].value=ele.accountId;
  173. this.treeData[index].children[i].key=ele.accountId;
  174. })
  175. }
  176. }
  177. });
  178. // console.log(this.treeData)
  179. }
  180. }
  181. })
  182. },
  183. sort(pagination, filters, sorter, { currentDataSource }){
  184. console.log(pagination, filters, sorter)
  185. // this.ipagination.current=pagination.current;
  186. getAction('/ctop/audiencePackage/queryByUserId',{
  187. userId:this.userId,
  188. pageNo:this.ipagination.current
  189. }).then((res)=>{
  190. console.log(res);
  191. this.dataSource=res.result.records;
  192. this.ipagination.total=res.result.total
  193. })
  194. },
  195. search(){
  196. this.dataSource=[];
  197. if(this.accountID){
  198. }else{
  199. this.$message.error('请先选择账户!')
  200. }
  201. },
  202. onDelete(record){
  203. console.log(record);
  204. let params=qs.stringify({
  205. id:record.id
  206. })
  207. postAction('/ctop/audiencePackage/delete',params).then((res)=>{
  208. console.log(res);
  209. if(res.success){
  210. this.getTableList()
  211. }else{
  212. this.$message.error('删除失败,请稍后重试!')
  213. }
  214. })
  215. },
  216. editDirectedPackage(id){
  217. this.$router.push(`/BatchCreate/newDirectedPackage?id=${id}`)
  218. },
  219. getTableList(){
  220. getAction('/ctop/audiencePackage/queryByUserId',{
  221. userId:this.userId
  222. }).then((res)=>{
  223. console.log(res);
  224. this.dataSource=res.result.records;
  225. this.ipagination.total=res.result.total
  226. })
  227. },
  228. },
  229. watch:{
  230. },
  231. mounted() {
  232. this.accountHttp();
  233. let userinfo=localStorage.getItem('pro__Login_Userinfo')
  234. if(userinfo){
  235. this.userId=JSON.parse(userinfo).value.id
  236. }
  237. this.getTableList()
  238. },
  239. filters: {
  240. toPercentage(val) {
  241. if(val){
  242. if(typeof val != 'string'){
  243. return (val * 100).toFixed(2) + '%'
  244. }else{
  245. return val
  246. }
  247. }else if(typeof val =='string'){
  248. return val
  249. }
  250. else{
  251. return 0
  252. }
  253. },
  254. //保留两位小数并且变成货币格式
  255. decimalsHandle(val){
  256. if(val && typeof val !='string'){
  257. if(val>=0){
  258. val=parseFloat(val).toFixed(2);
  259. let numberStr = val.toString()
  260. let str = numberStr.split('.')
  261. let str0=str[0].split('').reverse();
  262. for (let i = 0; i < str0.length; i++) {
  263. if ((i + 1) % 4 === 0) {
  264. str0.splice(i, 0, ',')
  265. }
  266. }
  267. str0.reverse()
  268. let handleResult = ''
  269. for (let j = 0; j < str0.length; j++) {
  270. handleResult += str0[j]
  271. }
  272. return handleResult+'.'+str[1]
  273. }else{
  274. val=parseFloat(val).toFixed(2);
  275. let numberStr = val.toString()
  276. let str = numberStr.split('.')
  277. let str0=str[0].substr(1).split('').reverse();
  278. for (let i = 0; i < str0.length; i++) {
  279. if ((i + 1) % 4 === 0) {
  280. str0.splice(i, 0, ',')
  281. }
  282. }
  283. str0.reverse()
  284. let handleResult = ''
  285. for (let j = 0; j < str0.length; j++) {
  286. handleResult += str0[j]
  287. }
  288. return '-'+handleResult+'.'+str[1]
  289. }
  290. }else if(typeof val =='string'){
  291. return val
  292. }
  293. else{
  294. return 0
  295. }
  296. },
  297. //变成货币格式
  298. formatCurrency(val){
  299. if((val||val==0)&& typeof val !='string'){
  300. let numberStr = val.toString()
  301. let str = numberStr.split('').reverse()
  302. for (let i = 0; i < str.length; i++) {
  303. if ((i + 1) % 4 === 0) {
  304. str.splice(i, 0, ',')
  305. }
  306. }
  307. str.reverse()
  308. let handleResult = ''
  309. for (let j = 0; j < str.length; j++) {
  310. handleResult += str[j]
  311. }
  312. return handleResult
  313. }else if(typeof val =='string'){
  314. return val
  315. }
  316. else{
  317. return '-'
  318. }
  319. }
  320. },
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. .directionalPackage{
  325. .topOptions{
  326. padding: 15px 15px;
  327. background-color: #fff;
  328. margin-bottom: 15px;
  329. .topOpt{
  330. width: 100%;
  331. margin-bottom: 10px;
  332. }
  333. .search{
  334. margin-right: 15px;
  335. }
  336. .addCol{
  337. float:right;
  338. }
  339. .optionBtn{
  340. // display: inline-block;
  341. float: right;
  342. .searchBtn{
  343. margin-right: 10px;
  344. }
  345. }
  346. }
  347. .tableBOX{
  348. background: #fff;
  349. padding: 15px 15px;
  350. .newOpt{
  351. margin-bottom: 10px;
  352. }
  353. }
  354. }
  355. </style>