123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- <template>
- <div tabindex="0" @blur="selectClihide()" style="display: inline-block;">
- <!-- <div :style="'width:' + selectWidth + 'px;height:' + selectHeight + 'px'" :class="classDiv ? 'select selectDiv' : 'select'" @click="selectCli" :ref="disabled ? '' : 'selectDiv'"> -->
- <div :class="disabled ? 'disabledTrue' : 'disabledFalse'" @mouseenter="moveIonDiv" @mouseleave="outIonDiv">
- <div :style="`width:${selectWidth}px;height:${selectHeight}px`" :class="classDiv ? 'select selectDiv' : 'select'" @click="selectCli" :ref="disabled ? '' : 'selectDiv'">
- <div v-if="!multiSelect" :style="'line-height: '+selectHeight+'px;font-size: '+selectFontSize+'px;'" :class="selectName == $t('defaultText.pleaseChoose') ? 'selecttex selecttexXuan' : 'selecttex'">
- <ww-open-data type='userName' :openid='selectName'></ww-open-data>
- <!-- {{selectName}} -->
- </div>
- <div v-if="multiSelect" :style="'line-height: '+selectHeight+'px;margin-left: -10px'" :class="selectName == $t('defaultText.pleaseChoose') ? 'selecttex selecttexXuan' : 'selecttex'">
- <span v-if="multiSelectList.length > 0">
- <span v-if="!tile">
- <span class="all">
- <ww-open-data type='userName' :openid='multiSelectList[0].name'></ww-open-data>
- {{multiSelectList[0].name}}
- <i class="el-icon-error" v-if="!disabled" @click.stop="deleteMultiSelectList('-1')"></i>
- </span>
- <span class="all" v-if="multiSelectList.length > 1"> + {{multiSelectList.length - 1}}</span>
- </span>
- <span v-if="tile">
- <span class="all" style="margin-right: 6px" v-for="(items, indexs) in multiSelectList" :key="indexs">
- <ww-open-data type='userName' :openid='items.name'></ww-open-data>
- <!-- {{items.name}} -->
- <span v-if="items.jobNumber">{{items.jobNumber}}</span>
- <i class="el-icon-error" @click.stop="deleteMultiSelectList(indexs)" v-if="!disabled"></i>
- </span>
- </span>
- </span>
- <span v-else class="allTwo">{{$t('defaultText.pleaseChoose')}}</span>
- </div>
- <i :class=" move ? 'el-icon-arrow-down iostu iostuHover' : 'el-icon-arrow-down iostu'" v-if="!moveIon"></i>
- <i v-if="moveIon" class="el-icon-circle-close iostu" @click.stop="clearDelete"></i>
- </div>
- </div>
- <transition name="el-zoom-in-top">
- <div v-show="show" style="position: relative;z-index: 99;">
- <!-- 搜索框 -->
- <div class="searchBox">
- <el-input :placeholder="$t('peaseenterthe')" size="mini" v-model="searchTex" style="width: 150px" @focus="searchBox()">
- <el-button slot="append" icon="el-icon-search" size="mini" @click="searchLick()"></el-button>
- </el-input>
- </div>
- <div class="transitionBox" :style="filterable ? 'margin: 30px 0;' : ''">
- <ul class="transitionBoxUl">
- <li :class="transitionBoxLiIdx == index ? 'liHover' : ''" v-for="(item, index) in options" :key="index" @mouseover="liMouseOver(index)" @click="liClick(item, index)">
- <span v-if="!multiSelect">
- <span v-if="item.name">
- <ww-open-data type='userName' :openid='item.name'></ww-open-data>
- </span>
- <span v-if="item.auditorName">
- <ww-open-data type='userName' :openid='item.auditorName'></ww-open-data>
- </span>
- <!-- {{item.name || item.auditorName}} -->
- <span v-if="item.jobNumber" class="spanFllat">{{item.jobNumber}}</span>
- </span>
- <span v-if="multiSelect">
- <span :class="item.flg ? 'hoverSpan hoverSpanHover' : 'hoverSpan'">
- <span>
- <ww-open-data type='userName' :openid='item.name'></ww-open-data>
- <!-- {{item.name}} -->
- <span v-if="item.jobNumber" class="spanFllat">{{item.jobNumber}}</span>
- </span>
- <span v-if="item.flg"><i class="el-icon-check"></i></span>
- </span>
- </span>
- </li>
- </ul>
- </div>
- </div>
- </transition>
- </div>
- </template>
- <script>
- export default {
- props: {
- subject:{
- type: Array
- },
- size: {
- type: String,
- },
- subjectId: {
- type: [String, Number, Array]
- },
- // 是否支持多选
- multiSelect: {
- type: Boolean,
- default: false
- },
- // 是否平铺 (需要 multiSelect 为 true)
- tile: {
- type: Boolean,
- default: false
- },
- // 当前页面用到的第几个
- distinction: {
- type: String,
- default: '1',
- },
- // 真对填写日报单独处理
- idx: {
- type: String
- },
- flg: {
- type: Boolean,
- default: false, // 默认值,不是填写日报
- },
- // 宽度
- widthStr: {
- type: String,
- default: false
- },
- // 剩下统一索引
- index: {
- type: String
- },
- // 是否禁用
- disabled: {
- type: Boolean,
- default: false
- },
- // 是否可清空
- clearable: {
- type: Boolean,
- default: false
- },
- // 是否可搜索
- filterable: {
- type: Boolean,
- default: false
- },
- // 其他数据
- other: {
- type: [String, Number, Boolean],
- default: false
- },
- // 是否执行到日报单独的函数
- flgs: {
- type: Boolean,
- default: false
- },
- },
- components: {
- selectWidth: '150',
- selectHeight: '28'
- },
- data() {
- return {
- selectWidth: '150',
- selectHeight: '28',
- selectFontSize: '12',
- show: false, // 下拉框
- options: [], // 列表数据
- transitionBoxLiIdx: '', // hover 背景色
- selectName: this.$t('defaultText.pleaseChoose'), // 显示的文字
- classDiv: false, // 获得焦点样式
- optionsOId: '', // 选中人的id
- dailyListObj: null, // 填写日报的数据
- dailyListIndex: null, // 日报点的索引
- move: false,
- moveIon: false,
- multiSelectList: [],
- searchTex: '', // 搜索文字
- cursor: '', // 搜索的标记(需传给后端)
- };
- },
- computed: {},
- watch: {
- subject: {
- handler(newValue, oldValue) {
- this.options = newValue
- if(this.flg) {
- if(newValue) {
- this.selectName = newValue[0].name || newValue[0].auditorName
- this.optionsOId = newValue[0].id || newValue[0].auditorId
- }
- }
- },
- },
- // 日报点的索引, 真对填写的日报
- idx: {
- handler(newValue, oldValue) {
- console.log(newValue, oldValue)
- this.dailyListIndex = newValue
- },
- },
- subjectId: {
- handler(newValue, oldValue) {
- console.log(newValue, oldValue)
- this.optionsOId = newValue
- this.multiSelectList = []
- if(!this.multiSelect) {
- if(this.optionsOId) {
- for(let i in this.options) {
- if(this.options[i].id == this.optionsOId || this.options[i].auditorId == this.optionsOId) {
- this.selectName = this.options[i].name || this.options[i].auditorName
- }
- }
- } else {
- this.selectName = this.$t('defaultText.pleaseChoose')
- }
- }
- if(this.multiSelect) {
- for(var i in this.options) {
- for(var j in this.optionsOId) {
- if(this.options[i].id == this.optionsOId[j] || this.options[i].auditorId == this.optionsOId[j]) {
- this.multiSelectList.push(this.options[i])
- this.options[i].flg = true
- }
- }
- }
- }
- },
- },
- widthStr: {
- handler(newValue, oldValue) {
- this.selectWidth = newValue
- },
- }
- },
- created() {},
- mounted() {
- if(this.size == 'mini') {
- this.selectWidth = '150'
- this.selectHeight = '28'
- } else if(this.size == 'small') {
- this.selectWidth = '191'
- this.selectHeight = '32'
- } else if(this.size == 'medium') {
- this.selectWidth = '205'
- this.selectHeight = '40'
- this.selectFontSize = '14'
- }
- if(this.widthStr) {
- this.selectWidth = this.widthStr
- }
-
- if(this.subject) {
- this.options = JSON.parse(JSON.stringify(this.subject))
- }
- if(this.subjectId) {
- this.multiSelectList = []
- if(!this.multiSelect) {
- this.optionsOId = JSON.parse(JSON.stringify(this.subjectId))
- for(let i in this.options) {
- if(this.options[i].id == this.optionsOId || this.options[i].auditorId == this.optionsOId) {
- this.selectName = this.options[i].name || this.options[i].auditorName
- }
- }
- }
- if(this.multiSelect) {
- for(var i in this.options) {
- for(var j in this.optionsOId) {
- if(this.options[i].id == this.optionsOId[j] || this.options[i].auditorId == this.optionsOId[j]) {
- this.multiSelectList.push(this.options[i])
- this.options[i].flg = true
- }
- }
- }
- }
- }
- console.log(this.subject)
- this.dailyListIndex = this.idx
- },
- methods: {
- selectCli() {
- if(!this.disabled) {
- this.$refs.selectDiv.focus()
- this.classDiv = !this.classDiv
- this.show = !this.show
- this.move = !this.move
- this.searchTex = ''
- }
- },
- selectClihide() {
- if(this.classDiv) {
- this.transitionBoxLiIdx = ''
- this.show = !this.show
- this.classDiv = false
- this.move = false
- if(this.multiSelect) {
- let obj = {
- // id: nameId,
- distinction: this.distinction,
- index: this.index, // 选中的索引
- other: this.other,
- arrUserList: this.multiSelectList,
- name: this.selectName
- }
- this.$emit("selectCal", obj)
- }
- }
- },
- liMouseOver(index) {
- this.transitionBoxLiIdx = index
- },
- liClick(item, itemIndex) {
- let nameId = item.id || item.auditorId
- if(!this.multiSelect) {
- console.log('我进来了', this.flg)
- if(this.flgs) {
- let obj = {
- id: nameId,
- idx: this.dailyListIndex
- }
- this.$emit("selectCatCli", obj);
- } else {
- let obj = {
- id: nameId,
- distinction: this.distinction,
- index: this.index, // 选中的索引
- other: this.other,
- name: this.selectName
- }
- this.$emit("selectCal", obj)
- }
- this.selectName = item.name || item.auditorName
- this.transitionBoxLiIdx = ''
- this.show = false
- this.classDiv = false
- this.move = false
- }
- if(this.multiSelect) {
- if(this.options[itemIndex].flg) {
- this.options[itemIndex].flg = !this.options[itemIndex].flg
- for(var i in this.multiSelectList) {
- if(this.multiSelectList[i].id == item.id) {
- this.multiSelectList.splice(i, 1)
- }
- }
- } else {
- this.options[itemIndex].flg = false
- this.options[itemIndex].flg = !this.options[itemIndex].flg
- this.multiSelectList.push(item)
- }
- }
- },
- moveIonDiv() {
- if(this.clearable) {
- this.moveIon = true
- }
- },
- outIonDiv() {
- if(this.clearable) {
- this.moveIon = false
- }
- },
- clearDelete() {
- if(!this.multiSelect) {
- this.selectName = this.$t('defaultText.pleaseChoose')
- let obj = {
- name: this.$t('defaultText.pleaseChoose'),
- id: ''
- }
- this.liClick(obj)
- }
- if(this.multiSelect) {
- this.multiSelectList = []
- let obj = {
- distinction: this.distinction,
- index: this.index, // 选中的索引
- other: this.other,
- arrUserList: []
- }
- for(var i in this.options) {
- if(this.options[i].flg) {
- this.options[i].flg = false
- }
- }
- this.$emit("selectCal", obj)
- }
- },
- deleteMultiSelectList(str) {
- let userId
- if(str == '-1') {
- userId = this.multiSelectList[0].id
- this.multiSelectList.splice(0, 1)
- } else {
- userId = this.multiSelectList[str].id
- this.multiSelectList.splice(str, 1)
- }
- for(var i in this.options) {
- if(this.options[i].id == userId) {
- if(this.options[i].flg) {
- this.options[i].flg = false
- }
- }
- }
-
- let obj = {
- distinction: this.distinction,
- index: this.index, // 选中的索引
- other: this.other,
- arrUserList: this.multiSelectList,
- name: this.selectName
- }
- this.$emit("selectCal", obj)
- },
- searchBox() {
- this.selectCli()
- },
- // 搜索
- searchLick() {
- console.log('文字')
- this.getSimpleActiveUserList()
- },
- // 针对 getSimpleActiveUserList 获取所有人员接口
- getSimpleActiveUserList() {
- this.http.post('/user/getSimpleActiveUserList', {
- keyword: this.searchTex,
- cursor: this.cursor
- },
- res => {
- if (res.code == "ok") {
- console.log('数据')
- this.options = res.data.retUser
- this.cursor = res.data.nextCursor
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- },
- triggerOption(){
- },
- choose(item,value){
-
- },
- };
- </script>
- <style scoped lang="scss">
- .selectDiv {
- border-color: #409EFF !important;
- }
- .disabledTrue {
- background: #F5F7FA !important;
- border-radius: 4px;
- cursor: not-allowed !important;
- position: relative;
- }
- .disabledFalse .select {
- background: #FFF !important;
- border-radius: 4px;
- }
- .select {
- -webkit-appearance: none;
- // background-color: #FFF;
- background-image: none;
- border-radius: 4px;
- border: 1px solid #DCDFE6;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- color: #606266;
- display: inline-block;
- font-size: inherit;
- height: 40px;
- line-height: 40px;
- outline: 0;
- padding: 0 15px;
- -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
- transition: border-color .2s cubic-bezier(.645,.045,.355,1);
- width: 100%;
- position: relative;
- cursor: pointer;
- }
- .selecttex {
- height: 28px;
- line-height: 28px;
- text-overflow: ellipsis;
- font-size: 12px;
- }
- .iostu {
- position: absolute;
- top: 50%;
- margin-top: -4px;
- right: 8px;
- color: #C0C4CC;
- transition: All 0.2s ease-in-out;
- }
- .iostuHover {
- transform: rotate(-180deg);
- }
- .searchBox {
- position: absolute;
- width: 100%;
- }
- .transitionBox {
- background: #FFF;
- position: absolute;
- width: 100%;
- border-radius: 2em;
- border: 1px solid #E4E7ED;
- border-radius: 4px;
- background-color: #FFF;
- box-sizing: border-box;
- margin: 5px 0;
- box-shadow: 0 2px 12px #dfdfdf;
- max-height: 274px;
- overflow: auto;
- z-index: 500 !important;
- }
- .transitionBoxUl {
- list-style: none;
- padding: 6px 0;
- margin: 0;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- }
- .transitionBoxUl li {
- font-size: 14px;
- padding: 0 20px;
- position: relative;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- color: #606266;
- height: 34px;
- line-height: 34px;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- cursor: pointer;
- }
- .liHover {
- background-color: #F5F7FA;
- }
- .selecttexXuan {
- color: #C0C4CC;;
- }
- .all {
- display: inline-block;
- font-size: 10px;
- background: #f4f4f5;
- height: 20px;
- line-height: 24px;
- padding: 0px 8px;
- color: #909399;
- }
- .allTwo {
- display: inline-block;
- margin-left: 10px;
- }
- .hoverSpan {
- display: flex;
- width: 100%;
- justify-content: space-between;
- }
- .hoverSpanHover {
- color: #409eff;
- font-weight: 700;
- }
- .spanFllat {
- display: inline-block;
- float: right;
- }
- </style>
|