select.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="billing_box_bg">
  3. <app-tabs
  4. :tabs="tabs"
  5. :currentTab="tabIndex"
  6. @change="change"
  7. itemWidth="50%"
  8. />
  9. <view class="input-wrap">
  10. <app-search-module
  11. v-model="py"
  12. placeholder="请输入关键词,支持拼音首字母搜索"
  13. @search="searchFn"
  14. />
  15. </view>
  16. <view class="scroll-middle_bx">
  17. <scroll-view
  18. scroll-y
  19. scroll-with-animation
  20. class="tab-view"
  21. :scroll-top="scrollTop"
  22. >
  23. <div
  24. v-for="(item, index) in filterProductInfo"
  25. :key="index"
  26. class="tab-bar-item"
  27. :class="[classIndex == index ? 'active' : '']"
  28. :data-current="index"
  29. @tap.stop="swichClass"
  30. >
  31. <text>{{ item.className || "" }}</text>
  32. <text class="tag" v-if=" getSelectClassById(item.classId).bigCount > 0 || getSelectClassById(item.classId).smallCount > 0">
  33. <text v-if="getSelectClassById(item.classId).bigCount > 0 || getSelectClassById(item.classId).smallCount > 0">
  34. {{ `${getSelectClassById(item.classId).bigCount}` }}
  35. </text>
  36. <text v-if="getSelectClassById(item.classId).smallCount > 0">/</text>
  37. <text v-if="getSelectClassById(item.classId).smallCount > 0">{{getSelectClassById(item.classId).smallCount}}</text>
  38. </text>
  39. </div>
  40. </scroll-view>
  41. <scroll-view scroll-y class="right-box" v-if="tabIndex == 0" :scroll-into-view="scrollClassId">
  42. <!--内容部分 start -->
  43. <block v-if="!$util.isEmpty(filterProductInfo)">
  44. <view
  45. class="item_list_bx"
  46. v-for="(classItem, classIndex) in filterProductInfo"
  47. :key="classIndex"
  48. :id="`class_${classItem.classId}`"
  49. >
  50. <view class="item_list_title">
  51. {{ classItem.className }}
  52. </view>
  53. <template v-for="(productItem, productIndex) in classItem.child">
  54. <view
  55. :id="`class_${classItem.classId}_${productItem.id}`"
  56. :key="productIndex"
  57. >
  58. <Commondity
  59. :info="productItem"
  60. :bigCount="
  61. getSelectItemById(productItem.id, classItem.classId).bigCount
  62. "
  63. :smallCount="
  64. getSelectItemById(productItem.id, classItem.classId).smallCount
  65. "
  66. @customNum="customNum"
  67. @add="addEvent"
  68. @del="delEvent"
  69. ></Commondity>
  70. </view>
  71. <!-- <Commondity
  72. :type="COMMODITY_TYPE.CHANGE"
  73. @customNum="customNum"
  74. ></Commondity> -->
  75. </template>
  76. </view>
  77. </block>
  78. <block v-else>
  79. <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(filterProductInfo)" />
  80. </block>
  81. <!--内容部分 end -->
  82. </scroll-view>
  83. <block v-else>
  84. <view style="width:100%">
  85. <AppWrapperEmpty title="敬请期待" :is-empty="true" />
  86. </view>
  87. </block>
  88. </view>
  89. <!-- :maskClosable="false" -->
  90. <modal-module :show="isModel" @cancel="modalCancel" @click="affirm" :title="customData.itemName" color="#333" :size="32" padding="30rpx 30rpx">
  91. <template slot="customContent">
  92. <view class="select-cmd_bx" v-if="customData">
  93. <view class="kc"> 库存{{ customData.stock }} </view>
  94. <view class="num_bx">
  95. <input v-model="customData.bigCount" focus type="number" >扎
  96. <!-- <input v-model="customData.bigCount" :focus="isModel" @focus="allSelect" :selection-start="startIndex" :selection-end="endIndex" type="number" >扎-->
  97. <input v-model="customData.smallCount" type="number" style="margin-left:24upx" />支
  98. </view>
  99. </view>
  100. </template>
  101. </modal-module>
  102. <modal-module :show="showSubmitModel" @cancel="cancelEvent" @click="submitEvent" :title="confirmContent" color="#333" :size="32" padding="30rpx 30rpx" >
  103. </modal-module>
  104. <FooterCart :price="allPrice" :count="allCount" @confirm="confirmSelectEvent" ></FooterCart>
  105. <kd-entrance></kd-entrance>
  106. </view>
  107. </template>
  108. <script>
  109. import AppSearchModule from "@/components/module/app-search";
  110. import AppTabs from "@/components/plugin/tabs";
  111. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  112. import Commondity from "@/components/module/app-commodity";
  113. import FooterCart from "@/components/module/app-footer-cart";
  114. import ModalModule from "@/components/plugin/modal";
  115. import { COMMODITY_TYPE } from "@/utils/declare";
  116. import { chooseOrderProductApi } from "@/api/order/index";
  117. import productMins from "@/mixins/product";
  118. export default {
  119. name: "Billing", // 开单
  120. components: {
  121. AppTabs,
  122. AppSearchModule,
  123. AppWrapperEmpty,
  124. Commondity,
  125. ModalModule,
  126. FooterCart
  127. },
  128. mixins: [productMins],
  129. data() {
  130. return {
  131. pageType: "order_change",
  132. COMMODITY_TYPE,
  133. tabIndex: 0,
  134. tabs: [
  135. {
  136. name: "花材"
  137. },
  138. {
  139. name: "成品"
  140. }
  141. // {
  142. // name: '课程'
  143. // },
  144. ],
  145. isModel: false,
  146. customData: {
  147. bigCount: 0,
  148. smallCount: 0
  149. },
  150. showSubmitModel: false
  151. };
  152. },
  153. computed: {
  154. confirmContent() {
  155. let content = "确认下一步?";
  156. if (this.hasNoStock) {
  157. content = "有花材库存不足,确认下一步?";
  158. }
  159. return content;
  160. }
  161. },
  162. onUnload() {
  163. this.resetSelectInfoByType(this.pageType);
  164. },
  165. methods: {
  166. //自定义数量
  167. customNum(info) {
  168. this.isModel = true;
  169. this.customData = info;
  170. },
  171. modalCancel() {
  172. this.isModel = false;
  173. this.customData = {};
  174. }, // 取消 确认
  175. affirm(val) {
  176. if (val.index === 0) {
  177. this.modalCancel();
  178. } else {
  179. const {
  180. bigCount,
  181. smallCount,
  182. bigNum,
  183. bigUnit,
  184. smallNum,
  185. smallUnit,
  186. ratio
  187. } = this.customData;
  188. const ratioNum = Number(ratio);
  189. //超过库存时 设置为库存最大值
  190. if (
  191. Number(bigCount) * ratioNum + Number(smallCount) >
  192. Number(bigNum) * ratioNum + Number(smallNum)
  193. ) {
  194. uni.showToast({
  195. title: `库存只有${bigNum}${bigUnit}${smallNum}${smallUnit}`,
  196. icon: "none"
  197. });
  198. this.customData.bigCount = bigNum;
  199. this.customData.smallCount = smallNum;
  200. } else {
  201. this.updateItemEvent(this.customData);
  202. this.modalCancel();
  203. }
  204. }
  205. },
  206. cancelEvent() {
  207. this.showSubmitModel = false;
  208. },
  209. submitEvent(val) {
  210. if (val.index === 0) {
  211. this.cancelEvent();
  212. } else {
  213. console.log(444, this.selectList);
  214. uni.navigateBack({
  215. delta: 1
  216. });
  217. this.cancelEvent();
  218. }
  219. },
  220. async confirmSelectEvent() {
  221. try {
  222. if (this.selectList.length > 0) {
  223. const product = this.selectList.map(ele => {
  224. return {
  225. classId:ele.classId,
  226. productId: ele.id,
  227. bigNum: ele.bigCount,
  228. smallNum: ele.smallCount
  229. };
  230. });
  231. let params = {
  232. id: this.option.id,
  233. product: JSON.stringify(product)
  234. };
  235. await chooseOrderProductApi(params);
  236. this.$msg("修改成功");
  237. uni.navigateBack({
  238. delta: 1
  239. });
  240. } else {
  241. this.$msg("请选择花材");
  242. }
  243. } catch (error) {}
  244. },
  245. change(e) {
  246. if (this.tabIndex == e.index) {
  247. return false;
  248. } else {
  249. this.tabIndex = e.index;
  250. }
  251. },
  252. scrollTop() {}
  253. }
  254. };
  255. </script>
  256. <style lang="scss" scoped>
  257. .billing_box_bg {
  258. height: 100%;
  259. display: flex;
  260. flex-direction: column;
  261. .input-wrap {
  262. padding: 22px 20px 22px 30px;
  263. }
  264. .scroll-middle_bx {
  265. flex: 1;
  266. display: flex;
  267. width: 100%;
  268. height: 100%;
  269. overflow: hidden;
  270. }
  271. .tab-view {
  272. height: 100%;
  273. width: 170upx;
  274. flex-shrink: 0;
  275. background-color: #f0f2f6;
  276. .tab-bar-item {
  277. position: relative;
  278. width: 170upx;
  279. height: 90upx;
  280. box-sizing: border-box;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. font-size: 26upx;
  285. color: #444;
  286. font-weight: 400;
  287. .tag {
  288. display: flex;
  289. padding: 0 20px;
  290. align-items: center;
  291. position: absolute;
  292. right: 0;
  293. top: 0;
  294. height: 32px;
  295. background: #ff2842;
  296. border-radius: 16px;
  297. color: #fff;
  298. font-size: 20px;
  299. }
  300. }
  301. .active {
  302. position: relative;
  303. color: $mainColor;
  304. font-size: 26px;
  305. background: #fff;
  306. }
  307. .active::before {
  308. content: "";
  309. position: absolute;
  310. border-left: 8upx solid $mainColor;
  311. height: 100%;
  312. left: 0;
  313. }
  314. }
  315. .right-box {
  316. height: 100%;
  317. flex: 1;
  318. box-sizing: border-box;
  319. }
  320. .item_list_bx {
  321. padding: 40px 16px;
  322. }
  323. .item_list_title {
  324. margin-bottom: 20px;
  325. font-size: 24px;
  326. font-weight: 600;
  327. color: #666666;
  328. }
  329. .select-cmd_bx {
  330. & .kc {
  331. color: #999999;
  332. font-size: 28px;
  333. font-weight: 400;
  334. margin-bottom: 60px;
  335. text-align: center;
  336. margin-top: 10px;
  337. }
  338. & .num_bx {
  339. display: flex;
  340. align-items: center;
  341. margin-bottom: 80px;
  342. & > input {
  343. width: 212px;
  344. height: 80px;
  345. border: 1px solid #dddddd;
  346. border-radius: 4px;
  347. text-align: center;
  348. margin-right: 24px;
  349. }
  350. }
  351. }
  352. }
  353. </style>