aevMobiel.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <template>
  2. <el-dialog :title="modalTitle" :visible.sync="modalVisible" :width="formLabelWidth" top="2vh" @close="handleCancel">
  3. <div class="gardenMobile">
  4. <el-tabs :tab-position="tabPosition" :stretch="true" style="height:600px;" v-model="activePlanName">
  5. <el-tab-pane label="园区基本信息" name="baseinfo" style="height:600px;overflow-y:auto;">
  6. <div class="wrap">
  7. <h3 class="title">园区基本信息</h3>
  8. <el-form label-width="80px" :model="form" :rules="rules" label-position="top" ref="baseinfo" class="gardenFrom">
  9. <el-row :gutter="20">
  10. <el-col :span="8">
  11. <el-form-item label="园区编码" prop="orchardCode">
  12. <el-input v-model="form.orchardCode" :disabled="limit.isRead"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="8">
  16. <el-form-item label="园区名称" prop="orchardName">
  17. <el-input v-model="form.orchardName" :disabled="limit.isRead"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="8">
  21. <el-form-item label="园区规模(平方米)" prop="orchardArea">
  22. <el-input v-model="form.orchardArea" :disabled="limit.isRead"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. </el-row>
  26. <el-row :gutter="20">
  27. <el-col :span="8">
  28. <el-form-item label="行业类型" prop="induType">
  29. <el-select v-model="form.induType" placeholder="请选择" :disabled="limit.isRead">
  30. <el-option v-for="item in agriTypeList" :key="item.id" :label="item.name" :disabled="limit.isRead" :value="item.id"></el-option>
  31. </el-select>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="8">
  35. <el-form-item label="人员数" prop="workerCount"><el-input v-model="form.workerCount" :disabled="limit.isRead"></el-input></el-form-item>
  36. </el-col>
  37. <el-col :span="8">
  38. <el-form-item label="建园日期">
  39. <el-date-picker
  40. :disabled="limit.isRead"
  41. v-model="form.beginDate"
  42. type="date"
  43. start-placeholder="请选择日期"
  44. value-format="yyyy-MM-dd"
  45. align="left"
  46. ></el-date-picker>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. <el-row :gutter="20">
  51. <el-col :span="8">
  52. <el-form-item label="负责人">
  53. <el-input v-model="form.leaderName" :disabled="limit.isRead"></el-input>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="8">
  57. <el-form-item label="联系方式" prop="telNo">
  58. <el-input v-model="form.telNo" :disabled="limit.isRead"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="8">
  62. <el-form-item label="海拔">
  63. <el-input v-model="form.elevation" :disabled="limit.isRead"></el-input>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. <el-row :gutter="20">
  68. <el-col :span="24">
  69. <el-form-item label="园区简介">
  70. <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="form.orchardDesc" :disabled="limit.isRead"></el-input>
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. <h3 class="title">产出管理</h3>
  75. <el-table :data="form.products" border style="width: 100%">
  76. <el-table-column type="index" width="50" label="序号" align="center"></el-table-column>
  77. <el-table-column label="产出物">
  78. <template slot-scope="scope">
  79. <span v-if="!scope.row.editing">{{ scope.row.prodName }}</span>
  80. <span v-else><el-input size="mini" placeholder="请输入内容" v-model="scope.row.prodName"></el-input></span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="产出面积(亩)">
  84. <template slot-scope="scope">
  85. <span v-if="!scope.row.editing">{{ scope.row.prodArea }}</span>
  86. <span v-else><el-input type="number" size="mini" placeholder="请输入内容" v-model="scope.row.prodArea"></el-input></span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="产量估算(公斤)">
  90. <template slot-scope="scope">
  91. <span v-if="!scope.row.editing">{{ scope.row.prodVol }}</span>
  92. <span v-else><el-input type="number" size="mini" placeholder="请输入内容" v-model="scope.row.prodVol"></el-input></span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column fixed="right" label="操作" align="center">
  96. <template slot-scope="scope">
  97. <el-button type="primary" size="mini" v-if="!scope.row.editing" :disabled="limit.isRead" icon="el-icon-edit-outline" @click="handleRowEdit(scope.$index, scope.row)">
  98. 编辑
  99. </el-button>
  100. <el-button type="primary" size="mini" v-if="scope.row.editing" :disabled="limit.isRead" icon="el-icon-success" @click="handleRowSave(scope.$index, scope.row)">
  101. 保存
  102. </el-button>
  103. <el-button size="mini" type="warning" v-if="scope.row.editing" :disabled="limit.isRead" icon="el-icon-warning" @click="handleRowCancel(scope.$index, scope.row)">
  104. 取消
  105. </el-button>
  106. <el-button size="mini" type="danger" v-if="!scope.row.editing" :disabled="limit.isRead" icon="el-icon-delete" @click="handleRowDelete(scope.$index, scope.row)">
  107. 删除
  108. </el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <a class="addCcw" @click="addProduct" v-if="!limit.isRead">
  113. <i class="el-icon-plus"></i>
  114. 新增产出物
  115. </a>
  116. </el-form>
  117. </div>
  118. </el-tab-pane>
  119. <el-tab-pane label="园区地理配置" name="mapConfig" style="height:600px;overflow-y:auto;">
  120. <div class="wrap">
  121. <h3 class="title">园区地理配置</h3>
  122. <div class="aMap">
  123. <el-card v-if="!limit.isRead" class="box-card" style="position: absolute;width:390px;top:60px;right: 30px;z-index: 9999;">
  124. <div slot="header" class="clearfix"><span>操作说明</span></div>
  125. <div>1、圆和矩形通过拖拽来绘制</div>
  126. <div>2、其他覆盖物通过点击来绘制、双击结束绘制</div>
  127. <div style="color: red;">3、右键单击图形清除绘制</div>
  128. <div style="color: red;">4、双击左键选定中心点</div>
  129. <div>
  130. <el-radio v-model="coversType" label="marker">画点</el-radio>
  131. <el-radio v-model="coversType" label="polyline">画折线</el-radio>
  132. <el-radio v-model="coversType" label="polygon">画多边形</el-radio>
  133. <el-radio v-model="coversType" label="rectangle">画矩形</el-radio>
  134. <el-radio v-model="coversType" label="circle">画圆</el-radio>
  135. </div>
  136. </el-card>
  137. <div ref="amap" style="width:100%;height:100%;position:relative;"></div>
  138. </div>
  139. <el-form label-width="80px" :model="form" :rules="rules" label-position="top" ref="mapConfig" class="gardenFrom">
  140. <el-row :gutter="20">
  141. <el-col :span="24">
  142. <el-form-item label="详细地址">
  143. <el-select
  144. v-model="citySelected.ids.provinceId"
  145. placeholder="请选择"
  146. @change="getCityList('add')">
  147. <el-option
  148. v-for="item in provinceList"
  149. :key="item.code"
  150. :label="item.name"
  151. :disabled="limit.isRead"
  152. :value="item.code"></el-option>
  153. </el-select>
  154. <el-select
  155. v-if="citySelected.ids.provinceId"
  156. v-model="citySelected.ids.cityId"
  157. placeholder="请选择"
  158. @change="getCountyList('add')">
  159. <el-option
  160. v-for="item in cityList"
  161. :key="item.code"
  162. :label="item.name"
  163. :disabled="limit.isRead"
  164. :value="item.code"></el-option>
  165. </el-select>
  166. <el-select
  167. v-if="citySelected.ids.cityId"
  168. v-model="citySelected.ids.countyId"
  169. placeholder="请选择"
  170. @change="getTownList('add')"
  171. >
  172. <el-option
  173. v-for="item in countyList"
  174. :key="item.code"
  175. :label="item.name"
  176. :disabled="limit.isRead"
  177. :value="item.code"></el-option>
  178. </el-select>
  179. <el-select
  180. v-if="citySelected.ids.countyId"
  181. v-model="citySelected.ids.townId"
  182. placeholder="请选择"
  183. @change="getAllAddress"
  184. >
  185. <el-option
  186. v-for="item in townList"
  187. :key="item.code"
  188. :label="item.name"
  189. :disabled="limit.isRead"
  190. :value="item.code"></el-option>
  191. </el-select>
  192. </el-form-item>
  193. <el-input
  194. v-model="citySelected.ids.address"
  195. placeholder="详细地址"
  196. :disabled="limit.isRead"
  197. class="address"></el-input>
  198. </el-col>
  199. </el-row>
  200. </el-form>
  201. </div>
  202. </el-tab-pane>
  203. </el-tabs>
  204. </div>
  205. <div slot="footer" class="dialog-footer">
  206. <el-button @click="submit" v-if="!limit.isRead">保 存</el-button>
  207. <el-button type="primary" v-if="!limit.isRead" @click="handelNext">{{ activePlanName == 'baseinfo' ? '下一步' : '上一步' }}</el-button>
  208. </div>
  209. </el-dialog>
  210. </template>
  211. <script>
  212. import { globalReg } from '@/api/CONST';
  213. export default {
  214. name: 'userMobiel',
  215. props: {
  216. visible: {
  217. type: Boolean,
  218. default: false
  219. },
  220. title: {
  221. type: String,
  222. default: 'title'
  223. },
  224. action: {
  225. type: String,
  226. default: 'add'
  227. },
  228. selectRow: {
  229. type: Object,
  230. default: {}
  231. }
  232. },
  233. watch: {
  234. visible(newVal, oldVal) {
  235. this.modalVisible = newVal;
  236. },
  237. title(newVal, oldVal) {
  238. this.modalTitle = newVal;
  239. },
  240. action(newVal, oldVal) {
  241. this.modalAction = newVal;
  242. },
  243. selectRow(newVal, oldVal) {
  244. this.modalSelectRow = newVal;
  245. },
  246. activePlanName(newVal,oldVal){
  247. console.log(newVal)
  248. }
  249. },
  250. data() {
  251. return {
  252. modalTitle: this.title,
  253. modalVisible: this.visible,
  254. modalAction: this.action,
  255. modalSelectRow: this.selectRow,
  256. formLabelWidth: '80%',
  257. tabPosition: 'left',
  258. activePlanName: 'baseinfo',
  259. agriTypeList: [], //涉及农业
  260. provinceList:[],
  261. cityList:[],
  262. countyList:[],
  263. townList:[],
  264. citySelected:{
  265. ids:{
  266. provinceId:'',
  267. cityId:'',
  268. countyId:'',
  269. townId:'',
  270. address:''
  271. }
  272. },
  273. limit: {
  274. isRead: false,
  275. isAdd: false
  276. },
  277. rules: {
  278. orchardCode: [
  279. { required: true, message: '园区编码不能为空!', trigger: 'blur' },
  280. { pattern: /^[0-9a-zA-Z]*$/g, message: '编码格式不正确,只能输入数字或字母!' },
  281. ],
  282. orchardName: [
  283. { required: true, message: '园区名称不能为空!', trigger: 'blur' },
  284. ],
  285. orchardArea: [
  286. { required: true, message: '园区规模不能为空!', trigger: 'blur' },
  287. { pattern: /^\d+(\.\d+)?$/, message: '园区规模格式不正确,只能输入数字和小数!' },
  288. ],
  289. induType: [
  290. { required: true, message: '行业类型不能为空!', trigger: 'blur' },
  291. ],
  292. workerCount: [
  293. { required: true, message: '人员数不能为空!', trigger: 'blur' },
  294. { pattern: /^[0-9]*$/g, message: '人员格式不正确,只能输入数字!' },
  295. ],
  296. telNo: [
  297. { required: false, validator: this.validateTel, trigger: 'blur' },
  298. ],
  299. address: [
  300. { required: true, message: '地址不能为空!', trigger: 'blur' },
  301. ]
  302. },
  303. form: {
  304. products: [],
  305. orchardBorder:[]
  306. },
  307. //覆盖物绘画类型
  308. coversType: 'polygon',
  309. mouseTool: null,
  310. overlaysId: [],
  311. path:[],
  312. };
  313. },
  314. created() {
  315. this.getAgriType()
  316. this.getProvince() //城市初始化
  317. switch (this.modalAction) {
  318. case 'add':
  319. this.limit.isAdd = true;
  320. break;
  321. case 'edit':
  322. this.getDetail(this.modalSelectRow.id);
  323. break;
  324. case 'view':
  325. this.getDetail(this.modalSelectRow.id);
  326. this.limit.isRead = true;
  327. break;
  328. default:
  329. break;
  330. }
  331. },
  332. mounted() {
  333. this.initmap();
  334. },
  335. watch: {
  336. coversType(n, v) {
  337. this.mouseTool[n]();
  338. }
  339. },
  340. methods: {
  341. //获取省
  342. getProvince(){
  343. this.$port.getProvince()
  344. .then(res=>{
  345. this.provinceList = res.list
  346. })
  347. },
  348. //获取市
  349. getCityList(status){
  350. if(status === 'add'){
  351. this.reSelCityAll()
  352. }
  353. let params = {
  354. id:this.citySelected.ids.provinceId
  355. }
  356. this.$port.getCity(params)
  357. .then(res=>{
  358. this.cityList = res.list
  359. })
  360. },
  361. //获取县区
  362. getCountyList(status){
  363. if(status === 'add'){
  364. this.citySelected.ids.countyId = ''
  365. this.citySelected.ids.townId = ''
  366. }
  367. let params = {
  368. id:this.citySelected.ids.cityId
  369. }
  370. this.$port.getCounty(params)
  371. .then(res=>{
  372. this.countyList = res.list
  373. })
  374. },
  375. //获取乡镇
  376. getTownList(status){
  377. if(status === 'add'){
  378. this.citySelected.ids.townId = ''
  379. }
  380. let params = {
  381. id:this.citySelected.ids.countyId
  382. }
  383. this.$port.getTown(params)
  384. .then(res=>{
  385. this.townList = res.list
  386. })
  387. },
  388. //重置城市选中
  389. reSelCityAll(){
  390. this.citySelected.ids.cityId = ''
  391. this.citySelected.ids.countyId = ''
  392. this.citySelected.ids.townId = ''
  393. this.citySelected.ids.address = ''
  394. },
  395. //获取选中对应城市的名称
  396. findCityName(type){
  397. let arr,activeId,obj = {};
  398. switch(type){
  399. case 'province':
  400. arr = this.provinceList
  401. activeId = this.citySelected.ids.provinceId
  402. break;
  403. case 'city':
  404. arr = this.cityList
  405. activeId = this.citySelected.ids.cityId
  406. break;
  407. case 'county':
  408. arr = this.countyList
  409. activeId = this.citySelected.ids.countyId
  410. break;
  411. case 'townList':
  412. arr = this.townList
  413. activeId = this.citySelected.ids.townId
  414. default:
  415. }
  416. obj = arr.find((item)=>{
  417. return item.code === activeId
  418. })
  419. return obj.name
  420. },
  421. //获取选择全地址
  422. getAllAddress(){
  423. let str;
  424. let province = this.findCityName('province')
  425. let city = this.findCityName('city')
  426. let county = this.findCityName('county')
  427. let townList = this.findCityName('townList')
  428. str = province+city+county+townList
  429. this.setMapCenter(str)
  430. },
  431. //地图操作 -> 检索切换城市
  432. setMapCenter(data){
  433. let params = {
  434. keywords:data,
  435. key:'952c5bea7e4b38bc32e1aa3beef06130',
  436. extensions: 'all'
  437. }
  438. this.$port.serachAmap(params)
  439. .then(res=>{
  440. if(res.data.status == 1){
  441. let center = res.data.pois[0].location.split(',');
  442. let [lng,lat] = center
  443. let position = new AMap.LngLat(lng,lat);
  444. this.mapObject.setZoomAndCenter(15, position);
  445. this.setAmapArea(this.path)
  446. }else{
  447. console.log("请求失败,请注意!")
  448. }
  449. })
  450. },
  451. //获取行业类型
  452. getAgriType() {
  453. this.$port.getAgriTypeList().then(res => {
  454. this.agriTypeList = res.list;
  455. });
  456. },
  457. //地图组件初始化
  458. initmap() {
  459. this.getAMap().then(res => {
  460. this.mapObject = new AMap.Map(res, {
  461. layers: [new AMap.TileLayer.RoadNet()],
  462. resizeEnable: true, //是否监控地图容器尺寸变化
  463. zoom: 13 //初始化地图层级
  464. });
  465. AMap.plugin('AMap.ToolBar', () => {
  466. this.mapObject.addControl(
  467. new AMap.ToolBar()
  468. );
  469. });
  470. //异步加载鼠标工具插件
  471. AMap.plugin('AMap.MouseTool', () => {
  472. //添加轮廓绘画工具
  473. this.mouseTool = new AMap.MouseTool(this.mapObject);
  474. //监听draw事件可获取画好的覆盖物
  475. if(!this.limit.isRead){
  476. this.mouseTool.on('draw', e => {
  477. const type = e.obj.CLASS_NAME.split('.')[1],
  478. id = e.obj._amap_id;
  479. switch (type) {
  480. case 'Marker':
  481. const position = e.obj.getPosition();
  482. this.path.push({
  483. id,
  484. type,
  485. position
  486. });
  487. break;
  488. case 'Circle':
  489. //获取中心
  490. const center = e.obj.getCenter(),
  491. //获取半径
  492. radius = e.obj.getRadius();
  493. this.path.push({
  494. id,
  495. type,
  496. center,
  497. radius,
  498. });
  499. break;
  500. case 'Polygon':
  501. case 'Polyline':
  502. const path = e.obj.getPath().map(x => {
  503. return [x.lng, x.lat];
  504. });
  505. this.path.push({
  506. id,
  507. type,
  508. path,
  509. });
  510. break;
  511. }
  512. this.overlaysId.push(id);
  513. //对画好的覆盖物绑定事件
  514. e.obj.on('rightclick', e => {
  515. if(!this.limit.isRead){
  516. this.mapObject.remove(e.target);
  517. const idIndex = this.overlaysId.indexOf(id);
  518. idIndex > -1 && this.path.splice(idIndex, 1);
  519. idIndex > -1 && this.overlaysId.splice(idIndex, 1);
  520. }
  521. });
  522. });
  523. this.mouseTool[this.coversType]();
  524. }
  525. });
  526. });
  527. },
  528. getAMap(i = 0) {
  529. if (this.$refs.amap) {
  530. return new Promise(r => {
  531. r(this.$refs.amap);
  532. });
  533. } else if (i < 5) {
  534. return new Promise(r => {
  535. setTimeout(() => {
  536. r(this.getAMap(i++));
  537. }, 500);
  538. });
  539. }
  540. },
  541. //回填地图边界
  542. setAmapArea(data){
  543. //同步数据ID
  544. const fgw = data.map((x, i) => {
  545. const id = x.id || i;
  546. this.overlaysId.includes(id) || this.overlaysId.push(id);
  547. let m = null;
  548. switch (x.type) {
  549. case 'Marker':
  550. m = new AMap[x.type]({
  551. position: x.position,
  552. icon: x.icon
  553. });
  554. break;
  555. case 'Circle':
  556. m = new AMap[x.type]({
  557. center: { ...x.center },
  558. radius: x.radius,
  559. ...x.style
  560. });
  561. break;
  562. case 'Polygon':
  563. case 'Polyline':
  564. m = new AMap[x.type]({
  565. path: [...x.path],
  566. ...x.style
  567. });
  568. break;
  569. }
  570. m && m.on('rightclick', e => {
  571. if(!this.limit.isRead){
  572. this.mapObject.remove(e.target);
  573. const idIndex = this.overlaysId.indexOf(id);
  574. idIndex > -1 && this.path.splice(idIndex, 1);
  575. idIndex > -1 && this.overlaysId.splice(idIndex, 1);
  576. }
  577. });
  578. m && this.mapObject.add(m);
  579. return m;
  580. });
  581. },
  582. //获取园区详情
  583. getDetail(id) {
  584. let params = {
  585. id: id
  586. };
  587. this.$port.getOrchard(params).then(res => {
  588. this.form = Object.assign({},res)
  589. // let timerArr = [this.form.beginDate]
  590. // this.form.createData = timerArr
  591. this.path = JSON.parse(this.form.orchardBorder)
  592. this.citySelected.ids['provinceId'] = this.form.provinceId
  593. this.citySelected.ids['cityId'] = this.form.cityId
  594. this.citySelected.ids['countyId'] = this.form.countyId
  595. this.citySelected.ids['townId'] = this.form.townId
  596. this.citySelected.ids['address'] = this.form.address
  597. this.getCityList();
  598. this.getCountyList();
  599. this.getTownList();
  600. setTimeout(()=>{
  601. this.getAllAddress()
  602. },2000)
  603. });
  604. },
  605. //切换表单
  606. handelNext() {
  607. this.activePlanName = this.activePlanName === 'baseinfo' ? 'mapConfig' : 'baseinfo';
  608. },
  609. //创建产出物
  610. addProduct() {
  611. let lineData = {
  612. prodName: '',
  613. prodArea: '',
  614. prodVol: '',
  615. editing: true
  616. };
  617. this.form.products = this.form.products || [];
  618. if (this.form.products.length == 0) {
  619. this.form.products.push(lineData);
  620. } else {
  621. for (let i of this.form.products) {
  622. if (i.editing) return this.$message.warning('请先保存当前编辑项目!');
  623. }
  624. this.form.products.push(lineData);
  625. }
  626. },
  627. //确定产出物
  628. handleRowSave($index, row) {
  629. this.$set(this.form.products[$index], 'editing', false);
  630. },
  631. //编辑产出物
  632. handleRowEdit($index, row) {
  633. this.$set(this.form.products[$index], 'editing', true);
  634. },
  635. //取消编辑产出物
  636. handleRowCancel($index, row) {
  637. this.$set(this.form.products[$index], 'editing', false);
  638. },
  639. //删除产出物
  640. handleRowDelete($index, row) {
  641. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  642. confirmButtonText: '确定',
  643. cancelButtonText: '取消',
  644. type: 'warning'
  645. })
  646. .then(() => {
  647. this.form.products.splice($index, 1);
  648. this.$message({
  649. type: 'success',
  650. message: '删除成功!'
  651. });
  652. })
  653. .catch(err => {
  654. this.$message({
  655. type: 'error',
  656. message: err
  657. });
  658. });
  659. },
  660. //提交前校验一把
  661. submit() {
  662. if (this.activePlanName === 'baseinfo') {
  663. this.$refs.baseinfo.validate(valid => {
  664. if (valid) {
  665. this.slUpSource();
  666. } else {
  667. return false;
  668. }
  669. });
  670. } else {
  671. // this.$refs.mapConfig.validate(valid => {
  672. // if (valid) {
  673. // console.log(this.form);
  674. // console.log(this.$refs.cityAddress.selected)
  675. this.slUpSource();
  676. // } else {
  677. // return false;
  678. // }
  679. // });
  680. }
  681. },
  682. //判断数据提交方式
  683. slUpSource() {
  684. switch (this.modalAction) {
  685. case 'add':
  686. this.add();
  687. break;
  688. case 'edit':
  689. this.update();
  690. break;
  691. default:
  692. break;
  693. }
  694. },
  695. //数据新增
  696. add() {
  697. this.form.orchardBorder = JSON.stringify(this.path)
  698. let params = Object.assign({},this.form,this.citySelected.ids)
  699. console.log(params)
  700. // if(params.createData){
  701. // params.beginDate = params.createData[0]
  702. // params.endDate = params.createData[1]
  703. // delete params.createData;
  704. // }
  705. this.$port.addOrchard(params).then(res => {
  706. if (!res.code) {
  707. this.form.id = res.id
  708. this.$message.success("操作成功!")
  709. this.handleCancel()
  710. this.$emit('closeModal',true)
  711. }
  712. });
  713. },
  714. //数据修改
  715. update() {
  716. this.form.orchardBorder = JSON.stringify(this.path)
  717. let params = Object.assign({},this.form,this.citySelected.ids)
  718. // if(params.createData){
  719. // params.beginDate = params.createData[0]
  720. // params.endDate = params.createData[1]
  721. // delete params.createData;
  722. // }
  723. this.$port.updateOrchard(params).then(res => {
  724. if (!res.code) {
  725. this.form.id = res.id
  726. this.$message.success("操作成功!")
  727. this.handleCancel()
  728. this.$emit('closeModal',true)
  729. }
  730. });
  731. },
  732. //自定义校验 -> 电话号码校验
  733. validateTel(rule, value, callback) {
  734. if (value === undefined || value === '' || value === null) {
  735. return callback();
  736. // new Error('请输入11位手机号,座机以 - 隔开')
  737. }
  738. let str = value.trim();
  739. if (globalReg.regPhone.test(str) || globalReg.regTel.test(str)) {
  740. callback();
  741. } else {
  742. callback(new Error('请输入11位手机号,座机以 - 隔开'));
  743. }
  744. callback();
  745. },
  746. //窗口关闭
  747. handleCancel() {
  748. this.$emit('closeModal', false);
  749. }
  750. }
  751. };
  752. </script>
  753. <style scoped lang="less">
  754. .gardenMobile {
  755. .wrap {
  756. width: 100%;
  757. padding: 0 15px;
  758. .title {
  759. display: block;
  760. padding: 15px 0;
  761. margin-bottom: 15px;
  762. border-bottom: 1px solid #dcdfe6;
  763. }
  764. .gardenFrom {
  765. .el-col {
  766. padding-right: 75px !important;
  767. &:last-child {
  768. padding-right: 0 !important;
  769. }
  770. }
  771. }
  772. .addCcw {
  773. display: block;
  774. cursor: pointer;
  775. margin-top: 15px;
  776. border: 1px dashed #ddd;
  777. padding: 13px 0;
  778. text-align: center;
  779. &:hover {
  780. border-color: #409eff;
  781. color: #409eff;
  782. }
  783. }
  784. .aMap {
  785. width: 100%;
  786. height: 350px;
  787. margin-bottom: 20px;
  788. background: #ddd;
  789. }
  790. }
  791. }
  792. .amap-maps .amap-icon img {
  793. width: 25px;
  794. height: 34px;
  795. }
  796. </style>