Browse Source

项目设置价格

zmq 1 year ago
parent
commit
d7471c44f8

+ 2 - 1
src/api/admin/ProjectPrice.ts

@@ -2,6 +2,7 @@ import { AxiosResponse } from 'axios'
 import {
     ResultOutputCompanyDrawOutput,
     CompanyDrawInput,
+    ProjectPriceSetInput,
     pageInputProjectPriceSetPageInput,
     ResultOutputPageOutputPriceGetPageOutput,
     PageInputTenantPriceGetPageInput,
@@ -79,7 +80,7 @@ export class ProjectPriceApi<SecurityDataType = unknown> extends HttpClient<Secu
   * @request Post:/api/admin/project-price/set-project-price
   * @secure
   */
-    updateProjectPrice = (data: CompanyDrawInput, params: RequestParams = {}) =>
+    updateProjectPrice = (data: ProjectPriceSetInput, params: RequestParams = {}) =>
         this.request<AxiosResponse, any>({
             path: `/api/admin/project-price/set-project-price`,
             method: 'Post',

+ 13 - 10
src/api/admin/data-contracts.ts

@@ -5110,11 +5110,12 @@ export interface PriceGetPageOutput_Price {
   // 价格
   price?: number
   // 设价方式
-  drawPriceWay?: number, 
+  drawPriceWay?: number | null, 
   //设价比率
-  DrawRatio?: number, 
+  drawRatio?: number| null, 
   //设价金额
-  DrawPrice?: number,                    
+  drawPrice?: number | null,                    
+  effectDate?: string | null,
 }
 export interface ProjectPriceSetInput {
   /** 项目价格Id */
@@ -5151,7 +5152,7 @@ export interface CompanyDrawInput {
   /** 抽成比例 */
   drawRatio?: number
   /** 生效时间 */
-  effectDate?: string  
+  effectDate?: string  |null
 }
 /** 平台单独设价分页信息输入 */
 export interface PageInputTenantPriceGetPageInput {
@@ -5208,19 +5209,21 @@ export interface TenantPriceGetPageOutput_Price {
   // 价格
   price?: number
   // 设价方式
-  drawPriceWay?: number,
+  drawPriceWay?: number | null,
   //设价比率
-  DrawRatio?: number,
+  drawRatio?: number | null,
   //设价金额
-  DrawPrice?: number,
+  drawPrice?: number | null,
+  //生效时间
+  effectDate?: string | null,
 }
 export interface TenantDrawSetInput {
   tenatntId: number,
   projectPriceId: Number,
-  drawPriceWay: number,  
-  drawPrice: number,
+  drawPriceWay?: number|null,  
+  drawPrice?: number | null,
   /** 抽成比例 */
-  drawRatio?: number
+  drawRatio?: number | null
   /** 生效时间 */
   effectDate?: string|null
 }

+ 2 - 3
src/views/admin/banner/index.vue

@@ -61,10 +61,9 @@
 
 <script lang="ts" setup name="admin/banner/index">
 import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
-import { BannerListOutput, PageInputbannerGetPageDto } from '/@/api/admin/data-contracts'
+import { BannerListOutput, PageInputBannerGetPageDto } from '/@/api/admin/data-contracts'
 import { BannerApi } from '/@/api/admin/Banner'
 import eventBus from '/@/utils/mitt'
-import { auth } from '/@/utils/authFunction'
 
 // 引入组件
 const bannerForm = defineAsyncComponent(() => import('./components/banner-form.vue'))
@@ -83,7 +82,7 @@ const state = reactive({
   pageInput: {
     currentPage: 1,
     pageSize: 20,
-  } as PageInputbannerGetPageDto,
+  } as PageInputBannerGetPageDto,
   listData: [] as Array<BannerListOutput>,
 })
 

+ 13 - 8
src/views/admin/project/index.vue

@@ -5,20 +5,27 @@
                 <el-form-item label="项目标题">
                     <el-input v-model="state.filter.keywrods" placeholder="项目标题" />
                 </el-form-item>
+                <el-form-item label="项目状态">
+                    <el-select v-model="state.filter.status" clearable>
+                        <el-option label="待上架" value="1"></el-option>
+                        <el-option label="上架" value="2"></el-option>
+                        <el-option label="下架" value="3"></el-option>
+                        <el-option label="暂停" value="4"></el-option>
+                        <el-option label="名额已满" value="5"></el-option>                            
+                    </el-select>                    
+                </el-form-item>
                 <el-form-item>
                     <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
                     <el-button v-auth="'api:admin:project:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增
-                    </el-button>
-                    <!-- <el-button type="primary" icon="ele-Plus" @click="onAdd"> 新增
-                        </el-button> -->
+                    </el-button>                    
                 </el-form-item>
             </el-form>
         </el-card>
 
         <el-card class="my-fill mt8" shadow="never">
             <el-table v-loading="state.loading" :data="state.projectListData" row-key="id" height="'100%'"
-                style="width: 100%; height: 100%">
-                <el-table-column type="index" width="80" label="序号"></el-table-column>
+                style="width: 100%; height: 100%">                
+                <el-table-column prop="id" width="180" label="项目ID"></el-table-column>
                 <el-table-column prop="logo" label="项目图标" width="100">
                     <template #default="{ row }">
                         <el-image style="width: 50px; height: 50px" :src="row.logo"></el-image>
@@ -59,7 +66,6 @@ import { ref, reactive, onMounted,  getCurrentInstance, onBeforeMount, defineAsy
 import { ProjectListOutput, PageInputProjectGetPageDto } from '/@/api/admin/data-contracts'
 import { ProjectApi } from '/@/api/admin/project'
 import eventBus from '/@/utils/mitt'
-import { auth } from '/@/utils/authFunction'
 
 // 引入组件
 const ProjectForm = defineAsyncComponent(() => import('./components/project-form.vue'))
@@ -112,8 +118,7 @@ const onAdd = () => {
     projectFormRef.value.open()
 }
 
-const onEdit = (row: ProjectListOutput) => {
-    console.log(row);
+const onEdit = (row: ProjectListOutput) => {    
     proxy.$modal.msgError("待开发");
     // state.ProjectFormTitle = '编辑项目'
     // projectFormRef.value.open(row)

+ 9 - 14
src/views/admin/projectprice/components/company-form.vue

@@ -4,10 +4,16 @@
             :close-on-press-escape="false" width="30%">
             <el-form ref="formRef" :model="form" size="default" label-width="80px">
                 <el-row :gutter="35">
+                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+                        <p>默认分成比例</p>
+                        <p>修改所有项目默认的分成比例(抽成金额精确到小数点后一位)</p>
+                    </el-col>
                     <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                         <el-form-item label="分成比例" prop="drawRatio"
                             :rules="[{ required: true, message: '请输入分成比例', trigger: ['blur', 'change'] }]">
-                            <el-input v-model="form.drawRatio" autocomplete="off" />
+                            <el-input v-model="form.drawRatio" autocomplete="off" >
+                                <template v-slot:append>%</template>
+                            </el-input>
                         </el-form-item>
                     </el-col>                    
                     <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">                        
@@ -36,8 +42,7 @@ import { reactive, toRefs, ref } from 'vue'
 import { CompanyDrawInput } from '/@/api/admin/data-contracts'
 import { ProjectPriceApi } from '/@/api/admin/ProjectPrice'
 import eventBus from '/@/utils/mitt'
-// 引入组件
-
+import { formatDate } from '/@/utils/formatTime'
 
 
 defineProps({
@@ -73,18 +78,8 @@ const onCancel = () => {
 const onSure = () => {
     formRef.value.validate(async (valid: boolean) => {
         if (!valid) return          
-        let d = new Date(state.form.effectDate);
-        let years = d.getFullYear();
-        let month :any = d.getMonth() + 1;
-        if (month < 10)
-            month = '0' + month;
-        let date: any = d.getDate();
-        if (date < 10)
-            date = '0' + date;
-
         
-        let dn :any= years +'-'+ month + '-' + date;        
-
+        let dn= formatDate(state.form.effectDate,"YYYY-mm-dd");                
         state.form.effectDate=dn    
 
         state.sureLoading = true

+ 63 - 26
src/views/admin/projectprice/components/tenant-price.vue

@@ -12,26 +12,26 @@
                                     </el-table-column>
                                     <el-table-column prop="price" label="价格" width="100">
                                     </el-table-column>
-                                    <el-table-column label="设价方式" min-width="180">
+                                    <el-table-column label="设价" min-width="180">
                                         <template #default="{ row }">                                    
                                             <el-form :inline="true" @submit.stop.prevent>            
-                                                <el-form-item>                                                               
-                                                    <el-select placeholder="请选择" v-model="row.drawPriceWay" style="width:110px">                                                        
-                                                        <el-option label="请选择" value="0"></el-option>
-                                                        <el-option label="抽成比例" value="1"></el-option>                                                
-                                                        <el-option label="抽成金额" value="2"></el-option>                                                    
+                                                <el-form-item style="width:110px">  
+                                                    <el-select placeholder="设价方式" v-model="row.drawPriceWay" clearable>                                                                                                                
+                                                        <el-option label="抽成比例" :value="1"></el-option>                                                
+                                                        <el-option label="抽成金额" :value="2"></el-option>                                                    
                                                     </el-select>                                             
                                                 </el-form-item>
-                                                <el-form-item>                                            
-                                                    <el-input v-if="row.drawPriceWay == 2" v-model="row.drawPrice" placeholder="请输入设价信息" style="width:50px"></el-input>
-                                                    <el-input v-if="row.drawPriceWay != 2" v-model="row.drawRatio" placeholder="请输入设价信息" style="width:50px"></el-input>                                            
+                                                <el-form-item style="width:130px">                                            
+                                                    <el-input v-if="row.drawPriceWay == 2" v-model="row.drawPrice" placeholder="设价信息" >
+                                                        <template v-slot:append>元</template>
+                                                    </el-input>
+                                                    <el-input v-if="row.drawPriceWay != 2" v-model="row.drawRatio" placeholder="设价信息" >
+                                                        <template v-slot:append>%</template>
+                                                    </el-input>                                            
                                                 </el-form-item>
-                                                <el-form-item v-if="row.drawPriceWay == 2">                                            
-                                                        元
-                                                </el-form-item>
-                                                <el-form-item v-else >                                            
-                                                        %
-                                                    </el-form-item>
+                                                <el-form-item v-if="state.projectStatus!=1" style="width:140px">
+                                                    <el-date-picker v-model="row.effectDate" type="date" placeholder="生效日期"></el-date-picker>
+                                                </el-form-item>                                                                                               
                                                 <el-form-item>                                                          
                                                     <el-button type="text" @click="onSetPrice(row, props.row.id)"> 设价 </el-button>
                                                 </el-form-item>
@@ -63,9 +63,12 @@
 </template>
 
 <script lang="ts" setup name="admin/projectprice/tenantprice">
-import { reactive, toRefs, getCurrentInstance, ref } from 'vue'
+import { reactive,  getCurrentInstance } from 'vue'
 import { PageInputTenantPriceGetPageInput, TenantPriceGetPageOutput, TenantDrawSetInput } from '/@/api/admin/data-contracts'
 import { ProjectPriceApi } from '/@/api/admin/ProjectPrice'
+import { formatDate } from '/@/utils/formatTime'
+
+const { proxy } = getCurrentInstance() as any
 
 import eventBus from '/@/utils/mitt'
 
@@ -83,7 +86,8 @@ defineProps({
 const state = reactive({
     showDialog: false,
     sureLoading: false, 
-    loading: false, 
+    loading: false,
+    projectStatus:0, 
     filter: {
         projectId: 0,        
     },
@@ -99,7 +103,8 @@ const state = reactive({
 
 
 // 打开对话框
-const open = async (row: any = {}) => {    
+const open = async (row: any = {}) => {      
+    state.projectStatus = row.status;
     state.filter.projectId = row.id;
 
     onQuery();
@@ -115,30 +120,62 @@ const onQuery = async () => {
     const res = await new ProjectPriceApi().getTenantPage(state.pageInput).catch(() => {
         state.loading = false
     })
-    state.listData = res?.data?.list ?? []
+    const listData = res?.data?.list ?? []
+    for (let i = 0; i < listData.length; i++) {
+        const prices = listData[i].prices?? [];
+        for (let j = 0; j < prices.length; j++) {
+            const price = prices[j];
+            if (price.drawPriceWay == 1) {
+                price.drawPrice = null
+            } else if (price.drawPriceWay == 2) {
+                price.drawRatio = null
+            } else { 
+                price.drawPriceWay = null
+                price.drawRatio = null
+                price.drawPrice=null
+            }
+        }
+    }    
+    state.listData = listData
     state.total = res?.data?.total ?? 0
     state.loading = false
 }
 // 设价
 const onSetPrice = async (row: TenantDrawSetInput,id:number) => {
-    // state.sureLoading = true
-    row.tenatntId=id;                
-    let res = {} as any
-
-    res = await new ProjectPriceApi().updateTenantPriceSet(row, { showSuccessMessage: true }).catch(() => {
+    // state.sureLoading = true    
+    row.tenatntId = id;                
+   if (row.drawPriceWay != 1 && row.drawPriceWay != 2) {
+        proxy.$modal.alertError(`请选择设价方式!`)
+        return;
+    }
+    if ((row.drawPriceWay == 1 && row.drawRatio == null) || (row.drawPriceWay == 2 && row.drawPrice == null)) {
+        proxy.$modal.alertError(`请请输入设价信息!`)
+        return;
+    }    
+    if (state.projectStatus != 1) {
+        if (row.effectDate == null) {
+            proxy.$modal.alertError(`请输入生效日期!`)
+            return;
+        }            
+        const effectDate = formatDate(row.effectDate, "YYYY-mm-dd") 
+        row.effectDate = effectDate;                
+    }    
+    const data = row;
+
+    let res = await new ProjectPriceApi().updateTenantPriceSet(data, { showSuccessMessage: true }).catch(() => {
         // state.sureLoading = false
     })
 
     // state.sureLoading = false
 
     if (res?.success) {
-        // eventBus.emit('refreshProjectPrice')
+        eventBus.emit('refreshProjectPrice')
         // state.showDialog = false
     }
 }
 const onSizeChange = (val: number) => {
     state.pageInput.pageSize = val
-    onQuery()
+    onQuery()    
 }
 
 const onCurrentChange = (val: number) => {

+ 57 - 27
src/views/admin/projectprice/index.vue

@@ -19,30 +19,31 @@
                         <el-table :data="props.row.prices" style="width: 100%;margin-bottom: 20px;" row-key="id"                            >
                             <el-table-column prop="name" label="结算标准" width="180">
                             </el-table-column>
-                            <el-table-column prop="price" label="价格" width="180">
+                            <el-table-column prop="price" label="价格" width="160">
                             </el-table-column>
                             <el-table-column label="设价方式" min-width="180">
                                 <template #default="{ row }">                                    
                                     <el-form :inline="true" @submit.stop.prevent>            
-                                        <el-form-item>            
-                                            <el-select placeholder="请选择设价方式" v-model="row.drawPriceWay">                                                        
-                                                <el-option label="请选择设价方式" value="0"></el-option>
-                                                <el-option label="抽成比例" value="1"></el-option>                                                
-                                                <el-option label="抽成金额" value="2"></el-option>                                                    
+                                        <el-form-item style="width:120px">            
+                                            <el-select placeholder="设价方式" v-model="row.drawPriceWay" >                                                                                                        
+                                                <el-option label="抽成比例" :value="1"></el-option>                                                
+                                                <el-option label="抽成金额" :value="2"></el-option>                                                    
                                             </el-select>                                             
                                         </el-form-item>
-                                        <el-form-item>                                            
-                                            <el-input v-if="row.drawPriceWay == 2" v-model="row.drawPrice" placeholder="请输入设价信息"></el-input>
-                                            <el-input v-if="row.drawPriceWay != 2" v-model="row.drawRatio" placeholder="请输入设价信息"></el-input>                                            
+                                        <el-form-item style="width: 180px;">                                            
+                                            <el-input v-if="row.drawPriceWay == 2" v-model="row.drawPrice" placeholder="请输入设价信息">
+                                                 <template v-slot:append>元</template>
+                                            </el-input>                                            
+                                            <el-input v-if="row.drawPriceWay != 2" v-model="row.drawRatio" placeholder="请输入设价信息">
+                                                <template v-slot:append>%</template>
+                                            </el-input>                                            
+                                        </el-form-item>                                        
+                                        <el-form-item v-if="props.row.status != 1" style="width:120px">  
+                                            <el-date-picker v-model="row.effectDate" type="date" placeholder="选择日期">
+                                            </el-date-picker>                                                                                                                                      
                                         </el-form-item>
-                                        <el-form-item v-if="row.drawPriceWay==2">                                            
-                                                元
-                                        </el-form-item>
-                                        <el-form-item v-else >                                            
-                                                %
-                                            </el-form-item>
                                         <el-form-item>                                                          
-                                            <el-button type="text" @click="onSetProjectPrice(row)"> 设价 </el-button>
+                                            <el-button type="text" @click="onSetProjectPrice(row, props.row.status)"> 设价 </el-button>
                                         </el-form-item>
                                     </el-form>                                    
                                 </template>
@@ -83,11 +84,11 @@
     </div>
 </template>
 <script lang="ts" setup name="admin/projectprice">
-import { stat } from 'fs'
-import { onMounted, reactive, onBeforeMount, defineAsyncComponent, ref } from 'vue'
-import { CompanyDrawOutput,pageInputProjectPriceSetPageInput, PriceGetPageOutput } from '/@/api/admin/data-contracts'
+import { onMounted, reactive, onBeforeMount, defineAsyncComponent, ref, getCurrentInstance } from 'vue'
+import { CompanyDrawOutput,pageInputProjectPriceSetPageInput, PriceGetPageOutput, PriceGetPageOutput_Price } from '/@/api/admin/data-contracts'
 import { ProjectPriceApi } from '/@/api/admin/ProjectPrice'
 import eventBus from '/@/utils/mitt'
+const { proxy } = getCurrentInstance() as any
 
 // 引入组件
 const CompanyForm = defineAsyncComponent(() => import('./components/company-form.vue'))
@@ -100,7 +101,7 @@ const state = reactive({
     TenantPriceFormTitle:'',  
     companydraw: {         
     } as CompanyDrawOutput,    
-    loading: false,    
+    loading: false,        
     linkFormTitle: '',            
     filter: {
     },
@@ -109,7 +110,7 @@ const state = reactive({
         pageSize: 20,
     } as pageInputProjectPriceSetPageInput,
     total: 0,
-    listData: [] as Array<PriceGetPageOutput>        
+    listData: [] as Array<PriceGetPageOutput>,      
 })
 onMounted(() => { 
     onCompanyQuery();   
@@ -122,7 +123,6 @@ onMounted(() => {
     eventBus.on('refreshProjectPrice', async () => {
         onQuery()
     })
-
 })
 onBeforeMount(() => {
     eventBus.off('refreshCompanyDraw')
@@ -135,15 +135,45 @@ const onQuery = async () => {
     const res = await new ProjectPriceApi().getPricePage(state.pageInput).catch(() => {
         state.loading = false
     })
-    state.listData = res?.data?.list ?? []
+    //数据重组
+    const listData = res?.data?.list ?? [];    
+    for (let index = 0; index < listData.length; index++) {
+        const prices = listData[index]?.prices ?? [];
+        for (let j = 0; j < prices.length; j++) {
+            const price = prices[j];            
+            if (price.drawPriceWay === 1) {                 
+                price.drawPrice = null;                
+            }
+            else if (price.drawPriceWay === 2) {
+                price.drawRatio = null;
+            } else{
+                price.drawRatio = null;
+                price.drawPrice = null;
+                price.drawPriceWay = null;
+            }
+        }        
+    }
+    console.log("重组之后",listData);
+    state.listData = listData
     state.total = res?.data?.total ?? 0
     state.loading = false
 }
 //设置项目价格
-const onSetProjectPrice = async (row: any) => {    
-    // state.sureLoading = true            
-    let res = {} as any
-    
+const onSetProjectPrice = async (row: PriceGetPageOutput_Price,status:number) => {    
+    // state.sureLoading = true   
+    if (row.drawPriceWay !=1 && row.drawPriceWay != 2) { 
+        proxy.$modal.alertError(`请选择设价方式!`)
+        return;
+    }
+    if ((row.drawPriceWay == 1 && row.drawRatio==null)|| (row.drawPriceWay == 2 && row.drawPrice == null)) {
+        proxy.$modal.alertError(`请请输入设价信息!`)
+        return;
+    }
+    if (status != 1 && row.effectDate == null) {
+        proxy.$modal.alertError(`请输入生效日期!`)
+        return;
+    }  
+    let res = {} as any    
     res = await new ProjectPriceApi().updateProjectPrice(row, { showSuccessMessage: true }).catch(() => {
         // state.sureLoading = false
     })