Browse Source

预算模板功能完善

xuzuoyun 5 years ago
parent
commit
2af363931e

+ 0 - 3
src/views/modules/advertiser/AdvertiserList.vue

@@ -338,11 +338,8 @@
         } else {
           this.showLogin = false;
           this.showAuthorization = true;
-
-
         }
       }
-
     }
   }
 </script>

+ 9 - 103
src/views/template/budget/list.vue

@@ -7,32 +7,11 @@
         <a-row :gutter="24">
 
           <a-col :md="6" :sm="8">
-            <a-form-item label="广告主id">
-              <a-input placeholder="请输入广告主id" v-model="queryParam.advertiserId"></a-input>
+            <a-form-item label="模板名称">
+              <a-input placeholder="请输入模板名称" v-model="queryParam.name"></a-input>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="8">
-            <a-form-item label="头条账号id">
-              <a-input placeholder="请输入头条账号id" v-model="queryParam.toutiaoId"></a-input>
-            </a-form-item>
-          </a-col>
-            <a-col :md="6" :sm="8">
-              <a-form-item label="bidType">
-                <a-input placeholder="请输入bidType" v-model="queryParam.bidType"></a-input>
-              </a-form-item>
-            </a-col>
-            <a-col :md="6" :sm="8">
-              <a-form-item label="flowControlMode">
-                <a-input placeholder="请输入flowControlMode"
-                         v-model="queryParam.flowControlMode"></a-input>
-              </a-form-item>
-            </a-col>
-            <a-col :md="6" :sm="8">
-              <a-form-item label="budgetPrice">
-                <a-input placeholder="请输入budgetPrice" v-model="queryParam.budgetPrice"></a-input>
-              </a-form-item>
-            </a-col>
-          <a-col :md="6" :sm="8">
             <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
               <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
               <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
@@ -60,23 +39,10 @@
         :dataSource="dataSource"
         :pagination="ipagination"
         :loading="loading"
-        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
         @change="handleTableChange">
 
         <span slot="action" slot-scope="text, record">
           <a @click="handleEdit(record)">编辑</a>
-
-          <a-divider type="vertical"/>
-          <a-dropdown>
-            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
-            <a-menu slot="overlay">
-              <a-menu-item>
-                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
-                  <a>删除</a>
-                </a-popconfirm>
-              </a-menu-item>
-            </a-menu>
-          </a-dropdown>
         </span>
 
       </a-table>
@@ -91,7 +57,7 @@
 <script>
   import ByteDanceBudgetTemplateModal from './modules/ByteDanceBudgetTemplateModal'
   import {JeecgListMixin} from '@/mixins/JeecgListMixin'
-
+  import jq from 'jquery'
   export default {
     name: "ByteDanceBudgetTemplateList",
     mixins: [JeecgListMixin],
@@ -114,79 +80,19 @@
             }
           },
           {
-            title: '广告主id',
-            align: "center",
-            dataIndex: 'advertiserId'
-          },
-          {
-            title: '头条账号id',
-            align: "center",
-            dataIndex: 'toutiaoId'
-          },
-          {
-            title: '出价方式',
-            align: "center",
-            dataIndex: 'bidType'
-          },
-          {
-            title: '投放方式',
-            align: "center",
-            dataIndex: 'flowControlMode'
-          },
-          {
-            title: '预算价格',
-            align: "center",
-            dataIndex: 'budgetPrice'
-          },
-          {
-            title: '预算类型',
-            align: "center",
-            dataIndex: 'budgetPriceMode'
-          },
-          {
-            title: '投放时间模式',
-            align: "center",
-            dataIndex: 'flowDateType'
-          },
-          {
-            title: '开始时间',
-            align: "center",
-            dataIndex: 'startDate'
-          },
-          {
-            title: '结束时间',
-            align: "center",
-            dataIndex: 'endDate'
-          },
-          {
-            title: '投放时间段方式',
-            align: "center",
-            dataIndex: 'dateQuantum'
-          },
-          {
-            title: '投放时间段',
-            align: "center",
-            dataIndex: 'dateQuantumRange'
-          },
-          {
-            title: '付费方式',
-            align: "center",
-            dataIndex: 'priceType'
-          },
-          {
-            title: '目标转化出价',
+            title: '模板名称',
             align: "center",
-            dataIndex: 'convertPrice'
+            dataIndex: 'name'
           },
           {
-            title: '过滤已转化用户',
+            title: '创建人',
             align: "center",
-            dataIndex: 'filterType'
+            dataIndex: 'createBy'
           },
           {
-            title: '状态',
+            title: '修改人',
             align: "center",
-            dataIndex: 'status'
+            dataIndex: 'updateBy'
           },
           {
             title: '操作',

+ 124 - 48
src/views/template/budget/modules/ByteDanceBudgetTemplateModal.vue

@@ -13,7 +13,7 @@
               label="模板名称"
             :labelCol="labelCol"
             :wrapperCol="wrapperCol">
-              <a-input v-model="name" placeholder="请输入模板名称">
+              <a-input v-model="name"  placeholder="请输入模板名称">
               </a-input>
             </a-form-item>
             <a-form-item
@@ -47,7 +47,6 @@
                 <a-select
                   slot="addonBefore"
                   v-model="budgetPriceMode"
-                  v-decorator="['prefix',{ initialValue: 'BUDGET_MODE_DAY' }]"
                   style="width: 100px">
                   <a-select-option value="BUDGET_MODE_DAY">日预算</a-select-option>
                   <a-select-option value="BUDGET_MODE_TOTAL">总预算</a-select-option>
@@ -74,16 +73,16 @@
               <a-range-picker
                 name="buildTime"
                 style="width: 100%"
-                v-model="time"
-              />
+                v-model="time"/>
             </a-form-item>
             <a-form-item
               label="投放时段"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol">
-              <a-radio-group @change="dateQuantumChange" v-model="dateQuantum">
+              <a-radio-group
+                v-model="dateQuantum" @change="dateQuantumChange">
                 <a-radio-button value="date_unlimited">不限</a-radio-button>
-                <a-radio-button value="date_appoint">指定时间段</a-radio-button>
+                <a-radio-button value="date_appoint">按时间段投放</a-radio-button>
               </a-radio-group>
             </a-form-item>
             <a-form-item
@@ -92,6 +91,7 @@
               :labelCol="labelCol"
               :wrapperCol="wrapperCol">
               <div id="table_time_selected1" class="table_time_selected1">
+
               </div>
             </a-form-item>
             <a-form-item
@@ -108,20 +108,20 @@
               label="目标转化出价"
               :labelCol="labelCol"
               :wrapperCol="wrapperCol">
-              <a-input-number v-model="convertPrice" :min="0" :max="10"/>
+              <a-input-number v-model="convertPrice" :min="0" :max="10000000"/>
             </a-form-item>
-            <a-form-item
-              label="过滤已转化用户"
-              :labelCol="labelCol"
-              :wrapperCol="wrapperCol">
-              <a-radio-group v-model="filterType">
-                <a-radio-button v-for="filterType in filterTypeList" :key="filterType.itemValue"
-                                :value="filterType.itemValue">
-                  {{filterType.itemText}}
-                </a-radio-button>
-              </a-radio-group>
-            </a-form-item>
+<!--            <a-form-item-->
+<!--              label="过滤已转化用户"-->
+<!--              :labelCol="labelCol"-->
+<!--              :wrapperCol="wrapperCol">-->
+<!--              <a-radio-group v-model="filterType">-->
+<!--                <a-radio-button v-for="filterType in filterTypeList" :key="filterType.itemValue"-->
+<!--                                :value="filterType.itemValue">-->
+<!--                  {{filterType.itemText}}-->
+<!--                </a-radio-button>-->
+<!--              </a-radio-group>-->
+<!--            </a-form-item>-->
           </a-form>
         </a-spin>
     </a-modal>
@@ -129,10 +129,11 @@
 
 <script>
     import {deleteAction, postAction, getAction} from '@/api/manage'
+    import pick from 'lodash.pick'
     import jq from 'jquery'
     import moment from 'moment';
     import AFormItem from "ant-design-vue/es/form/FormItem";
-
+    let dateQuantumRangeConst = '';
     export default {
       name: 'ByteDanceBudgetTemplateModal',
       components: {AFormItem},
@@ -141,7 +142,7 @@
           title: "操作",
           visible: false,
           model: {},
-          time: [],
+          time:[],
           labelCol: {
             xs: {span: 24},
             sm: {span: 5},
@@ -150,12 +151,25 @@
             xs: {span: 24},
             sm: {span: 16},
           },
+          // validatorRules: {
+          //   name: {rules: [{required: true, message: '请输入模板名称!'}]},
+          //   convertPrice: {rules: []},
+          //   priceType: {rules: []},
+          //   dateQuantum: {rules: []},
+          //   flowDateType: {rules: []},
+          //   budgetPrice:{rules:[]},
+          //   budgetPriceMode: {rules: []},
+          //   flowControlMode: {rules: []},
+          //   bidType: {rules: []},
+          //   time:{rules:[]}
+          // },
+          name:'',
           confirmLoading: false,
           convertPrice: 0,
           budgetPrice: 0,
           budgetPriceMode: 'BUDGET_MODE_DAY',
           showDateFlowRange: false,
-          showDateQuantumRange:false,
+          showDateQuantumRange:true,
           flowControlMode: 'FLOW_CONTROL_MODE_FAST',
           flowDateType: 'SCHEDULE_FROM_NOW',
           dateQuantum: 'date_unlimited',
@@ -177,13 +191,64 @@
       },
       methods: {
         add() {
-          this.edit({});
+          this.edit({
+            id:null,
+            time:[],
+            convertPrice:0,
+            priceType:'PRICING_OCPM',
+            dateQuantum:'date_unlimited',
+            dateQuantumRange:'',
+            flowDateType:'SCHEDULE_FROM_NOW',
+            budgetPrice:0,
+            budgetPriceMode:'BUDGET_MODE_DAY',
+            flowControlMode:'FLOW_CONTROL_MODE_FAST',
+            bidType:'SMART_BID_CUSTOM',
+            filterType:'NO_EXCLUDE'
+          });
         },
         edit(record) {
           this.form.resetFields();
+
+          // this.time[0] = record.startDate
+          // this.time[1] = record.endDate
           this.model = Object.assign({}, record);
           this.visible = true;
-
+          this.id=record.id
+          this.name=record.name
+          this.convertPrice=record.convertPrice
+          this.budgetPrice=record.budgetPrice
+          this.budgetPriceMode=record.budgetPriceMode
+          this.flowControlMode=record.flowControlMode
+          this.flowDateType=record.flowDateType
+          this.dateQuantum=record.dateQuantum
+          if(record.dateQuantumRange != undefined){
+            this.dateQuantumRange=record.dateQuantumRange
+            dateQuantumRangeConst = record.dateQuantumRange
+          }
+          if(record.startDate != null && record.endDate != null){
+            this.time=[moment(record.startDate),moment(record.endDate)]
+          }
+          this.bidType=record.bidType
+          this.priceType=record.priceType
+          this.price=record.price
+          this.filterType=record.filterType
+          if (this.flowDateType == 'SCHEDULE_FROM_NOW') {
+            this.showDateFlowRange = false;
+          } else {
+            this.showDateFlowRange = true;
+          }
+          if (this.dateQuantum == 'date_unlimited') {
+            this.showDateQuantumRange = false;
+          } else {
+            this.showDateQuantumRange = true;
+            jq(function () {
+              load_time_table('table_time_selected1',dateQuantumRangeConst);
+            });
+          }
+          // this.$nextTick(() => {
+          //   this.form.setFieldsValue(pick(this.model, 'name', 'convertPrice', 'priceType', 'dateQuantum', 'flowDateType', 'budgetPriceMode', 'flowControlMode', 'bidType','budgetPrice','startDate','endDate'))
+          //   //时间格式化
+          // });
         },
         close() {
           this.$emit('close');
@@ -203,13 +268,17 @@
               console.log('Received values of form: ', values);
               let params = {};
               this.dateQuantumRange = jq("#table_time_selected1_time_num").val();
+              params.id=this.id;
+              params.name=this.name;
               params.bidType = this.bidType;
               params.flowControlMode = this.flowControlMode;
               params.budgetPrice = this.budgetPrice;
               params.budgetPriceMode = this.budgetPriceMode;
               params.flowDateType = this.flowDateType;
-              params.startDate = this.startDate;
-              params.endDate = this.endDate;
+              if(this.time != [] && this.time.length==2){
+                params.startDate = moment(this.time[0]).format('YYYY-MM-DD')
+                params.endDate = moment(this.time[1]).format('YYYY-MM-DD')
+              }
               params.dateQuantum = this.dateQuantum;
               params.priceType = this.priceType;
               params.convertPrice = this.convertPrice;
@@ -219,8 +288,14 @@
               postAction(this.url.insertUrl,params).then((res)=>{
                 console.log(res)
                 if(res.success){
-                  alert("预算模板创建成功");
+                  this.$message.success(res.message);
+                  this.$emit('ok');
+                  this.close();
+                }else {
+                  this.$message.warning(res.message);
                 }
+                this.confirmLoading = false;
+
               });
             }
           })
@@ -229,15 +304,13 @@
           console.log(value)
         },
         dateQuantumChange(value){
-          console.log(this.dateQuantum);
           if (this.dateQuantum == 'date_unlimited') {
             this.showDateQuantumRange = false;
           } else {
             this.showDateQuantumRange = true;
             jq(function () {
-              load_time_table('table_time_selected1');
+              load_time_table('table_time_selected1',dateQuantumRangeConst);
             });
-
           }
         },
         onChangeFlowDate() {
@@ -587,7 +660,6 @@
           }
         }
         arr_hour[i] = oDate_hour + ':' + oDate_minute;
-        // alert(oDate_hour + ':' + oDate.getMinutes());
       }
       return arr_hour;
     }
@@ -611,7 +683,7 @@
     function binary_selected(){
       var default_time_val = jq('#'+box_id+' .default_time_val').val();
       if (default_time_val) {
-        for(i=0 ; i<336; i++){
+        for(var i=0 ; i<336; i++){
           var td_selected = default_time_val.charAt(i);
           if (td_selected != 0 ) {
             jq('#' + box_id + ' table tbody tr td').eq(i).attr('class','Selected');
@@ -625,11 +697,12 @@
 
 
     //实例化程序
-    function load_time_table(id){
+    function load_time_table(id,value){
       //包住table的元素id
       box_id = id;
       var html;
-      html = '<table cellspacing="0" cellpadding="0" border="0" class="plug-timer-grid"  onselectstart="return false" onselect="document.selection.empty()">';
+      html = '<input type="hidden" class="default_time_val" value="'+value+'"/>';
+      html += '<table cellspacing="0" cellpadding="0" border="0" class="plug-timer-grid"  onselectstart="return false" onselect="document.selection.empty()">';
       html += '<thead>';
       html += '<tr>';
       html += '<th></th>';
@@ -642,15 +715,13 @@
       html += '</thead>';
       html += '<tbody></tbody>';
       html += '</table>';
-      html += '<input class="focus" style="opacity: 0;">';
-      html += '<div id="'+box_id+'_time_seled"></div>';
-      html += '<input v-model="dateQuantumRange" type="hidden" id="'+box_id+'_time_num" name="time" caption="每日投放时段" switchname="selectTime"  value="">';
-
+      html += '<input class="focus" type="hidden" style="opacity: 0;">';
+      html += '<div id="'+box_id+'_time_seled" style="line-height: 15px;font-size:10px;"></div>';
+      html += '<input type="hidden" id="'+box_id+'_time_num" name="time" caption="每日投放时段" switchname="selectTime"  value="'+value+'">';
+      jq('#'+box_id).html('');
       jq('#'+box_id).append(html);
-      console.log(jq('#table_time_selected1').html())
       var html_tbody_td = '';
       var html_thead_td = '';
-
       //创建表格
       for (var i = 0; i < 7; i++) {
         var week = i+1;
@@ -785,14 +856,19 @@
       return convert_date(binary);
     }
 
-    jq(function(){
-      load_time_table('table_time_selected1');
-    });
+    // jq(function(){
+    //   load_time_table('table_time_selected1',this.dateQuantumRange);
+    // });
 
 </script>
 <style type="text/css">
-  .plug-timer-grid{width: 80%;}
-  .plug-timer-grid td, .plug-timer-grid th{border: 1px solid #97B4D1;text-align: center; /*cursor:pointer;*/}
+  .plug-timer-grid{width: 100%;}
+  .plug-timer-grid td, .plug-timer-grid th{
+    border: 1px solid #97B4D1;
+    text-align: center; /*cursor:pointer;*/
+    font-size: 10px;
+    line-height: 10px;
+  }
   .Selected{background-color: rgb(102,162,243);opacity: 0.5;}
 
   .plug-timer-grid {
@@ -806,7 +882,7 @@
   }
 
   table td{
-    height: 30px;
+    height: 20px;
     max-width: 5px;
     border: 1px solid #dfe6ec;
     font-size: 12px;
@@ -823,7 +899,7 @@
   .plug-timer-grid tbody tr td{
     width: 2%;
   }
-  .clear{
-    margin:20px 0px 20px 0px;
-  }
+  /*.clear{*/
+  /*  margin:20px 0px 20px 0px;*/
+  /*}*/
 </style>