Explorar o código

添加项目页面

zmq hai 1 ano
pai
achega
a47b857f15

+ 1 - 0
.env.development

@@ -2,4 +2,5 @@
 ENV = 'development'
 
 # 本地环境接口地址
+# VITE_API_URL = 'http://localhost:8000'
 VITE_API_URL = 'http://192.144.191.50:8000'

+ 2 - 2
src/api/admin/project.ts

@@ -68,7 +68,7 @@ export class ProjectApi<SecurityDataType = unknown> extends HttpClient<SecurityD
     /**
      * No description
      *
-     * @tags tenant
+     * @tags project
      * @name Add
      * @summary 新增
      * @request POST:/api/admin/tenant/add
@@ -76,7 +76,7 @@ export class ProjectApi<SecurityDataType = unknown> extends HttpClient<SecurityD
      */
     add = (data: TenantAddInput, params: RequestParams = {}) =>
         this.request<ResultOutputInt64, any>({
-            path: `/api/admin/tenant/add`,
+            path: `/api/admin/project/add`,
             method: 'POST',
             body: data,
             secure: true,

+ 1 - 1
src/views/admin/notice/index.vue

@@ -46,7 +46,7 @@
   </div>
 </template>
 
-<script lang="ts" setup name="admin/notice">
+<script lang="ts" setup name="admin/notice/index">
 import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { NoticeGetPageOutput, PageInputNoticeGetPageDto } from '/@/api/admin/data-contracts'
 import { NoticeApi } from '/@/api/admin/Notice'

+ 94 - 54
src/views/admin/project/components/project-form.vue

@@ -8,7 +8,7 @@
       :close-on-click-modal="false"
       :close-on-press-escape="false"
       width="769px"
-    >
+    >    
       <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">
@@ -32,60 +32,57 @@
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
-            <el-form-item label="结算周期" prop="code" :rules="[{ required: true, message: '请输入结算周期', trigger: ['blur', 'change'] }]">
-              <el-input v-model="form.code" autocomplete="off" />
+            <el-form-item label="结算周期" prop="settleDay" :rules="[{ required: true, message: '请输入结算周期', trigger: ['blur', 'change'] }]">
+              <el-input v-model="form.settleDay" autocomplete="off" />
             </el-form-item>
           </el-col>          
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
-            <el-form-item label="最高佣金" prop="realName" :rules="[{ required: true, message: '请输入最高佣金', trigger: ['blur', 'change'] }]">
-              <el-input v-model="form.realName" autocomplete="off" />
+            <el-form-item label="最高佣金" prop="maxPrice" :rules="[{ required: true, message: '请输入最高佣金', trigger: ['blur', 'change'] }]">
+              <el-input v-model="form.maxPrice" autocomplete="off" />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-              <el-form-item label="项目简介" prop="realName" :rules="[{ required: true, message: '请输入最高佣金', trigger: ['blur', 'change'] }]">
-                <el-input v-model="form.description" clearable type="textarea" />
+              <el-form-item label="项目简介" prop="tips" :rules="[{ required: true, message: '请输入项目简介', trigger: ['blur', 'change'] }]">
+                <el-input v-model="form.tips" clearable type="textarea" />
               </el-form-item>
           </el-col>          
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-            <el-form-item label="项目价格" prop="realName" :rules="[{ required: true, message: '请输入最高佣金', trigger: ['blur', 'change'] }]">
-                <el-form :inline="true" ref="formPrice" :model="state.formPrice" class="demo-form-inline">
-                    <el-form-item label="结算标准">
-                      <el-input v-model="state.formPrice.name"></el-input>
+            <el-form-item label="项目价格">              
+                <el-form :inline="true" ref="PriceformRef" :model="state.formPrice" class="demo-form-inline">
+                    <el-form-item prop="name" :rules="[{ required: true, message: '请输入结算标准', trigger: ['blur', 'change'] }]">
+                      <el-input v-model="state.formPrice.name" autocomplete="off" placeholder="结算标准" ></el-input>
                     </el-form-item>
-                    <el-form-item label="价格">
-                        <el-input v-model="state.formPrice.price"></el-input>
+                    <el-form-item prop="price" :rules="[{ required: true, message: '请输入结算价格', trigger: ['blur', 'change'] },
+                     { type: 'number', message: '请结算价格为数字类型' }]">
+                        <el-input v-model.number="state.formPrice.price" autocomplete="off" placeholder="结算价格"></el-input>
                     </el-form-item>
                     <el-form-item>
-                      <el-button type="primary">添加</el-button>
+                      <el-button type="primary" @click="onPriceAdd">添加</el-button>
                     </el-form-item>
                 </el-form>
             </el-form-item>
-            <el-form-item label="" prop="realName" :rules="[{ required: true, message: '请输入最高佣金', trigger: ['blur', 'change'] }]">
-                  <el-table :data="state.form.prices" row-key="id" height="'100%'" style="width: 100%; height: 100%">
+            <el-form-item label="" prop="prices" :rules="[{ required: true, message: '请添加项目价格', trigger: ['blur', 'change'] }]">
+                <el-table :data="state.form.prices" row-key="id" height="'100%'" style="width: 100%; height: 100%">
                 <el-table-column type="index" width="80" label="序号"></el-table-column>                                
                 <el-table-column prop="name" label="结算标准" min-width="140" show-overflow-tooltip/>                  
                 <el-table-column prop="price" label="价格" width="100" show-overflow-tooltip/>                
-                <!-- <el-table-column label="操作" width="140" header-align="center" align="center" fixed="right">
-                    <template #default="{ row }">
-                        <el-button v-auth="'api:admin:tenant:update'" icon="ele-EditPen" size="small" text type="primary"                            
-                            >删除</el-button>                        
+                <el-table-column label="操作" width="140" header-align="center" align="center" fixed="right">
+                    <template #default="{row}">
+                        <el-button size="small" text type="primary" @click="onPriceDelete(row)">删除</el-button>                        
                     </template>
-                </el-table-column> -->
+                </el-table-column>
             </el-table>
-              </el-form-item>
-            
-          </el-col>
-
-
-                        
-
+              </el-form-item>            
+          </el-col>                        
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-            <el-form-item label="项目详情">
-              <el-input v-model="form.description" clearable type="textarea" />
+            <el-form-item label="项目详情" prop="detail" :rules="[{ required: true, message: '请输入项目详请', trigger: ['blur', 'change'] }]">
+              <!-- <el-input v-model="form.description" clearable type="textarea" /> -->
+              <Editor v-model:get-html="state.editor.htmlVal" v-model:get-text="state.editor.textVal" :disable="state.editor.disable" />
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
+      
       <template #footer>
         <span class="dialog-footer">
           <el-button @click="onCancel" size="default">取 消</el-button>
@@ -97,18 +94,22 @@
 </template>
 
 <script lang="ts" setup name="admin/project/form">
-import { reactive, toRefs, getCurrentInstance, ref, computed } from 'vue'
+import { reactive, toRefs, getCurrentInstance, ref, computed, defineAsyncComponent } from 'vue'
 import { ProjectAddInput, TenantUpdateInput } from '/@/api/admin/data-contracts'
 import { ProjectApi } from '/@/api/admin/project'
- import type { UploadInstance, UploadProps, UploadFile } from 'element-plus'
+import type { UploadInstance, UploadProps, UploadFile } from 'element-plus'
 import eventBus from '/@/utils/mitt'
 import { ElMessage } from 'element-plus'
 import { useUserInfo } from '/@/stores/userInfo'
 
+// 引入组件
+const Editor = defineAsyncComponent(()=> import("/@/components/editor/index.vue") )
+
 const storesUserInfo = useUserInfo()
 
 const uploadRef = ref<UploadInstance>()
 
+
 defineProps({
   title: {
     type: String,
@@ -119,6 +120,8 @@ defineProps({
 const { proxy } = getCurrentInstance() as any
 
 const formRef = ref()
+const PriceformRef = ref()
+
 const state = reactive({  
   showDialog: false,
   sureLoading: false,  
@@ -126,24 +129,23 @@ const state = reactive({
   fileList: [] as UploadFile[],
   fileDirectory:'project',
   token: storesUserInfo.getToken(),
-  formPrice: {
+  formPrice: {    
     name: "",
     price:""
-  }
+  },
+  editor: {
+    htmlVal: '',
+    textVal: '',
+    disable: false,
+  }, numberValidateForm: {
+    age: ''
+  }  
 })
 const { form } = toRefs(state)
 
-// const getPkgs = async () => {
-//   const res = await new PkgApi().getList().catch(() => {
-//     state.pkgData = []
-//   })
-
-//   state.pkgData = res?.data ?? []
-// }
 
 // 打开对话框
-const open = async (row: any = {}) => {
-  // await getPkgs()
+const open = async (row: any = {}) => {  
 
   if (row.id > 0) {
     const res = await new ProjectApi().get({ id: row.id }, { loading: true }).catch(() => {
@@ -154,18 +156,54 @@ const open = async (row: any = {}) => {
       state.form = res.data as ProjectAddInput & TenantUpdateInput
     }
   } else {
-    state.form = { pkgIds: [] as number[], enabled: true } as ProjectAddInput & TenantUpdateInput
+    state.form = {  } as ProjectAddInput & TenantUpdateInput
   }
   state.showDialog = true
 }
+// 价格添加按钮
+const onPriceAdd = () => {     
+  PriceformRef.value.validate(async (valid: boolean) => {    
+    if (!valid) return
 
-// //手机号失去焦点
-// const onBlurMobile = () => {
-//   if (!state.form.userName && state.form.phone && isMobile(state.form.phone)) {
-//     state.form.userName = state.form.phone
-//   }
-// }
-
+    if (state.form.prices == undefined) {
+      state.form.prices = [];
+    }
+    let pri: unknown  = state.formPrice.price;
+    var price =  {name:state.formPrice.name,price:pri as number};
+    if (state.form.prices.length != 0) {
+      for (let i = 0; i < state.form.prices.length; i++) {
+        const element = state.form.prices[i];
+        if (element.name === price.name) {
+          proxy.$modal.alertError(`该结算标准已存在!`)
+          return;
+        }
+      }
+    }
+    state.form.prices.push(price);
+    state.formPrice.name = '';
+    state.formPrice.price = '';
+  });
+}
+//价格删除按钮
+const onPriceDelete = (row: any) => {  
+    
+    proxy.$modal
+        .confirmDelete(`确定要删除【${row.name}】?`)
+      .then(async () => {
+        // state.form.prices = [];
+          const pricenew = [];
+          const prices = state.form.prices;
+          for (let i = 0; i < prices.length; i++) {
+            const element = prices[i];            
+            if (element != row.name && element.price != row.price) {                         
+              pricenew.push(element);
+            }            
+          }        
+          state.form.prices = [];
+          state.form.prices = pricenew;
+        })
+        .catch(() => { })
+}
 // 取消
 const onCancel = () => {
   state.showDialog = false
@@ -173,7 +211,9 @@ const onCancel = () => {
 
 // 确定
 const onSure = () => {
-  formRef.value.validate(async (valid: boolean) => {
+  state.form.detail = state.editor.htmlVal;
+  
+  formRef.value.validate(async (valid: boolean) => {    
     if (!valid) return
 
     state.sureLoading = true
@@ -190,7 +230,7 @@ const onSure = () => {
     state.sureLoading = false
 
     if (res?.success) {
-      eventBus.emit('refreshTenant')
+      eventBus.emit('refreshProject')
       state.showDialog = false
     }
   })
@@ -249,7 +289,7 @@ const onError: UploadProps['onError'] = (error) => {
 //     // this.$message.success('设置成功');
 //     value.kpi.edit = false;
 //   }
-// }    
+// }   
 
 defineExpose({
   open,

+ 0 - 176
src/views/admin/project/components/project-select.vue

@@ -1,176 +0,0 @@
-<template>
-  <el-dialog
-    v-model="state.showDialog"
-    destroy-on-close
-    :title="title"
-    append-to-body
-    draggable
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    width="780px"
-  >
-    <div style="padding: 0px 0px 8px 8px; background-color: var(--ba-bg-color)">
-      <el-card shadow="never" :body-style="{ paddingBottom: '0' }" style="margin-top: 8px">
-        <el-form :model="state.filter" :inline="true" @submit.stop.prevent>
-          <el-form-item label="企业名" prop="name">
-            <el-input v-model="state.filter.name" placeholder="企业名" @keyup.enter="onQuery" />
-          </el-form-item>
-          <el-form-item>
-            <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
-          </el-form-item>
-        </el-form>
-      </el-card>
-
-      <el-card shadow="never" style="margin-top: 8px">
-        <el-table
-          ref="tenantTableRef"
-          :data="state.tenantListData"
-          style="width: 100%"
-          v-loading="state.loading"
-          row-key="id"
-          default-expand-all
-          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
-          :highlight-current-row="!multiple"
-          @row-click="onRowClick"
-          @row-dblclick="onRowDbClick"
-        >
-          <el-table-column v-if="multiple" type="selection" width="55" />
-          <el-table-column prop="name" label="企业名" min-width="80" show-overflow-tooltip />
-          <el-table-column prop="code" label="企业编码" min-width="120" show-overflow-tooltip />
-          <!-- <el-table-column prop="email" label="邮箱" min-width="120" show-overflow-tooltip /> -->
-        </el-table>
-        <div class="my-flex my-flex-end" style="margin-top: 20px">
-          <el-pagination
-            v-model:currentPage="state.pageInput.currentPage"
-            v-model:page-size="state.pageInput.pageSize"
-            :total="state.total"
-            :page-sizes="[10, 20, 50, 100]"
-            small
-            background
-            @size-change="onSizeChange"
-            @current-change="onCurrentChange"
-            layout="total, sizes, prev, pager, next"
-          />
-        </div>
-      </el-card>
-    </div>
-    <template #footer>
-      <span class="dialog-footer">
-        <el-button @click="onCancel" size="default">取 消</el-button>
-        <el-button type="primary" @click="onSure" size="default" :loading="sureLoading">确 定</el-button>
-      </span>
-    </template>
-  </el-dialog>
-</template>
-
-<script lang="ts" setup name="admin/tenant/components/tenant-select">
-import { ref, reactive } from 'vue'
-import { ElTable } from 'element-plus'
-import { TenantListOutput, PageInputTenantGetPageDto } from '/@/api/admin/data-contracts'
-import { TenantApi } from '/@/api/admin/Tenant'
-
-const props = defineProps({
-  title: {
-    type: String,
-    default: '',
-  },
-  multiple: {
-    type: Boolean,
-    default: false,
-  },
-  sureLoading: {
-    type: Boolean,
-    default: false,
-  },
-})
-
-const emits = defineEmits(['sure'])
-
-const tenantTableRef = ref<InstanceType<typeof ElTable>>()
-
-const state = reactive({
-  showDialog: false,
-  loading: false,
-  filter: {
-    name: '',
-  },
-  total: 0,
-  pageInput: {
-    currentPage: 1,
-    pageSize: 20,
-    filter: {
-      name: '',
-    },
-  } as PageInputTenantGetPageDto,
-  tenantListData: [] as Array<TenantListOutput>,
-})
-
-// 打开对话框
-const open = () => {
-  state.showDialog = true
-
-  onQuery()
-}
-
-// 关闭对话框
-const close = () => {
-  state.showDialog = false
-}
-
-const onQuery = async () => {
-  state.loading = true
-  state.pageInput.filter = state.filter
-  const res = await new TenantApi().getPage(state.pageInput).catch(() => {
-    state.loading = false
-  })
-
-  state.tenantListData = res?.data?.list ?? []
-  state.total = res?.data?.total ?? 0
-  state.loading = false
-}
-
-const onSizeChange = (val: number) => {
-  state.pageInput.pageSize = val
-  onQuery()
-}
-
-const onCurrentChange = (val: number) => {
-  state.pageInput.currentPage = val
-  onQuery()
-}
-
-const onRowClick = (row: TenantListOutput) => {
-  // TODO: improvement typing when refactor table
-  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-  // @ts-expect-error
-  tenantTableRef.value!.toggleRowSelection(row, props.multiple ? undefined : true)
-}
-
-const onRowDbClick = () => {
-  if (!props.multiple) {
-    onSure()
-  }
-}
-
-// 取消
-const onCancel = () => {
-  state.showDialog = false
-}
-
-// 确定
-const onSure = () => {
-  const selectionRows = tenantTableRef.value!.getSelectionRows() as TenantListOutput[]
-  emits('sure', props.multiple ? selectionRows : selectionRows.length > 0 ? selectionRows[0] : null)
-}
-
-defineExpose({
-  open,
-  close,
-})
-</script>
-
-<style scoped lang="scss">
-:deep(.el-dialog__body) {
-  padding: 5px 10px;
-}
-</style>

+ 3 - 1
src/views/admin/project/index.vue

@@ -7,8 +7,10 @@
                 </el-form-item>
                 <el-form-item>
                     <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
-                    <el-button v-auth="'api:admin:tenant:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增
+                    <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-form-item>
             </el-form>
         </el-card>