otherFindEnterprise.vue 5.7 KB
<template>
  <div>
    <el-dialog :title="props.title" v-model="state.openDialog" width="1000px" append-to-body destroy-on-close @close="handleClose(false)">
      <el-form ref="queryForm" :model="state.queryParams" :rules="queryRules" label-position="left" label-width="80px">
        <el-row :gutter="10">
          <el-col :span="24">
            <el-form-item label="国家" prop="country">
              <el-select v-model="state.queryParams.country" placeholder="请选择国家" clearable filterable>
                <el-option v-for="(item, index) in state.countryList" :key="index" :label="item.gj" :value="item.jcCode"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="企业名称" prop="ename">
              <el-input v-model.trim="state.queryParams.ename" placeholder="请输入企业名称" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item>
              <el-button type="primary" icon="Search" v-debounceClick="()=>handleSearch()">查询</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

<!--      <el-table :data="state.tableList" style="width: 100%" @selection-change="handleSelectionChange" border v-loading="state.isLoading" class="own_table" max-height="400px">
        <el-table-column v-for="(table, index) in state.tableColumns" :key="'table'+index" :label="table.label" :prop="table.prop" :min-width="table.width">
          <template #default="scope">
            <template v-if="table.limitLength">
              {{scope.row[table.prop].substring(0, table.limitLength)}}
            </template>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="40%">
          <template #default="scope">
            <slot name="cop" :row="scope.row"></slot>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="state.total > 0"
        :total="state.total"
        :page.sync="state.queryParams.pageNum"
        :limit.sync="state.queryParams.pageSize"
        @pagination="getList"
      />-->

    </el-dialog>
  </div>
</template>

<script setup lang="ts">
  import * as api from '../interface/api.ts'
  import { loginMain } from '../store'
  import { storeToRefs } from 'pinia';
  import router from "../router";
  let loginAct = loginMain()
  let { getStoreToken, getUserInfo } = storeToRefs(loginAct)

  let queryForm = ref<FormInstance>()
  const emit = defineEmits(["handleClose"]);

  let props = defineProps({
    title: {
      default: "",
      type: String
    },
    open: {
      default: false,
      type: Boolean
    },
    openName: {
      type: String,
      required: true,
      default: ""
    },
  })

  let state = reactive( {
    openDialog: false,
    // 选中数组
    ids: [],
    // 非单个禁用
    single: true,
    // 非多个禁用
    multiple: true,
    tableList: [],
  // { "regStatus": "存续", "estiblishTime": "1995-12-25 00:00:00.0", "regCapital": "120000万人民币", "companyType": 1, "matchType": "公司名称匹配", "type": 1, "legalPersonName": "王晓秋", "regNumber": "310115400033897", "creditCode": "913101156073392545", "name": "联合汽车电子有限公司", "id": 466517252, "orgNumber": "60733925-4", "base": "上海" }
    isLoading: false,
    total: 0,
    queryParams: {
      pageNum: 1,
      pageSize: 10,
      ename: null,
      country: null,
    },
    tableColumns: [
      {
        label: "企业名称",
        prop: "name"
      },{
        label: "统一信用代码",
        prop: "creditCode",
        width: "55%"
      },{
        label: "法定代表人",
        prop: "legalPersonName",
        width: "30%"
      },{
        label: "状态",
        prop: "regStatus",
        width: "20%"
      },{
        label: "注册资本",
        prop: "regCapital",
        width: "40%"
      },{
        label: "成立日期",
        prop: "estiblishTime",
        limitLength: 10,
        width: "33%"
      },
    ],
    countryList: []
  })

  let queryRules = reactive<FormRules>({
    country: [
      { required: true, message: "国家不能为空", trigger: ["blur","change"] }
    ],
    ename: [
      { required: true, message: "企业名称不能为空", trigger: ["blur","change"] }
    ]
  })

  let handleClose = (isRefresh: boolean) => {
    emit('handleClose', props.openName, false, isRefresh)
  }

  let handleSearch = () => {
    router.push("/otherEnterpriseList?name=" + state.queryParams.ename + "&country=" + state.queryParams.country)
  }

  let handleSelectionChange = (selection: Array<any>) => {
    state.ids = selection.map((item: Object) => item.id)
    state.single = selection.length !== 1
    state.multiple = !selection.length
  }

  let getList = () => {
    queryForm.value.validate((valid: boolean, fields: Object)=> {
      if (valid) {
        state.isLoading = true
        api.searchCompany(state.queryParams).then((res: Object)=> {
          state.tableList = res.data.rows
        }).finally(()=> {
          state.isLoading = false
        })
      }
    })
  }

  let getCountryList = () => {
    api.getInfoList({},'/web/worldBox/getAllCountry').then((res: any)=> {
      state.countryList = res.data
      state.countryList.forEach((item: any)=> {
        if (item.jcCode === "CN") {
          state.countryList.splice(state.countryList.indexOf(item), 1)
        }
      })
    })
  }

  let reset = () => {
    state.queryParams.ename = null
    state.tableList = []
  }

  watchEffect(()=> {
    state.openDialog = props.open
    if (props.open) {
      reset()
      getCountryList()
    }
  })

  onMounted(()=>{
  })
</script>

<style scoped>

</style>