agencyDetail.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. <template>
  2. <section>
  3. <!-- 机构信息 -->
  4. <el-col :span="24" class="agencyHead">
  5. <el-container>
  6. <el-container>
  7. <el-aside width="335px;">
  8. <div class="agencyHead_img">
  9. <img class="agencyHead_imgbox" :src="detail.briefIntroductionPic">
  10. </div>
  11. </el-aside>
  12. <el-container>
  13. <el-header height="90px;">
  14. {{detail.name}}
  15. <el-button type="text" @click="editDetail(0)" icon="el-icon-edit" class="agencyHead_edit"></el-button>
  16. <el-button type="text" @click="backToList" class="agencyHead_back"><i class="iconfont iconfanhui1"></i></el-button>
  17. </el-header>
  18. <el-footer>
  19. <span class="info">{{detail.headIntroduction==null?"暂无简介":detail.headIntroduction}}</span>
  20. </el-footer>
  21. </el-container>
  22. </el-container>
  23. </el-container>
  24. </el-col>
  25. <el-col :span="24" class="agencyDeail">
  26. <!-- 轮播图 -->
  27. <el-col :span="24" class="agencyBody_title">轮播图</el-col>
  28. <el-col :span="24" class="agencyBody_main">
  29. <el-upload action="/api/institutional/updatePics/" accept="image/*" multiple :limit="5" :data="uploadMsg" list-type="picture-card"
  30. :file-list="detail.pics"
  31. :on-preview="handlePictureCardPreview"
  32. :on-remove="handleRemove"
  33. :on-success="handleUploadSuccess"
  34. :on-error="handleUploadError">
  35. <i slot="default" class="el-icon-plus"></i>
  36. <div slot="file" slot-scope="{file}">
  37. <img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
  38. <span class="el-upload-list__item-actions">
  39. <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
  40. <i class="el-icon-zoom-in"></i>
  41. </span>
  42. <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
  43. <i class="el-icon-delete"></i>
  44. </span>
  45. </span>
  46. </div>
  47. </el-upload>
  48. <el-dialog :visible.sync="dialogVisible">
  49. <img width="100%" :src="dialogImageUrl" alt="">
  50. </el-dialog>
  51. </el-col>
  52. <!-- 基本信息 -->
  53. <el-col :span="24" class="agencyBody_title">
  54. 基本信息
  55. <el-button type="text" @click="editDetail(1)" icon="el-icon-edit" class="agencyHead_edit"></el-button>
  56. </el-col>
  57. <el-col :span="24" class="agencyBody_main">
  58. <el-col :span="24" class="agencyBody_detail">
  59. 上课时间:
  60. <span class="info" v-if="detail.amTime != null || detail.pmTime != null">{{detail.amTime}} - {{detail.pmTime}}</span>
  61. <span class="info" v-else>暂无</span>
  62. </el-col>
  63. <el-col :span="24" class="agencyBody_detail">
  64. 收费标准:
  65. <span class="info">{{detail.chargingStandard==null||detail.chargingStandard==''?'暂无':detail.chargingStandard}}</span>
  66. </el-col>
  67. <el-col :span="24" class="agencyBody_detail">
  68. 机构位置:
  69. <span class="info">{{detail.address==null||detail.address==''?'暂无':detail.address}}</span>
  70. </el-col>
  71. <el-col :span="24" class="agencyBody_detail">
  72. 联系方式:
  73. <span class="info">{{detail.phone==null||detail.phone==''?'暂无':detail.phone}}</span>
  74. </el-col>
  75. </el-col>
  76. <!-- 机构简介 -->
  77. <el-col :span="24" class="agencyBody_title">
  78. 机构介绍
  79. <el-button type="text" @click="editDetail(2)" icon="el-icon-edit" class="agencyHead_edit"></el-button>
  80. </el-col>
  81. <el-col :span="24" class="agencyBody_main">
  82. <el-col :span="24" class="agencyBody_detail">
  83. <span class="info">{{detail.briefIntroduction==null?'暂无':detail.briefIntroduction}}</span>
  84. </el-col>
  85. </el-col>
  86. <!-- 课程特色 -->
  87. <el-col :span="24" class="agencyBody_title">
  88. 课程特色
  89. <el-button type="text" @click="editDetail(3)" icon="el-icon-edit" class="agencyHead_edit"></el-button>
  90. </el-col>
  91. <el-col :span="24" class="agencyBody_main">
  92. <el-col :span="24" class="agencyBody_detail">
  93. <span class="info">{{detail.classAdvantages==null?'暂无':detail.classAdvantages}}</span>
  94. </el-col>
  95. </el-col>
  96. </el-col>
  97. <!--编辑基础信息-->
  98. <el-dialog title="编辑机构信息" v-if="editFormVisible" :visible.sync="editFormVisible" :close-on-click-modal="false" customClass='customWidth'>
  99. <el-form :model="editForm" label-width="100px" :rules="formRules" ref="editForm">
  100. <el-col :span="24">
  101. <el-form-item label="机构名称" prop="name">
  102. <el-input v-model="editForm.name" autocomplete="off" placeholder="请输入项目名称"></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="24">
  106. <el-form-item label="机构简介">
  107. <el-input v-model="editForm.headIntroduction" type="textarea" :rows="5" placeholder="请输入机构简介"></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="24">
  111. <el-form-item label="机构图片">
  112. <el-upload class="avatar-uploader" ref="upload" accept="image/*" list-type="picture-card"
  113. :limit="1" action="action" :auto-upload="false" :http-request="uploadDiscardFile" :file-list='editForm.headPic'>
  114. <i slot="default" class="el-icon-plus"></i>
  115. </el-upload>
  116. </el-form-item>
  117. </el-col>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button @click.native="editFormVisible = false">取消</el-button>
  121. <el-button type="primary" @click.native="addSubmit" :loading="editLoading">提交</el-button>
  122. </div>
  123. </el-dialog>
  124. <el-dialog title="编辑机构信息" v-if="editFormVisibleOther" :visible.sync="editFormVisibleOther" :close-on-click-modal="false" customClass='customWidth'>
  125. <el-form :model="editFormOther" label-width="70px" :rules="formRules" ref="editFormOther">
  126. <el-form-item label="上课时间" v-if="editType == 1">
  127. <el-time-picker is-range v-model="editFormOther.time" format="HH:mm:ss" value-format="HH:mm:ss"
  128. range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围" style=width:565px;></el-time-picker>
  129. </el-form-item>
  130. <el-form-item label="收费标准" v-if="editType == 1">
  131. <el-input v-model="editFormOther.chargingStandard" autocomplete="off" placeholder="请输入收费标准"></el-input>
  132. </el-form-item>
  133. <el-form-item label="联系方式" v-if="editType == 1">
  134. <el-input v-model="editFormOther.phone" autocomplete="off" placeholder="请输入联系方式"></el-input>
  135. </el-form-item>
  136. <el-form-item label="机构位置" v-if="editType == 1">
  137. <el-input v-model="editFormOther.address" :change="changeFactoryArea('editContainer')" autocomplete="off" placeholder="请输入机构位置"></el-input>
  138. </el-form-item>
  139. <div id="editContainer" v-if="editType == 1" class="formMap"></div>
  140. <el-form-item label="机构介绍" v-if="editType == 2">
  141. <el-input v-model="editFormOther.briefIntroduction" type="textarea" :rows="5" placeholder="请输入机构介绍"></el-input>
  142. </el-form-item>
  143. <el-form-item label="课程特色" v-if="editType == 3">
  144. <el-input v-model="editFormOther.classAdvantages" type="textarea" :rows="5" placeholder="请输入课程特色"></el-input>
  145. </el-form-item>
  146. </el-form>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button @click.native="editFormVisibleOther = false">取消</el-button>
  149. <el-button type="primary" @click.native="addSubmitOther" :loading="editOtherLoading">提交</el-button>
  150. </div>
  151. </el-dialog>
  152. </section>
  153. </template>
  154. <script>
  155. export default {
  156. data() {
  157. return {
  158. //基础信息
  159. detailId: this.$route.params.id==null?JSON.parse(sessionStorage.getItem('user')).ageId:this.$route.params.id,
  160. user: JSON.parse(sessionStorage.getItem('user')),
  161. detail: {},
  162. dialogImageUrl: '',
  163. dialogVisible: false,
  164. disabled: false,
  165. uploadMsg: {
  166. "id": this.$route.params.id
  167. },
  168. formRules: {
  169. name: [
  170. { required: true, message: '请输入机构名称', trigger: 'blur' }
  171. ],
  172. },
  173. // 地图
  174. map: '',
  175. marker: '',
  176. //编辑
  177. editType: 0,
  178. editFormVisible: false,
  179. editLoading: false,
  180. editForm: {
  181. name: '',
  182. headIntroduction: '',
  183. headPic: [{url:""}],
  184. },
  185. editFormVisibleOther: false,
  186. editOtherLoading: false,
  187. editFormOther: {
  188. time: ['09:00:00','18:00:00'],
  189. chargingStandard: '',
  190. phone: '',
  191. address: '',
  192. yLng: '',
  193. xLat: '',
  194. briefIntroduction: '',
  195. classAdvantages: '',
  196. },
  197. };
  198. },
  199. methods: {
  200. //返回
  201. backToList() {
  202. this.$router.go(-1);
  203. },
  204. //获取详情
  205. getDetail() {
  206. this.http.post(this.port.agency.detail, {
  207. id: this.detailId
  208. }, res => {
  209. if (res.code == "ok") {
  210. this.detail = res.data;
  211. } else {
  212. this.$message({
  213. message: res.msg,
  214. type: 'error'
  215. });
  216. }
  217. }, error => {
  218. this.$message({
  219. message: error,
  220. type: 'error'
  221. });
  222. })
  223. },
  224. //图片上传
  225. handleUploadSuccess(response, file, fileList) {
  226. if(response.code == "ok") {
  227. this.$message({
  228. message: "上传成功",
  229. type: "success"
  230. });
  231. } else {
  232. this.$message({
  233. message: err,
  234. type: "error"
  235. });
  236. }
  237. },
  238. handleUploadError(err, file, fileList) {
  239. this.$message({
  240. message: err,
  241. type: "error"
  242. });
  243. },
  244. //预览图片
  245. handlePictureCardPreview(file) {
  246. this.dialogImageUrl = file.picUrl;
  247. this.dialogVisible = true;
  248. },
  249. //删除图片
  250. handleRemove(file) {
  251. this.$confirm('确认删除该图片吗?', '提示', {
  252. type: 'warning'
  253. }).then(() => {
  254. this.http.post(this.port.agency.deletePic, {
  255. id: file.id
  256. }, res => {
  257. if (res.code == "ok") {
  258. this.$message({
  259. message: '删除成功',
  260. type: 'success'
  261. });
  262. this.getDetail();
  263. } else {
  264. this.$message({
  265. message: res.msg,
  266. type: 'error'
  267. });
  268. }
  269. }, error => {
  270. this.$message({
  271. message: error,
  272. type: 'error'
  273. });
  274. })
  275. });
  276. },
  277. //打开编辑页面
  278. editDetail(type) {
  279. this.editType = type;
  280. this.editLoading = false;
  281. this.editOtherLoading = false;
  282. if(type == 0) {
  283. this.editFormVisible = true;
  284. this.editForm = {
  285. "name": this.detail.name,
  286. "headIntroduction": this.detail.headIntroduction,
  287. "headPic": [{url:this.detail.briefIntroductionPic}]
  288. }
  289. } else {
  290. this.editFormVisibleOther = true;
  291. const time = this.editFormOther.time;
  292. if(this.detail.amTime != null) {
  293. time[0] = this.detail.amTime;
  294. }
  295. if(this.detail.pmTime != null) {
  296. time[1] = this.detail.pmTime;
  297. }
  298. this.editFormOther = {
  299. "time": time,
  300. "chargingStandard": this.detail.chargingStandard,
  301. "phone": this.detail.phone,
  302. "address": this.detail.address,
  303. "yLng": this.detail.lng,
  304. "xLat": this.detail.lat,
  305. "briefIntroduction": this.detail.briefIntroduction,
  306. "classAdvantages": this.detail.classAdvantages,
  307. }
  308. }
  309. },
  310. //提交
  311. addSubmit() {
  312. this.$refs.editForm.validate(valid => {
  313. if (valid) {
  314. if(this.$refs.upload.uploadFiles.length == 1 && this.$refs.upload.uploadFiles[0].url != this.detail.briefIntroductionPic) {
  315. this.$refs.upload.submit();
  316. } else {
  317. this.http.post( this.port.agency.edit, {
  318. id: this.detail.id,
  319. name: this.editForm.name,
  320. headIntroduction: this.editForm.headIntroduction,
  321. },
  322. res => {
  323. if (res.code == "ok") {
  324. this.editFormVisible = false;
  325. this.$message({
  326. message: "修改成功",
  327. type: "success"
  328. });
  329. this.getDetail();
  330. } else {
  331. this.$message({
  332. message: res.msg,
  333. type: "error"
  334. });
  335. }
  336. },
  337. error => {
  338. this.editFormVisible = false;
  339. this.$message({
  340. message: error,
  341. type: "error"
  342. });
  343. });
  344. }
  345. }
  346. })
  347. },
  348. addSubmitOther() {
  349. var form = {};
  350. if(this.editType == 1) {
  351. form = {
  352. id: this.detail.id,
  353. amTime: this.editFormOther.time[0],
  354. pmTime: this.editFormOther.time[1],
  355. chargingStandard: this.editFormOther.chargingStandard,
  356. phone: this.editFormOther.phone,
  357. address: this.editFormOther.address,
  358. };
  359. } else if(this.editType == 2) {
  360. form = {
  361. id: this.detail.id,
  362. briefIntroduction: this.editFormOther.briefIntroduction,
  363. };
  364. } else if(this.editType == 3) {
  365. form = {
  366. id: this.detail.id,
  367. classAdvantages: this.editFormOther.classAdvantages,
  368. };
  369. }
  370. this.http.post( this.port.agency.edit, form ,
  371. res => {
  372. if (res.code == "ok") {
  373. this.editFormVisibleOther = false;
  374. this.$message({
  375. message: "修改成功",
  376. type: "success"
  377. });
  378. this.getDetail();
  379. } else {
  380. this.$message({
  381. message: res.msg,
  382. type: "error"
  383. });
  384. }
  385. },
  386. error => {
  387. this.editFormVisibleOther = false;
  388. this.$message({
  389. message: error,
  390. type: "error"
  391. });
  392. });
  393. },
  394. uploadDiscardFile(params){
  395. var fileObj = params.file;
  396. var form = new FormData();
  397. form.append("file", fileObj);
  398. form.append("id", this.detail.id);
  399. form.append("name", this.editForm.name);
  400. form.append("headIntroduction", this.editForm.headIntroduction);
  401. this.http.uploadFile( this.port.agency.edit, form,
  402. res => {
  403. if (res.code == "ok") {
  404. this.$message({
  405. message: "修改成功",
  406. type: "success"
  407. });
  408. this.editFormVisible = false;
  409. this.$refs.upload.clearFiles();
  410. this.getDetail();
  411. } else {
  412. this.$message({
  413. message: res.msg,
  414. type: "error"
  415. });
  416. }
  417. },
  418. error => {
  419. this.editFormVisible = false;
  420. this.$message({
  421. message: error,
  422. type: "error"
  423. });
  424. });
  425. },
  426. //地址输入切换
  427. changeFactoryArea(mapId) {
  428. if(mapId == "addContainer"){
  429. this.markLocation(this.addForm.address, mapId);
  430. } else {
  431. this.markLocation(this.editFormOther.address, mapId);
  432. }
  433. },
  434. //获取地图
  435. setMap(mapId) {
  436. if(mapId == 'addContainer') {
  437. this.map = new AMap.Map('addContainer', {
  438. resizeEnable: true, // 允许缩放
  439. center:[ this.addForm.yLng , this.addForm.xLat ],
  440. zoom:10
  441. })
  442. this.marker = new AMap.Marker({
  443. map: this.map,
  444. position: new AMap.LngLat(this.addForm.yLng , this.addForm.xLat), // 经纬度
  445. });
  446. } else {
  447. this.map = new AMap.Map('editContainer', {
  448. resizeEnable: true, // 允许缩放
  449. center:[this.editFormOther.yLng , this.editFormOther.xLat],
  450. zoom:10
  451. })
  452. this.marker = new AMap.Marker({
  453. map: this.map,
  454. position: new AMap.LngLat(this.editFormOther.yLng , this.editFormOther.xLat), // 经纬度
  455. });
  456. }
  457. var _this = this;
  458. this.map.on('click', function(e) {
  459. if(_this.map){
  460. _this.map.remove(_this.marker);
  461. }
  462. var Lng = e.lnglat.getLng(),
  463. Lat = e.lnglat.getLat();
  464. if(mapId == 'addContainer') {
  465. _this.addForm.yLng = Lng;
  466. _this.addForm.xLat = Lat;
  467. } else {
  468. _this.editFormOther.yLng = Lng;
  469. _this.editFormOther.xLat = Lat;
  470. }
  471. _this.marker = new AMap.Marker({
  472. map: _this.map,
  473. position: new AMap.LngLat(Lng , Lat), // 经纬度
  474. });
  475. });
  476. },
  477. // 获取经纬度
  478. markLocation(address,mapId) {
  479. var _this = this;
  480. AMap.plugin('AMap.Geocoder', function() {
  481. var geocoder = new AMap.Geocoder();
  482. geocoder.getLocation(address, function(status, result) {
  483. if (status === 'complete' && result.info === 'OK') {
  484. // 经纬度
  485. var lng = result.geocodes[0].location.lng;
  486. var lat = result.geocodes[0].location.lat;
  487. _this.noSub = false;
  488. if(mapId == "addContainer") {
  489. _this.addForm.yLng = lng;
  490. _this.addForm.xLat = lat;
  491. } else {
  492. _this.editFormOther.yLng = lng;
  493. _this.editFormOther.xLat = lat;
  494. }
  495. // 添加标记
  496. if(_this.map){
  497. _this.map.remove(_this.marker);
  498. _this.map.setZoomAndCenter(10, [lng, lat]);
  499. _this.marker = new AMap.Marker({
  500. map: _this.map,
  501. position: new AMap.LngLat(lng, lat), // 经纬度
  502. });
  503. }
  504. } else {
  505. //console.log('定位失败!');
  506. }
  507. });
  508. });
  509. }
  510. },
  511. watch: {
  512. addFormVisible(val) {
  513. if(val){
  514. var _this = this
  515. setTimeout(function(){ _this.setMap('addContainer'); }, 300);
  516. }
  517. },
  518. editFormVisibleOther(val) {
  519. if(val){
  520. var _this = this
  521. setTimeout(function(){ _this.setMap('editContainer'); }, 300);
  522. }
  523. }
  524. },
  525. mounted() {
  526. this.getDetail();
  527. }
  528. };
  529. </script>
  530. <style scoped lang="scss">
  531. a {
  532. text-decoration:none;
  533. color: #333;
  534. }
  535. .agencyDeail {
  536. margin-bottom: 45px;
  537. }
  538. .el-header {
  539. font-size: 18px;
  540. font-weight: 600;
  541. color: #333;
  542. line-height: 40px;
  543. }
  544. .el-footer {
  545. font-size: 16px;
  546. color: #333;
  547. line-height: 30px;
  548. }
  549. .el-container.is-vertical {
  550. overflow: hidden;
  551. }
  552. .agencyHead {
  553. margin: 20px 0 0 0;
  554. }
  555. .agencyHead_img {
  556. width:335px;
  557. height:160px;
  558. overflow:hidden;
  559. .agencyHead_imgbox {
  560. width:335px;
  561. height:160px;
  562. }
  563. }
  564. .agencyHead_edit {
  565. font-size:16px;
  566. margin: 0 0 0 15px;
  567. padding: 0;
  568. }
  569. .agencyHead_back {
  570. float: right;
  571. margin: 0;
  572. position: relative;
  573. .iconfont {
  574. font-size: 25px;
  575. position: absolute;
  576. right: -10px;
  577. top: 0px;
  578. }
  579. }
  580. .allDetail {
  581. overflow-y: auto;
  582. }
  583. .agencyBody_title {
  584. padding-left: 10px;
  585. padding-bottom: 0px;
  586. margin: 20px 0;
  587. font-size: 16px;
  588. line-height: 20px;
  589. border-left: 1px #20a0ff solid;
  590. position: relative;
  591. }
  592. .agencyBody_main {
  593. padding-left: 40px;
  594. }
  595. .agencyBody_detail {
  596. margin-bottom: 20px;
  597. }
  598. .toolbar .el-form-item {
  599. font-size: 14px;
  600. vertical-align: middle;
  601. }
  602. .divLine {
  603. width: 2px;
  604. background: #c3c3c3;
  605. height: 100%;
  606. }
  607. .projectTitle {
  608. font-size: 18px;
  609. color: #333;
  610. }
  611. .upload-demo {
  612. position: absolute;
  613. right: 0;
  614. top: -5px;
  615. }
  616. .editDetail {
  617. margin-left: 10px;
  618. color:#20a0ff;
  619. cursor: pointer;
  620. }
  621. .info {
  622. color: grey;
  623. }
  624. .model {
  625. cursor: pointer;
  626. color:#20a0ff;
  627. }
  628. .el-collapse {
  629. border: none;
  630. }
  631. .formMap {
  632. height: 400px;
  633. }
  634. </style>