selectTaskName.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择" @clickLeft="backAdd">
  4. </uni-nav-bar>
  5. <view class="searchBox">
  6. <input v-model="searchVal" placeholder="请输入名称" class="searchInput" />
  7. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" data-icon="Search" class="searchBtn">
  8. <view class="iconfont icon-sousuo"></view>
  9. <view class="text">搜索</view>
  10. </u-button>
  11. </view>
  12. <view class="wrapper">
  13. <u-list @scrolltolower="scrolltolower" class="listContent">
  14. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  15. <label>
  16. <view class="listBox">
  17. <view class="listBox-sel">
  18. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  19. :checked="item.checked" />
  20. </view>
  21. <view class="listBox-con">
  22. <view class="listBox-top">
  23. <view class="listBox-name">
  24. {{ item.name }}
  25. </view>
  26. <view class="listBox-code">
  27. {{ item.code }}
  28. </view>
  29. </view>
  30. <view class="listBox-bottom">
  31. <view>工序控制码:{{ item.controlName }}</view>
  32. <view>所属工作中心:{{ item.workCenterName }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </label>
  37. </checkbox-group>
  38. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  39. </u-list>
  40. </view>
  41. <view class="footer">
  42. <view class="bottom" v-if="this.isAll==1">
  43. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  44. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  45. </checkbox>
  46. </view>
  47. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  48. <view class="selBtn">选择( {{ checkListLen }} )</view>
  49. </u-button>
  50. </view>
  51. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择部门"
  52. :localdata="classificationList" valueKey="id" textKey="name" />
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. producetask,
  58. } from '@/api/purchasingManage/purchaseNeedManage.js'
  59. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  60. export default {
  61. components: {
  62. baTreePicker
  63. },
  64. data() {
  65. return {
  66. page: 1,
  67. size: 10,
  68. isEnd: false,
  69. searchVal: '',
  70. pickTabIndex: 1,
  71. popupShow: false, //右侧搜索窗
  72. typeIndex: 1,
  73. listData: [], //列表数据
  74. classificationList: [], //分类数据
  75. seletedAll: false, //全选状态,
  76. isAll: ''
  77. }
  78. },
  79. //选择的列表长度
  80. computed: {
  81. checkListLen() {
  82. return this.listData.filter(el => el.checked).length
  83. },
  84. },
  85. onShow() {
  86. this.isEnd = false
  87. this.page = 1
  88. this.getList()
  89. },
  90. onLoad({
  91. isAll
  92. }) {
  93. this.isAll = isAll //1多选 2单选
  94. this.getList()
  95. },
  96. onShow() {},
  97. methods: {
  98. scrolltolower() {
  99. this.getList()
  100. },
  101. //列表数据
  102. getList() {
  103. if (this.isEnd) {
  104. return
  105. }
  106. uni.showLoading({
  107. title: '加载中'
  108. })
  109. let params = {
  110. pageNum: this.page,
  111. size: this.size,
  112. name: this.searchVal
  113. }
  114. producetask(params).then(res => {
  115. console.log(res)
  116. if (this.page === 1) {
  117. this.listData = res.list
  118. } else {
  119. this.listData.push(...res.list)
  120. }
  121. this.page += 1
  122. this.isEnd = this.listData.length >= res.count
  123. }).then(() => {
  124. uni.hideLoading()
  125. })
  126. // this.isEnd = false
  127. // this._getClassifyList()
  128. },
  129. async _getClassifyList() {
  130. uni.showLoading({
  131. title: '数据加载中'
  132. })
  133. const params = {
  134. pageNum: 1,
  135. size: this.size,
  136. name: this.searchVal,
  137. }
  138. producetask(params).then(res => {
  139. uni.hideLoading()
  140. if (this.page == 1) {
  141. this.listData = []
  142. }
  143. this.listData = this.listData.concat(res.list)
  144. this.isEnd = this.listData.length >= res.count
  145. })
  146. },
  147. confirm([id]) {
  148. this.categoryLevelId = id
  149. this.page = 1
  150. this.getList()
  151. },
  152. async getClassify() {
  153. listOrganizations(1).then(res => {
  154. this.classificationList = res
  155. this.page = 1
  156. this.getList()
  157. });
  158. },
  159. doSearch() {
  160. this.isEnd = false
  161. this.page = 1
  162. this.getList()
  163. },
  164. //勾选
  165. selectVal(e, val, index) {
  166. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  167. if (this.isAll != 1) {
  168. this.listData.forEach((item, i) => {
  169. if (item.id != val.id) {
  170. this.$set(this.listData[i], 'checked', false)
  171. }
  172. })
  173. } else {
  174. this.seletedAll = !this.listData.some(item => !item.checked)
  175. }
  176. },
  177. //全选按钮
  178. _seletedAll() {
  179. if (!this.seletedAll) {
  180. this.seletedAll = true
  181. this.listData.map(item => {
  182. this.$set(item, 'checked', true)
  183. })
  184. } else {
  185. this.seletedAll = false
  186. this.listData.map(item => {
  187. this.$set(item, 'checked', false)
  188. })
  189. }
  190. },
  191. //跳转回添加页面
  192. jumpAdd() {
  193. uni.$emit(
  194. 'setTaskName',
  195. this.listData.filter(item => item.checked)
  196. )
  197. uni.navigateBack()
  198. },
  199. //返回添加页
  200. backAdd() {
  201. uni.navigateBack()
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .mainBox {
  208. height: 100vh;
  209. display: flex;
  210. flex-direction: column;
  211. .wrapper {
  212. flex: 1;
  213. overflow: hidden;
  214. }
  215. .searchBox {
  216. padding: 10rpx 0;
  217. box-sizing: border-box;
  218. background-color: #dedede;
  219. height: 90rpx;
  220. width: 100%;
  221. line-height: 90rpx;
  222. display: flex;
  223. justify-content: space-around;
  224. align-items: center;
  225. input {
  226. height: 78rpx;
  227. width: 65%;
  228. background: #f9f9f9 !important;
  229. margin: 0 10rpx;
  230. padding: 0 10rpx;
  231. box-sizing: border-box;
  232. border-radius: 5rpx;
  233. }
  234. .searchBtn {
  235. height: 80rpx;
  236. background: #f9f9f9 !important;
  237. color: #676767;
  238. font-size: 28rpx;
  239. padding: 0 42rpx;
  240. box-sizing: border-box;
  241. outline: none;
  242. border: none;
  243. width: 260rpx;
  244. .icon-sousuo {
  245. font-size: 22px;
  246. }
  247. .text {
  248. font-size: 16px;
  249. margin-left: 10px;
  250. }
  251. }
  252. }
  253. .tab-title {
  254. position: fixed;
  255. top: 190rpx;
  256. z-index: 99;
  257. width: 100%;
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. height: $tab-height;
  262. line-height: $tab-height;
  263. background-color: #ffffff;
  264. border-bottom: 2rpx solid #f2f2f2;
  265. box-sizing: border-box;
  266. .tab-item {
  267. width: 25%;
  268. text-align: center;
  269. font-size: 32rpx;
  270. color: $uni-text-color-grey;
  271. }
  272. .tab-item.active {
  273. color: $j-primary-border-green;
  274. border-bottom: 1px solid $j-primary-border-green;
  275. font-weight: bold;
  276. }
  277. .tab-item.filter {
  278. flex: 1;
  279. padding: 0px 30rpx;
  280. .uni-icons {
  281. display: flex;
  282. padding-top: 5px;
  283. }
  284. }
  285. .screenIcon {
  286. display: flex;
  287. width: 80px;
  288. justify-content: center;
  289. .screenText {
  290. font-size: 32rpx;
  291. color: $uni-text-color-grey;
  292. }
  293. }
  294. }
  295. .listContent {
  296. height: 100% !important;
  297. .listBox {
  298. display: flex;
  299. // height: 180rpx;
  300. padding: 20rpx 0;
  301. border-bottom: 2rpx solid #e5e5e5;
  302. .listBox-sel {
  303. height: 90rpx;
  304. width: 80rpx;
  305. // line-height: 90rpx;
  306. text-align: center;
  307. checkbox {
  308. transform: scale(1.2);
  309. }
  310. }
  311. .listBox-con {
  312. width: 100%;
  313. // display: flex;
  314. // flex-wrap: wrap;
  315. // justify-content: space-between;
  316. align-items: center;
  317. padding: 0 18rpx 0 0;
  318. .listBox-top {
  319. width: 100%;
  320. display: flex;
  321. justify-content: space-between;
  322. padding-bottom: 10rpx;
  323. .listBox-name,
  324. .listBox-code {
  325. display: inline-block;
  326. font-size: $uni-font-size-sm;
  327. font-weight: bold;
  328. }
  329. }
  330. .listBox-bottom {
  331. width: 100%;
  332. display: flex;
  333. justify-content: space-between;
  334. font-size: $uni-font-size-sm;
  335. flex-wrap: wrap;
  336. >view {
  337. width: 50%;
  338. overflow: hidden;
  339. white-space: nowrap;
  340. text-overflow: ellipsis;
  341. }
  342. }
  343. }
  344. }
  345. .noDate {
  346. height: 100%;
  347. }
  348. }
  349. //底部按钮
  350. .footer {
  351. height: 90rpx;
  352. position: relative;
  353. display: flex;
  354. justify-content: space-between;
  355. align-items: center;
  356. bottom: 0;
  357. width: 100%;
  358. height: 100rpx;
  359. border-top: 1rpx solid #eeecec;
  360. background-color: #ffffff;
  361. z-index: 999;
  362. .bottom {
  363. margin-left: 10rpx;
  364. }
  365. .u-reset-button {
  366. position: absolute;
  367. right: 10rpx;
  368. top: 20rpx;
  369. width: 150rpx;
  370. }
  371. }
  372. }
  373. </style>