select.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="billing_box_bg">
  3. <view class="input-wrap">
  4. <app-search-module
  5. v-model="py"
  6. placeholder="请输入关键词,支持拼音首字母搜索"
  7. @input="searchFn"
  8. />
  9. </view>
  10. <!-- <app-tabs-->
  11. <!-- :tabs="tabs"-->
  12. <!-- :currentTab="tabIndex"-->
  13. <!-- @change="change"-->
  14. <!-- itemWidth="50%"-->
  15. <!-- />-->
  16. <view class="scroll-middle_bx">
  17. <scroll-view scroll-y scroll-with-animation class="tab-view" :scroll-top="scrollTop">
  18. <div v-for="(item, index) in filterProductInfo" :key="index" class="tab-bar-item" :class="[classIndex == index ? 'active' : '']" :data-current="index" @tap.stop="swichClass(index)" >
  19. <text>{{ item.className || "" }}</text>
  20. <text class="tag"
  21. v-if=" getSelectClassById(item.classId).bigCount > 0 || getSelectClassById(item.classId).smallCount > 0">
  22. <text v-if="getSelectClassById(item.classId).bigCount > 0 || getSelectClassById(item.classId).smallCount > 0">
  23. {{ `${getSelectClassById(item.classId).bigCount}` }}
  24. </text>
  25. <text v-if="getSelectClassById(item.classId).smallCount > 0">/</text>
  26. <text v-if="getSelectClassById(item.classId).smallCount > 0">{{getSelectClassById(item.classId).smallCount}}</text>
  27. </text>
  28. </div>
  29. <view style="height: 120rpx"></view>
  30. <!-- <view class="switchover-unit" @tap="isSmallCount = !isSmallCount">{{isSmallCount?'支':'扎'}}</view> -->
  31. </scroll-view>
  32. <!-- <scroll-view scroll-y class="right-box" v-if="tabIndex == 0" :scroll-into-view="scrollClassId">-->
  33. <scroll-view scroll-y class="right-box" v-if="tabIndex == 0" :scroll-into-view="scroll_into_view" scroll-with-animation="true"
  34. @scroll="scroll_detail"
  35. lower-threshold="100"
  36. @scrolltolower="scroll_bottom">
  37. <!--内容部分 start -->
  38. <block v-if="!$util.isEmpty(filterProductInfo)">
  39. <view class="item_list_bx selectAll" v-for="(classItem, classIndex) in filterProductInfo" :key="classIndex" :id="`class_${classIndex}`">
  40. <view class="item_list_title">
  41. {{ classItem.className }}
  42. </view>
  43. <template v-for="(productItem, productIndex) in classItem.child">
  44. <view style="height: 160rpx" :id="`class_${classItem.classId}_${productItem.id}`" :key="productIndex">
  45. <Commondity v-if="classItem.isActive"
  46. :offPrice="true"
  47. :key="productIndex"
  48. :info="productItem"
  49. :bigCount="
  50. getSelectItemById(productItem.id, classItem.classId).bigCount
  51. "
  52. :smallCount="
  53. getSelectItemById(productItem.id, classItem.classId).smallCount
  54. "
  55. @customNum="customNum"
  56. @add="addEvent"
  57. @addOneEvent="addCustomNumEvent"
  58. @del="delEvent"
  59. ></Commondity>
  60. </view>
  61. </template>
  62. </view>
  63. </block>
  64. <block v-else>
  65. <app-wrapper-empty
  66. title="暂无数据"
  67. :is-empty="$util.isEmpty(filterProductInfo)"
  68. />
  69. </block>
  70. <!--内容部分 end -->
  71. </scroll-view>
  72. <block v-else>
  73. <view style="width:100%">
  74. <AppWrapperEmpty title="敬请期待" :is-empty="true" />
  75. </view>
  76. </block>
  77. </view>
  78. <!-- :maskClosable="false" -->
  79. <modal-module
  80. :show="isModel"
  81. @cancel="modalCancel"
  82. @click="affirm"
  83. :title="customData.itemName"
  84. color="#333"
  85. :size="32"
  86. padding="30rpx 30rpx"
  87. >
  88. <template slot="customContent">
  89. <view class="select-cmd_bx" v-if="customData">
  90. <view class="kc"> 库存{{ customData.stock }} </view>
  91. <view class="num_bx">
  92. <!--<allMoreSelectInput-->
  93. <!--:isActive="isActive" :isFocus="isFocus" :value="customData.bigCount"-->
  94. <!--:isActiveOne="isActiveOne" :isFocusOne="isFocusOne" :valueOne="customData.smallCount"-->
  95. <!--@deleteInputVal="deleteInputVal" @initAllInput="initAllInput" @moveAllInput="moveAllInput"-->
  96. <!--@deleteInputValOne="deleteInputValOne" @initAllInputOne="initAllInputOne" @moveAllInputOne="moveAllInputOne">-->
  97. <!--</allMoreSelectInput>-->
  98. <input v-model="customData.bigCount" :focus="isFocus" type="number" />扎
  99. <input v-model="customData.smallCount" type="number" style="margin-left:24upx"/>支
  100. </view>
  101. </view>
  102. </template>
  103. </modal-module>
  104. <modal-module
  105. :show="showSubmitModel"
  106. @cancel="cancelEvent"
  107. @click="submitEvent"
  108. :title="confirmContent"
  109. color="#333"
  110. :size="32"
  111. padding="30rpx 30rpx"
  112. >
  113. </modal-module>
  114. <FooterCart :offPrice="true" :price="allPrice" :count="allCount" @confirm="confirmSelectEvent"></FooterCart>
  115. <!-- <FooterCart-->
  116. <!-- :price="allPrice"-->
  117. <!-- :count="allCount"-->
  118. <!-- @confirm="confirmSelectEvent"-->
  119. <!-- ></FooterCart>-->
  120. </view>
  121. </template>
  122. <script>
  123. import AppSearchModule from "@/components/module/app-search";
  124. import AppTabs from "@/components/plugin/tabs";
  125. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  126. import Commondity from "@/components/module/app-commodity";
  127. import FooterCart from "@/components/module/app-footer-cart";
  128. import ModalModule from "@/components/plugin/modal";
  129. import productMins from "@/mixins/product";
  130. import allMoreSelectInput from "@/components/module/allMoreSelectInput";
  131. import allMoreSelectInputMins from "@/mixins/allMoreSelectInput";
  132. import { mapGetters } from "vuex";
  133. export default {
  134. name: "allotEx", // 开单
  135. components: {
  136. AppTabs,
  137. AppSearchModule,
  138. AppWrapperEmpty,
  139. Commondity,
  140. ModalModule,
  141. FooterCart,
  142. allMoreSelectInput
  143. },
  144. mixins: [productMins,allMoreSelectInputMins],
  145. data() {
  146. return {
  147. pageType: "inventory",
  148. isLimit: false,
  149. isFocus: false,
  150. isSmallCount:false,//是否是小单位(支)
  151. offVerifyRepertory:true,
  152. tabIndex: 0,
  153. tabs: [
  154. {
  155. name: "花材"
  156. },
  157. {
  158. name: "成品"
  159. }
  160. // {
  161. // name: '课程'
  162. // },
  163. ],
  164. isModel: false,
  165. customData: {
  166. bigCount: 0,
  167. smallCount: 0
  168. },
  169. showSubmitModel: false,
  170. autoLoad: false, //不自动请求数据 自定义请求
  171. };
  172. },
  173. computed: {
  174. confirmContent() {
  175. let content = "确认下一步?";
  176. return content;
  177. }
  178. },
  179. computed:{
  180. ...mapGetters(["getMyShopInfo","getLoginInfo"]),
  181. },
  182. onLoad() {
  183. let type = '';
  184. this.initData({ type,status:0});
  185. },
  186. methods: {
  187. //自定义数量
  188. customNum(info) {
  189. this.isModel = true;
  190. this.customData = info;
  191. this.isFocus = false;
  192. this.$nextTick(()=>{
  193. this.customData.smallCount = this.customData.smallCount==0?null:this.customData.smallCount;
  194. this.customData.bigCount = this.customData.bigCount==0?null:this.customData.bigCount;
  195. this.isFocus = true;
  196. })
  197. // this.$nextTick(()=>{
  198. // this.initAllInput();
  199. // })
  200. },
  201. modalCancel() {
  202. this.isModel = false;
  203. this.customData = {};
  204. },
  205. // 取消 确认
  206. affirm(val) {
  207. this.isFocus = false;
  208. this.isFocusOne = false;
  209. this.$nextTick(()=>{
  210. //取消
  211. if (val.index === 0) {
  212. if(this.customData.bigCount>0 || this.customData.smallCount>0){
  213. }else{
  214. this.delAllEvent(this.customData)
  215. }
  216. this.modalCancel();
  217. return;
  218. }
  219. //二个都不是数值
  220. if(/(^[1-9]\d*$)/.test(this.customData.bigCount) == false && /(^[1-9]\d*$)/.test(this.customData.smallCount) == false){
  221. this.delAllEvent(this.customData)
  222. this.modalCancel();
  223. return;
  224. }
  225. if(/(^[1-9]\d*$)/.test(this.customData.bigCount)){
  226. if(this.customData.bigCount<=0){
  227. uni.showToast({title:"数量要大于0",icon:"none"})
  228. return;
  229. }
  230. }
  231. if(/(^[1-9]\d*$)/.test(this.customData.smallCount)){
  232. if(this.customData.smallCount<=0){
  233. uni.showToast({title:"数量要大于0",icon:"none"})
  234. return;
  235. }
  236. }
  237. this.updateItemEvent(this.customData);
  238. this.modalCancel();
  239. })
  240. },
  241. cancelEvent() {
  242. this.showSubmitModel = false;
  243. },
  244. submitEvent(val) {
  245. if (val.index === 0) {
  246. this.cancelEvent();
  247. } else {
  248. uni.navigateBack({
  249. delta: 1
  250. });
  251. this.cancelEvent();
  252. }
  253. },
  254. confirmSelectEvent() {
  255. if (this.selectList.length > 0) {
  256. //因历史遗留原因,打开花材页马上点花材出现数量0或null的情况,需要过滤 shish 20210716
  257. let selectList = this.selectList;
  258. let list = [];
  259. console.log('过滤前',selectList)
  260. for (let i=0;i<selectList.length;i++){
  261. if(/(^[1-9]\d*$)/.test(selectList[i].bigCount) == false && /(^[1-9]\d*$)/.test(selectList[i].smallCount) == false){
  262. continue
  263. }
  264. list.push(selectList[i])
  265. }
  266. if(list.length <= 0){
  267. this.$msg("请选择花材")
  268. return
  269. }
  270. console.log('过滤后',list)
  271. this.setSelectInfoByType({ type: this.pageType, info: list });
  272. this.submitEvent(1);
  273. } else {
  274. this.$msg('请选择花材')
  275. }
  276. },
  277. change(e) {
  278. if (this.tabIndex == e.index) {
  279. return false;
  280. } else {
  281. this.tabIndex = e.index;
  282. }
  283. },
  284. scrollTop() {}
  285. }
  286. };
  287. </script>
  288. <style lang="scss" scoped>
  289. .billing_box_bg {
  290. height: 100%;
  291. display: flex;
  292. flex-direction: column;
  293. .input-wrap {
  294. padding: 22px 20px 22px 30px;
  295. }
  296. .scroll-middle_bx {
  297. flex: 1;
  298. display: flex;
  299. width: 100%;
  300. height: 100%;
  301. overflow: hidden;
  302. }
  303. .tab-view {
  304. height: 100%;
  305. width: 170upx;
  306. flex-shrink: 0;
  307. background-color: #f0f2f6;
  308. .tab-bar-item {
  309. position: relative;
  310. width: 170upx;
  311. height: 90upx;
  312. box-sizing: border-box;
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. font-size: 26upx;
  317. color: #444;
  318. font-weight: 400;
  319. .tag {
  320. display: flex;
  321. padding: 0 20px;
  322. align-items: center;
  323. position: absolute;
  324. right: 0;
  325. top: 0;
  326. height: 32px;
  327. background: #ff2842;
  328. border-radius: 16px;
  329. color: #fff;
  330. font-size: 20px;
  331. }
  332. &:last-child{
  333. margin-bottom: 110upx;
  334. }
  335. }
  336. .active {
  337. position: relative;
  338. color: $mainColor;
  339. font-size: 26px;
  340. background: #fff;
  341. }
  342. .active::before {
  343. content: "";
  344. position: absolute;
  345. border-left: 8upx solid $mainColor;
  346. height: 100%;
  347. left: 0;
  348. }
  349. }
  350. .right-box {
  351. height: 100%;
  352. flex: 1;
  353. box-sizing: border-box;
  354. }
  355. .item_list_bx {
  356. padding: 40px 16px;
  357. &:last-child{
  358. margin-bottom: 70upx;
  359. }
  360. }
  361. .item_list_title {
  362. margin-bottom: 20px;
  363. font-size: 24px;
  364. font-weight: 600;
  365. color: #666666;
  366. }
  367. .select-cmd_bx {
  368. & .kc {
  369. color: #999999;
  370. font-size: 28px;
  371. font-weight: 400;
  372. margin-bottom: 60px;
  373. text-align: center;
  374. margin-top: 10px;
  375. }
  376. & .num_bx {
  377. display: flex;
  378. align-items: center;
  379. margin-bottom: 80px;
  380. & > input {
  381. width: 212px;
  382. height: 80px;
  383. border: 1px solid #dddddd;
  384. border-radius: 4px;
  385. text-align: center;
  386. margin-right: 24px;
  387. }
  388. }
  389. }
  390. }
  391. </style>