zhangback
2025-11-27 d457a0f31290ba12273a51e75f6c2cc714659efc
ui/admin-ui3/src/views/tms/collectionTmsQuotePlan/index.vue
@@ -46,8 +46,40 @@
        </el-button>
      </template>
      <template #menu-before="{row}">
        <el-link size="small" type="primary" @click="goToDetail(row)"  class="link-btn" :underline="false" icon="el-icon-d-arrow-right">报价明细</el-link>
        <el-link size="small" type="primary" @click="goToDetail(row)"  class="link-btn" :underline="false" icon="el-icon-d-arrow-right">运费报价</el-link>
      </template>
      <template #items-form="scope">
        <avue-crud
            :option="{...itemsTableOption,selection: !scope.disabled}"          @selection-change="selectionChange2"
            :data="form.items" ref="itemsCrudRef"
        >
          <template #unit="{row}">
            <el-select  v-model="row.unit" :disabled="scope.disabled" placeholder="请选择计费单位">
              <el-option
                  v-for="dict in sys_unit"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              ></el-option>
            </el-select>
          </template>
          <template #price="{row}">
            <el-input v-model="row.price" :min="1" :disabled="scope.disabled" type="number" placeholder="请输入金额"></el-input>
          </template>
          <template #currency="{row}">
            <el-radio-group v-model="row.currency"  :disabled="scope.disabled">
              <el-radio
                  v-for="dict in sys_currency"
                  :key="dict.value"
                  :label="dict.value"
              >{{ dict.label }}</el-radio>
            </el-radio-group>
          </template>
        </avue-crud>
      </template>
    </avue-crud>
  </basicContainer>
</template>
@@ -63,16 +95,19 @@
  updateTmsQuotePlan
} from "@/api/tms/tmsQuotePlan";
import useCurrentInstance from "@/utils/useCurrentInstance";
import {computed, reactive, ref, toRefs} from "vue";
import {computed, reactive, ref, toRefs,nextTick} from "vue";
import {PagesInterface, PageQueryInterface} from "@/utils/globalInterface";
import {usePagePlus} from "@/hooks/usePagePlus";
import {hasPermission} from "@/utils/permissionUtils";
import {getTmsProject, listTmsProject} from "@/api/tms/tmsProject";
import router from "@/router";
import {getDicts} from "@/api/system/dict/data";
import { randomId } from "@smallwei/avue";
const {proxy} = useCurrentInstance();
const crudRef = ref();
const {sys_quotation_items,sys_unit,sys_currency} =
    proxy.useDict("sys_quotation_items","sys_unit","sys_currency");
const permissionList = computed(() => {
  return {
    addBtn: hasPermission(["tms:tmsQuotePlan:add"]),
@@ -91,8 +126,10 @@
    currentPage: 1,
  },
  selectionList: [],
  selectionList2: <any>[],
})
const {queryParams, form, page, selectionList} = toRefs(data);
const {queryParams, form, page, selectionList,selectionList2} = toRefs(data);
const option = ref({
  pageKey: 'TmsQuotePlan',
  rowKey: 'id',
@@ -236,6 +273,15 @@
      }
    },
    {
      label: '应收费用报价',
      prop: 'bjxm',
      column:{
        items:{
          label: '', labelWidth:0,span:24,
        }
      }
    },
    {
      label: '其他信息',
      prop: 'qtxx',
      column:{
@@ -339,6 +385,30 @@
  }
})
const itemsTableOption = ref({
  pageKey: 'itemsTable',
  rowKey: 'rowKey',
  header: false,
  addBtn: false,menu: false,
  column:{
    freeName:{
      label: '费用名称',
    },
    unit:{
      label: '*计量单位',
    },
    price:{
      label: '*计费金额',
    },
    currency:{
      label: '币制',
    }
  }
})
const itemsCrudRef =ref()
const {
  tableData,
  pageF,
@@ -376,11 +446,84 @@
  },
  getBeginListFunc:()=>{
    queryParams.value.planType = '0'
  },
  handleBeforeOpenFunc:(type:string)=>{
    form.value.items = [];
    if (type === 'add'){
      form.value.items = sys_quotation_items.value.map((item:any)=>{
        return { rowKey: randomId() ,freeName: item.label,unit: '次'}
      })
    }
  },
  rowSaveBegin:(row:any,loading:any)=>{
      if (selectionList2.value.length == 0){
        proxy.$modal.msgError("请至少选择一条应收费用报价项");
        loading();
        throw new Error("请至少选择一条应收费用报价项");
      }
      let filter = selectionList2.value.filter((item:any)=>{
         return !item.price || !item.currency
       });
      if (filter.length > 0){
        proxy.$modal.msgError("请填写所有必填项");
        loading();
        throw new Error("请填写所有必填项")
      }
      row.quoteItems = selectionList2.value;
  },
  rowUpdateBegin(row:any,loading:any){
    if (selectionList2.value.length == 0){
      proxy.$modal.msgError("请至少选择一条应收费用报价项");
      loading();
      throw new Error("请至少选择一条应收费用报价项");
    }
    let filter = selectionList2.value.filter((item:any)=>{
      return !item.price || !item.currency
    });
    if (filter.length > 0){
      proxy.$modal.msgError("请填写所有必填项");
      loading();
      throw new Error("请填写所有必填项")
    }
    row.quoteItems = selectionList2.value;
  },
  handleEndOpenFunc:(type:string,res:any)=>{
    if (type === 'edit'){
      selectionList2.value = (res.data.quoteItems || []).map((item:any)=>{
        item.rowKey =randomId()
        return item;
      });
      form.value.items = sys_quotation_items.value.map((item:any)=>{
        let find = selectionList2.value.find((ele:any)=>
          ele.freeName === item.label
        );
        if ( find){
          return find;
        }else{
          return { rowKey: randomId() ,freeName: item.label,unit: '次'}
        }
      })
      nextTick( ()=>{
        selectionList2.value.map((find:any)=>{
          itemsCrudRef.value.toggleRowSelection(find,true)
        })
      })
    }else{
      form.value.items = res.data.quoteItems || [];
    }
  }
})
const goToDetail = (row?:any) => {
  router.push("/basic/tmsQuoteDetail?quotePlanId=" + row.id);
  router.push("/collectionTmsQuotePlan/collectionTmsQuotePlanItem?quotePlanType=0&quotePlanId=" + row.id);
}
const selectionChange2 = (selection?: any[]) => {
  selectionList2.value = selection;
}
</script>