ソースを参照

政策 模块 联调

jiayufei 3 年 前
コミット
886760bd2c

+ 1 - 1
src/views/modules/policy-management/policy-management-server.js

@@ -7,5 +7,5 @@
  // export const urlAcount = 'http://apipre.tjyourong.com.cn'; // 预生产
  // export const urlAcount = 'http://192.168.1.43:8808'; // 子安
  // export const urlAcount = 'http://139.186.165.84:8808'; // 测试
- export const urlAcount = 'http://192.168.1.8:7005'; // 学超
+ export const urlAcount = 'http://192.168.1.8:9999'; // 学超
  

+ 272 - 112
src/views/modules/policy-management/policy-management.vue

@@ -48,7 +48,7 @@
                         </a-select>
                     </a-form-item>
                     <a-form-item label="返点类型:">
-                        <a-select v-model="configForm.creativeRebate" style="width: 100px">
+                        <a-select v-model="configForm.creativeRebate" style="width: 140px">
                             <a-select-option
                                 v-for="item in creativeRebateOptions"
                                 :key="item.id"
@@ -68,7 +68,12 @@
                         <a-input v-model="configForm.creativeAdvance" placeholder="请输入垫付公司名称"/>
                     </a-form-item>
                     <a-form-item label="销售:">
-                        <a-select v-model="configForm.creativeSale" style="width: 100px">
+                        <a-select
+                            v-model="configForm.creativeSale"
+                            style="width: 100px"
+                            :filter-option="filterOption"
+                            show-search
+                        >
                             <a-select-option
                                 v-for="item in allSaleListOption"
                                 :key="item.userId"
@@ -127,6 +132,14 @@
                 <span slot="advertiserName" slot-scope="text">
                     <a>{{ text }}</a>
                 </span>
+                <span slot="updatePolicyProductName" slot-scope="text">
+                    <a-tooltip placement="top">
+                        <template slot="title">
+                            <span>{{ text }}</span>
+                        </template>
+                        <a>{{ text }}</a>
+                    </a-tooltip>
+                </span>
                 <span slot="promotionType" slot-scope="text">
                     <a>{{ text === 0 ? '自运营' : '代运营' }}</a>
                 </span>
@@ -337,16 +350,16 @@
                     :wrapper-col="wrapperCol"
                 >
                     <a-row class="policy-operation-form-left">
-                        <a-form-model-item label="公司名称" prop="name1">
+                        <a-form-model-item label="公司名称" prop="companyName">
                             <a-input
-                                v-model="policyOperationForm.name1"
+                                v-model="policyOperationForm.companyName"
                                 placeholder="请输入公司名称"
                                 allow-clear
                             />
                         </a-form-model-item>
-                        <a-form-model-item label="广告主" prop="name1">
+                        <a-form-model-item label="广告主" prop="advertiserName">
                             <a-input
-                                v-model="policyOperationForm.name3"
+                                v-model="policyOperationForm.advertiserName"
                                 placeholder="请输入广告主"
                                 allow-clear
                             />
@@ -384,39 +397,64 @@
                                 <a-icon v-if="policyOperationForm.defaultFormList.length > 1 && index > 0" class="circle-icon-class circle-icon-plus" type="minus-circle" @click="handleDelOrigin(item)"/>
                             </a-form-model-item>
                         </div>
-                        <a-form-model-item label="媒体" prop="name6">
-                            <a-select v-model="policyOperationForm.name6" placeholder="请选择投放媒体">
+                        <a-form-model-item label="媒体" prop="mediaType">
+                            <a-select v-model="policyOperationForm.mediaType" placeholder="请选择投放媒体">
                                 <a-select-option :value="1">快手</a-select-option>
                                 <a-select-option :value="2">头条</a-select-option>
                             </a-select>
                         </a-form-model-item>
-                        <a-form-model-item label="销售" prop="name7">
-                            <a-select v-model="policyOperationForm.name7" placeholder="请选择所属销售">
-                                <a-select-option :value="2">不限</a-select-option>
-                                <a-select-option :value="0">待审核</a-select-option>
+                        <a-form-model-item label="销售" prop="createUserId">
+                            <a-select
+                                v-model="policyOperationForm.createUserId"
+                                style="width: 100px"
+                                :filter-option="filterOption"
+                                show-search
+                            >
+                                <a-select-option
+                                    v-for="item in saleShowOption"
+                                    :key="item.userId"
+                                    :value="item.userId"
+                                >
+                                    {{ item.userName }}
+                                </a-select-option>
                             </a-select>
                         </a-form-model-item>
-                        <a-form-model-item label="区域" prop="name8">
-                            <a-select v-model="policyOperationForm.name8" placeholder="请选择区域">
-                                <a-select-option :value="2">不限</a-select-option>
-                                <a-select-option :value="0">待审核</a-select-option>
+                        <a-form-model-item label="区域" prop="areaInfo">
+                            <a-select v-model="policyOperationForm.areaInfo" placeholder="请选择区域">
+                                <a-select-option
+                                    v-for="item in addAreaList"
+                                    :key="item"
+                                    :value="item"
+                                >
+                                    {{ item }}
+                                </a-select-option>
                             </a-select>
                         </a-form-model-item>
-                        <a-form-model-item label="我司主体" prop="name9">
-                            <a-select v-model="policyOperationForm.name9" placeholder="请选择我司主体">
-                                <a-select-option :value="2">不限</a-select-option>
-                                <a-select-option :value="0">待审核</a-select-option>
+                        <a-form-model-item label="我司主体" prop="companySubjectId">
+                            <a-select
+                                v-model="policyOperationForm.companySubjectId"
+                                placeholder="请选择我司主体"
+                                :filter-option="filterOption"
+                                show-search
+                            >
+                                <a-select-option
+                                    v-for="item in addSubjectList"
+                                    :key="item.id"
+                                    :value="item.id"
+                                >
+                                    {{ item.companySubjectName }}
+                                </a-select-option>
                             </a-select>
                         </a-form-model-item>
-                        <a-form-model-item label="运营方式" prop="name10">
-                            <a-radio-group v-model="policyOperationForm.name10" button-style="solid">
-                                <a-radio-button value="a">自运营</a-radio-button>
-                                <a-radio-button value="b">代运营</a-radio-button>
+                        <a-form-model-item label="运营方式" prop="promotionType">
+                            <a-radio-group v-model="policyOperationForm.promotionType" button-style="solid">
+                                <a-radio-button :value="0">自运营</a-radio-button>
+                                <a-radio-button :value="1">代运营</a-radio-button>
                             </a-radio-group>
                         </a-form-model-item>
                         <a-form-model-item label="集团简称">
                             <a-input
-                                v-model="policyOperationForm.name11"
+                                v-model="policyOperationForm.groupAbbreviation"
                                 placeholder="请输入集团简称"
                                 allow-clear
                                 @change="handleGroupAbbreviationChange"
@@ -425,62 +463,64 @@
                         <div v-if="subTitleMsgStatus" style="color: #f00;margin-left: 140px">只能输入30个汉字</div>
                     </a-row>
                     <a-row class="policy-operation-form-right">
-                        <a-form-model-item label="是否预付" prop="name2">
-                            <a-radio-group v-model="policyOperationForm.name2" button-style="solid" @change="handlePrepaidNotChange">
-                                <a-radio-button value="a">是</a-radio-button>
-                                <a-radio-button value="b">否</a-radio-button>
+                        <a-form-model-item label="是否预付" prop="advancePay">
+                            <a-radio-group v-model="policyOperationForm.advancePay" button-style="solid" @change="handlePrepaidNotChange">
+                                <a-radio-button :value="1">是</a-radio-button>
+                                <a-radio-button :value="0">否</a-radio-button>
                             </a-radio-group>
                         </a-form-model-item>
-                        <a-form-model-item label="返点类型:" prop="name4">
-                            <a-select v-model="policyOperationForm.name4" placeholder="请选择返点类型">
-                                <a-select-option :value="2">不限</a-select-option>
-                                <a-select-option :value="0">待审核</a-select-option>
-                                <a-select-option :value="1">审核中</a-select-option>
-                                <a-select-option :value="1">审核通过</a-select-option>
-                                <a-select-option :value="1">审核拒绝</a-select-option>
+                        <a-form-model-item label="返点类型:" prop="rebateType">
+                            <a-select v-model="policyOperationForm.rebateType" placeholder="请选择返点类型">
+                                <a-select-option :value="0">返现</a-select-option>
+                                <a-select-option :value="1">返货</a-select-option>
+                                <a-select-option :value="2">返现+返货</a-select-option>
                             </a-select>
                         </a-form-model-item>
-                        <a-form-model-item label="返点比例" prop="name12">
+                        <a-form-model-item label="返点比例" prop="rebateRate">
                             <a-input-number
-                                v-model="policyOperationForm.name12"
+                                v-model="policyOperationForm.rebateRate"
                                 :precision="2"
                             /> %
                         </a-form-model-item>
-                        <a-form-model-item v-if="policyOperationForm.name2 === 'b'" label="账期" prop="name13">
+                        <a-form-model-item v-if="policyOperationForm.advancePay === 0" label="账期" prop="accountingPeriod">
                             <a-input-number
-                                v-model="policyOperationForm.name13"
+                                v-model="policyOperationForm.accountingPeriod"
                                 :precision="0"
                             /> 天
                         </a-form-model-item>
-                        <a-form-model-item v-if="policyOperationForm.name2 === 'b'" label="是否第三方垫付" prop="name14">
-                            <a-radio-group v-model="policyOperationForm.name14" button-style="solid">
-                                <a-radio-button value="a">是</a-radio-button>
-                                <a-radio-button value="b">否</a-radio-button>
-                            </a-radio-group>
-                        </a-form-model-item>
-                        <a-form-model-item v-if="policyOperationForm.name14 === 'a'" label="垫付公司" prop="name15">
-                            <a-input
-                                v-model="policyOperationForm.name15"
-                                placeholder="请输入垫付公司"
-                                allow-clear
-                            />
-                        </a-form-model-item>
-                        <a-form-model-item v-if="policyOperationForm.name14 === 'a'" label="垫付返点" prop="name16">
-                            <a-input
-                                v-model="policyOperationForm.name16"
-                                placeholder="请输入垫付返点"
-                                allow-clear
-                            />
-                        </a-form-model-item>
-                        <a-form-model-item label="政策起止时间" prop="name17">
+                        <div v-if="policyOperationForm.advancePay === 0">
+                            <a-form-model-item label="是否第三方垫付" prop="isDianPay" @change="handleIsDianPayChange">
+                                <a-radio-group v-model="policyOperationForm.isDianPay" button-style="solid">
+                                    <a-radio-button :value="1">是</a-radio-button>
+                                    <a-radio-button :value="0">否</a-radio-button>
+                                </a-radio-group>
+                            </a-form-model-item>
+                            <div v-if="policyOperationForm.isDianPay === 1">
+                                <a-form-model-item label="垫付公司" prop="dianPayCompanyName">
+                                    <a-input
+                                        v-model="policyOperationForm.dianPayCompanyName"
+                                        placeholder="请输入垫付公司"
+                                        allow-clear
+                                    />
+                                </a-form-model-item>
+                                <a-form-model-item label="垫付返点" prop="dianPayCompanyRebateRate">
+                                    <a-input-number
+                                        v-model="policyOperationForm.dianPayCompanyRebateRate"
+                                        :precision="2"
+                                    />
+                                </a-form-model-item>
+                            </div>
+                        </div>
+                        <a-form-model-item label="政策起止时间" prop="addTimes">
                             <a-range-picker
-                                v-model="policyOperationForm.name17"
+                                v-model="policyOperationForm.addTimes"
                                 format="YYYY-MM-DD"
+                                @change="handleAddTimesChange"
                             />
                         </a-form-model-item>
                         <a-form-model-item label="备注">
                             <a-input
-                                v-model="policyOperationForm.name18"
+                                v-model="policyOperationForm.remarks"
                                 placeholder="请输入备注"
                                 allow-clear
                                 @change="handleRemarksChange"
@@ -494,9 +534,10 @@
     </div>
 </template>
 <script>
-import {getAction, postAction, deleteAction} from '@/api/manage';
-import {urlAcount} from './policy-management-server.js';
+import {getAction, postAction} from '@/api/manage';
 import {mapGetters} from 'vuex';
+import moment from 'moment';
+import {urlAcount} from './policy-management-server.js';
 
 export default {
     name: 'policy-management',
@@ -582,49 +623,49 @@ export default {
                         value: ''
                     }
                 ],
-                name1: '',
-                name2: 'a',
-                name3: '',
-                name4: undefined,
-                name6: 1,
-                name7: undefined,
-                name8: undefined,
-                name9: undefined,
-                name10: 'b',
-                name11: '',
-                name12: '',
-                name13: '',
-                name14: undefined,
-                name15: '',
-                name16: '',
-                name17: [],
-                name18: ''
+                companyName: '',
+                advancePay: 1,
+                advertiserName: '',
+                rebateType: undefined,
+                mediaType: 1,
+                createUserId: undefined,
+                areaInfo: undefined,
+                companySubjectId: undefined,
+                promotionType: 1,
+                groupAbbreviation: '',
+                rebateRate: '',
+                accountingPeriod: '',
+                isDianPay: undefined,
+                dianPayCompanyName: '',
+                dianPayCompanyRebateRate: '',
+                addTimes: [],
+                remarks: ''
             },
             reasonForm: {
                 desc: ''
             },
             policyOperationRules: {
-                name1: [
+                companyName: [
                     {required: true, message: '请输入公司名称', trigger: 'blur'},
                     {validator: handleCharacterLen30, trigger: 'blur'}
                 ],
-                name3: [
+                advertiserName: [
                     {required: true, message: '请输入广告主名称', trigger: 'blur'},
                     {validator: handleCharacterLen30, trigger: 'blur'}
                 ],
-                name4: [{required: true, message: '请选择返点类型', trigger: 'change'}],
-                name6: [{required: true, message: '请选择投放媒体', trigger: 'change'}],
-                name7: [{required: true, message: '请选择所属销售', trigger: 'change'}],
-                name8: [{required: true, message: '请选择区域', trigger: 'change'}],
-                name9: [{required: true, message: '请选择我司主体', trigger: 'change'}],
-                name12: [{required: true, message: '请输入返点比例', trigger: 'blur'}],
-                name13: [{required: true, message: '请输入账期', trigger: 'blur'}],
-                name15: [
+                rebateType: [{required: true, message: '请选择返点类型', trigger: 'change'}],
+                mediaType: [{required: true, message: '请选择投放媒体', trigger: 'change'}],
+                createUserId: [{required: true, message: '请选择所属销售', trigger: 'change'}],
+                areaInfo: [{required: true, message: '请选择区域', trigger: 'change'}],
+                companySubjectId: [{required: true, message: '请选择我司主体', trigger: 'change'}],
+                rebateRate: [{required: true, message: '请输入返点比例', trigger: 'blur'}],
+                accountingPeriod: [{required: true, message: '请输入账期', trigger: 'blur'}],
+                dianPayCompanyName: [
                     {required: true, message: '请输入垫付公司', trigger: 'blur'},
                     {validator: handleCharacterLen30, trigger: 'blur'}
                 ],
-                name16: [{required: true, message: '请输入垫付返点', trigger: 'blur'}],
-                name17: [{required: true, message: '请选择时间', trigger: 'change'}],
+                dianPayCompanyRebateRate: [{required: true, message: '请输入垫付返点', trigger: 'blur'}],
+                addTimes: [{required: true, message: '请选择时间', trigger: 'change'}]
             },
             reasonRules: {
                 desc: [
@@ -652,7 +693,8 @@ export default {
                     align: 'center',
                     dataIndex: 'updatePolicyProductName',
                     ellipsis: true,
-                    width: 190
+                    width: 190,
+                    scopedSlots: {customRender: 'updatePolicyProductName'}
                 },
                 {
                     title: '媒体',
@@ -771,9 +813,12 @@ export default {
                 page: 1,
                 size: 10
             },
+            addAreaList: [],
+            saleShowOption: [],
+            addSubjectList: [],
             rejectionReasonList: {},
             tableOnlyId: ''
-        }; 
+        };
     },
     created() {
         this.searchForm = this.$form.createForm(this);
@@ -781,9 +826,35 @@ export default {
     mounted() {
         this.handleInitTable();
         this.handleGetAllSaleList();
+        this.handleAddGetArea();
     },
     methods: {
         ...mapGetters(['userInfo']),
+        moment,
+        filterOption(input, option) {
+            return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
+        },
+        handleAddTimesChange(date, dateString) {
+            this.policyOperationForm.addTimes = dateString;
+        },
+        handleAddGetArea(data) {
+            const paramsData = {
+                userId: this.userInfo().id
+            };
+            getAction(urlAcount + '/finance/cwjsPolicyInfo/queryAeraByUserId', paramsData).then(result => {
+                if (result.code === 0) {
+                    const defaultList = result.result[0].UserCompany;
+                    this.saleShowOption = defaultList;
+                    this.addAreaList = defaultList[0].nickName.split(',');
+                    this.addSubjectList = result.result[0].companySubjects;
+                }
+                else {
+                    this.$message.error(result.message);
+                }
+            }).catch(error => {
+                console.log(error, 'eeee');
+            });
+        },
         handleExamineAll(data) {
             const paramsData = {
                 id: data.id,
@@ -791,7 +862,7 @@ export default {
                 userId: this.userInfo().id,
                 approvalContent: data.value
             };
-            getAction('http://192.168.1.8:9999/finance/cwjsPolicyInfo/policyApproval', paramsData).then(result => {
+            getAction(urlAcount + '/finance/cwjsPolicyInfo/policyApproval', paramsData).then(result => {
                 if (result.code === 0) {
                     this.rejectAuditStatus = false;
                     this.auditPolicyStatus = false;
@@ -810,7 +881,7 @@ export default {
             const paramsData = {
                 userId: this.userInfo().id
             };
-            getAction('http://192.168.1.8:9999/finance/cwjsPolicyInfo/getAllSaleList', paramsData).then(result => {
+            getAction(urlAcount + '/finance/cwjsPolicyInfo/getAllSaleList', paramsData).then(result => {
                 if (result.code === 200) {
                     this.allSaleListOption = result.result;
                 }
@@ -840,11 +911,12 @@ export default {
                 pageNo: this.tablePag.page,
                 pageSize: this.tablePag.size
             };
-            getAction('http://192.168.1.8:9999/finance/cwjsPolicyInfo/list', paramsData).then(result => {
+            getAction(urlAcount + '/finance/cwjsPolicyInfo/list', paramsData).then(result => {
                 if (result.code === 0) {
                     let defaultList = result.result.list;
                     defaultList.forEach(item => {
                         item.updatePolicyProductName = item.policyProductName.join(',');
+                        item.remarks = item.remarks ? item.remarks : '-';
                         item.updateOperation = item.operation.split('|');
                         item.updateMediaType = this.creativeMediaOptions.filter(val => val.id === item.mediaType)[0].name;
                         item.updateRebateType = this.creativeRebateOptions.filter(val => val.id === item.rebateType)[0].name;
@@ -909,11 +981,9 @@ export default {
         },
         handleAddOrigin() {
             const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
-            this.$nextTick(() => {
-                this.policyOperationForm.defaultFormList.push({
-                    id: randomNum,
-                    value: ''
-                });
+            this.policyOperationForm.defaultFormList.push({
+                id: randomNum,
+                value: ''
             });
         },
         handleDelOrigin(list) {
@@ -923,12 +993,21 @@ export default {
             let formData = this.policyOperationForm.defaultFormList;
             this.policyOperationForm.defaultFormList = formData.filter(item => list.id !== item.id);
         },
+        handleIsDianPayChange(e) {
+            if (e.target.value === 0) {
+                this.policyOperationForm.dianPayCompanyName = '';
+                this.policyOperationForm.dianPayCompanyRebateRate = '';
+            }
+        },
         handlePrepaidNotChange(e) {
-            if (e.target.value === 'a') {
-                this.policyOperationForm.name14 = undefined;
+            if (e.target.value === 1) {
+                this.policyOperationForm.accountingPeriod = '';
+                this.policyOperationForm.dianPayCompanyName = '';
+                this.policyOperationForm.dianPayCompanyRebateRate = '';
+                this.policyOperationForm.isDianPay = undefined;
             }
-            else if (e.target.value === 'b') {
-                this.policyOperationForm.name14 = 'a';
+            else if (e.target.value === 0) {
+                this.policyOperationForm.isDianPay = 1;
             }
         },
         handleExportRules(value, min, max, callback) {
@@ -958,9 +1037,24 @@ export default {
             };
             this.handleInitTable();
         },
-        handleEditTable() {
+        // 编辑按钮操作
+        handleEditTable(list) {
             this.addType = 'edit';
             this.policyOperationStatus = true;
+            this.queryByIdList = list;
+            let changeProductName = [];
+            this.queryByIdList.policyProductName.forEach(item => {
+                const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
+                changeProductName.push({
+                    id: randomNum,
+                    value: item
+                });
+            });
+            const originChange = {
+                defaultFormList: changeProductName,
+                addTimes: [list.policyStartDate, list.policyEndDate]
+            };
+            this.policyOperationForm = Object.assign({}, list, originChange);
         },
         // 政策导出按钮
         handlePolicyExport() {
@@ -969,23 +1063,89 @@ export default {
         // 新增政策按钮
         handleAddAccountPolicy() {
             this.addType = 'add';
+            this.policyOperationForm.createUserId = this.saleShowOption[0].userId;
             this.policyOperationStatus = true;
         },
         // 新增政策确定按钮
         handlePolicyOperationSure() {
-            console.log('新增政策确定按钮');
+            const {companyName, advancePay, advertiserName, rebateType, mediaType, defaultFormList, addTimes, createUserId, areaInfo, companySubjectId, promotionType, groupAbbreviation, rebateRate, accountingPeriod, isDianPay, dianPayCompanyName, dianPayCompanyRebateRate, remarks, id} = this.policyOperationForm;
+            const paramsData = {
+                policyProductName: defaultFormList.map(item => item.value),
+                policyStartDate: addTimes[0],
+                policyEndDate: addTimes[1],
+                companyName,
+                advancePay,
+                advertiserName,
+                rebateType,
+                mediaType,
+                createUserId,
+                areaInfo,
+                companySubjectId,
+                promotionType,
+                groupAbbreviation,
+                rebateRate,
+                accountingPeriod,
+                isDianPay,
+                dianPayCompanyName,
+                dianPayCompanyRebateRate,
+                remarks
+            };
             this.$refs.policyOperationForm.validate(valid => {
                 if (valid) {
-                    this.policyOperationStatus = false;
+                    if (this.addType === 'add') {
+                        this.handleAddSureBtn(paramsData, '/finance/cwjsPolicyInfo/add');
+                    }
+                    else {
+                        this.handleAddSureBtn({...paramsData, id}, '/finance/cwjsPolicyInfo/edit');
+                    }
                 }
                 else {
-                    console.log('error submit!!');
                     return false;
                 }
             });
         },
+        handleAddSureBtn(data, url) {
+            postAction(urlAcount + url, data).then(result => {
+                if (result.code === 200) {
+                    this.$message.success(result.message);
+                }
+                else {
+                    this.$message.error(result.message);
+                }
+            }).catch(error => {
+                console.log(error, 'eeee');
+            }).finally(() => {
+                this.policyOperationStatus = false;
+                this.handleInitTable();
+            });
+        },
         // 新增政策取消按钮
         handlePolicyOperationCancel() {
+            this.policyOperationForm = {
+                defaultFormList: [
+                    {
+                        id: 1,
+                        value: ''
+                    }
+                ],
+                companyName: '',
+                advancePay: 1,
+                advertiserName: '',
+                rebateType: undefined,
+                mediaType: 1,
+                createUserId: undefined,
+                areaInfo: undefined,
+                companySubjectId: undefined,
+                promotionType: 1,
+                groupAbbreviation: '',
+                rebateRate: '',
+                accountingPeriod: '',
+                isDianPay: undefined,
+                dianPayCompanyName: '',
+                dianPayCompanyRebateRate: '',
+                addTimes: [],
+                remarks: ''
+            },
             this.policyOperationStatus = false;
         },
         // 审核拒绝确定按钮