<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>
|