mall-list.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view>
  3. <view class="box-head"><uni-mall-head ref="refUniMallHead" @change="tabChange"></uni-mall-head></view>
  4. <view class="box-list">
  5. <u-checkbox-group v-model="checkboxList" placement="column" :activeColor="$settingStore.themeColor.color" @change="checkboxChange">
  6. <view
  7. v-for="item in currentData"
  8. class="box-list-item"
  9. :class="[item.children && item.children.length >= 0 ? 'box-list-item-department-icon' : 'box-list-item-user']"
  10. :key="item.id"
  11. @click="handelClickItem(item)"
  12. >
  13. <view class="box-list-item-department-pic" v-if="item.children && item.children.length >= 0"><image src="@/static/department-icon.png"></image></view>
  14. <view class="box-list-item-user-pic flex" v-else>
  15. <u-checkbox class="box-list-item-user-pic-checkbox mr9" :name="item.id"> </u-checkbox>
  16. <u-avatar
  17. class="box-list-item-user-pic-avatar mr10"
  18. :src="item.avatar"
  19. shape="square"
  20. size="40"
  21. fontSize="12"
  22. color="#ffffff"
  23. :bgColor="$settingStore.themeColor.color"
  24. v-if="item.avatar"
  25. ></u-avatar>
  26. <u-avatar
  27. class="box-list-item-user-pic-avatar mr10"
  28. :text="item.label.length > 2 ? item.label.slice(1, 3) : item.label"
  29. shape="square"
  30. size="40"
  31. fontSize="12"
  32. color="#ffffff"
  33. :bgColor="$settingStore.themeColor.color"
  34. v-else
  35. ></u-avatar>
  36. </view>
  37. <view class="box-list-item-right">
  38. <view class="box-list-item-text">{{ item.label }} {{ item.children && item.children.length > 0 ? `(${item.children.length})` : "" }}</view>
  39. <view class="box-list-item-user-tag" v-if="!item.children && item.post">
  40. <text>{{ item.post }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </u-checkbox-group>
  45. </view>
  46. <view class="box-foot">
  47. <view class="box-foot-left" style="justify-self: center">
  48. <view class="box-foot-left-count" :style="{ color: $settingStore.themeColor.color }">已选择:{{ checkboxUserList.length }}人</view>
  49. <view class="box-foot-left-people"> {{ checkboxUserList.toString() || "最多选择200人" }}</view>
  50. </view>
  51. <view class="box-foot-right">
  52. <u-button class="app-buttom" type="primary" @click="handleSubmit()" shape="square" :color="$settingStore.themeColor.color"> 确定({{ checkboxUserList.length + "/200" }}) </u-button>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import uniMallHead from "./mall-head.vue";
  59. import common from "@/plugins/common.plugins.js";
  60. import { storageSystem } from "@/utils/storage"; // 公共方法引用
  61. export default {
  62. props: {
  63. dataList: {
  64. type: Array,
  65. default: () => [],
  66. },
  67. defaultHeadList: {
  68. type: Object,
  69. default: () => {},
  70. },
  71. },
  72. components: {
  73. uniMallHead,
  74. },
  75. data() {
  76. return {
  77. checkboxList: [],
  78. currentData: [],
  79. checkboxUserData: [],
  80. checkboxUserList: [],
  81. };
  82. },
  83. mounted() {
  84. this.init();
  85. },
  86. methods: {
  87. init() {
  88. if (Object.keys(this.defaultHeadList).length > 0) {
  89. this.$refs.refUniMallHead.addTab(this.defaultHeadList);
  90. }
  91. this.currentData = this.dataList;
  92. var userList = storageSystem.get("project").userList;
  93. if (userList) {
  94. userList.forEach((e) => {
  95. this.checkboxList.push(e.id);
  96. this.checkboxUserData.push(e);
  97. this.checkboxUserList.push(e.label);
  98. });
  99. }
  100. },
  101. tabChange(obj) {
  102. this.getCurrentData(obj.id, this.dataList);
  103. },
  104. handelClickItem(item) {
  105. if (item.children && item.children.length > 0) {
  106. this.$refs.refUniMallHead.addTab({ label: item.label, id: item.id });
  107. this.currentData = item.children;
  108. this.currentData.forEach((e) => {
  109. this.checkboxUserData.forEach((f) => {
  110. if (e.id === f.id) {
  111. this.checkboxList.push(f.id);
  112. }
  113. });
  114. });
  115. } else {
  116. this.$modal.msg("该部门下暂无可选择人员!");
  117. }
  118. // this.$emit("change", item);
  119. },
  120. getCurrentData(id, data) {
  121. if (id === this.defaultHeadList.id) {
  122. this.currentData = this.dataList;
  123. } else {
  124. if (data.length > 0) {
  125. data.map((item) => {
  126. if (item.id === id) {
  127. this.currentData = item.children;
  128. }
  129. if (item.children && item.children.length > 0) {
  130. this.getCurrentData(id, item.children);
  131. }
  132. });
  133. }
  134. }
  135. },
  136. handleSubmit() {
  137. this.$emit("submit", this.checkboxUserData);
  138. },
  139. checkboxChange(event) {
  140. this.currentData.forEach((f) => {
  141. if (event.includes(f.id)) {
  142. this.checkboxUserData.push(f);
  143. } else {
  144. this.checkboxUserData.forEach((e, index) => {
  145. if (e.id === f.id) {
  146. delete this.checkboxUserData[index];
  147. }
  148. });
  149. }
  150. });
  151. this.checkboxUserList = [];
  152. this.checkboxUserData = common.uniq(this.checkboxUserData, "id");
  153. this.checkboxUserData.forEach((e) => {
  154. this.checkboxUserList.push(e.label);
  155. });
  156. },
  157. },
  158. };
  159. </script>
  160. <style lang="scss" scoped>
  161. .box-head {
  162. position: fixed;
  163. left: 0px;
  164. width: 100%;
  165. height: 48px;
  166. background: #ffffff;
  167. padding-left: 17px;
  168. box-sizing: border-box;
  169. overflow-y: hidden;
  170. z-index: 999;
  171. }
  172. .box-list {
  173. padding-top: 52px;
  174. //#ifdef APP-PLUS || MP-WEIXIN
  175. padding-bottom: 60px;
  176. //#endif
  177. .box-list-item {
  178. position: relative;
  179. height: 60px;
  180. display: flex;
  181. align-items: center;
  182. padding: 0 15px;
  183. box-sizing: border-box;
  184. background: #ffffff;
  185. margin-bottom: 1px;
  186. &:active {
  187. background: #f2f3f4;
  188. }
  189. &:last-child {
  190. margin-bottom: 0px;
  191. }
  192. .box-list-item-department-pic {
  193. width: 40px;
  194. height: 40px;
  195. background: rgba(55, 127, 255, 0.1);
  196. border-radius: 4px;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. margin-right: 15px;
  201. overflow: hidden;
  202. image {
  203. width: 20px;
  204. height: 20px;
  205. }
  206. }
  207. .box-list-item-right {
  208. display: flex;
  209. align-items: center;
  210. justify-content: space-between;
  211. flex: 1;
  212. }
  213. .box-list-item-text {
  214. color: #333333;
  215. font-size: 14px;
  216. }
  217. .box-list-item-user-tag {
  218. text {
  219. box-sizing: border-box;
  220. border-radius: 8px;
  221. padding: 4px 8px;
  222. font-size: 10px;
  223. margin-left: 5px;
  224. &:first-child {
  225. margin-left: 0px;
  226. }
  227. &:nth-child(1) {
  228. background: rgba(49, 210, 144, 0.05);
  229. border: 1px solid #31d290;
  230. color: #31d290;
  231. }
  232. &:nth-child(2) {
  233. background: rgba(55, 127, 255, 0.05);
  234. border: 1px solid #377fff;
  235. color: #377fff;
  236. }
  237. }
  238. }
  239. &.box-list-item-department-icon {
  240. &::before {
  241. content: " ";
  242. height: 10px;
  243. width: 10px;
  244. border-width: 2px 2px 0 0;
  245. border-color: #c0c0c0;
  246. border-style: solid;
  247. transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  248. position: absolute;
  249. top: 50%;
  250. margin-top: -6px;
  251. right: 14px;
  252. }
  253. }
  254. }
  255. .box-list-item-department + .box-list-item-user {
  256. margin-top: 10px;
  257. }
  258. }
  259. .box-foot {
  260. position: fixed;
  261. bottom: 0px;
  262. width: 100%;
  263. height: 60px;
  264. background: #ffffff;
  265. z-index: 999;
  266. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  267. display: flex;
  268. padding: 0 15px;
  269. &-left {
  270. margin: auto auto auto 0;
  271. &-count {
  272. color: #377fff;
  273. font-size: 14px;
  274. margin-bottom: 5px;
  275. }
  276. &-people {
  277. color: #999;
  278. font-size: 12px;
  279. }
  280. }
  281. &-right {
  282. margin: auto 0 auto 15px;
  283. }
  284. }
  285. </style>