123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <div class="search-container">
- <el-row :gutter="10" type="flex" class="search-items" justify="end">
- <el-col v-for="(item, index) in propCfg" :key="index" :span="6">
- <el-select
- v-if="item.type === $GCFG.typeSel"
- :key="index"
- v-model="searchForm[item.prop]"
- style="width: 100%"
- :placeholder="getPropPH(item, businessKey, 'search')"
- clearable
- @change="selectChg($event, item)"
- >
- <el-option
- v-for="selItem in dictMap[item.prop]"
- :key="selItem[item.dict.props.value]"
- :label="selItem[item.dict.props.label]"
- :value="selItem[item.dict.props.value]"
- />
- </el-select>
- <el-date-picker
- v-if="item.type === $GCFG.typeDateTime"
- :key="index"
- v-model="searchForm[item.prop]"
- :placeholder="getPropPH(item, businessKey, 'search')"
- type="datetime"
- format="yyyy-MM-dd HH:mm:ss"
- value-format="yyyy-MM-dd HH:mm:ss"
- />
- <el-input
- v-if="item.type === $GCFG.typeOrg"
- ref="deptName"
- :key="index"
- v-model="searchForm[$GCFG.getOrgObjKeyFlag(item.prop)].name"
- :placeholder="getPropPH(item, businessKey, 'search')"
- suffix-icon="el-icon-search"
- @click.native="showOfficeDialog(searchForm, item)"
- />
- <el-input
- v-if="item.type === $GCFG.typeInput"
- :key="index"
- v-model="searchForm[item.prop]"
- :placeholder="getPropPH(item, businessKey, 'search')"
- />
- </el-col>
- </el-row>
- <div class="btn-container">
- <el-button
- type="primary"
- icon="el-icon-search"
- @click="search()"
- >{{ $GPROP.searchBtn }}</el-button>
- <el-button
- icon="el-icon-refresh"
- @click="search('reset')"
- >{{ $GPROP.resetBtn }}</el-button>
- </div>
- </div>
- </template>
- <script>
- import common from './mixins/common'
- import props from './mixins/props'
- import org from './mixins/org'
- import { initDicts } from './core/dictService'
- export default {
- name: 'CustomSearch',
- mixins: [common, props, org],
- data() {
- return {
- searchForm: {}
- }
- },
- created() {
- this.initSearchForm()
- },
- methods: {
- search(isReset) {
- this.$emit('search-change', isReset)
- },
- initSearchForm() {
- for (const item of this.propCfg) {
- if (item.type === this.$GCFG.typeOrg) {
- const keyFlag = this.$GCFG.getOrgObjKeyFlag(item.prop)
- this.$set(this.searchForm, item.prop, '')
- this.$set(this.searchForm, keyFlag, {})
- this.$set(this.searchForm[keyFlag], 'id', '')
- this.$set(this.searchForm[keyFlag], 'name', '')
- continue
- }
- this.$set(this.searchForm, item.prop, '')
- }
- },
- selectChg(id, item) {
- const that = this
- if (item.cascader && item.cascader.length > 0) {
- item.cascader.forEach((cascaderItem) => {
- that.searchForm[cascaderItem] = ''
- that.dictMap[cascaderItem] = []
- initDicts(item.cascaderObj[cascaderItem], id, false, (data) => {
- that.dictMap[cascaderItem] = data
- })
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .search-container {
- display: flex;
- width: 100%; // 占满整个可用空间
- justify-content: space-between; // 从右边到左边布局
- .btn-container {
- padding-left: 10px;
- flex: 0 0 auto; // 仅占用本身所需要的最小空间
- }
- .search-items {
- flex: 1; // 占用剩余的所有空间
- }
- }
- </style>
|