index.vue 11 KB

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