Bläddra i källkod

更改数据资源目录中自定义中文字典共呢个

lkk 1 år sedan
förälder
incheckning
95b021fde9
2 ändrade filer med 57 tillägg och 77 borttagningar
  1. 56 76
      src/views/system/zyml/index.vue
  2. 1 1
      vue.config.js

+ 56 - 76
src/views/system/zyml/index.vue

@@ -133,11 +133,9 @@
             type="text"
             icon="el-icon-s-cooperation"
             v-if="
-              scope.row.parent == 0 &&
-              ['WMTS', 'WMS'].indexOf(scope.row.type) > -1
+              scope.row.parent == 0 && ['Vector'].indexOf(scope.row.type) > -1
             "
             @click="handleDict(scope.row)"
-            v-hasPermi="['system:zyml:edit']"
             >字典维护</el-button
           >
           <!-- scope.row.parent == 0 地图服务 1:目录 -->
@@ -433,16 +431,6 @@
                 <span v-else>{{ row.fieldaliasname }}</span>
               </template>
             </el-table-column>
-            <!-- <el-table-column align="center" prop="isvisible" label="是否展示" width="">
-                    <template slot-scope="scope">
-                        <el-switch
-                            v-model="scope.row.isvisible"
-                            :active-value="1"
-                            :inactive-value="0"
-                            @change="handleStatusChange(scope.row)"
-                        ></el-switch>
-                    </template>
-                </el-table-column> -->
           </el-table>
         </el-tab-pane>
       </el-tabs>
@@ -468,6 +456,7 @@ import request from "@/utils/requestServer";
 import { getToken } from "@/utils/auth";
 import { getXzq } from "@/api/system/user";
 import { GetFieldValue, UpdateFieldValue } from "@/api/system/yztfield";
+import axios from "axios";
 
 export default {
   name: "Zyml",
@@ -559,6 +548,7 @@ export default {
       columnIndex: -1, //列索引
       cellClickRow: {},
       dic_loading: false,
+      tempRowData: undefined,
     };
   },
   created() {
@@ -850,75 +840,63 @@ export default {
       }
     },
     /** 字典维护 */
-    handleDict(row) {
-      this.cur_server_name_dic = row.name;
-      this.dialogDictVisible = true;
-      this.dic_loading = true;
+    async handleDict(row) {
+      this.tempRowData = row;
       this.tabelList = [];
-      // 初始化数据
-      // 调用mapserver获取leyers
-      // http://192.168.100.252:6080/arcgis/rest/services/150500/YJJBNTTB_00/MapServer
-      let url = row.url;
-      request({
-        method: "get",
-        url: url + "/layers?f=pjson",
-      })
-        .then((res) => {
-          // TODO 暂时先按单图层服务做,通辽现在是没有图层组情况,后续有图层组再改
-          let layerId = res.layers[0].id;
-          let name = res.layers[0].name.split(".");
-          let layerName = name[name.length - 1];
-          let layerFields = res.layers[0].fields;
-          GetFieldValue({ bsm: row.bsm })
-            .then((res) => {
-              if (res.success) {
-                if (res.data.length > 0) {
-                  this.tabelList.push({
-                    bsm: row.bsm,
-                    name: layerName,
-                    tabelData: res.data,
-                    servicename: row.name,
-                  });
-                } else {
-                  let tb = layerFields.map((item) => {
-                    return {
-                      bsm: row.bsm,
-                      fieldname: item.name,
-                      fieldaliasname: item.alias,
-                      servicename: row.name,
-                    };
-                  });
-                  this.tabelList.push({
-                    id: layerId,
-                    name: layerName,
-                    tabelData: tb,
-                  });
-                }
-                if (this.tabelList.length > 0) {
-                  this.tabActiveName = this.tabelList[0].name;
-                }
-              } else {
-                this.$message.warning(res.message);
-              }
-            })
-            .finally(() => {
-              this.dic_loading = false;
+      this.tempTableData = [];
+      //默认选中
+      this.tabActiveName = row.name;
+      if (row.legend == "") {
+        //从iserver中获取数据地址
+        let newUrl =
+          "http://192.168.60.3:8099/iserver/services/data-sanqusanxian/rest/data/datasources/sanqusanxian/datasets/" +
+          row.name +
+          "/fields.json";
+        request({
+          method: "get",
+          url: newUrl,
+        }).then((res) => {
+          console.log(res);
+          if (res.fieldNames.length > 0) {
+            //处理数据
+            res.fieldNames.forEach((item) => {
+              this.tempTableData.push({
+                fieldname: item,
+                fieldaliasname: item,
+              });
             });
-        })
-        .finally(() => {
-          this.dic_loading = false;
+
+            this.tabelList.push({
+              bsm: row.bsm,
+              name: row.name,
+              tabelData: this.tempTableData,
+              servicename: row.name,
+            });
+          }
+        });
+      } else {//如果lenged中存在字段修正数据,则直接使用
+        this.tabelList.push({
+          bsm: row.bsm,
+          name: row.name,
+          tabelData: JSON.parse(row.legend),
+          servicename: row.name,
         });
+      }
+
+      this.cur_server_name_dic = row.name;
+      this.dialogDictVisible = true;
     },
+    //确定字典维护的修改
     confirmUpdateDict() {
-      console.log(this.tabelList);
       if (this.tabelList.length > 0) {
-        UpdateFieldValue(this.tabelList[0].tabelData).then((res) => {
-          if (res.success) {
-            this.$message.success(res.message);
-            this.dialogDictVisible = false;
-          } else {
-            this.$message.warning(res.message);
-          }
+        //将数据转化为字符串存储
+        this.tempRowData.legend = JSON.stringify(this.tabelList[0].tabelData);
+        updateZyml(this.tempRowData).then((response) => {
+          this.$modal.msgSuccess("修改成功");
+          this.dialogDictVisible = false;
+          //关闭弹窗时还原编辑状态
+          this.columnIndex = -1
+          this.getList();
         });
       }
     },
@@ -926,6 +904,8 @@ export default {
     closeDialogDict() {
       this.resetDict();
       this.dialogDictVisible = false;
+      //关闭弹窗时还原编辑状态
+      this.columnIndex = -1
     },
     resetDict() {
       this.cur_server_name_dic = "";

+ 1 - 1
vue.config.js

@@ -35,7 +35,7 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://192.168.100.252:8080`,
+        target: `http://192.168.60.4:8080`,
         changeOrigin: true,
         pathRewrite: {
           ["^" + process.env.VUE_APP_BASE_API]: "",