|
@@ -4,6 +4,18 @@
|
|
|
<el-input v-model="con" style="width:250px"></el-input>
|
|
|
<el-button type="primary" @click="search">查询</el-button>
|
|
|
<el-button type="primary" @click="insert">新增</el-button>
|
|
|
+ <el-button type="primary">
|
|
|
+ <el-upload
|
|
|
+ class="upload-excel"
|
|
|
+ action=""
|
|
|
+ :on-change="importExcel"
|
|
|
+ :show-file-list="false"
|
|
|
+ accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
|
+ :auto-upload="false"
|
|
|
+ >
|
|
|
+ 导入Excel</el-upload
|
|
|
+ >
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
<div class="table">
|
|
|
<dilTable v-bind.sync="options">
|
|
@@ -75,6 +87,7 @@
|
|
|
remoteMethod(query, scope.row, item.prop)
|
|
|
}
|
|
|
"
|
|
|
+ @change="onChange($event, scope.row, item.prop)"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="(e, index) in getOptions(scope.row, item.prop)"
|
|
@@ -180,7 +193,8 @@ export default {
|
|
|
townData: [],
|
|
|
districtData: [],
|
|
|
districtUrl: '/api/v1/uc/getDistrictByProvince',
|
|
|
- townUrl: '/api/v1/uc/getTownByDistrict'
|
|
|
+ townUrl: '/api/v1/uc/getTownByDistrict',
|
|
|
+ directlyList: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -206,6 +220,75 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ onChange(e, row, item) {
|
|
|
+ console.log(e, row, item)
|
|
|
+ if (item == 'provinceName') {
|
|
|
+ this.onchangeProvince(e)
|
|
|
+ }
|
|
|
+ if (item == 'districtName') {
|
|
|
+ this.onchangeCity(e)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ handleSelectTable(item, row, prop) {
|
|
|
+ console.log(item, row, prop)
|
|
|
+ },
|
|
|
+ importExcel(file) {
|
|
|
+ let that = this
|
|
|
+ if (!file) {
|
|
|
+ that.$message({
|
|
|
+ message: '文件错误!',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.tableData = []
|
|
|
+ var reader = new FileReader()
|
|
|
+ var data = null
|
|
|
+ var workbook = null
|
|
|
+ //设置读取操作
|
|
|
+ reader.onload = function(e) {
|
|
|
+ data = e.target.result
|
|
|
+ workbook = XLSX.read(data, {
|
|
|
+ type: 'binary'
|
|
|
+ })
|
|
|
+ let rows = XLSX.utils.sheet_to_json(
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]
|
|
|
+ ) //只取第一页
|
|
|
+ Array.from(rows).forEach((e, index) => {
|
|
|
+ let map = {}
|
|
|
+ try {
|
|
|
+ console.log(e, 'e')
|
|
|
+ Object.keys(e).forEach(e1 => {
|
|
|
+ if (e1.includes('摘要备注')) {
|
|
|
+ map.directlySentName = e[e1]
|
|
|
+ }
|
|
|
+ if (e1.includes('省')) {
|
|
|
+ map.provinceName = e[e1]
|
|
|
+ }
|
|
|
+ if (e1.includes('市')) {
|
|
|
+ map.districtName = e[e1]
|
|
|
+ }
|
|
|
+ if (e1.includes('县')) {
|
|
|
+ map.townName = e[e1]
|
|
|
+ }
|
|
|
+ if (e1.includes('详细地址')) {
|
|
|
+ map.place = e[e1]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (es) {
|
|
|
+ that.$message.error(es.message)
|
|
|
+ }
|
|
|
+ if (Object.keys(map).length > 0) {
|
|
|
+ that.directlyList.push(map)
|
|
|
+ }
|
|
|
+ console.log(that.directlyList, 'that.directlyList')
|
|
|
+ })
|
|
|
+ that.addExcelInport()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reader.readAsBinaryString(file.raw) //以二进制方式读取
|
|
|
+ },
|
|
|
search() {
|
|
|
this.options.requestUrl =
|
|
|
'/api/v1/rms/getDirectlySentCity?apiId=528&con=' +
|
|
@@ -258,6 +341,34 @@ export default {
|
|
|
this.carrierList = res.data.data
|
|
|
})
|
|
|
},
|
|
|
+ //省改变
|
|
|
+ onchangeProvince(val) {
|
|
|
+ this.axios
|
|
|
+ .post(
|
|
|
+ '/api/v1/uc/getDistrictByProvince?addressProvince=' +
|
|
|
+ val +
|
|
|
+ '&i=' +
|
|
|
+ new Date()
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ this.districtData = res.data.data
|
|
|
+ // this.city = "";
|
|
|
+ // this.county = "";
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //市改变
|
|
|
+ onchangeCity(val) {
|
|
|
+ this.axios
|
|
|
+ .post(
|
|
|
+ '/api/v1/uc/getTownByDistrict?addressDistrict=' +
|
|
|
+ val +
|
|
|
+ '&i=' +
|
|
|
+ new Date()
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ this.townData = res.data.data
|
|
|
+ })
|
|
|
+ },
|
|
|
search() {
|
|
|
this.options.requestUrl =
|
|
|
'/api/v1/rms/getDirectlySentCity?apiId=528&con=' +
|
|
@@ -293,6 +404,36 @@ export default {
|
|
|
directlySentName: row.directlySentName
|
|
|
})
|
|
|
},
|
|
|
+ addExcelInport() {
|
|
|
+ if (this.directlyList.length == 0) {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: '数据读取错误,请检查表格'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let map = {
|
|
|
+ userName: getCookie('loginName'),
|
|
|
+ mapList: this.directlyList
|
|
|
+ }
|
|
|
+ this.axios
|
|
|
+ .post('/api/v1/rms/insertDirectlySentCityInfo', map)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.status == 'succeed') {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: res.data.data
|
|
|
+ })
|
|
|
+ this.search()
|
|
|
+ this.visible = false
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: res.data.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
makeSure() {
|
|
|
console.log(this.tableData)
|
|
|
let map = {
|