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
|
| <template>
| <div 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" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" @on-change="onChange" @on-save-after="onSaveAfter"></yrt-editor>
|
| </div>
|
| </template>
|
| <script>
| import baseLayout from "@/components/common/base-layout.vue";
|
| export default {
| name: "crm-base-client",
| // 自定义JSON路由地址
| custoJsonmRoute: "/crm/base/client",
|
| components: {},
| mixins: [baseLayout],
| data() {
| return {};
| },
| methods: {
| // 级联改变数据
| 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
| );
| },
| // 编辑加载后事件
| onEditLoadAfter(formData) {
| // 加载市
| this.loadChildrenNode(formData.Province_Id, 614, "provinceName");
| // 加载市
| this.loadChildrenNode(formData.city_Id, 615, "cityName");
| },
| // 保存后事件
| onSaveAfter(formData) {
| this.refreshDropdown();
| }
| }
| };
| </script>
|
|