|
@@ -4,7 +4,7 @@
|
|
|
<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
|
|
|
<el-form :inline="true" :model="filters">
|
|
|
<el-form-item>
|
|
|
- <el-input v-model="filters.keyName" placeholder="请输入工厂名称进行搜索" clearable></el-input>
|
|
|
+ <el-input v-model="filters.keyName" placeholder="请输入生产方名称进行搜索" clearable></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click.native="getFactory">查询</el-button>
|
|
@@ -18,8 +18,8 @@
|
|
|
<!--列表-->
|
|
|
<el-table :data="list" highlight-current-row :height="tableHeight" v-loading="listLoading" style="width: 100%;">
|
|
|
<el-table-column type="index" width="60"></el-table-column>
|
|
|
- <el-table-column prop="factoryName" label="工厂名称" width="300" sortable></el-table-column>
|
|
|
- <el-table-column prop="factoryArea" label="工厂地址" sortable></el-table-column>
|
|
|
+ <el-table-column prop="companyName" label="生产方名称" width="300" sortable></el-table-column>
|
|
|
+ <el-table-column prop="companyAddress" label="生产方地址" sortable></el-table-column>
|
|
|
<el-table-column label="操作" width="150">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button size="small" @click.native="handleEdit(scope.$index, scope.row)">编辑</el-button>
|
|
@@ -42,15 +42,15 @@
|
|
|
</el-col>
|
|
|
|
|
|
<!--新增界面-->
|
|
|
- <el-dialog title="新增工厂" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass='customWidth'>
|
|
|
- <el-form :model="addForm" label-width="100px" :rules="formRules" ref="addForm" :inline="true" class="demo-form-inline">
|
|
|
- <el-form-item label="工厂名称" prop="factoryName">
|
|
|
- <el-input v-model="addForm.factoryName" autocomplete="off" placeholder="请输入工厂名称"></el-input>
|
|
|
+ <el-dialog title="新增生产方" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass='customWidth'>
|
|
|
+ <el-form :model="addForm" label-width="100px" :rules="formRules" ref="addForm">
|
|
|
+ <el-form-item label="生产方名称" prop="factoryName">
|
|
|
+ <el-input v-model="addForm.companyName" autocomplete="off" placeholder="请输入生产方名称"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="工厂地址" prop="factoryArea">
|
|
|
- <el-input v-model="addForm.factoryArea" autocomplete="off" :change="changeFactoryArea('addContainer')" placeholder="请输入工厂地址"></el-input>
|
|
|
+ <el-form-item label="生产方地址" prop="factoryArea">
|
|
|
+ <el-input v-model="addForm.companyAddress" autocomplete="off" :change="changeFactoryArea('addContainer')" placeholder="请输入生产方地址"></el-input>
|
|
|
</el-form-item>
|
|
|
- <div id="addContainer" class="formMap" v-if="addForm.factoryArea != ''"></div>
|
|
|
+ <div id="addContainer" class="formMap"></div>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button @click.native="addFormVisible = false">取消</el-button>
|
|
@@ -59,15 +59,15 @@
|
|
|
</el-dialog>
|
|
|
|
|
|
<!--编辑界面-->
|
|
|
- <el-dialog title="编辑工厂" v-if="editFormVisible" :visible.sync="editFormVisible" :close-on-click-modal="false" customClass='customWidth'>
|
|
|
- <el-form :model="editForm" label-width="100px" :rules="formRules" ref="editForm" :inline="true" class="demo-form-inline">
|
|
|
- <el-form-item label="工厂名称" prop="factoryName">
|
|
|
- <el-input v-model="editForm.factoryName" autocomplete="off" placeholder="请输入工厂名称"></el-input>
|
|
|
+ <el-dialog title="编辑生产方" v-if="editFormVisible" :visible.sync="editFormVisible" :close-on-click-modal="false" customClass='customWidth'>
|
|
|
+ <el-form :model="editForm" label-width="100px" :rules="formRules" ref="editForm">
|
|
|
+ <el-form-item label="生产方名称" prop="factoryName">
|
|
|
+ <el-input v-model="editForm.companyName" autocomplete="off" placeholder="请输入生产方名称"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="工厂地址" prop="factoryArea">
|
|
|
- <el-input v-model="editForm.factoryArea" autocomplete="off" :change="changeFactoryArea('editContainer')" placeholder="请输入工厂地址"></el-input>
|
|
|
+ <el-form-item label="生产方地址" prop="factoryArea">
|
|
|
+ <el-input v-model="editForm.companyAddress" autocomplete="off" :change="changeFactoryArea('editContainer')" placeholder="请输入生产方地址"></el-input>
|
|
|
</el-form-item>
|
|
|
- <div id="editContainer" class="formMap" v-if="editForm.factoryArea != ''"></div>
|
|
|
+ <div id="editContainer" class="formMap"></div>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button @click.native="editFormVisible = false">取消</el-button>
|
|
@@ -78,6 +78,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import Vue from 'vue';
|
|
|
import util from '../../common/js/util'
|
|
|
|
|
|
export default {
|
|
@@ -93,22 +94,26 @@
|
|
|
listLoading: false,
|
|
|
tableHeight: 0,
|
|
|
|
|
|
- noSub: false,
|
|
|
formRules: {
|
|
|
- factoryName: [
|
|
|
- { required: true, message: '请输入公司名称', trigger: 'blur' }
|
|
|
+ companyName: [
|
|
|
+ { required: true, message: '请输入生产方名称', trigger: 'blur' }
|
|
|
],
|
|
|
- factoryArea: [
|
|
|
- { required: true, message: '请输入公司地址', trigger: 'blur' }
|
|
|
+ companyAddress: [
|
|
|
+ { required: true, message: '请输入生产方地址', trigger: 'blur' }
|
|
|
]
|
|
|
},
|
|
|
|
|
|
+ // 地图
|
|
|
+ map: '',
|
|
|
+ marker: '',
|
|
|
+
|
|
|
// 新增界面
|
|
|
addFormVisible: false,
|
|
|
addLoading: false,
|
|
|
addForm: {
|
|
|
- factoryName: '',
|
|
|
- factoryArea: '',
|
|
|
+ companyName: '',
|
|
|
+ companyType: 1,
|
|
|
+ companyAddress: '',
|
|
|
yLng: 0,
|
|
|
xLat: 0,
|
|
|
flag: 0
|
|
@@ -119,8 +124,9 @@
|
|
|
editLoading: false,
|
|
|
editForm: {
|
|
|
id: 0,
|
|
|
- factoryName: '',
|
|
|
- factoryArea: '',
|
|
|
+ companyName: '',
|
|
|
+ companyType: 1,
|
|
|
+ companyAddress: '',
|
|
|
yLng: 0,
|
|
|
xLat: 0,
|
|
|
flag: 1
|
|
@@ -139,13 +145,14 @@
|
|
|
this.getFactory();
|
|
|
},
|
|
|
|
|
|
- //获取用户列表
|
|
|
+ //获取列表
|
|
|
getFactory() {
|
|
|
this.listLoading = true;
|
|
|
- this.http.post(this.port.base.factoryList, {
|
|
|
+ this.http.post(this.port.base.companyList, {
|
|
|
keyName: this.filters.keyName,
|
|
|
pageNum: this.page,
|
|
|
- pageSize: this.size
|
|
|
+ pageSize: this.size,
|
|
|
+ companyType: 1
|
|
|
}, res => {
|
|
|
this.listLoading = false;
|
|
|
if (res.code == "ok") {
|
|
@@ -169,9 +176,9 @@
|
|
|
//地址输入切换
|
|
|
changeFactoryArea(mapId) {
|
|
|
if(mapId == "addContainer"){
|
|
|
- this.markLocation(this.addForm.factoryArea, mapId);
|
|
|
+ this.markLocation(this.addForm.companyAddress, mapId);
|
|
|
} else {
|
|
|
- this.markLocation(this.editForm.factoryArea, mapId);
|
|
|
+ this.markLocation(this.editForm.companyAddress, mapId);
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -179,61 +186,54 @@
|
|
|
//显示新增界面
|
|
|
handleAdd() {
|
|
|
this.addFormVisible = true;
|
|
|
- this.noSub = false;
|
|
|
this.addForm = {
|
|
|
- factoryName: '',
|
|
|
- factoryArea: '',
|
|
|
- yLng: 0,
|
|
|
- xLat: 0,
|
|
|
+ companyName: '',
|
|
|
+ companyType: 1,
|
|
|
+ companyAddress: '',
|
|
|
+ yLng: 116.397511,
|
|
|
+ xLat: 39.907545,
|
|
|
flag: 0
|
|
|
- };
|
|
|
+ };
|
|
|
},
|
|
|
|
|
|
//新增
|
|
|
addSubmit() {
|
|
|
this.$refs.addForm.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- if(this.noSub){
|
|
|
- this.$message({
|
|
|
- message: '定位失败!',
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.addLoading = true;
|
|
|
- this.http.post(this.port.base.addFactory, this.addForm , res => {
|
|
|
- this.addLoading = false;
|
|
|
- this.addFormVisible = false;
|
|
|
- if (res.code == "ok") {
|
|
|
- this.$message({
|
|
|
- message: '创建成功',
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- this.getFactory();
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: res.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- }
|
|
|
- }, error => {
|
|
|
- this.addLoading = false;
|
|
|
- this.addFormVisible = false;
|
|
|
+ this.addLoading = true;
|
|
|
+ this.http.post(this.port.base.addCompany, this.addForm , res => {
|
|
|
+ this.addLoading = false;
|
|
|
+ this.addFormVisible = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: '创建成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getFactory();
|
|
|
+ } else {
|
|
|
this.$message({
|
|
|
- message: error,
|
|
|
+ message: res.msg,
|
|
|
type: 'error'
|
|
|
});
|
|
|
- })
|
|
|
- }
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ this.addLoading = false;
|
|
|
+ this.addFormVisible = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
//删除
|
|
|
handleDel(index, row) {
|
|
|
- this.$confirm('确认删除该工厂吗?', '提示', {
|
|
|
+ this.$confirm('确认删除该生产方吗?', '提示', {
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- this.http.post(this.port.base.delFactory, {
|
|
|
+ this.http.post(this.port.base.delCompany, {
|
|
|
id: row.id
|
|
|
}, res => {
|
|
|
if (res.code == "ok") {
|
|
@@ -258,60 +258,98 @@
|
|
|
},
|
|
|
|
|
|
//显示编辑界面
|
|
|
- handleEdit: function (index, row) {
|
|
|
+ handleEdit(index, row) {
|
|
|
this.editFormVisible = true;
|
|
|
- this.noSub = false;
|
|
|
this.editForm = {
|
|
|
id: row.id,
|
|
|
- factoryName: row.factoryName,
|
|
|
- factoryArea: row.factoryArea,
|
|
|
- yLng: row.yLng,
|
|
|
- xLat: row.xLat,
|
|
|
+ companyName: row.companyName,
|
|
|
+ companyType: 1,
|
|
|
+ companyAddress: row.companyAddress,
|
|
|
+ yLng: row.ylng,
|
|
|
+ xLat: row.xlat,
|
|
|
flag: 1
|
|
|
};
|
|
|
},
|
|
|
|
|
|
//编辑
|
|
|
- editSubmit: function () {
|
|
|
+ editSubmit() {
|
|
|
this.$refs.editForm.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- if(this.noSub){
|
|
|
- this.$message({
|
|
|
- message: '定位失败!',
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.editLoading = true;
|
|
|
- this.http.post(this.port.base.addFactory, this.editForm , res => {
|
|
|
- this.editLoading = false;
|
|
|
- this.editFormVisible = false;
|
|
|
- if (res.code == "ok") {
|
|
|
- this.$message({
|
|
|
- message: '修改成功',
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- this.getFactory();
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: res.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- }
|
|
|
- }, error => {
|
|
|
- this.editLoading = false;
|
|
|
- this.editFormVisible = false;
|
|
|
+ this.editLoading = true;
|
|
|
+ this.http.post(this.port.base.addCompany, this.editForm , res => {
|
|
|
+ this.editLoading = false;
|
|
|
+ this.editFormVisible = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
this.$message({
|
|
|
- message: error,
|
|
|
+ message: '修改成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getFactory();
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
type: 'error'
|
|
|
});
|
|
|
- })
|
|
|
- }
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ this.editLoading = false;
|
|
|
+ this.editFormVisible = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ //获取地图
|
|
|
+ setMap(mapId) {
|
|
|
+ if(mapId == 'addContainer') {
|
|
|
+ this.map = new AMap.Map('addContainer', {
|
|
|
+ resizeEnable: true, // 允许缩放
|
|
|
+ center:[118.784333,32.041546],
|
|
|
+ zoom:10
|
|
|
+ })
|
|
|
+
|
|
|
+ this.marker = new AMap.Marker({
|
|
|
+ map: this.map,
|
|
|
+ position: new AMap.LngLat(118.784333,32.041546), // 经纬度
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.map = new AMap.Map('editContainer', {
|
|
|
+ resizeEnable: true, // 允许缩放
|
|
|
+ center:[this.editForm.yLng , this.editForm.xLat],
|
|
|
+ zoom:10
|
|
|
+ })
|
|
|
+
|
|
|
+ this.marker = new AMap.Marker({
|
|
|
+ map: this.map,
|
|
|
+ position: new AMap.LngLat(this.editForm.yLng , this.editForm.xLat), // 经纬度
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ var _this = this;
|
|
|
+ this.map.on('click', function(e) {
|
|
|
+ _this.map.remove(_this.marker);
|
|
|
+ var Lng = e.lnglat.getLng(),
|
|
|
+ Lat = e.lnglat.getLat();
|
|
|
+ if(mapId == 'addContainer') {
|
|
|
+ _this.addForm.yLng = Lng;
|
|
|
+ _this.addForm.xLat = Lat;
|
|
|
+ } else {
|
|
|
+ _this.editForm.yLng = Lng;
|
|
|
+ _this.editForm.xLat = Lat;
|
|
|
+ }
|
|
|
+ _this.marker = new AMap.Marker({
|
|
|
+ map: _this.map,
|
|
|
+ position: new AMap.LngLat(Lng , Lat), // 经纬度
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
// 获取经纬度
|
|
|
- markLocation: function(address,mapId) {
|
|
|
+ markLocation(address,mapId) {
|
|
|
var _this = this;
|
|
|
AMap.plugin('AMap.Geocoder', function() {
|
|
|
var geocoder = new AMap.Geocoder();
|
|
@@ -329,29 +367,23 @@
|
|
|
_this.editForm.yLng = lng;
|
|
|
_this.editForm.xLat = lat;
|
|
|
}
|
|
|
-
|
|
|
- // 地图实例
|
|
|
- var map = new AMap.Map(mapId, {
|
|
|
- resizeEnable: true, // 允许缩放
|
|
|
- center: [lng, lat], // 设置地图的中心点
|
|
|
- zoom: 15 // 设置地图的缩放级别,0 - 20
|
|
|
- });
|
|
|
|
|
|
// 添加标记
|
|
|
- var marker = new AMap.Marker({
|
|
|
- map: map,
|
|
|
+ _this.map.remove(_this.marker);
|
|
|
+ _this.map.setZoomAndCenter(10, [lng, lat]);
|
|
|
+ _this.marker = new AMap.Marker({
|
|
|
+ map: _this.map,
|
|
|
position: new AMap.LngLat(lng, lat), // 经纬度
|
|
|
});
|
|
|
|
|
|
+
|
|
|
} else {
|
|
|
- _this.noSub = true;
|
|
|
//console.log('定位失败!');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
created() {
|
|
|
let height = window.innerHeight;
|
|
|
this.tableHeight = height - 210;
|
|
@@ -360,7 +392,20 @@
|
|
|
that.tableHeight = window.innerHeight - 210;
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
+ watch: {
|
|
|
+ addFormVisible(val) {
|
|
|
+ if(val){
|
|
|
+ var _this = this
|
|
|
+ setTimeout(function(){ _this.setMap('addContainer'); }, 300);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editFormVisible(val) {
|
|
|
+ if(val){
|
|
|
+ var _this = this
|
|
|
+ setTimeout(function(){ _this.setMap('editContainer'); }, 300);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.getFactory();
|
|
|
}
|