333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<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">
      <template slot="common-column-slot" slot-scope="{row, col}">
        <template v-if="['isMain'].indexOf(col.prop)>=0">
          <template v-if="row[col.prop]==1">
            <el-tag color="#7aaffe" style="color:white;border:0">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
          </template>
          <template v-else>
            <el-tag color="#ffcc33" style="color:white;border:0">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop]||0, col.dropdown_Id) }}
            </el-tag>
          </template>
        </template>
        <template v-else-if="['sex'].indexOf(col.prop)>=0">
          {{ $refs[dataListRef].translateText(col.prop, row[col.prop]||0, col.dropdown_Id) }}
        </template>
        <template v-else-if="col.prop==dataOptions.linkColumn">
          <el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">{{ row[col.prop] }}</el-link>
        </template>
        <template v-else>
          {{ row[col.prop] }}
        </template>
      </template>
    </yrt-data-list>
 
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" @on-key-up="onClientShortName" @on-change="onChange" @on-row-change="(ref, selectedRow) => {onRowChange(ref, selectedRow);}"></yrt-editor>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
 
export default {
  name: "crm-base-linker",
  components: {},
  mixins: [baseLayout],
  data() {
    return {};
  },
  methods: {
    // 物料名称下拉框输入改变后
    onClientShortName(ref, val, event, field, tableData) {
      if (field.options.prop === "clientShortName") {
        if (!val) {
          tableData = [];
          return;
        }
        const url = "/api/basicInfo/base/client/getList";
        const params = {
          name: val
        };
        this.common.ajax(url, params, res => {
          this.common.showMsg(res);
          if (res.result) {
            res.data.forEach(item => {
              this.$set(tableData, tableData.length, item);
            });
          }
        });
      }
    },
    // 物料名称下拉框行数据单击事件
    onRowChange(ref, selectedRow) {
      this.editor.changeValue("client_Id", selectedRow.client_Id);
      this.editor.changeValue("clientCode", selectedRow.clientCode);
      this.editor.changeValue("clientShortName", selectedRow.clientShortName);
      this.editor.changeValue("clientFullName", selectedRow.clientFullName);
    },
    // 级联改变数据
    onChange(ref, val, field) {
      // 记录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 the = this;
      var editorRef = this.editor;
 
      var where = { parentId: id };
      var url = "/api/common/loadTreeNode";
      var params = {
        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: ""
      };
      the.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 {
            the.$message.error(res.Msg);
          }
        },
        true
      );
    }
  }
};
</script>