沈丘营商办后台前端项目
wjt
2024-07-22 225e92ed4fd01dd9be529d7f9e5e546e05a0d277
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
   <el-dialog title="导入记录" v-model="dialogVisible" width="1200px" append-to-body @close="closeDialog"
  >
    <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 { checkImport as checkImportHttp, saveImport } from '@/api/system/company/company'
import { ElMessage} from 'element-plus'
const dialogVisible = ref(false)
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 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>
<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>