123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <view>
- <view class="head">
- 请选择角色
- </view>
- <My_listbox ref="List" @getlist="getList" bottomHeight="70">
- <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.roleid"
- @click="selectItem(item)">
- <view class="checkbox-box">
- <checkbox :checked="selectList.some(v => v == item.roleid)" color="#3874F6"
- style="transform:scale(0.7)" />
- </view>
- <view class="name u-line-1">
- {{ item.rolename || '--' }}
- </view>
- </view>
- </My_listbox>
- <view class="footer">
- <view class="total">
- 已选:{{ selectList.length }}
- </view>
- <view class="confirm" :class="selectList.length ? '' : 'forbidden'" @click="selectList.length ? submit() : ''">
- 确定
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- list: [],
- "content": {
- "where": {
- "sys_enterprise_hrid": 0
- }
- },
- selectList: [],
- results: [],
- }
- },
- onLoad(options) {
- console.log("options", options)
- uni.setNavigationBarTitle({
- title: options.title || '选择角色'
- });
- if (options.sys_enterprise_hrid) this.content.where.sys_enterprise_hrid = options.sys_enterprise_hrid;
- if (options.alreadySelecteds) {
- const alreadySelecteds = JSON.parse(options.alreadySelecteds);
- this.selectList = alreadySelecteds.value;
- this.results = alreadySelecteds.value.map((v, i) => {
- return {
- roleid: v,
- rolename: alreadySelecteds.showValue[i]
- }
- });
- }
- this.getList()
- },
- methods: {
- getList(init = false) {
- if (this.paging(this.content, init)) return;
- this.$Http.basic({
- "id": 20240411110602,
- content: this.content
- }).then(res => {
- this.$refs.List.RefreshToComplete()
- console.log("获取角色列表", res)
- if (this.cutoff(res.msg)) return;
- this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
- this.content = this.$refs.List.paging(this.content, res)
- })
- },
- selectItem(item) {
- let index = this.selectList.findIndex(v => v == item.roleid);
- if (index == -1) {
- this.selectList.push(item.roleid)
- this.results.push(item)
- } else {
- this.selectList.splice(index, 1);
- this.results.splice(index, 1);
- }
- },
- submit() {
- this.$Http.routeSelected({
- value: this.selectList,
- showValue: this.results.map(v => v.rolename)
- })
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .head {
- line-height: 17px;
- font-family: Source Han Sans SC, Source Han Sans SC;
- font-size: 12px;
- color: #666666;
- padding: 10px;
- }
- .item {
- display: flex;
- align-items: center;
- height: 50px;
- background: #fff;
- .checkbox-box {
- display: flex;
- justify-content: center;
- width: 44px;
- flex-shrink: 0;
- }
- .name {
- height: 50px;
- line-height: 50px;
- width: 100%;
- box-sizing: border-box;
- border-bottom: 0.5px solid #ddd;
- font-family: PingFang SC, PingFang SC;
- font-size: 14px;
- color: #333333;
- padding-right: 10px;
- }
- }
- .footer {
- position: fixed;
- bottom: 0;
- width: 100vw;
- height: 65px;
- background: #FFFFFF;
- box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
- box-sizing: border-box;
- padding: 5px 10px;
- display: flex;
- justify-content: space-between;
- .total {
- line-height: 45px;
- font-family: PingFang SC, PingFang SC;
- font-size: 14px;
- color: #333333;
- }
- .confirm {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 112px;
- height: 45px;
- background: #C30D23;
- border-radius: 5px;
- font-family: PingFang SC, PingFang SC;
- font-size: 14px;
- color: #FFFFFF;
- }
- .forbidden {
- opacity: .6;
- }
- }
- </style>
|