schangxiang@126.com
2025-09-10 3d43ffa3152110b7823f9fa6320c08a6ae02358a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
<template>
  <div ref="container" class="page-list-container">
    <!--数据Table-->
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
    </yrt-data-list>
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :btn-read-only="btnReadOnly" :auth-nodes="authNodes" @on-change="onChange" @on-item-click="(ref, val, itemData, field, formData)=>{onChange(ref, val, field, formData, itemData)}">
    </yrt-editor>
 
  </div>
</template>
<script>
import baseLayout from "@/components/common/base-layout.vue";
 
export default {
  name: "basicInfo-consignor-base-consignorAddress",
  components: {},
  mixins: [baseLayout],
  data() {
    return {};
  },
  methods: {
    // 级联改变数据
    onChange(ref, val, field, formData) {
      // 记录ID和Name
      if (field.options.prop === "provinceName") {
        // 设置表单数据
        const item = ref.getOption(val);
        // 改变市级下拉框
        this.loadChildrenNode(item.value, 614, field.options.prop);
      } else if (field.options.prop === "cityName") {
        // 设置表单数据
        const item = ref.getOption(val);
        // 改变区级下拉框
        this.loadChildrenNode(item.value, 615, field.options.prop);
      }
    },
    // 根据省ID获得市
    loadChildrenNode(id, dropdown_Id, prop) {
      var editorRef = this.editor;
      var where = { parentId: id };
      var url = "/api/common/loadTreeNode";
      var params = {
        openNodeApi: true,
        folder: "basicInfo/base",
        dbServer: "Sys",
        tableName: "Base_City",
        tableView: "Base_City",
        keyName: "city_Id",
        nodeName: "cityName",
        fixHasChild: false,
        isBreakWay: false,
        displayBreakWay: false,
        parentName: "parentId",
        orderBy: "orderNo desc, city_Id",
        where: where,
        extendColumns: ""
      };
      this.common.ajax(
        url,
        params,
        res => {
          if (res.result) {
            var data = res.data.map(item => {
              if (prop === "provinceName") {
                const newItem = {
                  city_Id: item.value,
                  cityName: item.label,
                  value: item.value,
                  label: item.label
                };
                return newItem;
              } else if (prop === "cityName") {
                const newItem = {
                  region_Id: item.value,
                  regionName: item.label,
                  value: item.value,
                  label: item.label
                };
                return newItem;
              }
            });
            editorRef.setDropdownData(dropdown_Id, data);
          } else {
            this.$message.error(res.msg);
          }
        },
        true
      );
    }
  }
};
</script>