addDetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view>
  3. <view class="bgBox" @click="onBlurBg" :style="{height:bgHeight + '%'}"></view>
  4. <view class="chooseBox" :style="{bottom:chooseBox +'vh'}">
  5. <view class="titBox"> {{title}} <view class="closeBox"><uni-icons type="closeempty" color="#999" size="20" @click="onBlurBg"></uni-icons></view></view>
  6. <view class="TabBox">
  7. <view :class="tabindex==index?'on':''" v-for="(item,index) in tabList" :key="index" @click="changeTab(index)">{{item.label}}</view>
  8. </view>
  9. <view class="treeBox" v-if="tabindex == 0">
  10. <!--一级循环-->
  11. <view class="treeItem" v-for="(item,index) in materTree" :key="index">
  12. <view class="itemBox">
  13. <view class="selectItem" @click="selectAll(item.code,0,'')">
  14. <uni-icons :color="firstChoose.code==item.code?'#19be6b':'#ddd'" :type="firstChoose.code==item.code?'circle-filled':'circle'" size="24"></uni-icons> {{item.name}}
  15. </view>
  16. <view class="openItem" @click="openItem(item.code)" v-if="item.children" :class="item.childOpen?'on':''"><uni-icons color="#ddd" type="right" size="18"></uni-icons></view>
  17. </view>
  18. <view class="itemChild" v-if="item.children" :class="item.childOpen?'onItemChild':''">
  19. <!--二级循环-->
  20. <view class="itemBox" v-for="(arrt,idx) in item.children" :key="idx">
  21. <view class="selectItem" @click="selectAll(item.code,1,arrt.code)">
  22. <uni-icons :color="firstChoose.code==arrt.code?'#19be6b':'#ddd'" :type="firstChoose.code==arrt.code?'circle-filled':'circle'" size="24"></uni-icons> {{arrt.name}}
  23. </view>
  24. </view>
  25. <!--二级循环-->
  26. </view>
  27. </view>
  28. <!--一级循环-->
  29. </view>
  30. <!--台账列表-->
  31. <view class="treeBox" v-if="tabindex == 1">
  32. <view class="treeListBox">
  33. <view class="treeListInfo" v-for="(item,index) in secondChoose.items" :key="index" @click="addItems(index)">
  34. <view class="flBox">{{item.name}}</view>
  35. <view class="frBox">
  36. <view class="attr">{{item.manageType.name}} / {{item.unit}}</view>
  37. <view class="icoBox" :class="item.checked?'on':''"><uni-icons color="#fff" type="forward" size="16"></uni-icons></view>
  38. </view>
  39. </view>
  40. <!--列表为空-->
  41. <u-empty mode="list" icon="../../../static/list.png" v-if="secondChoose.items !== undefined &&secondChoose.items.length < 1"></u-empty>
  42. </view>
  43. </view>
  44. <!--已选物料-->
  45. <view class="treeBox" v-if="tabindex == 2">
  46. <view class="titItemBox"><view>名称</view><view>数量</view><view>操作</view> </view>
  47. <view class="isChosenBox">
  48. <view class="isChosenItem" v-for="(item,index) in isChosen" :key="index">
  49. <view>{{item.name}}</view>
  50. <view><uni-number-box @change="changeValue(index)" v-model="item.num" /></view>
  51. <view><view class="icoBox" @click="getDelete(index)"><uni-icons color="#999" type="trash" size="16"></uni-icons></view></view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import { post,postJ,get } from "@/utils/api.js";
  60. export default {
  61. name:"addDetails",
  62. props: {
  63. show:{
  64. type: Boolean,
  65. default: false
  66. },
  67. tabList:{
  68. type: Array
  69. },
  70. materTree:{
  71. type: Array
  72. },
  73. title:{
  74. type: String,
  75. default:''
  76. }
  77. },
  78. data() {
  79. return {
  80. bgHeight:0, //底层背景高度
  81. chooseBox:-100, //选择框
  82. tabindex:0,
  83. firstChoose:'', //第一列
  84. secondChoose:[], //第二列
  85. isChosen:[] //第三列-已选择
  86. };
  87. },
  88. watch: {
  89. show(res){
  90. if(res){
  91. this.chooseBox = 0;
  92. this.bgHeight = 100;
  93. }else{
  94. this.chooseBox = -100;
  95. this.bgHeight = 0;
  96. }
  97. }
  98. },
  99. mounted(){
  100. },
  101. methods:{
  102. //关闭弹层
  103. onBlurBg(){
  104. this.$emit("openChoose");
  105. this.$emit("getChooseInfo",this.isChosen);
  106. },
  107. //切换Tab
  108. changeTab(index){
  109. this.tabindex = index;
  110. },
  111. //选择项
  112. selectAll(code,pid,childCode){
  113. let that = this;
  114. //遍历数组
  115. that.materTree.forEach(function(res, key) {
  116. if(res.code == code && pid == 0){
  117. that.firstChoose = that.materTree[key];
  118. }else if(res.code == code && pid == 1){
  119. let childData = that.materTree[key].children;
  120. childData.forEach(function(vo, k) {
  121. if(vo.code == childCode){
  122. that.firstChoose = childData[k];
  123. }
  124. })
  125. }
  126. });
  127. //请求二级Tab数据
  128. if(that.firstChoose){
  129. let data = {
  130. typeCode:that.firstChoose.code
  131. };
  132. //获取物料列表
  133. post(this.apiWebUrl + "/wms/enter/material/numList",data).then((res)=>{
  134. this.secondChoose = res.data;
  135. //console.log(this.secondChoose);
  136. //给列表项添加已选状态
  137. let isChosen = this.isChosen;
  138. let secondChoose = this.secondChoose.items;
  139. for (let i = 0; i < isChosen.length; i++) {
  140. for (let j = 0; j < secondChoose.length; j++) {
  141. if (secondChoose[j].batchNo == isChosen[i].batchNo) {
  142. this.secondChoose.items[j].checked = true;
  143. }
  144. }
  145. }
  146. });
  147. };
  148. //Tab索引
  149. this.tabindex = 1;
  150. },
  151. //点击展示下级
  152. openItem(code){
  153. let that = this;
  154. //遍历数组
  155. that.materTree.forEach(function(res, key) {
  156. if(res.code == code){
  157. that.materTree[key].childOpen = !that.materTree[key].childOpen;
  158. }
  159. });
  160. },
  161. //已选项
  162. addItems(index){
  163. if(!this.secondChoose.items[index].checked){
  164. //添加新的属性
  165. this.$set(this.secondChoose.items[index], 'checked', true);
  166. this.$set(this.secondChoose.items[index], 'num', 1);
  167. this.$set(this.secondChoose.items[index], 'material', {
  168. id:this.secondChoose.items[index].code,
  169. name:this.secondChoose.items[index].name
  170. });
  171. this.$set(this.secondChoose.items[index], 'manageType', this.secondChoose.items[index].manageType.id);
  172. this.$set(this.secondChoose.items[index], 'pkgUnit', this.secondChoose.items[index].pkgUnit.name);
  173. this.isChosen.push(this.secondChoose.items[index]);
  174. }
  175. //console.log(this.isChosen);
  176. },
  177. //更新数量
  178. changeValue(index){
  179. // console.log(this.isChosen);
  180. },
  181. //删除
  182. getDelete(index){
  183. this.isChosen.splice(index,1);
  184. },
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .bgBox{
  190. position: fixed;
  191. bottom: 0px;
  192. left: 0px;
  193. right: 0px;
  194. width: 100%;
  195. background: rgba(0,0,0,0.2);
  196. }
  197. .chooseBox{
  198. position: fixed;
  199. left: 0;
  200. width: 100%;
  201. height:80vh;
  202. background: #fff;
  203. box-shadow: 0px 10px 20px rgba(0,0,0,1);
  204. border-top-left-radius: 20px;
  205. border-top-right-radius: 20px;
  206. z-index: 9;
  207. transition: all 0.3s;
  208. }
  209. .titBox{
  210. margin: 20rpx 0;
  211. height: 80rpx;
  212. line-height: 80rpx;
  213. text-align: center;
  214. position: relative;
  215. color: #999;
  216. .closeBox{
  217. height: 20px;
  218. line-height: 20px;
  219. position: absolute;
  220. right:15px;
  221. top:5px;
  222. }
  223. }
  224. .TabBox{
  225. display: flex;
  226. align-items: center;
  227. justify-content: space-between;
  228. border-bottom: 1px #f2f2f2 solid;
  229. height: 80rpx;
  230. line-height: 80rpx;
  231. padding: 0px 40rpx;
  232. > view{
  233. text-align: center;
  234. padding: 0px 20rpx;
  235. font-size: $uni-font-size-lg;
  236. position: relative;
  237. }
  238. > view.on{
  239. color: #19be6b;
  240. font-weight: bold;
  241. }
  242. > view.on::after{
  243. content: '';
  244. position: absolute;
  245. left: 0px;
  246. bottom: -1px;
  247. width: 100%;
  248. height: 2px;
  249. background: #19be6b;
  250. }
  251. }
  252. .treeBox{
  253. margin: 40rpx auto;
  254. line-height:60rpx;
  255. color: #666;
  256. height: calc(80vh - 280rpx);
  257. overflow-y: auto;
  258. .treeItem{
  259. width: 85%;
  260. margin: 0px auto;
  261. padding: 4rpx 0;
  262. .itemBox{
  263. display: flex;
  264. align-items: center;
  265. }
  266. .uni-icons{
  267. margin-right: 10rpx;
  268. }
  269. .selectItem{
  270. display: flex;
  271. }
  272. .openItem{
  273. margin-left: auto;
  274. }
  275. .openItem.on{
  276. -webkit-transform: rotate(90deg);
  277. }
  278. .itemChild{
  279. margin: 0px auto;
  280. padding-left: 60rpx;
  281. max-height: 0px;
  282. overflow: hidden;
  283. transition: all 0.3s;
  284. }
  285. .itemChild.onItemChild{
  286. max-height: 60vh;
  287. }
  288. }
  289. }
  290. .treeListInfo{
  291. display: flex;
  292. align-items: center;
  293. justify-content: space-between;
  294. width: 85%;
  295. margin: 0px auto;
  296. padding: 20rpx 0;
  297. border-bottom: 1px #f2f2f2 solid;
  298. .flBox{
  299. width: 60%;
  300. overflow: hidden;
  301. white-space:nowrap;
  302. -o-text-overflow:ellipsis;
  303. text-overflow:ellipsis;
  304. font-size: $uni-font-size-base;
  305. }
  306. .frBox{
  307. display: flex;
  308. align-items: center;
  309. .attr{
  310. font-size: $uni-font-size-base;
  311. line-height: 32rpx;
  312. margin-right: 20rpx;
  313. color: #999;
  314. text{
  315. display: block;
  316. }
  317. }
  318. .icoBox{
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. background: #19be6b;
  323. border-radius: 100%;
  324. width:42rpx;
  325. height: 42rpx;
  326. }
  327. .icoBox.on{
  328. background: #ccc;
  329. }
  330. }
  331. }
  332. .titItemBox{
  333. padding: 0px 10rpx;
  334. display: flex;
  335. align-items: center;
  336. justify-content: space-between;
  337. background: #f2f2f2;
  338. font-size: $uni-font-size-base;
  339. > view{
  340. padding:10rpx;
  341. }
  342. > view:nth-child(1){
  343. width: 50%;
  344. overflow: hidden;
  345. }
  346. > view:nth-child(2){
  347. width: 30%;
  348. text-align: center;
  349. overflow: hidden;
  350. }
  351. > view:nth-child(3){
  352. width: 80rpx;
  353. overflow: hidden;
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. }
  358. }
  359. .isChosenItem{
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. font-size: $uni-font-size-sm;
  364. border-bottom: 1px #f2f2f2 solid;
  365. > view{
  366. padding:10rpx 20rpx;
  367. }
  368. > view:nth-child(1){
  369. width: 50%;
  370. overflow: hidden;
  371. white-space:nowrap;
  372. -o-text-overflow:ellipsis;
  373. text-overflow:ellipsis;
  374. overflow: hidden;
  375. }
  376. > view:nth-child(2){
  377. width: 30%;
  378. overflow: hidden;
  379. }
  380. > view:nth-child(3){
  381. width: 80rpx;
  382. overflow: hidden;
  383. display: flex;
  384. align-items: center;
  385. justify-content: center;
  386. }
  387. .icoBox{
  388. width: 50rpx;
  389. height: 50rpx;
  390. border: 1px #ddd solid;
  391. border-radius: 100%;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. }
  396. }
  397. </style>