LayerManagement.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <el-container :class="'content'">
  3. <el-header>
  4. <el-button type="primary" class="add-item" @click="handleAddClass">
  5. 图层新增
  6. </el-button>
  7. </el-header>
  8. <el-main>
  9. <el-tree
  10. class="item-tree"
  11. :data="layerList"
  12. node-key="id"
  13. :props="defaultProps"
  14. default-expand-all
  15. >
  16. <span class="operations" slot-scope="{ node, data }">
  17. <span class="node-label">
  18. <i v-if="data.isLeaf" class="el-icon-s-flag leaf-icon"></i>
  19. {{ node.label }}
  20. </span>
  21. <span>
  22. <template v-if="data.isLeaf">
  23. <el-button
  24. type="text"
  25. icon="el-icon-warning-outline"
  26. @click.stop="handleLook(data)"
  27. title="查看"
  28. >
  29. </el-button>
  30. <el-button
  31. type="text"
  32. icon="el-icon-edit iconfont"
  33. @click.stop="handleEdit(data)"
  34. title="编辑"
  35. ></el-button>
  36. <el-button
  37. type="text"
  38. icon="el-icon-delete iconfont"
  39. @click.stop="handleDelete(data)"
  40. title="删除"
  41. >
  42. </el-button>
  43. </template>
  44. </span>
  45. </span>
  46. </el-tree>
  47. </el-main>
  48. <!--添加栏目弹窗-->
  49. <LayerDetail
  50. v-bind="{
  51. isShow: isShowAddModelDetailDialog,
  52. edit: edit,
  53. title: title,
  54. beforeClose: beforeCloseAddDetailDialog,
  55. updateData: getMenu,
  56. formData: modelDeatailData,
  57. operationType: operationType, // 0 增加,1 查看,2 编辑
  58. }"
  59. ></LayerDetail>
  60. </el-container>
  61. </template>
  62. <script>
  63. import api from "@/api/model";
  64. export default {
  65. components: {
  66. LayerDetail: () => import("@/components/DataLayer/LayerDetail.vue"),
  67. },
  68. data() {
  69. return {
  70. title: "图层新增", // 图层修改
  71. isShowAddModelDetailDialog: false,
  72. edit: false,
  73. layerList: [],
  74. defaultProps: {
  75. children: "models",
  76. label: "title",
  77. },
  78. modelDeatailData: null,
  79. operationType: 0,
  80. };
  81. },
  82. created() {},
  83. methods: {
  84. // 增加图层
  85. handleAddClass() {
  86. this.edit = true;
  87. this.title = "图层新增";
  88. this.operationType = 0;
  89. this.modelDeatailData = {
  90. alpha: "",
  91. content: "",
  92. createDate: "",
  93. fillColor: "#FF0000",
  94. geometryType: "Point",
  95. iconUrl: "",
  96. id: "",
  97. jsonStr: "",
  98. lineWidth: "",
  99. tableName: "",
  100. threeId: "",
  101. title: "",
  102. type: 0,
  103. updateDate: "",
  104. };
  105. this.isShowAddModelDetailDialog = true;
  106. },
  107. // 目录
  108. getMenu() {
  109. getMenu();
  110. },
  111. // 渲染列表前数据整理
  112. handleMenuDataBeforeRenderUI(data) {
  113. if (data)
  114. return data.map(function (item) {
  115. item.title = item.name;
  116. item.models = item.models.map(function (params) {
  117. params.isLeaf = true;
  118. return params;
  119. });
  120. return item;
  121. });
  122. },
  123. // 模型窗体关闭前
  124. beforeCloseAddDetailDialog(judge) {
  125. this.isShowAddModelDetailDialog = false;
  126. if (judge) this.getMenu();
  127. },
  128. // 查看模型
  129. handleLook(data) {
  130. let that = this;
  131. api
  132. .getDetailModelInfo({
  133. id: data.id,
  134. })
  135. .then((result) => {
  136. if (result.code == 200) {
  137. that.modelDeatailData = result.content;
  138. that.title = "图层详情";
  139. that.operationType = 1;
  140. that.edit = false;
  141. that.isShowAddModelDetailDialog = true;
  142. } else {
  143. this.$checkRequestCode(result);
  144. }
  145. })
  146. .catch((err) => {
  147. that.$message({
  148. type: "error",
  149. message: err,
  150. });
  151. });
  152. },
  153. // 编辑模型
  154. handleEdit(data) {
  155. let that = this;
  156. api
  157. .getDetailModelInfo({
  158. id: data.id,
  159. })
  160. .then((result) => {
  161. if (result.code == 200) {
  162. that.modelDeatailData = result.content;
  163. that.title = "图层编辑";
  164. that.operationType = 2;
  165. that.edit = true;
  166. that.isShowAddModelDetailDialog = true;
  167. } else {
  168. this.$checkRequestCode(result);
  169. }
  170. })
  171. .catch((err) => {
  172. that.$message({
  173. type: "error",
  174. message: err,
  175. });
  176. });
  177. },
  178. // 删除模型
  179. handleDelete(data) {
  180. this.$confirm("此操作将删除图层和其中数据,不可恢复,是否继续?", "警告", {
  181. confirmButtonText: "确定",
  182. cancelButtonText: "取消",
  183. type: "warning",
  184. })
  185. .then(() => {
  186. let that = this;
  187. api
  188. .delModel({
  189. id: data.id,
  190. })
  191. .then(function (response) {
  192. if (response.code == 200) {
  193. that.$message({ type: "success", message: "删除成功!" });
  194. } else {
  195. this.$checkRequestCode(result);
  196. }
  197. that.getMenu();
  198. })
  199. .catch((err) => {
  200. that.$message({
  201. type: "error",
  202. message: err,
  203. });
  204. that.getMenu();
  205. });
  206. })
  207. .catch(() => {
  208. that.$message({
  209. type: "waring",
  210. message: "服务器异常,请稍后重试!",
  211. });
  212. that.getMenu();
  213. });
  214. },
  215. },
  216. computed: {
  217. layerData() {
  218. return this.$store.state.layerList;
  219. },
  220. },
  221. watch: {
  222. layerData: {
  223. immediate: true,
  224. handler(newVal, oldName) {
  225. if (newVal) this.layerList = this.handleMenuDataBeforeRenderUI(newVal);
  226. },
  227. },
  228. },
  229. };
  230. </script>
  231. <style lang="less" scoped>
  232. .content {
  233. width: calc(100% - 20px);
  234. margin-left: 20px;
  235. .el-header {
  236. background: #ffffff;
  237. margin-bottom: 20px;
  238. padding-top: 10px;
  239. }
  240. .el-main {
  241. background: #ffffff;
  242. overflow: hidden;
  243. overflow-y: auto;
  244. box-sizing: border-box;
  245. position: relative;
  246. border-radius: 5px;
  247. padding: 20px 50px;
  248. .item-tree {
  249. .operations {
  250. flex: 1;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. font-size: 14px;
  255. padding-right: 8px;
  256. .single {
  257. margin-right: 28px;
  258. }
  259. }
  260. .node-label {
  261. font-size: 14px;
  262. .empty-icon {
  263. color: #c0c4cc;
  264. width: 12px;
  265. height: 12px;
  266. padding: 6px;
  267. margin-left: -24px;
  268. }
  269. .leaf-icon {
  270. margin-right: 5px;
  271. margin-left: -15px;
  272. }
  273. }
  274. /deep/ .el-tree-node__content {
  275. height: 40px;
  276. cursor: default;
  277. .el-icon-caret-right {
  278. padding: 20px;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>