当前位置:   article > 正文

sprinboot+vue集成neo4j图数据库_springboot neo4j vue d3.js

springboot neo4j vue d3.js

一 、java后台

1.1

  1. package com.admin.domain;
  2. /**
  3. * 功能描述:
  4. *
  5. * @author wangwei
  6. * @date 2024-01-15 22:13
  7. */
  8. public class ConnectWeb {
  9. private String connectWebId;
  10. private String connectWebName;
  11. private String connectWebInfo;
  12. private String personWebIdAlpha;
  13. private String personWebIdBeta;
  14. private String personWebIdAlphaName;
  15. private String personWebIdBetaName;
  16. public String getPersonWebIdAlphaName() {
  17. return personWebIdAlphaName;
  18. }
  19. public void setPersonWebIdAlphaName(String personWebIdAlphaName) {
  20. this.personWebIdAlphaName = personWebIdAlphaName;
  21. }
  22. public String getPersonWebIdBetaName() {
  23. return personWebIdBetaName;
  24. }
  25. public void setPersonWebIdBetaName(String personWebIdBetaName) {
  26. this.personWebIdBetaName = personWebIdBetaName;
  27. }
  28. public String getConnectWebId() {
  29. return connectWebId;
  30. }
  31. public void setConnectWebId(String connectWebId) {
  32. this.connectWebId = connectWebId;
  33. }
  34. public String getConnectWebName() {
  35. return connectWebName;
  36. }
  37. public void setConnectWebName(String connectWebName) {
  38. this.connectWebName = connectWebName;
  39. }
  40. public String getConnectWebInfo() {
  41. return connectWebInfo;
  42. }
  43. public void setConnectWebInfo(String connectWebInfo) {
  44. this.connectWebInfo = connectWebInfo;
  45. }
  46. public String getPersonWebIdAlpha() {
  47. return personWebIdAlpha;
  48. }
  49. public void setPersonWebIdAlpha(String personWebIdAlpha) {
  50. this.personWebIdAlpha = personWebIdAlpha;
  51. }
  52. public String getPersonWebIdBeta() {
  53. return personWebIdBeta;
  54. }
  55. public void setPersonWebIdBeta(String personWebIdBeta) {
  56. this.personWebIdBeta = personWebIdBeta;
  57. }
  58. @Override
  59. public String toString() {
  60. return "ConnectWeb{" +
  61. "connectWebId='" + connectWebId + '\'' +
  62. ", connectWebName='" + connectWebName + '\'' +
  63. ", connectWebInfo='" + connectWebInfo + '\'' +
  64. ", personWebIdAlpha='" + personWebIdAlpha + '\'' +
  65. ", personWebIdBeta='" + personWebIdBeta + '\'' +
  66. ", personWebIdAlphaName='" + personWebIdAlphaName + '\'' +
  67. ", personWebIdBetaName='" + personWebIdBetaName + '\'' +
  68. '}';
  69. }
  70. }

1.2

  1. package com.admin.domain;
  2. /**
  3. * 功能描述:
  4. *人物属性实体描述
  5. *
  6. * @author wangwei
  7. * @date 2024-01-15 22:12
  8. */
  9. public class PersonWeb {
  10. private String personWebId;
  11. private String personWebName;
  12. private String personWebPic;
  13. private String personWebShow;
  14. private String personWebLink;
  15. private String personWebPlatform;
  16. private String personWebField;
  17. private String personWebInfo;
  18. private String personWebKey;
  19. public String getPersonWebId() {
  20. return personWebId;
  21. }
  22. public void setPersonWebId(String personWebId) {
  23. this.personWebId = personWebId;
  24. }
  25. public String getPersonWebName() {
  26. return personWebName;
  27. }
  28. public void setPersonWebName(String personWebName) {
  29. this.personWebName = personWebName;
  30. }
  31. public String getPersonWebPlatform() {
  32. return personWebPlatform;
  33. }
  34. public void setPersonWebPlatform(String personWebPlatform) {
  35. this.personWebPlatform = personWebPlatform;
  36. }
  37. public String getPersonWebField() {
  38. return personWebField;
  39. }
  40. public void setPersonWebField(String personWebField) {
  41. this.personWebField = personWebField;
  42. }
  43. public String getPersonWebInfo() {
  44. return personWebInfo;
  45. }
  46. public void setPersonWebInfo(String personWebInfo) {
  47. this.personWebInfo = personWebInfo;
  48. }
  49. public String getPersonWebKey() {
  50. return personWebKey;
  51. }
  52. public void setPersonWebKey(String personWebKey) {
  53. this.personWebKey = personWebKey;
  54. }
  55. public String getPersonWebPic() {
  56. return personWebPic;
  57. }
  58. public void setPersonWebPic(String personWebPic) {
  59. this.personWebPic = personWebPic;
  60. }
  61. public String getPersonWebShow() {
  62. return personWebShow;
  63. }
  64. public void setPersonWebShow(String personWebShow) {
  65. this.personWebShow = personWebShow;
  66. }
  67. public String getPersonWebLink() {
  68. return personWebLink;
  69. }
  70. public void setPersonWebLink(String personWebLink) {
  71. this.personWebLink = personWebLink;
  72. }
  73. @Override
  74. public String toString() {
  75. return "PersonWeb{" +
  76. "personWebId='" + personWebId + '\'' +
  77. ", personWebName='" + personWebName + '\'' +
  78. ", personWebPic='" + personWebPic + '\'' +
  79. ", personWebShow='" + personWebShow + '\'' +
  80. ", personWebLink='" + personWebLink + '\'' +
  81. ", personWebPlatform='" + personWebPlatform + '\'' +
  82. ", personWebField='" + personWebField + '\'' +
  83. ", personWebInfo='" + personWebInfo + '\'' +
  84. ", personWebKey='" + personWebKey + '\'' +
  85. '}';
  86. }
  87. }

1.3

  1. package com.admin.controller;
  2. import com.admin.common.core.controller.BaseController;
  3. import com.admin.common.core.domain.AjaxResult;
  4. import com.admin.common.core.page.TableDataInfo;
  5. import com.admin.domain.ConnectWeb;
  6. import com.admin.domain.PersonWeb;
  7. import com.admin.service.WebService;
  8. import com.admin.utils.transport.Result;
  9. import org.neo4j.driver.Record;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.List;
  13. /**
  14. * 功能描述:
  15. *
  16. * @author wangwei
  17. * @date 2024-01-16 11:09
  18. */
  19. @RestController
  20. @RequestMapping("/people/web")
  21. public class WebController extends BaseController {
  22. @Autowired
  23. private WebService webService;
  24. @GetMapping("/map")
  25. public TableDataInfo getPersonWebMap() {
  26. List<Record> list = webService.selectPersonWebMap();
  27. return getDataTable(list);
  28. }
  29. @GetMapping("/list")
  30. public TableDataInfo getPersonWebList() {
  31. List<PersonWeb> list = webService.selectPersonWebList();
  32. return getDataTable(list);
  33. }
  34. @GetMapping("/search/{personWebName}")
  35. public AjaxResult getPersonWebSearchList(@PathVariable("personWebName") String personWebName) {
  36. List<PersonWeb> list = webService.selectPersonWebSearchList(personWebName);
  37. return AjaxResult.success(list);
  38. }
  39. @GetMapping("/search/{personWebId}/{personWebName}")
  40. public AjaxResult getPersonWebSearchListOther(@PathVariable("personWebName") String personWebName, @PathVariable("personWebId") String personWebId) {
  41. List<PersonWeb> list = webService.selectPersonWebSearchListOther(personWebName, personWebId);
  42. return AjaxResult.success(list);
  43. }
  44. @GetMapping(value = "/person/{personWebId}")
  45. public AjaxResult getPersonWebInfo(@PathVariable("personWebId") String personWebId) {
  46. return AjaxResult.success(webService.selectPersonWebById(personWebId));
  47. }
  48. @PostMapping("/person")
  49. public AjaxResult addPersonWeb(@RequestBody PersonWeb personWeb) {
  50. return toAjax(webService.insertPersonWeb(personWeb));
  51. }
  52. @PutMapping("/person")
  53. public AjaxResult editPersonWeb(@RequestBody PersonWeb personWeb) {
  54. return toAjax(webService.updatePersonWeb(personWeb));
  55. }
  56. @DeleteMapping("/person/{personWebId}")
  57. public AjaxResult removePersonWeb(@PathVariable String personWebId) {
  58. try{
  59. int rsg = webService.deletePersonWeb(personWebId);
  60. return toAjax(rsg);
  61. } catch (Exception e){
  62. return AjaxResult.error(500, "此节点仍与其他节点有关联关系!");
  63. }
  64. }
  65. @GetMapping(value = "/connect/{connectWebId}")
  66. public AjaxResult getInfoConnectWeb(@PathVariable("connectWebId") String connectWebId) {
  67. return AjaxResult.success(webService.selectConnectWebById(connectWebId));
  68. }
  69. @PostMapping("/connect")
  70. public AjaxResult addConnectWeb(@RequestBody ConnectWeb connectWeb) {
  71. return toAjax(webService.insertConnectWeb(connectWeb));
  72. }
  73. @PutMapping("/connect")
  74. public AjaxResult editConnectWeb(@RequestBody ConnectWeb connectWeb) {
  75. return toAjax(webService.updateConnectWeb(connectWeb));
  76. }
  77. @DeleteMapping("/connect/{connectWebId}")
  78. public AjaxResult removeConnectWeb(@PathVariable String connectWebId) {
  79. return toAjax(webService.deleteConnectWeb(connectWebId));
  80. }
  81. }

1.4

  1. package com.admin.service;
  2. import com.admin.domain.ConnectWeb;
  3. import com.admin.domain.PersonWeb;
  4. import org.neo4j.driver.Record;
  5. import java.util.List;
  6. public interface WebService {
  7. List<Record> selectPersonWebMap();
  8. public List<PersonWeb> selectPersonWebList() ;
  9. public List<PersonWeb> selectPersonWebSearchList(String personWebName) ;
  10. public List<PersonWeb> selectPersonWebSearchListOther(String personWebName, String personWebId) ;
  11. public PersonWeb selectPersonWebById(String personWebId) ;
  12. public int insertPersonWeb(PersonWeb personWeb) ;
  13. public int updatePersonWeb(PersonWeb personWeb) ;
  14. public int deletePersonWeb(String personWebId) ;
  15. public ConnectWeb selectConnectWebById(String connectWebId) ;
  16. public int insertConnectWeb(ConnectWeb connectWeb) ;
  17. public int updateConnectWeb(ConnectWeb connectWeb) ;
  18. public int deleteConnectWeb(String connectWebId) ;
  19. }

1.5 

  1. package com.admin.service.impl;
  2. import com.admin.common.annotation.DataSource;
  3. import com.admin.common.enums.DataSourceType;
  4. import com.admin.domain.ConnectWeb;
  5. import com.admin.domain.PersonWeb;
  6. import com.admin.mapper.ConnectWebMapper;
  7. import com.admin.mapper.PersonWebMapper;
  8. import com.admin.service.WebService;
  9. import com.admin.utils.SnowflakeIdWorker;
  10. import org.neo4j.driver.Record;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import java.util.List;
  14. @Service
  15. public class WebServiceImpl implements WebService {
  16. @Autowired
  17. private PersonWebMapper personWebMapper;
  18. @Autowired
  19. private ConnectWebMapper connectWebMapper;
  20. @Autowired
  21. private SnowflakeIdWorker snowflakeIdWorker;
  22. @DataSource(value = DataSourceType.SLAVE)
  23. public List<Record> selectPersonWebMap() {
  24. return personWebMapper.selectPersonWebMap();
  25. }
  26. @DataSource(value = DataSourceType.SLAVE)
  27. public List<PersonWeb> selectPersonWebList() {
  28. List<PersonWeb> personWebs = personWebMapper.selectPersonWebList();
  29. return personWebs;
  30. }
  31. @DataSource(value = DataSourceType.SLAVE)
  32. public List<PersonWeb> selectPersonWebSearchList(String personWebName) {
  33. // System.out.println(personWebName);
  34. return personWebMapper.selectPersonWebSearchList(personWebName);
  35. }
  36. @DataSource(value = DataSourceType.SLAVE)
  37. public List<PersonWeb> selectPersonWebSearchListOther(String personWebName, String personWebId) {
  38. // System.out.println(personWebName);
  39. return personWebMapper.selectPersonWebSearchListOther(personWebName, personWebId);
  40. }
  41. @DataSource(value = DataSourceType.SLAVE)
  42. public PersonWeb selectPersonWebById(String personWebId) {
  43. return personWebMapper.selectPersonWebById(personWebId);
  44. }
  45. @DataSource(value = DataSourceType.SLAVE)
  46. public int insertPersonWeb(PersonWeb personWeb) {
  47. personWeb.setPersonWebId(snowflakeIdWorker.nextId());
  48. return personWebMapper.insertPersonWeb(personWeb);
  49. }
  50. @DataSource(value = DataSourceType.SLAVE)
  51. public int updatePersonWeb(PersonWeb personWeb) {
  52. return personWebMapper.updatePersonWeb(personWeb);
  53. }
  54. @DataSource(value = DataSourceType.SLAVE)
  55. public int deletePersonWeb(String personWebId) {
  56. return personWebMapper.deletePersonWeb(personWebId);
  57. }
  58. @DataSource(value = DataSourceType.SLAVE)
  59. public ConnectWeb selectConnectWebById(String connectWebId) {
  60. return connectWebMapper.selectConnectWebById(connectWebId);
  61. }
  62. @DataSource(value = DataSourceType.SLAVE)
  63. public int insertConnectWeb(ConnectWeb connectWeb) {
  64. connectWeb.setConnectWebId(snowflakeIdWorker.nextId());
  65. return connectWebMapper.insertConnectWeb(connectWeb);
  66. }
  67. @DataSource(value = DataSourceType.SLAVE)
  68. public int updateConnectWeb(ConnectWeb connectWeb) {
  69. return connectWebMapper.updateConnectWeb(connectWeb);
  70. }
  71. @DataSource(value = DataSourceType.SLAVE)
  72. public int deleteConnectWeb(String connectWebId) {
  73. return connectWebMapper.deleteConnectWeb(connectWebId);
  74. }
  75. }

1.6

  1. package com.admin.mapper;
  2. import com.admin.domain.ConnectWeb;
  3. import org.springframework.stereotype.Repository;
  4. /**
  5. * @author wangwei
  6. */
  7. @Repository
  8. public interface ConnectWebMapper {
  9. /**
  10. * 查询单个连接信息
  11. *
  12. * @param connectWebId 连接id
  13. * @return ConnectWeb实体信息
  14. */
  15. ConnectWeb selectConnectWebById(String connectWebId);
  16. /**
  17. * 插入单个连接信息
  18. *
  19. * @param connectWeb 连接实体
  20. * @return 插入个数
  21. */
  22. int insertConnectWeb(ConnectWeb connectWeb);
  23. /**
  24. * 修改单个连接信息
  25. *
  26. * @param connectWeb 修改实体
  27. * @return 插入个数
  28. */
  29. int updateConnectWeb(ConnectWeb connectWeb);
  30. /**
  31. * 删除单个连接
  32. *
  33. * @param connectWebId 连接实体
  34. * @return 删除个数
  35. */
  36. int deleteConnectWeb(String connectWebId);
  37. }

1.7

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org/DTD Mapper 3.0" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.admin.mapper.ConnectWebMapper">
  4. <select id="selectConnectWebById" parameterType="String" resultType="com.admin.domain.ConnectWeb">
  5. MATCH (m)-[c:ConnectWeb{
  6. connectWebId: #{connectWebId}
  7. }]->(n)
  8. RETURN
  9. c.connectWebId as connectWebId,
  10. c.connectWebName as connectWebName,
  11. c.connectWebInfo as connectWebInfo,
  12. m.personWebId as personWebIdAlpha,
  13. m.personWebName as personWebIdAlphaName,
  14. n.personWebId as personWebIdBeta,
  15. n.personWebName as personWebIdBetaName
  16. </select>
  17. <insert id="insertConnectWeb" parameterType="com.admin.domain.ConnectWeb">
  18. match(pa:PersonWeb{
  19. personWebId: #{personWebIdAlpha}
  20. }),(pb:PersonWeb{
  21. personWebId: #{personWebIdBeta}
  22. })
  23. merge (pa)-[c:ConnectWeb{
  24. connectWebId: #{connectWebId},
  25. connectWebName: #{connectWebName},
  26. connectWebInfo: #{connectWebInfo}
  27. }]->(pb)
  28. </insert>
  29. <update id="updateConnectWeb" parameterType="com.admin.domain.ConnectWeb">
  30. MATCH (m)-[c:ConnectWeb{
  31. connectWebId: #{connectWebId}
  32. }]->(n)
  33. <trim prefix="SET" suffixOverrides=",">
  34. <if test="connectWebName != null">c.connectWebName = #{connectWebName},</if>
  35. <if test="connectWebInfo != null">c.connectWebInfo = #{connectWebInfo},</if>
  36. <if test="personWebIdAlpha != null">m.personWebId = #{personWebIdAlpha},</if>
  37. <if test="personWebIdBeta != null">n.personWebId = #{personWebIdBeta},</if>
  38. </trim>
  39. </update>
  40. <delete id="deleteConnectWeb" parameterType="String">
  41. MATCH ()-[c:ConnectWeb{
  42. connectWebId: #{connectWebId}
  43. }]-()
  44. DELETE c
  45. </delete>
  46. </mapper>

1.8 maven 

  1. <!--手动添加-->
  2. <!--neo4j-jdbc-driver-->
  3. <dependency>
  4. <groupId>org.neo4j</groupId>
  5. <artifactId>neo4j-jdbc-driver</artifactId>
  6. <version>4.0.1</version>
  7. </dependency>

1.9 数据库配置

  1. #TODO 从库数据源 neo4j
  2. slave:
  3. # 从数据源开关/默认关闭
  4. enabled: true
  5. url: jdbc:neo4j:bolt://127.0.0.1:1273
  6. username: neo4j
  7. password: neo4j
  8. driverClassName: org.neo4j.jdbc.bolt.BoltDriver
  9. #TODO NEO4J 配置检测连接是否有效
  10. validationQuery: match (n) return id(n) limit 2

二、vue前台

2.1

  1. <template>
  2. <div class="app-container">
  3. <div class="echarts">
  4. <div class="bin" id="main"></div>
  5. </div>
  6. <el-row :gutter="10" class="mb8">
  7. <el-col :span="1.5">
  8. <el-button
  9. type="primary"
  10. icon="el-icon-plus"
  11. size="mini"
  12. @click="handleAdd"
  13. >新增成员
  14. </el-button>
  15. </el-col>
  16. <el-col :span="1.5">
  17. <el-button
  18. type="success"
  19. icon="el-icon-edit"
  20. size="mini"
  21. :disabled="single"
  22. @click="handleUpdate"
  23. >修改成员
  24. </el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button
  28. type="danger"
  29. icon="el-icon-plus"
  30. size="mini"
  31. @click="handleAddConnect"
  32. >新增关系
  33. </el-button>
  34. </el-col>
  35. <right-toolbar :showSearch.sync="showSearch" @queryTable="refresh"></right-toolbar>
  36. </el-row>
  37. <el-table v-loading="loading" :data="personList" @selection-change="handleSelectionChange">
  38. <el-table-column type="selection" width="55" align="center"/>
  39. <el-table-column label="成员昵称" align="center" prop="personWebName" :show-overflow-tooltip="true">
  40. <template slot-scope="scope">
  41. <a v-if="scope.row.personWebLink" target="_blank" :href="scope.row.personWebLink" class="link-type"
  42. style="margin-right: 10px;">
  43. <span>{{ scope.row.personWebName }}</span>
  44. </a>
  45. <span v-else>{{ scope.row.personWebName }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="成员简介" align="center" prop="personWebInfo" :show-overflow-tooltip="true"/>
  49. <el-table-column label="成员头像" align="center">
  50. <template slot-scope="scope">
  51. <img :src="person_pic_url + scope.row.personWebPic" alt="" class="pic-in-list">
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="活跃平台" align="center" prop="personWebPlatform" :formatter="personPlatformFormat">
  55. </el-table-column>
  56. <el-table-column label="常驻领域" align="center" prop="personWebField">
  57. <template slot-scope="scope">
  58. <el-tag v-for="ikey in scope.row.personWebField" :key="ikey" type="success" style="margin: 10px;">
  59. {{ikey}}
  60. </el-tag>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="沟通要旨" align="center" prop="personWebKey" :show-overflow-tooltip="true"/>
  64. <el-table-column label="是否展示" align="center" width="100" prop="personWebShow" :formatter="personShowFormat">
  65. <template slot-scope="scope">
  66. <el-tag :type="scope.row.personWebShow | statusFilter">
  67. {{ scope.row.personWebShow | statusShowFilter}}
  68. </el-tag>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  72. <template slot-scope="scope">
  73. <el-button
  74. size="mini"
  75. type="text"
  76. icon="el-icon-edit"
  77. @click="handleUpdate(scope.row)"
  78. >修改
  79. </el-button>
  80. <el-button
  81. size="mini"
  82. type="text"
  83. icon="el-icon-delete"
  84. @click="handleDelete(scope.row)"
  85. >删除
  86. </el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <el-dialog :visible.sync="openConnect" width="600px" append-to-body :title="titleConnect">
  91. <el-form ref="formConnect" :model="formConnect" :rules="rulesConnect" size="medium" label-width="100px">
  92. <el-row type="flex" justify="start" align="top">
  93. <el-col :span="12">
  94. <el-form-item
  95. label="关联上级"
  96. prop="personWebIdAlpha"
  97. :rules="requireFlag ? rulesConnect.personWebIdAlpha:[{
  98. required: false
  99. }]"
  100. >
  101. <el-select
  102. :disabled="!requireFlag"
  103. v-model="formConnect.personWebIdAlpha"
  104. class="filter-item"
  105. filterable
  106. remote
  107. reserve-keyword
  108. clearable
  109. :placeholder="formConnect.personWebIdAlphaName"
  110. :remote-method="remoteMethodStart"
  111. :loading="selectLoading" value="">
  112. <el-option
  113. v-for="item in optionsStart"
  114. :key="item.personWebId"
  115. :label="item.personWebName"
  116. :value="item.personWebId">
  117. </el-option>
  118. </el-select>
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="12">
  122. <el-form-item
  123. label="关联下属"
  124. prop="personWebIdBeta"
  125. :rules="requireFlag ? rulesConnect.personWebIdBeta:[{
  126. required: false
  127. }]"
  128. >
  129. <el-select
  130. :disabled="!requireFlag"
  131. v-model="formConnect.personWebIdBeta"
  132. class="filter-item"
  133. filterable
  134. remote
  135. reserve-keyword
  136. clearable
  137. :placeholder="formConnect.personWebIdBetaName"
  138. :remote-method="remoteMethodEnd"
  139. :loading="selectLoading" value="">
  140. <el-option
  141. v-for="item in optionsEnd"
  142. :key="item.personWebId"
  143. :label="item.personWebName"
  144. :value="item.personWebId">
  145. </el-option>
  146. </el-select>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. <el-form-item label="关联关系" prop="connectWebName">
  151. <el-input v-model="formConnect.connectWebName" placeholder="请输入关联关系" clearable :style="{width: '100%'}">
  152. </el-input>
  153. </el-form-item>
  154. <el-form-item label="关联信息" prop="connectWebInfo">
  155. <el-input v-model="formConnect.connectWebInfo" type="textarea" placeholder="请输入关联信息"
  156. :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
  157. </el-form-item>
  158. </el-form>
  159. <div slot="footer">
  160. <el-button v-if="!requireFlag" type="danger" @click="deleteConnect">删除</el-button>
  161. <el-button @click="cancelConnect">取消</el-button>
  162. <el-button type="primary" @click="handelConfirm">确定</el-button>
  163. </div>
  164. </el-dialog>
  165. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  166. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  167. <el-form-item label="成员昵称" prop="personWebName">
  168. <el-input v-model="form.personWebName" placeholder="请输入成员昵称"/>
  169. </el-form-item>
  170. <el-form-item label="成员简介" prop="personWebInfo">
  171. <el-input v-model="form.personWebInfo" type="textarea" placeholder="请输入成员简介"/>
  172. </el-form-item>
  173. <el-form-item label="跳转链接" prop="personWebLink">
  174. <el-input v-model="form.personWebLink" placeholder="请输入跳转链接"/>
  175. </el-form-item>
  176. <el-form-item label="成员头像" prop="personWebPic">
  177. <el-button v-show="!form.personWebPic" type="primary" size="mini" @click="imageCropperShow()">
  178. 上传图片
  179. </el-button>
  180. <el-button v-show="form.personWebPic" type="primary" size="mini" @click="imageCropperShow()">
  181. 更新图片
  182. </el-button>
  183. <el-button v-show="form.personWebPic" type="primary" size="mini" @click="picShow(form.personWebPic)">
  184. 预览
  185. </el-button>
  186. </el-form-item>
  187. <el-form-item label="活跃平台">
  188. <el-checkbox-group v-model="form.personWebPlatform">
  189. <el-checkbox
  190. v-for="dict in personWebPlatformOptions"
  191. :key="dict.dictValue"
  192. :label="dict.dictValue">
  193. {{dict.dictLabel}}
  194. </el-checkbox>
  195. </el-checkbox-group>
  196. </el-form-item>
  197. <el-form-item label="常驻领域" prop="personWebField">
  198. <el-tag
  199. :key="index"
  200. v-for="(tag, index) in form.personWebField"
  201. closable
  202. :disable-transitions="false"
  203. @close="handleClose(tag)">
  204. {{tag}}
  205. </el-tag>
  206. <el-input
  207. class="input-new-tag"
  208. v-if="inputVisible"
  209. v-model="inputValue"
  210. ref="saveTagInput"
  211. size="small"
  212. @keyup.enter.native="handleInputConfirm"
  213. @blur="handleInputConfirm"
  214. >
  215. </el-input>
  216. <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新标签</el-button>
  217. </el-form-item>
  218. <el-form-item label="沟通要旨" prop="personWebInfo">
  219. <el-input v-model="form.personWebKey" type="textarea" placeholder="请输入沟通要旨"/>
  220. </el-form-item>
  221. <el-form-item label="是否展示">
  222. <el-radio-group v-model="form.personWebShow">
  223. <el-radio
  224. v-for="dict in personWebShowOptions"
  225. :key="dict.dictValue"
  226. :label="dict.dictValue"
  227. >{{dict.dictLabel}}
  228. </el-radio>
  229. </el-radio-group>
  230. </el-form-item>
  231. </el-form>
  232. <div slot="footer" class="dialog-footer">
  233. <el-button type="primary" @click="submitForm">确 定</el-button>
  234. <el-button @click="cancel">取 消</el-button>
  235. </div>
  236. </el-dialog>
  237. <my-upload
  238. method="POST"
  239. field="file"
  240. v-model="upload.cropperShow"
  241. :headers="upload.headers"
  242. :width=300
  243. :height=300
  244. :url="this.upload.logo_url"
  245. lang-type='zh'
  246. img-format='jpg'
  247. img-bgc='#FFF'
  248. :no-circle=true
  249. @crop-upload-success="cropUploadSuccess">
  250. </my-upload>
  251. <el-dialog title="图片预览" :visible.sync="picVisible" width="500px" center>
  252. <div style="text-align: center">
  253. <img :src="answerPicImageUrl" alt="" class="pic-in-dialog">
  254. </div>
  255. <span slot="footer" class="dialog-footer">
  256. <el-button @click="picVisible = false">确定</el-button>
  257. </span>
  258. </el-dialog>
  259. </div>
  260. </template>
  261. <script>
  262. // import graph from '@/assets/binray/les-miserables';
  263. import {
  264. getPersonWebMap,
  265. getPersonWebList,
  266. getPersonWebSearch,
  267. getPersonWebInfo,
  268. addPersonWeb,
  269. editPersonWeb,
  270. removePersonWeb,
  271. getInfoConnectWeb,
  272. addConnectWeb,
  273. editConnectWeb,
  274. removeConnectWeb,
  275. getPersonWebSearchOther
  276. } from '@/api/person';
  277. import 'babel-polyfill'; // es6 shim
  278. import myUpload from 'vue-image-crop-upload/upload-2';
  279. export default {
  280. name: 'Echarts',
  281. components: {myUpload},
  282. filters: {
  283. statusShowFilter(status) {
  284. const statusMap = {
  285. 0: '正常',
  286. 1: '已下线',
  287. }
  288. return statusMap[status]
  289. },
  290. statusFilter(status) {
  291. const statusMap = {
  292. 0: 'success',
  293. 1: 'warning',
  294. }
  295. return statusMap[status]
  296. }
  297. },
  298. data() {
  299. return {
  300. // 新增or更新,新增为true,更新为false
  301. requireFlag: false,
  302. myChart: undefined,
  303. // 表单参数
  304. form: {},
  305. formConnect: {},
  306. // 表单校验
  307. rules: {
  308. personWebName: [{
  309. required: true,
  310. message: '成员名称为必填项',
  311. trigger: 'blur'
  312. }],
  313. /* personWebPic: [{
  314. required: true,
  315. message: '成员头图为必填项',
  316. trigger: 'change'
  317. }],*/
  318. personWebShow: [{
  319. required: true,
  320. message: '是否展示为必填项',
  321. trigger: 'change'
  322. }],
  323. },
  324. rulesConnect: {
  325. personWebIdAlpha: [{
  326. required: true,
  327. message: '',
  328. trigger: 'blur'
  329. }],
  330. personWebIdBeta: [{
  331. required: true,
  332. message: '',
  333. trigger: 'blur'
  334. }],
  335. connectWebName: [{
  336. required: true,
  337. message: '请输入关联关系',
  338. trigger: 'blur'
  339. }],
  340. connectWebInfo: [{
  341. required: true,
  342. message: '请输入关联信息',
  343. trigger: 'blur'
  344. }],
  345. },
  346. selectLoading: false,
  347. optionsStart: [],
  348. optionsEnd: [],
  349. personList: [],
  350. personMap: [],
  351. // 临时标签列表
  352. personWebPlatformTemp: undefined,
  353. personWebFieldTemp: undefined,
  354. // 路径
  355. person_pic_url: process.env.VUE_APP_BASE_API + "/File/upload/nosql/",
  356. //D:\File\upload\nosql
  357. // 图片预览框
  358. picVisible: false,
  359. // 拼接
  360. answerPicImageUrl: "",
  361. // 路径
  362. // 遮罩层
  363. loading: true,
  364. // 选中数组
  365. ids: [],
  366. // 非单个禁用
  367. single: true,
  368. // 非多个禁用
  369. multiple: true,
  370. // 显示搜索条件
  371. showSearch: true,
  372. // 总条数
  373. total: 0,
  374. upload: {
  375. // 显示上传图片的弹出框
  376. cropperShow: false,
  377. // 图标路径
  378. logo_url: process.env.VUE_APP_BASE_API + "/common/upload",
  379. },
  380. // 弹出层标题
  381. title: "",
  382. titleConnect: "",
  383. // 是否显示弹出层
  384. open: false,
  385. openConnect: false,
  386. inputVisible: false,
  387. // 具体内容
  388. inputValue: '',
  389. personWebShowOptions: [],
  390. personWebPlatformOptions: [],
  391. searchQueryParams: {
  392. // 这个一定得有
  393. personWebIdStart: null,
  394. // 这个可有可无
  395. personWebIdEnd: null,
  396. },
  397. graph: {
  398. nodes: [],
  399. links: []
  400. },
  401. mapCheckList: []
  402. }
  403. },
  404. created() {
  405. this.getList();
  406. this.personWebShowOptions = [{
  407. "searchValue": null,
  408. "createBy": "admin",
  409. "createTime": "2021-02-21 19:29:04",
  410. "updateBy": null,
  411. "updateTime": null,
  412. "remark": null,
  413. "params": {},
  414. "dictCode": 124,
  415. "dictSort": 0,
  416. "dictLabel": "已上架",
  417. "dictValue": "0",
  418. "dictType": "material_public",
  419. "cssClass": null,
  420. "listClass": null,
  421. "isDefault": "N",
  422. "status": "0",
  423. "default": false
  424. }, {
  425. "searchValue": null,
  426. "createBy": "admin",
  427. "createTime": "2021-02-21 19:29:39",
  428. "updateBy": null,
  429. "updateTime": null,
  430. "remark": null,
  431. "params": {},
  432. "dictCode": 125,
  433. "dictSort": 1,
  434. "dictLabel": "未发布",
  435. "dictValue": "1",
  436. "dictType": "material_public",
  437. "cssClass": null,
  438. "listClass": null,
  439. "isDefault": "N",
  440. "status": "0",
  441. "default": false
  442. }];
  443. this.personWebPlatformOptions = [{
  444. "searchValue": null,
  445. "createBy": "admin",
  446. "createTime": "2021-03-26 02:20:51",
  447. "updateBy": null,
  448. "updateTime": null,
  449. "remark": null,
  450. "params": {},
  451. "dictCode": 135,
  452. "dictSort": 0,
  453. "dictLabel": "哔哩哔哩",
  454. "dictValue": "0",
  455. "dictType": "media_platform",
  456. "cssClass": null,
  457. "listClass": null,
  458. "isDefault": "N",
  459. "status": "0",
  460. "default": false
  461. }, {
  462. "searchValue": null,
  463. "createBy": "admin",
  464. "createTime": "2021-03-26 02:21:03",
  465. "updateBy": null,
  466. "updateTime": null,
  467. "remark": null,
  468. "params": {},
  469. "dictCode": 136,
  470. "dictSort": 1,
  471. "dictLabel": "今日头条",
  472. "dictValue": "1",
  473. "dictType": "media_platform",
  474. "cssClass": null,
  475. "listClass": null,
  476. "isDefault": "N",
  477. "status": "0",
  478. "default": false
  479. }, {
  480. "searchValue": null,
  481. "createBy": "admin",
  482. "createTime": "2021-03-26 02:21:12",
  483. "updateBy": null,
  484. "updateTime": null,
  485. "remark": null,
  486. "params": {},
  487. "dictCode": 137,
  488. "dictSort": 2,
  489. "dictLabel": "抖音",
  490. "dictValue": "2",
  491. "dictType": "media_platform",
  492. "cssClass": null,
  493. "listClass": null,
  494. "isDefault": "N",
  495. "status": "0",
  496. "default": false
  497. }, {
  498. "searchValue": null,
  499. "createBy": "admin",
  500. "createTime": "2021-03-26 02:21:21",
  501. "updateBy": null,
  502. "updateTime": null,
  503. "remark": null,
  504. "params": {},
  505. "dictCode": 138,
  506. "dictSort": 3,
  507. "dictLabel": "西瓜视频",
  508. "dictValue": "3",
  509. "dictType": "media_platform",
  510. "cssClass": null,
  511. "listClass": null,
  512. "isDefault": "N",
  513. "status": "0",
  514. "default": false
  515. }, {
  516. "searchValue": null,
  517. "createBy": "admin",
  518. "createTime": "2021-03-26 02:21:29",
  519. "updateBy": null,
  520. "updateTime": null,
  521. "remark": null,
  522. "params": {},
  523. "dictCode": 139,
  524. "dictSort": 4,
  525. "dictLabel": "YouTube",
  526. "dictValue": "4",
  527. "dictType": "media_platform",
  528. "cssClass": null,
  529. "listClass": null,
  530. "isDefault": "N",
  531. "status": "0",
  532. "default": false
  533. }, {
  534. "searchValue": null,
  535. "createBy": "admin",
  536. "createTime": "2021-03-26 02:22:06",
  537. "updateBy": null,
  538. "updateTime": null,
  539. "remark": null,
  540. "params": {},
  541. "dictCode": 140,
  542. "dictSort": 5,
  543. "dictLabel": "知乎",
  544. "dictValue": "5",
  545. "dictType": "media_platform",
  546. "cssClass": null,
  547. "listClass": null,
  548. "isDefault": "N",
  549. "status": "0",
  550. "default": false
  551. }, {
  552. "searchValue": null,
  553. "createBy": "admin",
  554. "createTime": "2021-03-26 02:22:17",
  555. "updateBy": null,
  556. "updateTime": null,
  557. "remark": null,
  558. "params": {},
  559. "dictCode": 141,
  560. "dictSort": 6,
  561. "dictLabel": "小红书",
  562. "dictValue": "6",
  563. "dictType": "media_platform",
  564. "cssClass": null,
  565. "listClass": null,
  566. "isDefault": "N",
  567. "status": "0",
  568. "default": false
  569. }, {
  570. "searchValue": null,
  571. "createBy": "admin",
  572. "createTime": "2021-03-26 02:22:27",
  573. "updateBy": null,
  574. "updateTime": null,
  575. "remark": null,
  576. "params": {},
  577. "dictCode": 142,
  578. "dictSort": 7,
  579. "dictLabel": "快手",
  580. "dictValue": "7",
  581. "dictType": "media_platform",
  582. "cssClass": null,
  583. "listClass": null,
  584. "isDefault": "N",
  585. "status": "0",
  586. "default": false
  587. }, {
  588. "searchValue": null,
  589. "createBy": "admin",
  590. "createTime": "2021-03-26 02:22:49",
  591. "updateBy": null,
  592. "updateTime": null,
  593. "remark": null,
  594. "params": {},
  595. "dictCode": 143,
  596. "dictSort": 8,
  597. "dictLabel": "Acfun",
  598. "dictValue": "8",
  599. "dictType": "media_platform",
  600. "cssClass": null,
  601. "listClass": null,
  602. "isDefault": "N",
  603. "status": "0",
  604. "default": false
  605. }, {
  606. "searchValue": null,
  607. "createBy": "admin",
  608. "createTime": "2021-03-26 02:23:05",
  609. "updateBy": null,
  610. "updateTime": null,
  611. "remark": null,
  612. "params": {},
  613. "dictCode": 144,
  614. "dictSort": 9,
  615. "dictLabel": "网易云音乐",
  616. "dictValue": "9",
  617. "dictType": "media_platform",
  618. "cssClass": null,
  619. "listClass": null,
  620. "isDefault": "N",
  621. "status": "0",
  622. "default": false
  623. }, {
  624. "searchValue": null,
  625. "createBy": "admin",
  626. "createTime": "2021-03-26 02:23:34",
  627. "updateBy": null,
  628. "updateTime": null,
  629. "remark": null,
  630. "params": {},
  631. "dictCode": 145,
  632. "dictSort": 10,
  633. "dictLabel": "豆瓣",
  634. "dictValue": "10",
  635. "dictType": "media_platform",
  636. "cssClass": null,
  637. "listClass": null,
  638. "isDefault": "N",
  639. "status": "0",
  640. "default": false
  641. }, {
  642. "searchValue": null,
  643. "createBy": "admin",
  644. "createTime": "2021-03-26 02:23:52",
  645. "updateBy": null,
  646. "updateTime": null,
  647. "remark": null,
  648. "params": {},
  649. "dictCode": 146,
  650. "dictSort": 11,
  651. "dictLabel": "微博",
  652. "dictValue": "11",
  653. "dictType": "media_platform",
  654. "cssClass": null,
  655. "listClass": null,
  656. "isDefault": "N",
  657. "status": "0",
  658. "default": false
  659. }, {
  660. "searchValue": null,
  661. "createBy": "admin",
  662. "createTime": "2021-03-26 02:24:34",
  663. "updateBy": null,
  664. "updateTime": null,
  665. "remark": null,
  666. "params": {},
  667. "dictCode": 147,
  668. "dictSort": 12,
  669. "dictLabel": "新片场",
  670. "dictValue": "12",
  671. "dictType": "media_platform",
  672. "cssClass": null,
  673. "listClass": null,
  674. "isDefault": "N",
  675. "status": "0",
  676. "default": false
  677. }, {
  678. "searchValue": null,
  679. "createBy": "admin",
  680. "createTime": "2021-03-26 02:24:50",
  681. "updateBy": null,
  682. "updateTime": null,
  683. "remark": null,
  684. "params": {},
  685. "dictCode": 148,
  686. "dictSort": 13,
  687. "dictLabel": "图虫",
  688. "dictValue": "13",
  689. "dictType": "media_platform",
  690. "cssClass": null,
  691. "listClass": null,
  692. "isDefault": "N",
  693. "status": "0",
  694. "default": false
  695. }]
  696. },
  697. methods: {
  698. myEcharts() {
  699. const that = this;
  700. this.myChart.showLoading();
  701. this.graph.nodes.forEach(function (node) {
  702. node.label = {
  703. show: true
  704. };
  705. });
  706. const option = {
  707. title: {
  708. text: '',
  709. subtext: '',
  710. top: 'bottom',
  711. left: 'right'
  712. },
  713. tooltip: {
  714. trigger: "item",
  715. // textStyle: {
  716. // width: 10,
  717. // fontWeight: "bold",
  718. // overflow: "truncate"
  719. // },
  720. confine: 'true',
  721. formatter: function (param) {
  722. if (param.dataType === 'edge') {
  723. // 连接
  724. return [
  725. '关系:' + param.data["connectWebName"] + '<br/>',
  726. '详情:' + param.data["connectWebInfo"] + '<br/>'
  727. ].join('');
  728. } else if (param.dataType === 'node') {
  729. // 处理标签
  730. let graphTag = '';
  731. const arr1 = JSON.parse(param.data["personWebField"]);
  732. for (let i = 0; i < arr1.length; i++) {
  733. if (i === 0) {
  734. graphTag = `<span style="
  735. display: inline-block;
  736. border-radius: 4px;
  737. min-width: min-content;
  738. padding: 0 10px;
  739. margin: 5px;
  740. background-color: #e7faf0;
  741. border-color: #d0f5e0;
  742. color: #13ce66;
  743. border-width: 1px;
  744. border-style: solid;
  745. ">${arr1[i]}</span>`
  746. } else {
  747. graphTag = graphTag + `<span style="
  748. display: inline-block;
  749. border-radius: 4px;
  750. min-width: min-content;
  751. padding: 0 10px;
  752. margin: 5px;
  753. background-color: #e7faf0;
  754. border-color: #d0f5e0;
  755. color: #13ce66;
  756. border-width: 1px;
  757. border-style: solid;
  758. ">${arr1[i]}</span>`;
  759. }
  760. }
  761. // 处理字典
  762. let graphDict = '';
  763. const arrTemp = that.selectDictLabel(that.personWebPlatformOptions, JSON.parse(param.data["personWebPlatform"]));
  764. const arr2 = arrTemp.split(', ')
  765. for (let i = 0; i < arr2.length; i++) {
  766. if (i === 0) {
  767. graphDict = `<span style="
  768. display: inline-block;
  769. border-radius: 4px;
  770. min-width: min-content;
  771. padding: 0 10px;
  772. margin: 5px;
  773. background-color: #faece7;
  774. border-color: #f5dad0;
  775. color: #ff7d27;
  776. border-width: 1px;
  777. border-style: solid;
  778. ">${arr2[i]}</span>`
  779. } else {
  780. graphDict = graphDict + `<span style="
  781. display: inline-block;
  782. border-radius: 4px;
  783. min-width: min-content;
  784. padding: 0 10px;
  785. margin: 5px;
  786. background-color: #faece7;
  787. border-color: #f5dad0;
  788. color: #ff7d27;
  789. border-width: 1px;
  790. border-style: solid;
  791. ">${arr2[i]}</span>`;
  792. }
  793. }
  794. // 节点
  795. return [
  796. '<div style="text-align:left;max-width:1000px;">昵称:' + param.data["name"] + '<br/>',
  797. '<div style="display:block;word-break: break-all;word-wrap: break-word;white-space: pre-line;">简介:' + param.data["personWebInfo"] + '</div>',
  798. '常驻领域:' + graphTag + '<br/>',
  799. '活跃平台:' + graphDict + '</div><br/>',
  800. ].join('');
  801. }
  802. }
  803. },
  804. legend: [],
  805. animationDuration: 150,
  806. animationEasingUpdate: 'quinticInOut',
  807. series: [
  808. {
  809. name: '',
  810. type: 'graph',
  811. layout: "force",
  812. force: {
  813. repulsion: 200,
  814. edgeLength: 100,
  815. gravity: 0.2
  816. },
  817. symbolSize: 50,
  818. data: this.graph.nodes,
  819. links: this.graph.links,
  820. // data: graph.nodes,
  821. // links: graph.links,
  822. roam: true,
  823. label: {
  824. show: true,
  825. },
  826. draggable: true,
  827. labelLayout: {
  828. hideOverlap: false
  829. },
  830. lineStyle: {
  831. color: 'source',
  832. curveness: 0.3
  833. },
  834. emphasis: {
  835. focus: 'adjacency',
  836. lineStyle: {
  837. width: 10
  838. }
  839. }
  840. }
  841. ]
  842. };
  843. this.myChart.clear();
  844. option && this.myChart.setOption(option, true);
  845. // console.log(option)
  846. this.myChart.hideLoading();
  847. this.myChart.on("click", function (e) {
  848. if (e.dataType === 'edge') {
  849. that.handleUpdateConnect(e.data)
  850. } else if (e.dataType === 'node') {
  851. console.log(e)
  852. e.data.personWebId = e.data.id
  853. that.handleUpdate(e.data)
  854. }
  855. })
  856. },
  857. getList() {
  858. this.loading = true;
  859. getPersonWebList().then(response => {
  860. this.personList = response.rows;
  861. Object.keys(this.personList).forEach(key => {
  862. this.personList[key].personWebPlatform = JSON.parse(this.personList[key].personWebPlatform)
  863. this.personList[key].personWebField = JSON.parse(this.personList[key].personWebField)
  864. });
  865. this.loading = false;
  866. });
  867. },
  868. async getMap() {
  869. this.loading = true;
  870. await getPersonWebMap().then(response => {
  871. this.graph = {
  872. nodes: [],
  873. links: []
  874. };
  875. this.mapCheckList = [];
  876. this.personMap = response.rows;
  877. Object.keys(this.personMap).forEach(key => {
  878. // 导入节点,列表为空表示首次加入元素,反之亦然
  879. if (this.graph.nodes !== []) {
  880. // 如果导入过就不用重复导入了
  881. if (!this.mapCheckList.includes(this.personMap[key].PersonAlpha.personWebId)) {
  882. this.pushAlpha(key);
  883. }
  884. if (!this.mapCheckList.includes(this.personMap[key].PersonBeta.personWebId)) {
  885. this.pushBeta(key);
  886. }
  887. } else {
  888. this.pushAlpha(key);
  889. this.pushBeta(key);
  890. }
  891. // 把导入过的节点id存进checkList
  892. this.mapCheckList.push(this.personMap[key].PersonAlpha.personWebId)
  893. this.mapCheckList.push(this.personMap[key].PersonBeta.personWebId)
  894. // 导入关系
  895. this.pushConnect(key);
  896. });
  897. });
  898. // console.log(this.graph)
  899. this.loading = false;
  900. },
  901. pushAlpha(key) {
  902. this.graph.nodes.push({
  903. id: this.personMap[key].PersonAlpha.personWebId,
  904. name: this.personMap[key].PersonAlpha.personWebName,
  905. personWebPic: this.personMap[key].PersonAlpha.personWebPic,
  906. personWebShow: this.personMap[key].PersonAlpha.personWebShow,
  907. personWebLink: this.personMap[key].PersonAlpha.personWebLink,
  908. personWebPlatform: this.personMap[key].PersonAlpha.personWebPlatform,
  909. personWebField: this.personMap[key].PersonAlpha.personWebField,
  910. personWebInfo: this.personMap[key].PersonAlpha.personWebInfo,
  911. personWebKey: this.personMap[key].PersonAlpha.personWebKey,
  912. })
  913. },
  914. pushBeta(key) {
  915. this.graph.nodes.push({
  916. id: this.personMap[key].PersonBeta.personWebId,
  917. name: this.personMap[key].PersonBeta.personWebName,
  918. personWebPic: this.personMap[key].PersonBeta.personWebPic,
  919. personWebShow: this.personMap[key].PersonBeta.personWebShow,
  920. personWebLink: this.personMap[key].PersonBeta.personWebLink,
  921. personWebPlatform: this.personMap[key].PersonBeta.personWebPlatform,
  922. personWebField: this.personMap[key].PersonBeta.personWebField,
  923. personWebInfo: this.personMap[key].PersonBeta.personWebInfo,
  924. personWebKey: this.personMap[key].PersonBeta.personWebKey,
  925. })
  926. },
  927. pushConnect(key) {
  928. this.graph.links.push({
  929. source: this.personMap[key].PersonAlpha.personWebId,
  930. target: this.personMap[key].PersonBeta.personWebId,
  931. connectWebId: this.personMap[key].Connect.connectWebId,
  932. connectWebName: this.personMap[key].Connect.connectWebName,
  933. connectWebInfo: this.personMap[key].Connect.connectWebInfo,
  934. })
  935. },
  936. // 字典翻译
  937. personShowFormat(row, column) {
  938. return this.selectDictLabel(this.personWebShowOptions, row.personWebShow);
  939. },
  940. personPlatformFormat(row, column) {
  941. return this.selectDictLabel(this.personWebPlatformOptions, row.personWebPlatform);
  942. },
  943. // 取消按钮
  944. cancel() {
  945. this.open = false;
  946. this.reset();
  947. },
  948. // 取消按钮
  949. cancelConnect() {
  950. this.openConnect = false;
  951. this.resetConnect();
  952. },
  953. // 表单重置
  954. reset() {
  955. this.form = {
  956. personWebId: null,
  957. personWebName: null,
  958. personWebPic: null,
  959. personWebShow: "0",
  960. personWebLink: "",
  961. personWebPlatform: [],
  962. personWebField: [],
  963. personWebInfo: "",
  964. personWebKey: ""
  965. };
  966. this.answerPicImageUrl = null;
  967. this.resetForm("form");
  968. },
  969. resetConnect() {
  970. this.formConnect = {
  971. personWebIdAlpha: null,
  972. personWebIdBeta: null,
  973. personWebIdAlphaName: null,
  974. personWebIdBetaName: null,
  975. connectWebId: null,
  976. connectWebName: null,
  977. connectWebInfo: null,
  978. };
  979. this.resetForm("formConnect");
  980. },
  981. handleAddConnect() {
  982. this.optionsStart = []
  983. this.optionsEnd = []
  984. this.requireFlag = true;
  985. this.resetConnect();
  986. this.openConnect = true;
  987. this.titleConnect = "添加成员关系";
  988. },
  989. /** 修改按钮操作 */
  990. handleUpdateConnect(row) {
  991. this.optionsStart = []
  992. this.optionsEnd = []
  993. this.requireFlag = false;
  994. this.reset();
  995. const connectWeb = row.connectWebId;
  996. getInfoConnectWeb(connectWeb).then(response => {
  997. this.formConnect = response.data;
  998. // console.log(this.formConnect)
  999. this.formConnect.personWebIdAlpha = null;
  1000. this.formConnect.personWebIdBeta = null;
  1001. this.openConnect = true;
  1002. this.titleConnect = "修改成员关系";
  1003. });
  1004. },
  1005. // 多选框选中数据
  1006. handleSelectionChange(selection) {
  1007. this.ids = selection.map(item => item.personWebId)
  1008. this.single = selection.length !== 1
  1009. this.multiple = !selection.length
  1010. },
  1011. remoteMethodStart(keyword) {
  1012. if (keyword.trim() === '') {
  1013. this.optionsStart = []
  1014. return
  1015. }
  1016. // 当后一个对象不为空的情况
  1017. if (this.formConnect.personWebIdBeta) {
  1018. let others = [];
  1019. this.selectLoading = true;
  1020. getPersonWebSearch(keyword).then(data => {
  1021. getPersonWebSearchOther(this.formConnect.personWebIdBeta, keyword).then(dataOther => {
  1022. others = dataOther.rows;
  1023. this.optionsStart = [];
  1024. data.rows.forEach(ma => {
  1025. let exist = others.some(sa => {
  1026. return ma.personWebId === sa.personWebId
  1027. });
  1028. if (!exist) {
  1029. this.optionsStart.push(ma);
  1030. }
  1031. });
  1032. this.optionsStart = this.optionsStart.filter(item => item.personWebId !== this.formConnect.personWebIdBeta)
  1033. })
  1034. this.selectLoading = false;
  1035. })
  1036. }
  1037. // 后一个对象为空时
  1038. else {
  1039. this.selectLoading = true;
  1040. getPersonWebSearch(keyword).then(data => {
  1041. this.selectLoading = false;
  1042. this.optionsStart = data.rows;
  1043. })
  1044. }
  1045. },
  1046. remoteMethodEnd(keyword) {
  1047. if (keyword.trim() === '') {
  1048. this.optionsEnd = []
  1049. return
  1050. }
  1051. // 当前一个对象不为空的情况
  1052. if (this.formConnect.personWebIdAlpha) {
  1053. let others = [];
  1054. this.selectLoading = true;
  1055. getPersonWebSearch(keyword).then(data => {
  1056. getPersonWebSearchOther(this.formConnect.personWebIdAlpha, keyword).then(dataOther => {
  1057. others = dataOther.rows;
  1058. this.optionsEnd = [];
  1059. data.rows.forEach(ma => {
  1060. let exist = others.some(sa => {
  1061. return ma.personWebId === sa.personWebId
  1062. });
  1063. if (!exist) {
  1064. this.optionsEnd.push(ma);
  1065. }
  1066. });
  1067. this.optionsEnd = this.optionsEnd.filter(item => item.personWebId !== this.formConnect.personWebIdAlpha)
  1068. })
  1069. this.selectLoading = false;
  1070. })
  1071. }
  1072. // 前一个对象为空时
  1073. else {
  1074. this.selectLoading = true;
  1075. getPersonWebSearch(keyword).then(data => {
  1076. this.selectLoading = false;
  1077. this.optionsEnd = data.rows;
  1078. })
  1079. }
  1080. },
  1081. /** 新增按钮操作 */
  1082. handleAdd() {
  1083. this.reset();
  1084. this.open = true;
  1085. this.title = "添加成员管理";
  1086. },
  1087. /** 修改按钮操作 */
  1088. handleUpdate(row) {
  1089. this.reset();
  1090. const personWeb = row.personWebId || this.ids;
  1091. getPersonWebInfo(personWeb).then(response => {
  1092. this.form = response.data;
  1093. this.personWebPlatformTemp = this.form.personWebPlatform;
  1094. this.form.personWebPlatform = JSON.parse(this.personWebPlatformTemp);
  1095. this.personWebFieldTemp = this.form.personWebField;
  1096. this.form.personWebField = JSON.parse(this.personWebFieldTemp);
  1097. this.open = true;
  1098. this.title = "修改成員管理";
  1099. });
  1100. },
  1101. submitForm() {
  1102. this.$refs["form"].validate(valid => {
  1103. if (valid) {
  1104. this.open = false;
  1105. this.personWebPlatformTemp = this.form.personWebPlatform;
  1106. this.form.personWebPlatform = JSON.stringify(this.personWebPlatformTemp);
  1107. this.personWebFieldTemp = this.form.personWebField;
  1108. this.form.personWebField = JSON.stringify(this.personWebFieldTemp);
  1109. if (this.form.personWebId != null) {
  1110. editPersonWeb(this.form).then(response => {
  1111. if (response.code === 200) {
  1112. this.msgSuccess("修改成功");
  1113. this.refresh();
  1114. }
  1115. });
  1116. } else {
  1117. addPersonWeb(this.form).then(response => {
  1118. if (response.code === 200) {
  1119. this.msgSuccess("新增成功");
  1120. this.refresh();
  1121. }
  1122. });
  1123. }
  1124. }
  1125. });
  1126. },
  1127. handelConfirm() {
  1128. this.$refs["formConnect"].validate(valid => {
  1129. if (valid) {
  1130. this.openConnect = false;
  1131. if (this.formConnect.connectWebId != null) {
  1132. editConnectWeb(this.formConnect).then(response => {
  1133. if (response.code === 200) {
  1134. this.msgSuccess("修改成功");
  1135. this.refresh();
  1136. }
  1137. });
  1138. } else {
  1139. addConnectWeb(this.formConnect).then(response => {
  1140. if (response.code === 200) {
  1141. this.msgSuccess("新增成功");
  1142. this.refresh();
  1143. }
  1144. });
  1145. }
  1146. }
  1147. });
  1148. },
  1149. deleteConnect() {
  1150. const connectWebId = this.formConnect.connectWebId
  1151. this.$confirm('是否确认删除「' + this.formConnect.personWebIdAlphaName + '」和「' + this.formConnect.personWebIdBetaName + '」的关系?', "警告", {
  1152. confirmButtonText: "确定",
  1153. cancelButtonText: "取消",
  1154. type: "warning"
  1155. }).then(function () {
  1156. return removeConnectWeb(connectWebId);
  1157. }).then(() => {
  1158. this.openConnect = false;
  1159. this.refresh();
  1160. this.msgSuccess("删除成功");
  1161. }).catch(function (e) {
  1162. console.log(e)
  1163. });
  1164. },
  1165. /** 删除按钮操作 */
  1166. handleDelete(row) {
  1167. const personWebIds = row.personWebId || this.ids;
  1168. this.$confirm('是否确认删除成员编号为"' + personWebIds + '"的数据项?', "警告", {
  1169. confirmButtonText: "确定",
  1170. cancelButtonText: "取消",
  1171. type: "warning"
  1172. }).then(function () {
  1173. return removePersonWeb(personWebIds);
  1174. }).then(() => {
  1175. this.refresh();
  1176. this.msgSuccess("删除成功");
  1177. }).catch(function () {
  1178. });
  1179. },
  1180. // 显示图片上传模块
  1181. imageCropperShow() {
  1182. this.upload.cropperShow = !this.upload.cropperShow
  1183. },
  1184. // 图片上传成功后执行
  1185. cropUploadSuccess(jsonData, field) {
  1186. this.form.personWebPic = jsonData.fileName
  1187. // console.log(jsonData)
  1188. },
  1189. picShow(pic) {
  1190. this.picVisible = !this.picVisible;
  1191. this.answerPicImageUrl = this.person_pic_url + pic
  1192. },
  1193. handleClose(tag) {
  1194. this.form.personWebField.splice(this.form.personWebField.indexOf(tag), 1);
  1195. },
  1196. showInput() {
  1197. this.inputVisible = true;
  1198. this.$nextTick(_ => {
  1199. this.$refs.saveTagInput.$refs.input.focus();
  1200. });
  1201. },
  1202. handleInputConfirm() {
  1203. let inputValue = this.inputValue;
  1204. if (inputValue) {
  1205. this.form.personWebField.push(inputValue);
  1206. }
  1207. this.inputVisible = false;
  1208. this.inputValue = '';
  1209. },
  1210. async refresh() {
  1211. await this.getMap();
  1212. this.myEcharts();
  1213. this.getList()
  1214. },
  1215. },
  1216. async mounted() {
  1217. await this.getMap();
  1218. // 基于准备好的dom,初始化echarts实例
  1219. let echarts = require('echarts')
  1220. this.myChart = echarts.init(document.getElementById('main'));
  1221. this.myEcharts();
  1222. }
  1223. }
  1224. </script>
  1225. <style lang="scss" scoped>
  1226. .avatar-uploader .el-upload {
  1227. border: 1px dashed #d9d9d9;
  1228. border-radius: 6px;
  1229. cursor: pointer;
  1230. position: relative;
  1231. overflow: hidden;
  1232. width: 178px;
  1233. height: 178px;
  1234. }
  1235. .avatar-uploader .el-upload:hover {
  1236. border-color: #409EFF;
  1237. }
  1238. .avatar-uploader-icon {
  1239. line-height: 140px;
  1240. }
  1241. .avatar {
  1242. height: 144px;
  1243. }
  1244. .image-preview {
  1245. width: 178px;
  1246. height: 178px;
  1247. position: relative;
  1248. border: 1px dashed #d9d9d9;
  1249. border-radius: 6px;
  1250. float: left;
  1251. }
  1252. .image-preview .image-preview-wrapper {
  1253. position: relative;
  1254. width: 100%;
  1255. height: 100%;
  1256. }
  1257. .image-preview .image-preview-wrapper img {
  1258. width: 100%;
  1259. height: 100%;
  1260. }
  1261. .image-preview .image-preview-action {
  1262. position: absolute;
  1263. width: 100%;
  1264. height: 100%;
  1265. left: 0;
  1266. top: 0;
  1267. text-align: center;
  1268. color: #fff;
  1269. opacity: 0;
  1270. font-size: 20px;
  1271. background-color: rgba(0, 0, 0, .5);
  1272. transition: opacity .3s;
  1273. cursor: pointer;
  1274. line-height: 200px;
  1275. }
  1276. .image-preview .image-preview-action .el-icon-delete {
  1277. font-size: 32px;
  1278. }
  1279. .image-preview:hover .image-preview-action {
  1280. opacity: 1;
  1281. }
  1282. .el-upload--picture-card {
  1283. display: block;
  1284. width: 258px;
  1285. height: 146px;
  1286. overflow: hidden;
  1287. }
  1288. .input-new-tag {
  1289. width: 90px;
  1290. margin-left: 10px;
  1291. vertical-align: bottom;
  1292. }
  1293. .el-tag + .el-tag {
  1294. margin-left: 10px;
  1295. }
  1296. .button-new-tag {
  1297. margin-left: 10px;
  1298. height: 32px;
  1299. line-height: 30px;
  1300. padding-top: 0;
  1301. padding-bottom: 0;
  1302. }
  1303. .echarts {
  1304. width: 100%;
  1305. text-align: center;
  1306. height: 800px;
  1307. }
  1308. .bin {
  1309. /*text-align: center;*/
  1310. /*padding: 50px;*/
  1311. width: 100%;
  1312. height: 800px
  1313. }
  1314. .dashboard-editor-container {
  1315. padding: 32px;
  1316. background-color: rgb(240, 242, 245);
  1317. position: relative;
  1318. .chart-wrapper {
  1319. background: #fff;
  1320. padding: 16px 16px 0;
  1321. margin-bottom: 32px;
  1322. }
  1323. }
  1324. .graph-tag {
  1325. display: inline-block;
  1326. border-radius: 4px;
  1327. min-width: min-content;
  1328. padding: 5px;
  1329. background-color: #e7faf0;
  1330. border-color: #d0f5e0;
  1331. color: #13ce66;
  1332. }
  1333. @media (max-width: 1024px) {
  1334. .chart-wrapper {
  1335. padding: 8px;
  1336. }
  1337. }
  1338. </style>

2.2 

  1. import request from '@/utils/request'
  2. export function getPersonWebMap() {
  3. return request({
  4. url: '/people/web/map',
  5. method: 'get'
  6. })
  7. }
  8. export function getPersonWebList() {
  9. return request({
  10. url: '/people/web/list',
  11. method: 'get'
  12. })
  13. }
  14. export function getPersonWebSearch(personName) {
  15. return request({
  16. url: '/people/web/search/' + personName,
  17. method: 'get'
  18. })
  19. }
  20. export function getPersonWebSearchOther(personId, personName) {
  21. return request({
  22. url: '/people/web/search/' + personId + '/' + personName,
  23. method: 'get'
  24. })
  25. }
  26. export function getPersonWebInfo(personId) {
  27. return request({
  28. url: '/people/web/person/' + personId,
  29. method: 'get'
  30. })
  31. }
  32. export function addPersonWeb(data) {
  33. return request({
  34. url: '/people/web/person',
  35. method: 'post',
  36. data: data
  37. })
  38. }
  39. export function editPersonWeb(data) {
  40. return request({
  41. url: '/people/web/person',
  42. method: 'put',
  43. data: data
  44. })
  45. }
  46. export function removePersonWeb(personId) {
  47. return request({
  48. url: '/people/web/person/' + personId,
  49. method: 'delete'
  50. })
  51. }
  52. export function getInfoConnectWeb(connectId) {
  53. return request({
  54. url: '/people/web/connect/' + connectId,
  55. method: 'get'
  56. })
  57. }
  58. export function addConnectWeb(data) {
  59. return request({
  60. url: '/people/web/connect',
  61. method: 'post',
  62. data: data
  63. })
  64. }
  65. export function editConnectWeb(data) {
  66. return request({
  67. url: '/people/web/connect',
  68. method: 'put',
  69. data: data
  70. })
  71. }
  72. export function removeConnectWeb(connectId) {
  73. return request({
  74. url: '/people/web/connect/' + connectId,
  75. method: 'delete'
  76. })
  77. }

三、展示

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/904222
推荐阅读
相关标签
  

闽ICP备14008679号