沈丘营商办后台前端项目
wjt
2024-06-19 d5458eb28c1da630004b7679601bfd5474cd924d
src/views/infomanger/companymanger/components/exportRecord.vue
@@ -1,32 +1,155 @@
<template>
   <el-dialog title="导入记录" v-model="dialogVisible" width="1200px" append-to-body @close="closeDialog"
  >
    <el-table>
      <el-table-column label="序号"></el-table-column>
      <el-table-column label="导入文件"></el-table-column>
      <el-table-column label="导入人"></el-table-column>
      <el-table-column label="导入时间"></el-table-column>
      <el-table-column label="进度"></el-table-column>
      <el-table-column label="导入结果"></el-table-column>
      <el-table-column label="导入结果文件"></el-table-column>
    <el-table :data="recordValue" border>
      <el-table-column label="企业名(企业全称)" prop="companyName">
        <template #default="scope">
          <div class="flex-box-per">
            <el-input v-model="scope.row.companyName" @blur="checkImport(scope.row, scope.$index)"></el-input>
            <el-tooltip  v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 0)" :content="scope.row.errorList.find(item => item.index == 0).msg">
              <div class="ml5">
                <el-icon size="large" color="red" class="ml5"><CircleCloseFilled /></el-icon>
              </div>
            </el-tooltip>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="统一社会信用代码" prop="companyCode">
        <template #default="scope">
          <div class="flex-box-per">
            <el-input v-model="scope.row.companyCode"  @blur="checkImport(scope.row, scope.$index)"></el-input>
            <el-tooltip  v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 1)" :content="scope.row.errorList.find(item => item.index == 1).msg">
              <div class="ml5">
                <el-icon size="large" color="red" class="ml5"><CircleCloseFilled /></el-icon>
              </div>
            </el-tooltip>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="企业联系人" prop="companyUser">
        <template #default="scope">
          <div class="flex-box-per">
            <el-input v-model="scope.row.companyUser"  @blur="checkImport(scope.row, scope.$index)"></el-input>
            <el-tooltip  v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 2)" :content="scope.row.errorList.find(item => item.index == 2).msg">
              <div class="ml5" v-if="scope.row.errorList.length &&scope.row.errorList.find(item => item.index == 2)">
              <el-icon size="large" color="red" class="ml5"><CircleCloseFilled /></el-icon>
            </div>
            </el-tooltip>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="联系人电话" prop="companyPhone">
        <template #default="scope">
          <div class="flex-box-per">
            <el-input type="numer" :maxlength="11" v-model="scope.row.companyPhone"  @blur="checkImport(scope.row, scope.$index, 'companyPhone')"></el-input>
            <el-tooltip v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 3)" :content="scope.row.errorList.find(item => item.index == 3).msg">
              <div class="ml5">
              <el-icon size="large" color="red" class="ml5"><CircleCloseFilled /></el-icon>
            </div>
            </el-tooltip>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="企业地址" prop="companyAddress">
        <template #default="scope">
          <div class="flex-box-per">
            <el-input v-model="scope.row.companyAddress"  @blur="checkImport(scope.row, scope.$index)"></el-input>
            <el-tooltip v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 4)" :content="scope.row.errorList.find(item => item.index == 4).msg">
              <div class="ml5" v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 4)">
              <el-icon size="large" color="red" class="ml5"><CircleCloseFilled /></el-icon>
            </div>
            </el-tooltip>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="备注" prop="mark">
        <template #default="scope">
          <div class="flex-box-per">
            <el-input v-model="scope.row.mark"  @blur="checkImport(scope.row, scope.$index)"></el-input>
            <el-tooltip v-if="scope.row.errorList.length && scope.row.errorList.find(item => item.index == 5)" :content="scope.row.errorList.find(item => item.index == 5).msg">
              <div class="ml5">
              <el-icon size="large" color="red" class="ml5"><CircleCloseFilled /></el-icon>
            </div>
            </el-tooltip>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button type="primary" @click="addCompany">确 定</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup lang="ts">
import { importTemplateRecord } from '@/api/system/company/company'
import { checkImport as checkImportHttp, saveImport } from '@/api/system/company/company'
import { ElMessage} from 'element-plus'
const dialogVisible = ref(false)
const closeDialog = () => {
  dialogVisible.value = false
}
const openDialog = () => {
const emits = defineEmits()
const props = defineProps({
  recordRow: { type: Array, default: () => [] },
})
const recordValue = ref([])
watch(() => props.recordRow, (newValue) => {
  // console.log(props.recordRow)
  recordValue.value = newValue
})
function openDialog() {
  dialogVisible.value = true
}
function importTemplateRecord() {
  console.log('获取导入记录')
function closeDialog() {
  dialogVisible.value = false
}
function checkImport(row, index, item) {
  // row.companyPhone
  if(item && item == 'companyPhone') {
    if(row.companyPhone) {
      const reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/
      if(!reg.test(row.companyPhone)){
        ElMessage.error('请输入正确的手机号')
      }
    }
  }
  checkImportHttp({voList: [row]}).then(val => {
    // recordValue.value.splice(index, 1, val.data.voList[0])
    recordValue.value[index] = val.data.voList[0]
    // ElMessage.success('修改成功')
  })
}
function addCompany() {
  saveImport({voList: recordValue.value}).then(val =>{
    ElMessage.success('修改成功')
    closeDialog()
    emits('uploadList')
  })
}
defineExpose({
  openDialog,
  closeDialog
})
</script>
</script>
<style >
.dialog-footer{
  text-align: center;
}
.flex-box-per{
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.ml5{
  /* margin-left: 5px; */
  line-height: 15px;
}
</style>