123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- <template>
- <!-- 中文下拉 -->
- <div>
- <div style="display: flex;">
- <el-select v-model="value" @input="$emit('selectedValue', value)" :placeholder="'请输入 ' + placeholder"
- @change="selectChange" @clear="clear" :clearable="clearable" :multiple="multiple" :filterable="filterable"
- :remote="remote" :remote-method="remoteMethod" :loading="loading" :size="size" :disabled="disabled">
- <el-option v-for="item in options" :key="item[key]" :label="item[label]"
- :value="item[keyValue ? keyValue : label]">
- </el-option>
- </el-select>
- <el-button v-if="searchShow" icon="el-icon-search" size="small" :disabled="disabled" @click="open()" />
- </div>
- <el-dialog title="客户" :visible.sync="dialogVisible" width="70%" :before-close="false" @closed="closed"
- append-to-body>
- <span>
- <el-row v-if="treeShow">
- <el-col :span="4">
- <el-card class="box-card">
- <avue-tree ref="tree" :option="treeOption" :data="treeData" @node-click="nodeClick">
- </avue-tree>
- </el-card>
- </el-col>
- <el-col :span="20">
- <avue-crud :option="option" :table-loading="loading" :data="dataList" :page.sync="page"
- :search.sync="query" v-model="form" id="out-table" ref="crud" @row-del="rowDel"
- @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
- @current-change="currentChange" @size-change="sizeChange" @on-load="onLoad">
- </avue-crud>
- </el-col>
- </el-row>
- <avue-crud v-else :option="option" :table-loading="loading" :data="dataList" :page.sync="page"
- :search.sync="query" v-model="form" id="out-table" ref="crud" @row-del="rowDel"
- @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
- @current-change="currentChange" @size-change="sizeChange" @on-load="onLoad">
- </avue-crud>
- </span>
- <span slot="footer" class="dialog-footer">
- <el-button size="small" @click="dialogVisible = false">取 消</el-button>
- <el-button size="small" type="primary" :disabled="this.selectionList.length != 1" @click="importData">确
- 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getDicinit } from "@/api/dicSelect/index";
- import { bcorpstypedefineList } from "@/api/iosBasicData/bcorpstypedefine"
- export default {
- data() {
- return {
- dialogVisible: false,
- options: [],
- loading: false,
- data: {},
- form: {},
- query: {},
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- dataList: [],
- selectionList: [],
- option: {
- height: 400,
- calcHeight: 30,
- tip: false,
- searchIcon: true,
- searchIndex: 3,
- searchShow: true,
- searchMenuSpan: 6,
- border: true,
- index: true,
- selection: true,
- header: false,
- menu: false,
- column: [
- {
- label: "编码",
- prop: "code",
- search: true,
- rules: [{
- required: true,
- message: "请输入单位编码",
- trigger: "blur"
- }],
- overHidden: true,
- },
- {
- label: "中文名称",
- prop: "cnName",
- search: true,
- rules: [{
- required: true,
- message: "请输入中文名称",
- trigger: "blur"
- }],
- overHidden: true,
- },
- {
- label: "英文名称",
- prop: "enName",
- search: true,
- rules: [{
- required: true,
- message: "请输入英文名称",
- trigger: "blur"
- }],
- overHidden: true,
- },
- {
- label: "状态",
- prop: "status",
- type: 'select',
- search: true,
- dicData: [{
- label: '启用',
- value: 0
- }, {
- label: '停用',
- value: 1
- }],
- rules: [{
- required: true,
- message: "请输入状态",
- trigger: "blur"
- }],
- overHidden: true,
- },
- {
- label: "备注",
- prop: "remarks",
- span: 24,
- type: 'textarea',
- width: "180",
- slot: true,
- minRows: 3,
- overHidden: true,
- },
- ],
- designer: null,
- },
- treeOption: {
- nodeKey: "id",
- lazy: true,
- treeLoad: function (node, resolve) {
- const parentId = node.level === 0 ? 0 : node.data.id;
- },
- addBtn: false,
- menu: false,
- size: "small",
- props: {
- labelText: "标题",
- label: "cnName",
- value: "id",
- children: "children"
- }
- },
- treeData: []
- }
- },
- props: {
- activateCreated: {
- type: Boolean,
- default: true
- },
- key: {
- type: [String, Number],
- default: null
- },
- label: {
- type: String,
- default: ''
- },
- keyValue: {
- type: [String, Number],
- default: null
- },
- res: {
- type: String,
- default: ''
- },
- placeholder: {
- type: String,
- default: '请输入'
- },
- clearable: {
- type: Boolean,
- default: true
- },
- value: {
- type: [String, Number],
- default: ''
- },
- method: {
- type: String,
- default: 'GET'
- },
- url: {
- type: String,
- default: ''
- },
- dataName: {
- type: String,
- default: ''
- },
- multiple: {
- type: Boolean,
- default: false
- },
- filterable: {
- type: Boolean,
- default: false
- },
- remote: {
- type: Boolean,
- default: false
- },
- size: {
- type: String,
- default: 'small'
- },
- disabled: {
- type: Boolean,
- default: false
- },
- searchShow: {
- type: Boolean,
- default: false
- },
- treeShow: {
- type: Boolean,
- default: false
- },
- mockData: {
- type: Array,
- default: function () {
- return [];
- }
- }
- },
- model: {
- prop: "value",
- event: "selectedValue"
- },
- created() {
- if (this.activateCreated) {
- this.getDicData()
- } else {
- this.options = this.mockData
- }
- },
- methods: {
- open() {
- this.dialogVisible = true
- this.getTree()
- },
- // 获取客户类别
- getTree() {
- bcorpstypedefineList(1, 50).then(res => {
- this.treeData = res.data.data.records
- })
- },
- nodeClick(data) {
- this.query.corpTypeName = data.cnName
- this.onLoad(this.page, this.query);
- },
- closed() {
- this.query = {}
- this.selectionList = []
- },
- remoteMethod(query) {
- if (query !== '') {
- setTimeout(() => {
- this.data[this.dataName] = query
- this.getDicData()
- }, 200);
- } else {
- setTimeout(() => {
- this.data = this.$options.data().data
- this.getDicData()
- }, 200);
- }
- },
- getDicData() {
- this.loading = true
- getDicinit(this.method, this.url, this.data).then(res => {
- if (this.res) {
- this.options = res.data.data[this.res]
- } else {
- this.options = res.data.data
- }
- }).finally(() => {
- this.loading = false;
- })
- },
- IdGetDicData(data) {
- this.loading = true
- getDicinit(this.method, this.url, data).then(res => {
- if (this.res) {
- this.options = res.data.data[this.res]
- } else {
- this.options = res.data.data
- }
- }).finally(() => {
- this.loading = false;
- })
- },
- selectChange(row) {
- this.options.forEach(e => {
- if (row == e[this.label]) {
- this.$emit('selectChange', e)
- }
- })
- },
- clear() {
- if (this.remote) {
- this.data = this.$options.data().data
- this.getDicData()
- }
- this.$emit('selectChange', null)
- },
- importData() {
- this.dialogVisible = false
- this.$emit('selectChange', this.selectionList[0])
- },
- searchChange(params, done) {
- this.page.currentPage = 1;
- this.onLoad(this.page, this.query);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- let obj = {}
- obj = {
- current: page.currentPage,
- size: page.pageSize,
- ...Object.assign(params, this.query),
- }
- this.loading = true
- getDicinit(this.method, this.url, obj).then(res => {
- this.dataList = res.data.data.records
- this.page.total = res.data.data.total;
- }).finally(() => {
- this.loading = false;
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/ .el-col-md-8 {
- width: 24.33333%;
- }
- </style>
|