浏览代码

修改问题

tangning 2 年之前
父节点
当前提交
e9e98011a4
共有 2 个文件被更改,包括 64 次插入40 次删除
  1. 5 2
      src/views/spares/spareModal.vue
  2. 59 38
      src/views/work/quoteModel.vue

+ 5 - 2
src/views/spares/spareModal.vue

@@ -178,12 +178,15 @@
         console.log('data',data)
         fileFlow.title ='新增备件类型'
         if(data.partId){
-          setFieldsValue(data)
+          setFieldsValue({
+            ...data,
+            discount:data.partPriceDiscount?1:0
+          })
           fileFlow.title ='编辑备件类型'
         }
         updateSchema({
             field: 'partPriceDiscount',
-            ifShow: data.isDiscount == 1,
+            ifShow: data.partPriceDiscount,
         });
         fileFlow.type = data.type
       }

+ 59 - 38
src/views/work/quoteModel.vue

@@ -16,7 +16,7 @@
         <template #add>
           <div>
             <!-- <Button  @click="add" style="margin-left:20px">添加人工</Button> -->
-            <Button  @click="updataRepairInfo" style="margin-left:20px">重置</Button>
+            <Button  @click="updataRepairInfo">重置</Button>
           </div>
         </template> 
         <template #del="{ field }">
@@ -25,11 +25,6 @@
         <template #delList="{ field }">
           <Button @click="del(field)">删除</Button>
         </template>
-        <template #discount="{ model, field }">
-          <Checkbox v-model:checked="model[field]">
-            折扣
-          </Checkbox>
-        </template>
       </BasicForm>
       <div class="priceCount">
         <span>合计:</span>
@@ -45,13 +40,13 @@
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { getPriceList, checkRegisterInfo, addOrUpdatePriceList, allList } from '/@/api/spares'
-  import { Checkbox } from 'ant-design-vue';
+  import { Checkbox, Button } from 'ant-design-vue';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { uploadApi } from '/@/api/product/index';
   import { RedoOutlined, } from '@ant-design/icons-vue';
   const { t } = useI18n();
   export default defineComponent({
-    components: { BasicModal, BasicForm, RedoOutlined, Checkbox },
+    components: { BasicModal, BasicForm, RedoOutlined, Checkbox, Button },
     props: {
       userData: { type: Object },
     },
@@ -122,6 +117,11 @@
             componentProps: {
               options: fileFlow.manMadeList,
               maxLength: 50,
+              onChange:(val)=>{
+                setTimeout(() => {
+                updataCount()
+              }, 100)
+              },
             },
             colProps: {
               span: 24,
@@ -189,12 +189,21 @@
         n.value++
       }
       function addPriceItem(list){
+        console.log('addPriceItem',list)
         fileFlow.priceLists = list.reverse()
         let priceSchema = [],valueObj = {},count=0
+        let manMade = []
         list.map((ele,index) => {
+          if(ele.type == 1){//人工费
+            manMade.push(ele.partId)
+            count = count + ele.count*ele.price
+          }else{//备件
+          let price = ele.discount == 1?ele.priceDiscount:ele.price
           valueObj[`priceList${ele.priceListId}`] = ele.count || 0
           valueObj[`priceListText${ele.priceListId}`] = `${ele.name} ${ele.price} 元/次`
-          count = count + ele.count*ele.price
+          valueObj[`priceList${ele.priceListId}`] = ele.count || 0
+          valueObj[`discount${ele.priceListId}`] = [0]
+          count = count + ele.count*price
           priceSchema.unshift({
             field: 'priceListText' + ele.priceListId,
             component: 'InputNumber',
@@ -209,21 +218,21 @@
           },{
             field: 'discount' + ele.priceListId,
             component: 'CheckboxGroup',
-            // label: '',
-            // labelWidth:0,
-            // labelWidth:300,
-            // subLabel:"数量",
-            slot: 'discount',
             componentProps: {
+              onChange:(val)=>{
+                setTimeout(() => {
+                updataCount()
+              }, 100)
+              },
               options: [
               {
-                label: `折扣价${ele.priceListId}`,
+                label: `折扣价 ${ele.priceDiscount}元`,
                 value: 0,
               },
             ]
             },
             colProps: {
-              span: 4,
+              span: 8,
             }
           },{
             field: 'priceList' + ele.priceListId,
@@ -235,7 +244,7 @@
             // labelWidth:300,
             // subLabel:"数量",
             colProps: {
-              span: 12,
+              span: 8,
             },
             required: true,
             componentProps: {
@@ -250,8 +259,10 @@
               }
             },
           })
+          }
         })
         fileFlow.priceCount = count.toFixed(2)
+        valueObj.manMade = manMade
         priceSchema.map(item =>{
           console.log('priceSchema',item)
           appendSchemaByField(item,'')
@@ -318,9 +329,10 @@
           onOk: async () => {
             loading.value = true
             let priceListsparams = []
-            console.log('params',params) 
+            console.log('params',n.value,fileFlow.priceLists) 
             fileFlow.priceLists.map(ele => {
-              let discount = params[`discount${ele.priceListId}`]?'1':'0';
+              let discount = params[`discount${ele.priceListId}`]?.length?1:0;
+            console.log('discount',discount) 
               priceListsparams.push({
                 priceListId:ele.priceListId,
                 type:ele.type,
@@ -330,26 +342,25 @@
                 count:params[`priceList${ele.priceListId}`],
               })
             })
-            for (let index = 1; index < n.value; index++) {
-              if(params[`device_${index}`]){
+            let manMade = params.manMade
+            fileFlow.manMadeList.map(ele => {
+              if(manMade.includes(ele.laborCostId)){
                 priceListsparams.push({
-                  // priceListId:params[`deviceType${index}`],
-                  count:params[`device_${index}`],
-                  laborId:params[`deviceType${index}`],
-                  partId:params[`deviceType${index}`],
+                  count:1,
+                  laborId:ele.laborCostId,
+                  partId:ele.laborCostId,
                   type:1,
                 })
               }
-            }
-            console.log('addOrUpdatePriceList',params,priceListsparams) 
-            // let res = await addOrUpdatePriceList({
-            //   repairId:params.repairId,
-            //   priceLists:priceListsparams,
-            // })
-            // console.log('res',res)
-            // createMessage.success(t('common.optSuccess'));
-            // closeModal();
-            // emit('update');
+            })
+            let res = await addOrUpdatePriceList({
+              repairId:params.repairId,
+              priceLists:priceListsparams,
+            })
+            console.log('res',res)
+            createMessage.success(t('common.optSuccess'));
+            closeModal();
+            emit('update');
             loading.value = false
             // clearInfo()
           },
@@ -365,9 +376,19 @@
       function updataCount(){
         let fromData = getFieldsValue() ,count = 0
         // fileFlow.priceListsPrice
-        console.log('fromData',fromData)
+        console.log('fromData',fromData,fileFlow.priceLists)
         fileFlow.priceLists.map(ele => {
-          count = count + fromData[`priceList${ele.priceListId}`]*ele.price
+          let price = Number(fromData[`discount${ele.priceListId}`]?.length?ele.priceDiscount:ele.price);
+          console.log('count',price, count)
+          if(fromData[`priceList${ele.priceListId}`]){
+            count = count + fromData[`priceList${ele.priceListId}`]*price
+          }
+        })
+        let manMade = fromData.manMade
+        fileFlow.manMadeList.map(ele => {
+          if(manMade?.includes(ele.laborCostId)){
+            count = count + Number(ele.price)
+          }
         })
         for (let index = 1; index < n.value; index++) {
           if(fromData[`deviceType${index}`] && fromData[`device_${index}`]){
@@ -387,7 +408,7 @@
         }
         let clearFiled = []
         fileFlow.priceLists.map(ele =>{
-          clearFiled.push(`priceList${ele.priceListId}`,`priceListText${ele.priceListId}`)
+          clearFiled.push(`priceList${ele.priceListId}`,`priceListText${ele.priceListId}`,`discount${ele.priceListId}`)
         })
         for (let index = 1; index < indexa; index++) {
           clearFiled.push(`deviceType${index}`, `device_${index}`, `${index}`)