baseManage.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  1. <template>
  2. <div style="cursor: default">
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item>基地管理</el-breadcrumb-item>
  5. </el-breadcrumb>
  6. <!-- <SearchBar> -->
  7. <div class="baseoperationbox">
  8. <div slot="type-check">
  9. <!-- <el-input
  10. style="cursor: pointer"
  11. placeholder="请输入基地名称"
  12. size="mini"
  13. suffix-icon="el-icon-search"
  14. v-model="search"
  15. @change="searchBase"
  16. clearable
  17. ></el-input> -->
  18. <el-button
  19. v-if="$QueryPermission(110)"
  20. v-btnRight:added="$route.path"
  21. type="primary"
  22. size="mini"
  23. @click="addBase('新增基地')"
  24. >新增</el-button
  25. >
  26. </div>
  27. <div slot="search-common" style="display: inline-block; margin: 0 5px 0 0">
  28. <!-- <el-button
  29. v-btnRight:added="$route.path"
  30. type="primary"
  31. size="mini"
  32. @click="addBase('新增基地')"
  33. >新增</el-button
  34. > -->
  35. <el-input
  36. style="cursor: pointer; width: 240px"
  37. placeholder="请输入基地名称"
  38. size="mini"
  39. suffix-icon="el-icon-search"
  40. v-model="search"
  41. @change="searchBase"
  42. clearable
  43. ></el-input>
  44. </div>
  45. </div>
  46. <!-- </SearchBar> -->
  47. <el-row :gutter="20">
  48. <el-col
  49. :xs="24"
  50. :sm="24"
  51. :md="12"
  52. :lg="8"
  53. :xl="8"
  54. class="col-item"
  55. v-for="(item, index) in baseList"
  56. :key="index"
  57. >
  58. <el-card class="box-card boxCard">
  59. <!-- 全景VR -->
  60. <i class="whole-icon yficonfont icon-keshihuaquanjing" @click="wholeScene(item)"></i>
  61. <div class="baseCard">
  62. <div class="baseImg">
  63. <!-- <img :src="$host + item.base_img" /> -->
  64. <img :src="item.base_img" />
  65. </div>
  66. <div class="addBaseInfo">
  67. <h2>{{ item.base_name }}</h2>
  68. <div class="addBaseInfoDetails">
  69. <i class="yficonfont icon-yonghu11"></i>
  70. <div class="caption">负责人 :</div>
  71. <div>{{ item.base_charge }}</div>
  72. </div>
  73. <div class="addBaseInfoDetails">
  74. <i class="yficonfont icon-dianhua2"></i>
  75. <!-- <div class="caption">电&nbsp;&nbsp;&nbsp;&nbsp;话 :</div> -->
  76. <div class="caption">电&nbsp;&nbsp;话 :</div>
  77. <div>{{ item.base_phone }}</div>
  78. </div>
  79. <div class="addBaseInfoDetails">
  80. <i class="yficonfont icon-mianji"></i>
  81. <div class="caption">面积(亩) :</div>
  82. <div>{{ item.base_area }}</div>
  83. </div>
  84. <div class="addBaseInfoDetails">
  85. <i class="yficonfont icon-dingwei"></i>
  86. <div class="caption">地&nbsp;&nbsp;址 :</div>
  87. <!-- <div class="caption">地&nbsp;&nbsp;&nbsp;&nbsp;址 :</div> -->
  88. <div class="addr" :title="item.address">
  89. {{ (item.address || '未定位') | formatName }}
  90. </div>
  91. <!-- <div class="addr">{{ item.address || "未定位" }}</div> -->
  92. </div>
  93. </div>
  94. </div>
  95. <div
  96. v-if="$QueryPermission(111)"
  97. v-btnRight:change="$route.path"
  98. class="baseEditBox"
  99. @click="editBase(item.id, '修改基地', item.address)"
  100. >
  101. <img src="@/assets/images/fourMoodBase/baseEditIcon.png" alt />
  102. </div>
  103. <div class="baseBtn">
  104. <span class="detailBtn" @click="detailBase(item.id)">详情</span>
  105. <span class="delBtn" @click="delBase(item.id)">删除</span>
  106. </div>
  107. </el-card>
  108. </el-col>
  109. </el-row>
  110. <!-- 暂无数据 -->
  111. <div class="expertDiagnosis_referral_units_not" v-if="baseList.length <= 0">
  112. <img :src="$imghost + zanwu" alt class="expertDiagnosis_referral_units_notImg" />
  113. </div>
  114. <el-pagination
  115. v-if="baseList.length > 0"
  116. background
  117. :page-size="pageSize"
  118. layout="prev, pager, next, jumper"
  119. :current-page="page"
  120. :total="totalNum"
  121. @current-change="changePage"
  122. ></el-pagination>
  123. <!-- 基地新增/修改 -->
  124. <el-dialog
  125. :title="title"
  126. :visible.sync="baseAddVisible"
  127. width="60%"
  128. @close="addBaseDialogClosed"
  129. :close-on-click-modal="false"
  130. >
  131. <el-form
  132. ref="addBaseFormRef"
  133. :model="addBaseInfo"
  134. label-width="100px"
  135. :rules="addUserFormRules"
  136. >
  137. <el-form-item label="基地名称:" prop="baseName">
  138. <el-input v-model="addBaseInfo.baseName"></el-input>
  139. </el-form-item>
  140. <el-form-item label="基地图片:" prop="imgSrc">
  141. <el-upload
  142. class="avatar-uploader"
  143. action
  144. :auto-upload="false"
  145. :show-file-list="false"
  146. :on-change="changeUpload"
  147. >
  148. <img v-if="addBaseInfo.imgSrc" :src="addBaseInfo.imgSrc" class="avatar" />
  149. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  150. </el-upload>
  151. </el-form-item>
  152. <el-form-item label="负责人:" prop="principal">
  153. <el-input v-model="addBaseInfo.principal" @input="principalinput"></el-input>
  154. </el-form-item>
  155. <el-form-item label="联系电话:" prop="phone">
  156. <el-input v-model="addBaseInfo.phone"></el-input>
  157. </el-form-item>
  158. <el-form-item label="面积(亩):" prop="area">
  159. <el-input type="number" min="0" v-model="addBaseInfo.area"></el-input>
  160. </el-form-item>
  161. <el-form-item label="绑定设备:" prop="bindEquip">
  162. <!-- <el-cascader
  163. filterable
  164. :key="addBaseInfo.cascaderKey"
  165. style="width: 100%"
  166. :options="addBaseInfo.cascaderEquipArr"
  167. v-model="addBaseInfo.bindEquip"
  168. :props="{
  169. multiple: true,
  170. label: 'type_name',
  171. value: 'type_name',
  172. multiple: true
  173. }"
  174. clearable
  175. ></el-cascader> -->
  176. <el-row>
  177. <el-col :span="22">
  178. <el-tag
  179. style="margin-right: 5px"
  180. type="success"
  181. v-for="item in addBaseInfo.bindEquip"
  182. :key="item[1]"
  183. >{{ `${item[0]}/${item[1]}` }}</el-tag
  184. >
  185. </el-col>
  186. <el-col :span="2">
  187. <el-button
  188. type="primary"
  189. size="small"
  190. icon="el-icon-edit"
  191. circle
  192. @click="handleEditBindEquipment"
  193. ></el-button>
  194. </el-col>
  195. </el-row>
  196. </el-form-item>
  197. <el-form-item label="基地描述:" prop="baseIntro">
  198. <el-input type="textarea" v-model="addBaseInfo.baseIntro"></el-input>
  199. </el-form-item>
  200. <el-form-item label="基地地址:" prop="address" class="addressItem">
  201. <el-input
  202. type="text"
  203. v-model="addBaseInfo.address"
  204. disabled
  205. placeholder="请定位"
  206. ></el-input>
  207. <el-button type="primary" size="mini" @click="goLocation">基地定位</el-button>
  208. </el-form-item>
  209. </el-form>
  210. <span slot="footer" class="dialog-footer">
  211. <el-button @click="baseAddVisible = false">取 消</el-button>
  212. <el-button type="primary" @click="addBaseSubm">确认</el-button>
  213. </span>
  214. </el-dialog>
  215. <!-- vueCropper 剪裁图片实现-->
  216. <el-dialog title="图片剪裁" :visible.sync="cropperVisible" append-to-body>
  217. <div class="cropper-content">
  218. <div style="width: 100%; height: 500px">
  219. <vueCropper
  220. ref="cropper"
  221. :img="option.img"
  222. autoCrop
  223. centerBox
  224. fixed
  225. :fixedNumber="option.fixedNumber"
  226. :outputSize="option.size"
  227. :outputType="option.outputType"
  228. ></vueCropper>
  229. </div>
  230. </div>
  231. <div slot="footer" class="dialog-footer">
  232. <el-button @click="cropperVisible = false">取 消</el-button>
  233. <el-button type="primary" @click="finish">确认</el-button>
  234. </div>
  235. </el-dialog>
  236. <!-- 添加定位弹框 -->
  237. <el-dialog
  238. class="map_dialog"
  239. title="添加定位"
  240. v-if="addLocationDialogVisible"
  241. :visible.sync="addLocationDialogVisible"
  242. width="800px"
  243. @closed="addLocationDialogClosed"
  244. >
  245. <el-form :inline="true" :model="locationForm" class="demo-form-inline" size="mini">
  246. <el-form-item label="经度">
  247. <el-input v-model="locationForm.lng"></el-input>
  248. </el-form-item>
  249. <el-form-item label="纬度">
  250. <el-input v-model="locationForm.lat"></el-input>
  251. </el-form-item>
  252. <el-form-item>
  253. <el-button type="primary" size="mini" @click="locationSearch">定位</el-button>
  254. </el-form-item>
  255. <el-form-item>
  256. <el-input @change="addrChange()" clearable placeholder="请输入地区检索" v-model="addr">
  257. <i slot="suffix" class="el-input__icon el-icon-search"></i>
  258. </el-input>
  259. </el-form-item>
  260. </el-form>
  261. <baidu-map
  262. class="Bmap"
  263. :center="center"
  264. :zoom="mapZoom"
  265. :scroll-wheel-zoom="true"
  266. @ready="handlerBMap"
  267. @click="locationPoint"
  268. ></baidu-map>
  269. <span slot="footer" class="dialog-footer">
  270. <el-button @click="addLocationDialogVisible = false">取 消</el-button>
  271. <el-button type="primary" @click="addLocationSubm">确 定</el-button>
  272. </span>
  273. </el-dialog>
  274. <EquipmentDialog
  275. :visible.sync="equipmentDialogVisible"
  276. :baseID="addBaseInfo.base_id"
  277. :bindEquipmentList="currentEquipmentList"
  278. @submit="handleEquipmentBindSubmit"
  279. />
  280. </div>
  281. </template>
  282. <script>
  283. import EquipmentDialog from './components/EquipmentDialog.vue'
  284. import SearchBar from '@/components/SearchBar'
  285. export default {
  286. data() {
  287. var checkMobile = (rule, value, callback) => {
  288. const regMobile = /^1\d{10}$/
  289. if (regMobile.test(value)) {
  290. callback()
  291. } else {
  292. // 返回一个错误提示
  293. callback(new Error('请输入合法的手机号码'))
  294. }
  295. }
  296. var checkMobile2 = (rule, value, callback) => {
  297. const regMobile = /^[A-Za-z0-9\u4e00-\u9fa5]+$/
  298. if (regMobile.test(value)) {
  299. callback()
  300. } else {
  301. // 返回一个错误提示
  302. callback(new Error('请不要输入特殊字符!'))
  303. }
  304. }
  305. return {
  306. zanwu: '/images/expertDiagnosis/zanwu.png',
  307. dialogTxt: '',
  308. search: '',
  309. page: 1,
  310. flag: null, // 编辑基地提交为1,添加基地为2
  311. totalNum: null,
  312. pageSize: 6, // 设置每页显示条数
  313. baseAddVisible: false,
  314. cropperVisible: false,
  315. title: '',
  316. addBaseInfo: {
  317. baseName: '',
  318. imgSrc: '',
  319. principal: '',
  320. phone: '',
  321. area: 0,
  322. cascaderKey: 0, // 绑定key值,key值改变,cascader就重新渲染
  323. cascaderEquipArr: [],
  324. bindEquip: [],
  325. baseIntro: '',
  326. address: '',
  327. lng: '',
  328. lat: '',
  329. base_id: ''
  330. },
  331. addUserFormRules: {
  332. baseName: [
  333. { required: true, message: '请输入基地名称', trigger: 'blur' },
  334. { max: 20, message: '基地名称不能超过20个字符', trigger: 'blur' },
  335. {
  336. pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+$/,
  337. message: '不允许输入空格等特殊符号'
  338. }
  339. ],
  340. imgSrc: [{ required: true, message: '请选择基地图片', trigger: 'change' }],
  341. principal: [
  342. { required: true, message: '请输入负责人', trigger: 'blur' },
  343. {
  344. max: 20,
  345. message: '基地负责人名称不能超过20个字符',
  346. trigger: 'blur'
  347. },
  348. { required: true, validator: checkMobile2, trigger: 'blur' }
  349. ],
  350. phone: [
  351. { required: true, trigger: 'blur', message: '手机号不能为空' },
  352. { required: true, validator: checkMobile, trigger: 'blur' }
  353. ],
  354. cascaderEquipArr: [{ required: true, message: '请选择基地设备', trigger: 'change' }],
  355. address: [{ required: true, message: '请选择基地地址', trigger: 'change' }],
  356. baseIntro: [
  357. { max: 200, message: '基地描述不能超过200个字符', trigger: 'blur' },
  358. {
  359. pattern: /^[A-Za-z0-9\u4e00-\u9fa5_,-.。;!??]+$/,
  360. message: '不允许输入空格等特殊符号'
  361. }
  362. ]
  363. },
  364. // 裁剪组件的基础配置option
  365. option: {
  366. img: 'https://qn-qn-kibey-../../assets-cdn.app-echo.com/goodboy-weixin.PNG', // 裁剪图片的地址
  367. info: true, // 裁剪框的大小信息
  368. outputSize: 0.8, // 裁剪生成图片的质量
  369. outputType: 'jpeg', // 裁剪生成图片的格式
  370. // canScale: false, // 图片是否允许滚轮缩放
  371. // autoCrop: true, // 是否默认生成截图框
  372. // autoCropWidth: 300, // 默认生成截图框宽度
  373. // autoCropHeight: 200, // 默认生成截图框高度
  374. // fixedBox: true, // 固定截图框大小 不允许改变
  375. fixed: true, // 是否开启截图框宽高固定比例
  376. fixedNumber: [10, 7], // 截图框的宽高比例
  377. full: true, // 是否输出原图比例的截图
  378. canMoveBox: false, // 截图框能否拖动
  379. original: false, // 上传图片按照原始比例渲染
  380. centerBox: false, // 截图框是否被限制在图片里面
  381. infoTrue: true // true 为展示真实输出图片宽高 false 展示看到的截图框宽高
  382. },
  383. baseList: [],
  384. // 添加基地定位
  385. addLocationDialogVisible: false,
  386. addr: '', // 地图检索的地址
  387. locationForm: {
  388. lng: '',
  389. lat: ''
  390. },
  391. center: { lng: 113.271429, lat: 23.135336 },
  392. mapZoom: 6,
  393. equipmentDialogVisible: false,
  394. currentEquipmentList: [] // 存储当前绑定的数据
  395. }
  396. },
  397. filters: {
  398. formatName: function (value) {
  399. // 地址名称
  400. if (value.length > 7) {
  401. return value.slice(0, 7) + '...'
  402. }
  403. }
  404. },
  405. components: {
  406. SearchBar,
  407. EquipmentDialog
  408. },
  409. created() {
  410. this.getBaseList()
  411. },
  412. methods: {
  413. getBaseList() {
  414. this.$axios({
  415. method: 'POST',
  416. url: '/api/api_gateway?method=base.bases.base_list',
  417. data: this.qs.stringify({
  418. ret: 'list',
  419. page_size: this.pageSize,
  420. search: this.search,
  421. page: this.page
  422. })
  423. }).then((res) => {
  424. if (res.data.message == '') {
  425. let data = res.data.data.data
  426. let _this = this
  427. this.baseList = []
  428. getList(0, data.length)
  429. function getList(j, length) {
  430. let lat = data[j].lat
  431. let lng = data[j].lng
  432. // console.log(11111111111111)
  433. _this
  434. .$jsonp(`//restapi.amap.com/v3/geocode/regeo?output=json`, {
  435. key: '78ce288400f4fc6d9458989875c833c2',
  436. location: `${lng},${lat}`
  437. })
  438. .then((res) => {
  439. // console.log(res);
  440. let addressComponent = res.regeocode && res.regeocode.formatted_address
  441. if (addressComponent) {
  442. data[j].address = res.regeocode.formatted_address
  443. } else {
  444. data[j].address = ''
  445. }
  446. _this.baseList.push(data[j])
  447. if (++j < length) {
  448. getList(j, length)
  449. }
  450. })
  451. }
  452. this.totalNum = res.data.data.page_size
  453. }
  454. })
  455. },
  456. searchBase() {
  457. this.page = 1
  458. this.getBaseList()
  459. },
  460. // 获取所有未绑定设备+自己已绑定的设备
  461. getEquipList(id) {
  462. this.$axios({
  463. method: 'POST',
  464. url: '/api/api_gateway?method=base.bases.base_equip',
  465. data: this.qs.stringify({
  466. base_id: id
  467. })
  468. }).then((res) => {
  469. let data = res.data.data.data
  470. this.addBaseInfo.cascaderEquipArr = data
  471. })
  472. },
  473. changePage(val) {
  474. this.page = val
  475. this.getBaseList()
  476. },
  477. addBaseDialogClosed() {
  478. this.$refs.addBaseFormRef.resetFields()
  479. this.addBaseInfo.cascaderKey++
  480. this.addBaseInfo.baseName = ''
  481. this.addBaseInfo.baseName = ''
  482. this.addBaseInfo.principal = ''
  483. this.addBaseInfo.phone = ''
  484. this.addBaseInfo.area = ''
  485. this.addBaseInfo.imgSrc = ''
  486. this.addBaseInfo.cascaderEquipArr = []
  487. this.addBaseInfo.bindEquip = []
  488. this.addBaseInfo.baseIntro = ''
  489. this.addBaseInfo.address = ''
  490. this.addBaseInfo.lat = ''
  491. this.addBaseInfo.lng = ''
  492. this.addBaseInfo.base_id = ''
  493. },
  494. // 添加/删除基地
  495. addBaseSubm() {
  496. this.$refs.addBaseFormRef.validate((valid) => {
  497. if (valid) {
  498. let arr = this.addBaseInfo.bindEquip.map((item) => {
  499. return item[1]
  500. })
  501. if (this.flag == 1) {
  502. let ret = 'modify'
  503. // 编辑
  504. this.baseFun(ret, arr, '修改成功')
  505. } else if (this.flag == 2) {
  506. let ret = 'add'
  507. // 添加
  508. this.baseFun(ret, arr, '添加成功')
  509. }
  510. } else {
  511. return false
  512. }
  513. })
  514. // this.getEquipList()
  515. },
  516. baseFun(ret, arr, txt) {
  517. this.$axios({
  518. method: 'POST',
  519. url: '/api/api_gateway?method=base.bases.base_list',
  520. data: this.qs.stringify({
  521. ret: ret,
  522. base_id: this.addBaseInfo.base_id,
  523. base_name: this.addBaseInfo.baseName,
  524. base_charge: this.addBaseInfo.principal,
  525. base_phone: this.addBaseInfo.phone,
  526. base_area: this.addBaseInfo.area,
  527. base_img: this.addBaseInfo.imgSrc, // 去掉/api/
  528. base_equip: arr.join('#'),
  529. base_describe: this.addBaseInfo.baseIntro,
  530. lng: this.addBaseInfo.lng,
  531. lat: this.addBaseInfo.lat
  532. })
  533. }).then((res) => {
  534. if (res.data.message == '') {
  535. this.baseAddVisible = false
  536. this.getBaseList()
  537. this.$message.success(txt)
  538. }
  539. })
  540. },
  541. // 上传按钮 限制图片大小
  542. changeUpload(file, fileList) {
  543. const isLt5M = file.size / 1024 / 1024 < 5
  544. if (!isLt5M) {
  545. this.$message.error('上传文件大小不能超过 5MB!')
  546. return false
  547. }
  548. // 上传成功后将图片地址赋值给裁剪框显示图片
  549. this.$nextTick(() => {
  550. this.option.img = URL.createObjectURL(file.raw)
  551. this.cropperVisible = true
  552. })
  553. },
  554. // 点击裁剪,这一步是可以拿到处理后的地址
  555. finish() {
  556. // 获取截图的base64 数据
  557. this.$refs.cropper.getCropBlob((data) => {
  558. var form = new FormData()
  559. let resFile = this.blobToFile(data, 'filename.jpg')
  560. form.append('img_file', resFile)
  561. this.cropperVisible = false
  562. this.$axios({
  563. method: 'POST',
  564. url: '/api/api_gateway?method=base.bases.base_photo',
  565. data: form
  566. }).then((res) => {
  567. if (res.data.message == '') {
  568. this.addBaseInfo.imgSrc = res.data.data.src
  569. }
  570. })
  571. })
  572. },
  573. // 转成blob
  574. blobToFile(Blob, fileName) {
  575. Blob.lastModifiedDate = new Date()
  576. Blob.name = fileName
  577. return Blob
  578. },
  579. dataURLtoFile(dataurl, filename) {
  580. // 将base64转换为文件
  581. var arr = dataurl.split(','),
  582. mime = arr[0].match(/:(.*?);/)[1],
  583. bstr = atob(arr[1]),
  584. n = bstr.length,
  585. u8arr = new Uint8Array(n)
  586. while (n--) {
  587. u8arr[n] = bstr.charCodeAt(n)
  588. }
  589. if (!!window.ActiveXObject || 'ActiveXObject' in window) {
  590. // ie浏览器
  591. return new Blob([u8arr.buffer], { type: mime })
  592. } else {
  593. // 主流浏览器
  594. return new File([u8arr], filename, { type: mime })
  595. }
  596. },
  597. goLocation() {
  598. this.locationForm.lng = ''
  599. this.locationForm.lat = ''
  600. this.addr = ''
  601. this.addLocationDialogVisible = true
  602. },
  603. addrChange() {
  604. let local = new this.BMap.LocalSearch(this.map, {
  605. onSearchComplete: (results) => {
  606. console.log(results, ' addr change', results.Yr)
  607. if (results.Yr && results.Yr.length) {
  608. const data = results.Yr[0]
  609. const { lng, lat } = data.point
  610. this.locationForm.lng = lng
  611. this.locationForm.lat = lat
  612. }
  613. },
  614. renderOptions: {
  615. map: this.map,
  616. panel: 'r-result',
  617. selectFirstResult: true
  618. }
  619. })
  620. local.search(this.addr)
  621. // const results = local.getResults();
  622. // console.log(results, 'local search results');
  623. },
  624. addLocationDialogClosed() {},
  625. locationSearch() {},
  626. handlerBMap({ BMap, map }) {
  627. this.BMap = BMap
  628. this.map = map
  629. },
  630. // 在地图中点击定位
  631. locationPoint(e) {
  632. let { point } = e
  633. this.locationForm = point
  634. this.map.clearOverlays()
  635. this.map.addOverlay(new BMap.Marker(point))
  636. },
  637. addLocationSubm() {
  638. let { lng, lat } = this.locationForm
  639. this.$jsonp(`//restapi.amap.com/v3/geocode/regeo?output=json`, {
  640. key: '78ce288400f4fc6d9458989875c833c2',
  641. location: `${lng},${lat}`
  642. }).then((res) => {
  643. let addressComponent = res.regeocode && res.regeocode.formatted_address
  644. if (addressComponent) {
  645. this.addBaseInfo.address = res.regeocode.formatted_address
  646. } else {
  647. this.addBaseInfo.address = ''
  648. }
  649. this.addBaseInfo.lng = lng
  650. this.addBaseInfo.lat = lat
  651. this.addLocationDialogVisible = false // 关闭弹框
  652. })
  653. },
  654. editBase(id, title, address) {
  655. this.title = title
  656. this.flag = 1
  657. this.addBaseInfo.base_id = id
  658. this.$axios({
  659. method: 'POST',
  660. url: '/api/api_gateway?method=base.bases.base_list',
  661. data: this.qs.stringify({
  662. ret: 'details',
  663. base_id: id
  664. })
  665. }).then((res) => {
  666. let item = res.data.data[0]
  667. this.addBaseInfo.baseName = item.base_name
  668. this.addBaseInfo.principal = item.base_charge
  669. this.addBaseInfo.phone = item.base_phone
  670. this.addBaseInfo.area = Number(item.base_area)
  671. this.addBaseInfo.imgSrc = item.base_img
  672. this.addBaseInfo.bindEquip = item.base_equip
  673. this.addBaseInfo.baseIntro = item.base_describe
  674. this.addBaseInfo.address = address
  675. this.addBaseInfo.lat = item.lat
  676. this.addBaseInfo.lng = item.lng
  677. this.getEquipList(id) // 获取所有未绑定和已绑定的设备
  678. this.dialogTxt = '编辑基地'
  679. this.baseAddVisible = true
  680. })
  681. },
  682. addBase(title) {
  683. this.title = title
  684. this.flag = 2
  685. this.getEquipList('')
  686. this.baseAddVisible = true
  687. this.dialogTxt = '新建基地'
  688. },
  689. delBase(id) {
  690. console.log(id)
  691. this.$confirm(`确定删除基地么?`, '提示', {
  692. confirmButtonText: '确定',
  693. cancelButtonText: '取消',
  694. type: 'warning'
  695. })
  696. .then(() => {
  697. if (this.totalNum == this.pageSize + 1) {
  698. // 如果总条数与每页展示条数在加1的情况下相等,就是说当删除一条数据后页码会从2页变为1页,如果不改变当前page的话,列表会展示为空
  699. this.page = 1
  700. }
  701. this.$axios({
  702. method: 'POST',
  703. url: '/api/api_gateway?method=base.bases.base_list',
  704. data: this.qs.stringify({
  705. ret: 'del',
  706. base_id: id
  707. })
  708. }).then((res) => {
  709. this.getBaseList()
  710. this.$message({
  711. type: 'success',
  712. message: '删除成功!'
  713. })
  714. })
  715. })
  716. .catch(() => {
  717. this.$message({
  718. type: 'info',
  719. message: '已取消删除'
  720. })
  721. })
  722. },
  723. detailBase(id) {
  724. this.$router.push({ path: '/index/baseShow', query: { id: id } })
  725. },
  726. // 点击进入全景
  727. wholeScene(item) {
  728. this.$router.push({
  729. path: '/index/baseWholeimg',
  730. query: {
  731. img: item.base_img,
  732. name: '基地管理',
  733. url: '/index/fourMoodBase'
  734. }
  735. })
  736. },
  737. handleEditBindEquipment() {
  738. this.currentEquipmentList = this.addBaseInfo.bindEquip
  739. this.equipmentDialogVisible = true
  740. },
  741. handleEquipmentBindSubmit(data) {
  742. console.log(data)
  743. this.addBaseInfo.bindEquip = data || []
  744. }
  745. }
  746. }
  747. </script>
  748. <style lang="less" scoped>
  749. .baseoperationbox {
  750. width: 100%;
  751. display: flex;
  752. justify-content: space-between;
  753. margin-bottom: 20px;
  754. }
  755. .boxCard {
  756. position: relative;
  757. .baseCard {
  758. display: flex;
  759. .baseImg {
  760. flex: 1;
  761. overflow: hidden;
  762. height: 160px;
  763. img {
  764. width: 100%;
  765. height: auto;
  766. }
  767. }
  768. .addBaseInfo {
  769. flex: 1;
  770. padding-left: 15px;
  771. h2 {
  772. font-size: 16px;
  773. margin-bottom: 10px;
  774. white-space: nowrap;
  775. overflow: hidden;
  776. text-overflow: ellipsis;
  777. width: 80%;
  778. }
  779. .addBaseInfoDetails {
  780. display: flex;
  781. padding-bottom: 10px;
  782. color: #525252;
  783. line-height: 18px;
  784. font-size: 14px;
  785. i {
  786. font-size: 14px;
  787. }
  788. .caption {
  789. margin-left: 5px;
  790. // width: 70px;
  791. width: 80px;
  792. flex-grow: 0;
  793. flex-shrink: 0;
  794. text-align: left;
  795. }
  796. .addr {
  797. flex-grow: 1;
  798. text-overflow: -o-ellipsis-lastline;
  799. overflow: hidden;
  800. text-overflow: ellipsis;
  801. display: -webkit-box;
  802. -webkit-line-clamp: 2;
  803. line-clamp: 2;
  804. -webkit-box-orient: vertical;
  805. min-height: 40px;
  806. }
  807. }
  808. }
  809. }
  810. .baseEditBox {
  811. position: absolute;
  812. right: 20px;
  813. top: 0;
  814. cursor: pointer;
  815. img {
  816. width: 35px;
  817. }
  818. }
  819. .baseBtn {
  820. position: absolute;
  821. right: 20px;
  822. bottom: 10px;
  823. line-height: 22px;
  824. span {
  825. display: inline-block;
  826. width: 60px;
  827. border-radius: 20px;
  828. color: #666;
  829. text-align: center;
  830. cursor: pointer;
  831. }
  832. .delBtn {
  833. background: #ddd;
  834. font-size: 15px;
  835. }
  836. .detailBtn {
  837. background: #14a478;
  838. color: #fff;
  839. margin-right: 10px;
  840. font-size: 15px;
  841. }
  842. }
  843. }
  844. .avatar-uploader {
  845. /deep/.el-upload {
  846. .el-upload-dragge {
  847. width: 100%;
  848. height: 100%;
  849. }
  850. }
  851. }
  852. .col-item {
  853. height: 223px;
  854. }
  855. .cropper {
  856. width: auto;
  857. height: 300px;
  858. }
  859. .addressItem {
  860. /deep/.el-form-item__content {
  861. display: flex;
  862. .el-input {
  863. flex: 1;
  864. margin-right: 15px;
  865. }
  866. }
  867. }
  868. .Bmap {
  869. width: 100%;
  870. height: 400px;
  871. }
  872. .el-card {
  873. position: relative;
  874. .whole-icon {
  875. display: none;
  876. font-size: 16px;
  877. position: absolute;
  878. left: 25px;
  879. top: 25px;
  880. color: #f5f3f3;
  881. cursor: pointer;
  882. font-size: 35px;
  883. }
  884. &:hover {
  885. .whole-icon {
  886. display: block;
  887. }
  888. }
  889. }
  890. </style>