wujianwei
2025-12-26 ec0d0617f3bdbc4d424fdb6253a5075fbf594537
ui/admin-ui3/src/views/tms/tmsProject/index.vue
@@ -111,16 +111,85 @@
        projectCode: {
          label: '项目编号',
          display: true,
        },
        relatedCustomerId: {
          label: '关联客户',
          display: true,minWidth: 150,
          type: 'table',suffixIcon:'search',dataType:'string',
          rules: [
            {
              required: true,
              message: "项目编号不能为空", trigger: "blur"
              message: "关联客户不能为空", trigger: "change"
            }
          ],
          children:{
            border: true,
            searchMenuSpan: 5,
            column:{
              customerType: {
                label: '客户类型', minWidth: 120,
                type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/customer_type',
                search: true,
              },
              customerShortName: {
                label: '客户简称', minWidth: 130,
                search: true,
              },
              customerCode: {
                label: '客户编号',minWidth: 120,
                search: true,
              },
              contactName: {
                label: '联系人姓名',minWidth: 120,
              },
              signCompanyName: {
                label: '签约公司', minWidth: 150,
              },
            },
          },
          props:{
            label: 'customerShortName',
            value: 'id'
          },
          onLoad: ({ page, value, data }: { page: any, value: any, data: any }, callback:any) => {
            if (value){
              let id = value;
              if (Array.isArray(value)){
                id = value[0]
              }
              getTmsCustomerInfo(id).then(res=>{
                return callback(res.data||{})
              })
            }else{
              listTmsCustomerInfo({pageSize:page.pageSize,pageNum:page.currentPage,...data}).then(res=>{
                return callback({
                  total: res.total,
                  data: res.rows||[],
                })
              })
            }
          },
          change: (val: any) => {
            const table = crudRef.value?.getPropRef?.('relatedCustomerId')?.$refs?.temp;
            if (!table) return;
            let active = table.active;
            if (Array.isArray(active)) active = active[0];
            if (active) {
              Object.assign(form.value, {
                relatedCustomerId: active.id,
                relatedCustomerName: active.customerShortName,
              });
              form.value.relatedContractId = undefined;
              form.value.relatedContractName = undefined;
            }
          },
        },
        relatedContractId: {
          label: '关联合同',
          display: true,minWidth: 150,
          display: true,minWidth: 150,dataType:'string',
          type: 'table',suffixIcon:'search',
          rules: [
            {
@@ -177,7 +246,7 @@
                return callback(res.data||{})
              })
            }else{
              listTmsContract({pageSize:page.pageSize,pageNum:page.currentPage,...data}).then(res=>{
              listTmsContract({partyAId:form.value.relatedCustomerId,pageSize:page.pageSize,pageNum:page.currentPage,...data}).then(res=>{
                return callback({
                  total: res.total,
                  data: res.rows||[],
@@ -185,70 +254,21 @@
              })
            }
          }
        },
        relatedCustomerId: {
          label: '关联客户',
          display: true,minWidth: 150,
          type: 'table',suffixIcon:'search',
          rules: [
            {
              required: true,
              message: "关联客户不能为空", trigger: "change"
            }
          ],
          children:{
            border: true,
            searchMenuSpan: 5,
            column:{
              customerType: {
                label: '客户类型', minWidth: 120,
                type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/customer_type',
                search: true,
              },
              customerShortName: {
                label: '客户简称', minWidth: 130,
                search: true,
              },
              customerCode: {
                label: '客户编号',minWidth: 120,
                search: true,
              },
              contactName: {
                label: '联系人姓名',minWidth: 120,
              },
              signCompany: {
                label: '签约公司', minWidth: 150,
              },
            },
          },
          props:{
            label: 'customerShortName',
            value: 'id'
          },
          onLoad: ({ page, value, data }: { page: any, value: any, data: any }, callback:any) => {
            if (value){
              let id = value;
              if (Array.isArray(value)){
                id = value[0]
              }
              getTmsCustomerInfo(id).then(res=>{
                return callback(res.data||{})
              })
            }else{
              listTmsCustomerInfo({pageSize:page.pageSize,pageNum:page.currentPage,...data}).then(res=>{
                return callback({
                  total: res.total,
                  data: res.rows||[],
                })
              })
          change: (val: any) => {
            const table = crudRef.value?.getPropRef?.('relatedContractId')?.$refs?.temp;
            if (!table) return;
            let active = table.active;
            if (Array.isArray(active)) active = active[0];
            if (active) {
              Object.assign(form.value, {
                relatedContractId: active.id,
                relatedContractName: active.contractName,
              });
            }
          }
          },
        },
      }
    },
@@ -258,7 +278,7 @@
      column:{
        status: {
          label: '状态',dataType: 'string',
          type: 'radio', dicUrl: '/system/dict/data/type/data_status',
          type: 'radio', dicUrl: '/system/dict/data/type/project_status',
          addDisplay: false,minWidth: 150,
          editDisplay: false,
          viewDisplay: true,
@@ -328,7 +348,7 @@
    },
    status: {
      label: '状态',dataType: 'string',
      type: 'radio', dicUrl: '/system/dict/data/type/data_status',
      type: 'radio', dicUrl: '/system/dict/data/type/project_status',
      display: false,minWidth: 150,
      search: true,
    },
@@ -382,42 +402,4 @@
  }
})
onMounted(() => {
  watch(() => form.value.relatedContractId, () => {
    if (!form.value.relatedContractId){
      return;
    }
    const table = crudRef.value?.getPropRef?.('relatedContractId')?.$refs?.temp;
    if (!table) return;
    let active = table.active;
    if (Array.isArray(active)) active = active[0];
    if (active) {
      Object.assign(form.value, {
        relatedContractId: active.id,
        relatedContractName: active.contractName,
      });
    }
  });
  watch(() => form.value.relatedCustomerId, () => {
    if (!form.value.relatedCustomerId){
      return;
    }
    const table = crudRef.value?.getPropRef?.('relatedCustomerId')?.$refs?.temp;
    if (!table) return;
    let active = table.active;
    if (Array.isArray(active)) active = active[0];
    if (active) {
      Object.assign(form.value, {
        relatedCustomerId: active.id,
        relatedCustomerName: active.customerShortName,
      });
    }
  });
});
</script>