Browse Source

快捷字典

master
常熟吴彦祖 6 days ago
parent
commit
33e95126a8
  1. 211
      src/components/dict/SysDictSelect.vue
  2. 28
      src/views/modules/srmBaseInformation/srmSupplierGroup.vue
  3. 35
      src/views/modules/srmSupplier/supplierList.vue

211
src/components/dict/SysDictSelect.vue

@ -0,0 +1,211 @@
<!--
=============================================================================
SysDictSelect 通用数据字典下拉sys_dict_data
-----------------------------------------------------------------------------
约定dict_label界面展示文案dict_value业务表保存的编码dict_type字典类别
仅加载 status=Y 的记录后端按 dict_sort 升序
基础用法 · v-model = dict_value
import SysDictSelect from '@/components/dict/SysDictSelect.vue'
components: { SysDictSelect }
<sys-dict-select
v-model="form.taxType"
dict-type="supplier_group"
placeholder="请选择供应商分组"
style="width: 260px"
/>
获知选中行的 dict_label回填描述等
<sys-dict-select
v-model="form.groupCode"
dict-type="supplier_group"
@option-change="(row, val) => { form.groupDesc = row ? row.dictLabel : '' }"
/>
指定站点默认取当前用户的 $store.state.user.site可覆盖
<sys-dict-select v-model="x" dict-type="xxx" :site="'01'" />
需要默认选中字典里 is_default=Y 的行
apply-default 首次打开且 value 为空时自动 emit 默认值
刷新选项
ref 调用 this.$refs.d.reload()
与原有 dict-data-select 区别
路径统一 @/api/dict显式筛选 status=Y注释与事件更清晰
=============================================================================
-->
<template>
<el-select
v-bind="$attrs"
:value="value"
:placeholder="placeholder"
:disabled="disabled"
:clearable="clearable"
:filterable="filterable"
:popper-append-to-body="popperAppendToBody"
:style="computedStyle"
@change="onChange"
@clear="$emit('clear')"
>
<el-option
v-for="item in options"
:key="String(item.dictCode != null ? item.dictCode : item.dictValue)"
:label="item.dictLabel || item.dictValue"
:value="item.dictValue"
:disabled="disabledValues.includes(item.dictValue)"
/>
</el-select>
</template>
<script>
import { selectDictDataList } from '@/api/dict'
export default {
name: 'SysDictSelect',
inheritAttrs: false,
model: {
prop: 'value',
event: 'input'
},
props: {
/** 字典类型 sys_dict_data.dict_type,如 supplier_group */
dictType: {
type: String,
required: true
},
/** 绑定值(= dict_value) */
value: {
type: [String, Number],
default: null
},
placeholder: {
type: String,
default: '请选择'
},
disabled: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: true
},
filterable: {
type: Boolean,
default: true
},
popperAppendToBody: {
type: Boolean,
default: true
},
width: {
type: String,
default: ''
},
/** 是否使用站点过滤(一般为 true) */
useSite: {
type: Boolean,
default: true
},
/** 覆盖站点:不传则用 Vuex user.site */
site: {
type: String,
default: undefined
},
/** value 为空时,若字典存在 is_default=Y 的记录则自动选中 */
applyDefault: {
type: Boolean,
default: false
},
/** 禁用的 dict_value 列表 */
disabledValues: {
type: Array,
default: () => []
}
},
data () {
return {
options: [],
loading: false
}
},
computed: {
resolvedSite () {
if (!this.useSite) {
return '*'
}
if (this.site) {
return this.site
}
const s = this.$store && this.$store.state.user && this.$store.state.user.site
return s != null ? String(s) : ''
},
computedStyle () {
if (!this.width) {
return {}
}
return { width: this.width }
}
},
watch: {
dictType () {
this.reload()
},
resolvedSite () {
this.reload()
}
},
created () {
this.reload()
},
methods: {
reload () {
this.loadOptions()
},
async loadOptions () {
const site = this.resolvedSite
if (!site) {
this.options = []
return
}
this.loading = true
try {
const { data } = await selectDictDataList({
site,
dictType: this.dictType,
dictTypeList: [],
status: 'Y'
})
if (data && data.code === 0) {
this.options = data.rows || []
if (this.applyDefault && (this.value === null || this.value === '' || this.value === undefined)) {
const def = this.options.find(it => it.isDefault === 'Y' && it.status === 'Y')
if (def && def.dictValue != null) {
this.$emit('input', def.dictValue)
this.$emit('change', def.dictValue)
this.$emit('option-change', def, def.dictValue)
}
}
} else {
this.options = []
this.$message && this.$message.error((data && data.msg) || '字典加载失败')
}
} catch (e) {
this.options = []
console.error('SysDictSelect loadOptions', e)
} finally {
this.loading = false
}
},
onChange (val) {
const row = (this.options || []).find(it => String(it.dictValue) === String(val))
this.$emit('input', val)
this.$emit('change', val)
this.$emit('option-change', row || null, val)
}
}
}
</script>

28
src/views/modules/srmBaseInformation/srmSupplierGroup.vue

@ -68,15 +68,23 @@
layout="total, sizes, prev, pager, next, jumper"> layout="total, sizes, prev, pager, next, jumper">
</el-pagination> </el-pagination>
<el-dialog title="供应商分组" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="415px">
<el-dialog title="供应商分组" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="480px">
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;"> <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;">
<el-form-item label="供应商分组代码" prop="supplierGroup" :rules="rules.supplierGroup"> <el-form-item label="供应商分组代码" prop="supplierGroup" :rules="rules.supplierGroup">
<el-input v-model="modalData.supplierGroup" :disabled="modalDisableFlag" style="width: 100px"></el-input>
<sys-dict-select
v-model="modalData.supplierGroup"
dict-type="supplier_group"
:disabled="modalDisableFlag"
placeholder="选择字典编码(存入 supplier_group)"
width="260px"
filterable
@option-change="onSupplierGroupDictChange"
/>
</el-form-item> </el-form-item>
<el-form-item label="分组类型" prop="groupType"> <el-form-item label="分组类型" prop="groupType">
<el-select v-model="modalData.groupType" style="width: 100px">
<el-option label="供应商分组1" value="Y"></el-option>
<el-option label="供应商分组2" value="N"></el-option>
<el-select v-model="modalData.groupType" style="width: 160px">
<el-option label="供应商分组1" value="供应商分组1"></el-option>
<el-option label="供应商分组2" value="供应商分组2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="启用" prop="active"> <el-form-item label="启用" prop="active">
@ -106,9 +114,11 @@
updateSupplierGroup, updateSupplierGroup,
deleteSupplierGroup deleteSupplierGroup
} from "@/api/baseInformation/srmGroup.js" } from "@/api/baseInformation/srmGroup.js"
import excel from "@/utils/excel-util.js";
import excel from "@/utils/excel-util.js"
import SysDictSelect from '@/components/dict/SysDictSelect.vue'
export default { export default {
components: { SysDictSelect },
watch: { watch: {
searchData: { searchData: {
deep: true, deep: true,
@ -266,6 +276,12 @@
}, },
methods: { methods: {
/** 字典选中后回填描述(可再手工改描述) */
onSupplierGroupDictChange (row) {
if (row && row.dictLabel != null && String(row.dictLabel).trim() !== '') {
this.modalData.groupDesc = row.dictLabel
}
},
// //
sizeChangeHandle (val) { sizeChangeHandle (val) {
this.pageSize = val this.pageSize = val

35
src/views/modules/srmSupplier/supplierList.vue

@ -177,13 +177,17 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="6">
<el-form-item >
<span style="cursor: pointer" slot="label" @click="getBaseList(521)"><a href="#">供应商分类</a></span>
<el-input v-model="currentSupplier.supplierGroup" style="width: 130px"></el-input>
<el-col :span="8">
<el-form-item label="供应商分类">
<sys-dict-select
v-model="currentSupplier.supplierGroup"
dict-type="supplier_group"
placeholder="请选择"
width="100%"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6">
<el-col :span="5">
<el-form-item label="供应商等级"> <el-form-item label="供应商等级">
<el-input v-model="currentSupplier.abc"></el-input> <el-input v-model="currentSupplier.abc"></el-input>
</el-form-item> </el-form-item>
@ -193,7 +197,7 @@
<el-input v-model="currentSupplier.buyer"></el-input> <el-input v-model="currentSupplier.buyer"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6">
<el-col :span="5">
<el-form-item label="Sourcing专员"> <el-form-item label="Sourcing专员">
<el-input v-model="currentSupplier.sourcingStaff"></el-input> <el-input v-model="currentSupplier.sourcingStaff"></el-input>
</el-form-item> </el-form-item>
@ -350,6 +354,7 @@ import {
} from '@/api/srm/srmSupplier.js' } from '@/api/srm/srmSupplier.js'
import excel from '@/utils/excel-util.js' import excel from '@/utils/excel-util.js'
import Chooselist from '@/views/modules/common/Chooselist_eam' import Chooselist from '@/views/modules/common/Chooselist_eam'
import SysDictSelect from '@/components/dict/SysDictSelect.vue'
import contract from './com_srmSupplier_Contract' import contract from './com_srmSupplier_Contract'
import share from './com_srmSupplier_share' import share from './com_srmSupplier_share'
import documents from './com_srmSupplier_DocumentDefinition' import documents from './com_srmSupplier_DocumentDefinition'
@ -364,8 +369,6 @@ export default {
supplierNo: '', supplierNo: '',
supplierName: '', supplierName: '',
active: '', active: '',
supplierGroup1:'',
supplierGroup2:'',
currency:'', currency:'',
taxCode:'', taxCode:'',
paymentTerm:'', paymentTerm:'',
@ -1190,6 +1193,7 @@ export default {
/* 组件 */ /* 组件 */
components: { components: {
Chooselist, Chooselist,
SysDictSelect,
contract, contract,
documents, documents,
share, share,
@ -1233,12 +1237,6 @@ export default {
if (val === 1100) { if (val === 1100) {
strVal = this.searchData.supplierNo?this.searchData.supplierNo:'' strVal = this.searchData.supplierNo?this.searchData.supplierNo:''
} }
if (this.tagNo === 521) {
strVal = this.currentSupplier.supplierGroup1
}
if (this.taoNo === 525){
strVal = this.currentSupplier.supplierGroup2
}
if (val === 513){ if (val === 513){
strVal = this.currentSupplier.currency strVal = this.currentSupplier.currency
} }
@ -1264,12 +1262,6 @@ export default {
if(this.tagNo == 513){ if(this.tagNo == 513){
this.currentSupplier.currency = val.Currency this.currentSupplier.currency = val.Currency
} }
if (this.tagNo === 521 ) {
this.currentSupplier.supplierGroup1 = val.supplier_group
}
if (this.tagNo === 525) {
this.currentSupplier.supplierGroup2 = val.supplier_group
}
if (this.tagNo === 522) { if (this.tagNo === 522) {
this.currentSupplier.taxCode = val.TaxCode this.currentSupplier.taxCode = val.TaxCode
} }
@ -1436,8 +1428,7 @@ export default {
supplierName: '', supplierName: '',
supplierDocType: '', supplierDocType: '',
active: 'Y', active: 'Y',
supplierGroup1:'',
supplierGroup2: '',
supplierGroup: '',
abc: '', abc: '',
buyer: '', buyer: '',
sourcingStaff: '', sourcingStaff: '',

Loading…
Cancel
Save