瀏覽代碼

提交代码

Lijy 1 年之前
父節點
當前提交
11683e3d67

+ 1 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/api.ts

@@ -4,6 +4,7 @@ export const GETSYSFILED = "/sys-dict/getListByCode";
 export const GETPERSONNEL = "/user/getSimpleActiveUserList";
 export const GETGENERATEFOEM = `/sys-form/getListByCode${MOD}`
 export const GETBUSINESSLIST = `/business-opportunity/list`
+export const UPDATEINSET = `/business-opportunity/insertAndUpdate`
 
 export const stageStatus = [
     { id: 1, name: "赢单", progress: "100%" },

+ 42 - 7
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/component/relatedProducts.vue

@@ -11,8 +11,9 @@
                 <template #default="scope">
                     <el-select v-model="productTable[scope.$index].productId" placeholder="请选择"
                         v-if="productTableIndex == scope.$index" clearable @clear="clearTableItem(scope.$index)"
-                        @change="selectChange(scope.$index, productTable[scope.$index].productName)">
-                        <el-option v-for="item in productArrar" :key="item.productId" :label="item.productName" :value="item.productId" />
+                        @change="selectChange(scope.$index, productTable[scope.$index].productId)">
+                        <el-option v-for="item in productArrar" :key="item.productId" :label="item.productName"
+                            :value="item.productId" />
                     </el-select>
                     <span v-else>{{ productTable[scope.$index].productName }}</span>
                 </template>
@@ -23,19 +24,25 @@
             <el-table-column prop="inventory" label="库存" width="80"></el-table-column>
             <el-table-column prop="sellingPrice" label="售价" width="180">
                 <template #default="scope">
-                    <el-input-number v-model="productTable[scope.$index].sellingPrice" class="mx-4" :min="0" :max="100000000" controls-position="right" v-if="productTableIndex == scope.$index" />
+                    <el-input-number @change="inputNumberChange('sellingPrice', productTable[scope.$index])"
+                        v-model="productTable[scope.$index].sellingPrice" class="mx-4" :min="0" :max="100000000"
+                        controls-position="right" v-if="productTableIndex == scope.$index" />
                     <span v-else>{{ productTable[scope.$index].sellingPrice }}</span>
                 </template>
             </el-table-column>
             <el-table-column prop="quantity" label="数量" width="180">
                 <template #default="scope">
-                    <el-input-number v-model="productTable[scope.$index].quantity" class="mx-4" :min="0" :max="100000000" controls-position="right" v-if="productTableIndex == scope.$index" />
+                    <el-input-number @change="inputNumberChange('quantity', productTable[scope.$index])"
+                        v-model="productTable[scope.$index].quantity" class="mx-4" :min="0" :max="100000000"
+                        controls-position="right" v-if="productTableIndex == scope.$index" />
                     <span v-else>{{ productTable[scope.$index].quantity }}</span>
                 </template>
             </el-table-column>
             <el-table-column prop="discount" label="折扣(%)" width="180">
                 <template #default="scope">
-                    <el-input-number v-model="productTable[scope.$index].discount" class="mx-4" :min="0" :max="100" controls-position="right" v-if="productTableIndex == scope.$index" />
+                    <el-input-number @change="inputNumberChange('discount', productTable[scope.$index])"
+                        v-model="productTable[scope.$index].discount" class="mx-4" :min="0" :max="100"
+                        controls-position="right" v-if="productTableIndex == scope.$index" />
                     <span v-else>{{ productTable[scope.$index].discount }}</span>
                 </template>
             </el-table-column>
@@ -62,9 +69,20 @@ const productTable: any = ref([{}])
 const productTableIndex = ref(0) // 可以编辑索引
 const productArrar: any = ref([])
 
+type ProductTableField = 'sellingPrice' | 'quantity' | 'discount'
+
+function inputNumberChange(field: ProductTableField, row: any) {
+    const { sellingPrice, quantity, discount, price } = row
+    row.discount = field == 'sellingPrice' ? Math.round(sellingPrice / price * 100) : row.discount
+    row.sellingPrice = field == 'discount' ? Math.round(price * discount / 100) : row.sellingPrice
+    if (sellingPrice && quantity && price && discount) {
+        row.totalPrice = Math.round(Math.round(price * discount / 100) * quantity)
+    }
+}
+
 function selectChange(index: number, val: number | string) {
-    let newObj = productArrar.value.find((item: any) => item.id == val)
-    productTable.value.splice(index, 1, newObj)
+    let newObj = productArrar.value.find((item: any) => item.productId == val)
+    productTable.value.splice(index, 1, { index, ...newObj })
 }
 
 function tableRowItem(row: any) {
@@ -77,7 +95,9 @@ function tableRowClassName({ row, rowIndex, }: { row: any, rowIndex: number }) {
 }
 
 function addTableItem(index: number) {
+    productTableIndex.value = -1
     productTable.value.splice(index + 1, 0, {})
+    console.log(productTable.value)
 }
 
 function clearTableItem(index: number) {
@@ -85,13 +105,28 @@ function clearTableItem(index: number) {
 }
 
 function deteleTableItem(index: number) {
+    productTableIndex.value = -1
     productTable.value.splice(index, 1)
 }
 
+function returnData() {
+    let jsonstr = JSON.stringify(productTable.value)
+    let json = '[{"index":0}]'
+    if(jsonstr == json) {
+        return false
+    }
+    return productTable.value
+}
+
 watchEffect(() => {
     const { productTableList } = props
     productArrar.value = productTableList || []
 });
+
+defineExpose({
+    returnData
+})
+
 </script>
   
 <style lang="scss" scoped></style>

+ 47 - 19
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/index.vue

@@ -39,7 +39,7 @@
           </el-form>
         </div>
         <div class="w-full flex p-3 shadow-[0_-3px_5px_0px_rgba(0,0,0,0.2)]">
-          <El-button class="w-full">重置</El-Button>
+          <El-button class="w-full" @click="resetForm()">重置</El-Button>
           <El-button type="primary" class="w-full" @click="getBusinessTableList()">搜索</El-Button>
         </div>
       </div>
@@ -102,16 +102,18 @@
         <div class="flex justify-between items-center border-b pb-3 dialog-header">
           <h4 :id="titleId">{{ allText.newBusinessisibleText }}</h4>
           <div>
-            <el-button type="primary">保存并新建</el-button>
-            <el-button type="primary" @click="editBusiness()">保存</el-button>
+            <el-button type="primary" :loading="allLoading.newBusinessSaveLading"
+              :disabled="allLoading.businessSaveLading" @click="editBusiness(true)">保存并新建</el-button>
+            <el-button type="primary" @click="editBusiness(false)" :loading="allLoading.businessSaveLading"
+              :disabled="allLoading.newBusinessSaveLading">保存</el-button>
             <el-button @click="closeVisible('newBusinessisible')">取消</el-button>
           </div>
         </div>
       </template>
-      <div class="h-[60vh] overflow-y-auto scroll-bar">
+      <div class="h-[60vh] overflow-y-auto scroll-bar pt-3">
         <GenerateForm ref="generateForm" :data="generateFormData" />
         <div>相关产品</div>
-        <RelatedProducts :productTableList="productTableList" />
+        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList" />
       </div>
     </el-dialog>
   </div>
@@ -121,7 +123,7 @@
 import { ref, reactive, onMounted, inject } from "vue";
 import type { FormInstance, FormRules } from 'element-plus'
 import { useRouter, useRoute } from "vue-router";
-import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST } from './api'
+import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET } from './api'
 import { GETTABLELIST } from '@/pages/product/api'
 import { post, get } from "@/utils/request";
 import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate } from '@/utils/tools'
@@ -133,17 +135,18 @@ const router = useRouter()
 const globalPopup = inject<GlobalPopup>('globalPopup')
 const businessTotalTable = ref(0)
 const generateForm = ref<typeof GenerateForm>() // 自定义表单dom
+const relatedProductsRef = ref<typeof RelatedProducts>()
 const generateFormData = ref({
   config: {},
   list: []
 }) // 自定义表单数据
-const businessTable = ref([
-  { name: '商机040101', phone: '张山' }
-])
-const allLoading = reactive<AllLoadingInterface>({
-  businessTableLading: false
+const businessTable = ref([])
+const allLoading = reactive({
+  businessTableLading: false,
+  businessSaveLading: false,
+  newBusinessSaveLading: false,
 })
-const allVisible = reactive<AllVisibleInterface>({
+const allVisible = reactive({
   newBusinessisible: false,
   recycleVisible: false,
 })
@@ -170,20 +173,33 @@ const fixedData = reactive({
 const productTableList = ref([])
 
 
-function editBusiness() {
+function editBusiness(visibles: boolean) {
   generateForm.value?.getData().then((res: any) => {
-    console.log('正确')
-    console.log(res)
+    let productTableListData = relatedProductsRef?.value?.returnData()
+    let newForm = {
+      ...res,
+      expectedTransactionDate: res.expectedTransactionDate ? formatDate(new Date(res.expectedTransactionDate)) : '',
+      businessItemProductList: productTableListData ? JSON.stringify(productTableListData) : []
+    }
+    allLoading.businessSaveLading = true
+    post(UPDATEINSET, { ...newForm }).then((_res) => {
+      allVisible.newBusinessisible = visibles
+      globalPopup?.showSuccess('保存成功')
+      getBusinessTableList()
+    }).finally(() => {
+      allLoading.businessSaveLading = false
+    })
   }).catch((_err: any) => {
+    console.log(_err)
     globalPopup?.showError('请填写完整')
   })
 }
 
-function showVisible(type: keyof AllVisibleInterface) { // 显示弹窗
+function showVisible(type: keyof typeof allVisible) { // 显示弹窗
   allVisible[type] = true
 }
 
-function closeVisible(type: keyof AllVisibleInterface) {
+function closeVisible(type: keyof typeof allVisible) {
   allVisible[type] = false
 }
 
@@ -193,14 +209,25 @@ function handleClose(done: () => void) {
 
 function getBusinessTableList() {
   const formValue = getFromValue(businessOpportunityForm)
-  post(GETBUSINESSLIST, {...formValue }).then((res) => {
-    console.log(res, '<==== 返回的数据')
+  post(GETBUSINESSLIST, { ...formValue }).then((res) => {
     const { data, total } = res.data
     businessTable.value = data
     businessTotalTable.value = total
   })
 }
 
+function resetForm() {
+  let reset = {
+    startTime: getFirstDayOfMonth(new Date()),
+    endTime: formatDate(new Date()),
+    pageIndex: 1,
+    pageFrom: 10
+  }
+  let newBusinessOpportunityForm = resetFromValue(businessOpportunityForm, { ...reset })
+  Object.assign(businessOpportunityForm, newBusinessOpportunityForm)
+  getBusinessTableList()
+}
+
 async function getSystemField() {
   const systemField = getAllListByCode(['商机阶段'])
   for (let i in systemField) {
@@ -239,6 +266,7 @@ function getProductTableList() {
       productTableList.value = record.map((item: any) => {
         const { id, productName, productCode, unit, unitName, typeName, type, price, inventory } = item
         return {
+          id,
           productId: id,
           productName,
           productCode,

+ 0 - 10
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/type.d.ts

@@ -26,13 +26,3 @@ interface personnelInterface {
   phone: string;
   jobNumber: string;
 }
-
-type AllLoadingInterface = {
-  businessTableLading: boolean;
-}
-
-type AllVisibleInterface = {
-  newBusinessisible: boolean;
-  recycleVisible: boolean;
-}
-

+ 5 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -231,7 +231,11 @@
                      </div>
                 </template>
             </el-table-column>
-            <el-table-column prop="departmentName" :label="$t('subordinatedepartments')" sortable="custom" width="200" v-if="user.timeType.projectWithDept"></el-table-column>
+            <el-table-column prop="departmentName" :label="$t('subordinatedepartments')" sortable="custom" width="200" v-if="user.timeType.projectWithDept">
+                <template slot-scope="scope">
+                    <TranslationOpenDataText type='departmentName' :openid='scope.row.departmentName'></TranslationOpenDataText>
+                </template>
+            </el-table-column>
             <el-table-column prop="projectMainName" :label="$t('zhu-xiang-mu')" sortable="custom" min-width="250" v-if="user.timeType.mainProjectState == '1'">
             </el-table-column>
             <el-table-column prop="inchargerName" :label="$t('projectmanager')" sortable="custom" min-width="150">