select.vue 8.2 KB

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